From 2e2e3e9b65172f42b60ab151cf8f97441f99988a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 21 Mar 2018 17:17:01 +0200 Subject: [PATCH 001/605] move tests from old repo - part 1 --- .gitignore | 4 +- pom.xml | 255 ++++++++++-------- .../com/kaltura/client/test/CancelTest.java | 44 --- .../kaltura/client/test/KalturaTestSuite.java | 44 --- .../kaltura/client/test/MultiRequestTest.java | 147 ---------- .../client/test/RequestsTestSuite.java | 44 --- .../client/test/SingleRequestTest.java | 110 -------- .../com/kaltura/client/test/TestCommon.java | 49 ---- .../com/kaltura/client/test/TestConfig.java | 70 ----- .../kaltura/client/test/helper/Config.java | 41 +++ .../kaltura/client/test/helper/DBHelper.java | 50 ++++ .../kaltura/client/test/helper/Helper.java | 41 +++ .../test/servicesImpl/OttUserServiceImpl.java | 245 +++++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 27 ++ .../kaltura/client/test/tests/Sandbox.java | 61 +++++ .../resources/ott.test.template.properties | 5 - ...BillingTransactionListResponse_Schema.json | 35 +++ .../KalturaBillingTransaction_Schema.json | 104 +++++++ ...KalturaEntitlementListResponse_Schema.json | 29 ++ .../KalturaHouseholdDevice_Schema.json | 59 ++++ .../schemas/KalturaHouseholdUser_Schema.json | 43 +++ .../schemas/KalturaHousehold_Schema.json | 202 ++++++++++++++ .../schemas/KalturaLoginResponse_Schema.json | 19 ++ .../schemas/KalturaLoginSession_Schema.json | 21 ++ .../schemas/KalturaMediaAsset_Schema.json | 221 +++++++++++++++ ...raMultilingualStringValueArray_Schema.json | 32 +++ .../schemas/KalturaOttUser_Schema.json | 51 ++++ .../schemas/KalturaPpvEntitlement_Schema.json | 110 ++++++++ .../schemas/KalturaPpvPrice_Schema.json | 169 ++++++++++++ .../schemas/KalturaPrice_Schema.json | 35 +++ ...alturaProductPriceListResponse_Schema.json | 38 +++ ...KalturaSubscriptionEntitlement_Schema.json | 135 ++++++++++ .../KalturaSubscriptionPrice_Schema.json | 42 +++ .../schemas/KalturaTransaction_Schema.json | 54 ++++ src/test/java/resources/testng.xml | 10 + 35 files changed, 2015 insertions(+), 631 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/CancelTest.java delete mode 100644 src/test/java/com/kaltura/client/test/KalturaTestSuite.java delete mode 100644 src/test/java/com/kaltura/client/test/MultiRequestTest.java delete mode 100644 src/test/java/com/kaltura/client/test/RequestsTestSuite.java delete mode 100644 src/test/java/com/kaltura/client/test/SingleRequestTest.java delete mode 100644 src/test/java/com/kaltura/client/test/TestCommon.java delete mode 100644 src/test/java/com/kaltura/client/test/TestConfig.java create mode 100644 src/test/java/com/kaltura/client/test/helper/Config.java create mode 100644 src/test/java/com/kaltura/client/test/helper/DBHelper.java create mode 100644 src/test/java/com/kaltura/client/test/helper/Helper.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/BaseTest.java create mode 100644 src/test/java/com/kaltura/client/test/tests/Sandbox.java delete mode 100644 src/test/java/resources/ott.test.template.properties create mode 100644 src/test/java/resources/schemas/KalturaBillingTransactionListResponse_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaBillingTransaction_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaEntitlementListResponse_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaHouseholdDevice_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaHouseholdUser_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaHousehold_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaLoginResponse_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaLoginSession_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaMediaAsset_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaMultilingualStringValueArray_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaOttUser_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaPpvEntitlement_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaPpvPrice_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaPrice_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaProductPriceListResponse_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaSubscriptionEntitlement_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaSubscriptionPrice_Schema.json create mode 100644 src/test/java/resources/schemas/KalturaTransaction_Schema.json create mode 100644 src/test/java/resources/testng.xml diff --git a/.gitignore b/.gitignore index 0c42bdc0f..29cbfef85 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ build .idea *.iml -.gradle \ No newline at end of file +.gradle +target/ +src/test/java/resources/test.properties diff --git a/pom.xml b/pom.xml index f51037b97..ab99100b2 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ jar - 1.7 + 1.8 @@ -39,16 +39,16 @@ - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + @@ -96,7 +96,7 @@ com.google.code.gson gson - 2.7 + 2.8.2 @@ -132,127 +132,148 @@ - + - junit - junit - 4.11 + org.testng + testng + 6.11 test - junit - junit-dep - 4.11 + org.assertj + assertj-core + 3.9.1 test - - + + + org.hamcrest + hamcrest-all + 1.3 + test + + + org.awaitility awaitility - 3.0.0 + 3.1.0 + test + + + + com.microsoft.sqlserver + mssql-jdbc + 6.4.0.jre8 + test + + + + io.rest-assured + json-schema-validator + 3.0.7 test - + - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.3 - true - - ossrh - https://oss.sonatype.org/ - true - - - - maven-compiler-plugin - 2.3.2 - - 1.7 - 1.7 - - + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.3 + true + + ossrh + https://oss.sonatype.org/ + true + + + + maven-compiler-plugin + 2.3.2 + + 1.8 + 1.8 + + - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18.1 - - - **/KalturaTestSuite.java - - - + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + **/KalturaTestSuite.java + + + - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar - - - - + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar + + + + - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - - - - date - X - Date: - - - hide - X - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + + date + X + Date: + + + hide + X + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + - - + + diff --git a/src/test/java/com/kaltura/client/test/CancelTest.java b/src/test/java/com/kaltura/client/test/CancelTest.java deleted file mode 100644 index 26d8b5ff5..000000000 --- a/src/test/java/com/kaltura/client/test/CancelTest.java +++ /dev/null @@ -1,44 +0,0 @@ - -package com.kaltura.client.test; - -import com.kaltura.client.APIOkRequestsExecutor; -import com.kaltura.client.services.FavoriteService; -import com.kaltura.client.services.FavoriteService.ListFavoriteBuilder; -import com.kaltura.client.types.Favorite; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.OnCompletion; -import com.kaltura.client.utils.response.base.Response; - -import org.awaitility.Awaitility; -import org.awaitility.core.ConditionTimeoutException; -import org.junit.Assert; -import org.junit.Test; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -public class CancelTest extends TestCommon { - - AtomicBoolean beenHere = new AtomicBoolean(false); - - @Test(timeout = 3000, expected = ConditionTimeoutException.class) - public void testCancel() throws InterruptedException, ExecutionException { - logger.info("testCancelRequest"); - - ListFavoriteBuilder requestBuilder = FavoriteService.list(); - APIOkRequestsExecutor actionsQueue = APIOkRequestsExecutor.getExecutor(); - String reqId = actionsQueue.queue(requestBuilder.setCompletion(new OnCompletion>>() { - @Override - public void onComplete(Response> result) { - beenHere.set(true); - } - }).build(client)); - - actionsQueue.cancelRequest(reqId); - - Awaitility.await().timeout(2, TimeUnit.SECONDS); - - Assert.assertFalse(beenHere.get()); - } -} diff --git a/src/test/java/com/kaltura/client/test/KalturaTestSuite.java b/src/test/java/com/kaltura/client/test/KalturaTestSuite.java deleted file mode 100644 index 3dacf4024..000000000 --- a/src/test/java/com/kaltura/client/test/KalturaTestSuite.java +++ /dev/null @@ -1,44 +0,0 @@ -// =================================================================================================== -// _ __ _ _ -// | |/ /__ _| | |_ _ _ _ _ __ _ -// | ' . -// -// @ignore -// =================================================================================================== -package com.kaltura.client.test; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class KalturaTestSuite extends TestSuite -{ - public static Test suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(CancelTest.class); - suite.addTestSuite(SingleRequestTest.class); - suite.addTestSuite(MultiRequestTest.class); - - return suite; - } -} diff --git a/src/test/java/com/kaltura/client/test/MultiRequestTest.java b/src/test/java/com/kaltura/client/test/MultiRequestTest.java deleted file mode 100644 index 433becacc..000000000 --- a/src/test/java/com/kaltura/client/test/MultiRequestTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.kaltura.client.test; - -import com.kaltura.client.APIOkRequestsExecutor; -import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.AssetService.GetAssetBuilder; -import com.kaltura.client.services.OttUserService; -import com.kaltura.client.services.OttUserService.GetOttUserBuilder; -import com.kaltura.client.services.OttUserService.LoginOttUserBuilder; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.LoginResponse; -import com.kaltura.client.types.OTTUser; -import com.kaltura.client.types.SearchAssetFilter; -import com.kaltura.client.utils.request.MultiRequestBuilder; -import com.kaltura.client.utils.response.OnCompletion; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import org.awaitility.Awaitility; -import org.junit.Test; - -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Created by tehilarozin on 11/09/2016. - */ -public class MultiRequestTest extends TestCommon { - - private AtomicBoolean done; - - public void setUp() throws Exception { - super.setUp(); - done = new AtomicBoolean(false); - } - - @Test - public void testMultiRequest() throws InterruptedException, ExecutionException { - logger.info("testMultiRequest\n"); - - //final CountDownLatch doneSignal = new CountDownLatch(1); - - final AtomicInteger counter = new AtomicInteger(0); - //DataFactory.UserLogin userLogin = DataFactory.getUser(); - - LoginOttUserBuilder ottUserLoginRequestBuilder = OttUserService.login(testConfig.getPartnerId(), - testConfig.getUserName(), testConfig.getUserPassword()) - .setCompletion(new ApiCompletion() { - - @Override - public void onComplete(Response result) { - - assertNotNull(result); - assertNull(result.error); - counter.incrementAndGet(); - } - }); - - GetAssetBuilder assetGetRequestBuilder = AssetService.get(testConfig.getMediaId(), AssetReferenceType.MEDIA) - .setCompletion(new ApiCompletion() { - - @Override - public void onComplete(Response result) { - assertNotNull(result); - assertNull(result.error); - counter.incrementAndGet(); - } - }); - - GetOttUserBuilder ottUserGetRequestBuilder = OttUserService.get() - .setCompletion(new ApiCompletion() { - - @Override - public void onComplete(Response result) { - - assertNotNull(result); - assertNull(result.error); - counter.incrementAndGet(); - } - }); - - MultiRequestBuilder requestBuilder = new MultiRequestBuilder(ottUserLoginRequestBuilder, assetGetRequestBuilder, ottUserGetRequestBuilder); - requestBuilder.link(ottUserLoginRequestBuilder, assetGetRequestBuilder, "loginSession.ks", "ks"); - requestBuilder.link(ottUserLoginRequestBuilder, ottUserGetRequestBuilder, "loginSession.ks", "ks"); - - requestBuilder.setCompletion(new ApiCompletion>() { - - @Override - public void onComplete(Response> result) { - assertNotNull(result); - assertNull(result.error); - assertEquals(3, counter.get()); - assertEquals(3, result.results.size()); - - done.set(true); - - } - }); - APIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); - Awaitility.await().atMost(30, TimeUnit.SECONDS).untilTrue(done); - - assertTrue(done.get()); - } - - @Test - public void testListResponse(){ - SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); - searchAssetFilter.setOrderBy(AssetOrderBy.RELEVANCY_DESC.name()); - searchAssetFilter.setTypeIn("420, 423, 421, 0, 422"); - - FilterPager filterPager = new FilterPager(); - filterPager.setPageSize(10); - filterPager.setPageIndex(1); - final ListResponse assets = new ListResponse<>(); - - MultiRequestBuilder multiRequestBuilder = OttUserService.login(testConfig.getPartnerId(), - testConfig.getUserName(), testConfig.getUserPassword()) - .add(AssetService.list(searchAssetFilter, filterPager)) - .link(0, 1, "loginSession.ks", "ks") - .setCompletion(new OnCompletion>>() { - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void onComplete(Response> result) { - try { - assets.setObjects(((ListResponse)result.results.get(1)).getObjects()); - } catch (Exception e) { - e.printStackTrace(); - } - done.set(true); - } - }); - - APIOkRequestsExecutor.getExecutor().queue(multiRequestBuilder.build(client)); - - Awaitility.await().atMost(30, TimeUnit.SECONDS).untilTrue(done); - - assertTrue(done.get()); - assertFalse(assets.getObjects().isEmpty()); - } - -} diff --git a/src/test/java/com/kaltura/client/test/RequestsTestSuite.java b/src/test/java/com/kaltura/client/test/RequestsTestSuite.java deleted file mode 100644 index b96ea0635..000000000 --- a/src/test/java/com/kaltura/client/test/RequestsTestSuite.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.kaltura.client.test; -// =================================================================================================== -// _ __ _ _ -// | |/ /__ _| | |_ _ _ _ _ __ _ -// | ' . -// -// @ignore -// =================================================================================================== - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class RequestsTestSuite extends TestSuite -{ - public static Test suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(CancelTest.class); - suite.addTestSuite(SingleRequestTest.class); - suite.addTestSuite(MultiRequestTest.class); - - return suite; - } -} diff --git a/src/test/java/com/kaltura/client/test/SingleRequestTest.java b/src/test/java/com/kaltura/client/test/SingleRequestTest.java deleted file mode 100644 index c09e8529c..000000000 --- a/src/test/java/com/kaltura/client/test/SingleRequestTest.java +++ /dev/null @@ -1,110 +0,0 @@ - -package com.kaltura.client.test; - -import com.kaltura.client.APIOkRequestsExecutor; -import com.kaltura.client.services.FavoriteService; -import com.kaltura.client.services.FavoriteService.ListFavoriteBuilder; -import com.kaltura.client.services.OttUserService; -import com.kaltura.client.services.OttUserService.GetOttUserBuilder; -import com.kaltura.client.services.OttUserService.LoginOttUserBuilder; -import com.kaltura.client.types.Favorite; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.LoginResponse; -import com.kaltura.client.types.OTTUser; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import org.awaitility.Awaitility; -import org.junit.Test; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Created by tehilarozin on 11/09/2016. - */ -public class SingleRequestTest extends TestCommon{ - - @Test - /** - * synced requests: activates login request and if succeeded, activating another request to fetch user data - */ - public void testRequestWithinRequest() throws InterruptedException, ExecutionException{ - logger.info("testLogin"); - - final AtomicBoolean done = new AtomicBoolean(false); - - LoginOttUserBuilder requestBuilder = OttUserService.login(testConfig.getPartnerId(), testConfig.getUserName(), testConfig.getUserPassword()) - .setCompletion(new ApiCompletion() { - - @Override - public void onComplete(Response result) { - - assertNotNull(result); - assertNull(result.error); - - client.setKs(result.results.getLoginSession().getKs()); - - OTTUser ottUser = result.results.getUser(); - logger.debug("Hello " + ottUser.getFirstName() + " " + ottUser.getLastName() + ", username: " + ottUser.getUsername() + ", "); - - logger.debug("fetching user info: "); - GetOttUserBuilder requestBuilder = OttUserService.get() - .setCompletion(new ApiCompletion() { - - @Override - public void onComplete(Response result) { - - assertNotNull(result); - assertNull(result.error); - done.set(true); - } - }); - APIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); - } - }); - APIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); - Awaitility.await().atMost(20, TimeUnit.SECONDS).untilTrue(done); - - assertTrue(done.get()); - } - - @Test - public void testList() throws InterruptedException, ExecutionException { - logger.info("testCancelRequest"); - - final AtomicBoolean done = new AtomicBoolean(false); - - LoginOttUserBuilder requestBuilder = OttUserService.login(testConfig.getPartnerId(), - testConfig.getUserName(), testConfig.getUserPassword()) - .setCompletion(new ApiCompletion() { - - @Override - public void onComplete(Response result) { - - assertNotNull(result); - assertNull(result.error); - - client.setKs(result.results.getLoginSession().getKs()); - - ListFavoriteBuilder requestBuilder = FavoriteService.list() - .setCompletion(new ApiCompletion>() { - - @Override - public void onComplete(Response> result) { - - assertNotNull(result); - assertNull(result.error); - done.set(true); - } - }); - APIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); - } - }); - APIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); - Awaitility.await().atMost(20, TimeUnit.SECONDS).untilTrue(done); - - assertTrue(done.get()); - } -} diff --git a/src/test/java/com/kaltura/client/test/TestCommon.java b/src/test/java/com/kaltura/client/test/TestCommon.java deleted file mode 100644 index 292a2cdd3..000000000 --- a/src/test/java/com/kaltura/client/test/TestCommon.java +++ /dev/null @@ -1,49 +0,0 @@ - -package com.kaltura.client.test; - -import com.kaltura.client.Client; -import com.kaltura.client.Configuration; -import com.kaltura.client.ILogger; -import com.kaltura.client.Logger; - -import junit.framework.TestCase; - -public abstract class TestCommon extends TestCase { - - protected static ILogger logger = Logger.getLogger("java-test"); - - Client client; - TestConfig testConfig; - - - @SuppressWarnings("serial") - protected class CompletionException extends Exception { - - public CompletionException(String message) { - super(message); - } - - @Override - public String toString() { - return getMessage(); - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - - /* if (logger.isEnabled()) - logger.info("Starting test: " + getClass().getName() + "." + getName());*/ - - testConfig = new TestConfig(); - - Configuration config = new Configuration(); - config.setEndpoint(testConfig.getServiceUrl()); - config.setAcceptGzipEncoding(false); - - client = new Client(config); - - } - -} diff --git a/src/test/java/com/kaltura/client/test/TestConfig.java b/src/test/java/com/kaltura/client/test/TestConfig.java deleted file mode 100644 index c488f07bd..000000000 --- a/src/test/java/com/kaltura/client/test/TestConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.kaltura.client.test; -// =================================================================================================== -// _ __ _ _ -// | |/ /__ _| | |_ _ _ _ _ __ _ -// | ' . -// -// @ignore -// =================================================================================================== - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -public class TestConfig { - private static Properties properties; - - private static final String PARTNER_ID = "partnerId"; - private static final String ENDPOINT = "serviceUrl"; - private static final String USER_NAME = "userName"; - private static final String USER_PASSWORD = "userPassword"; - private static final String MEDIA_ID = "mediaId"; - - TestConfig() throws IOException{ - if(properties == null){ - InputStream inputStream = getClass().getClassLoader().getResourceAsStream("resources/ott.test.properties"); - properties = new Properties(); - properties.load(inputStream); - } - } - - int getPartnerId(){ - return Integer.parseInt(properties.getProperty(PARTNER_ID)); - } - - String getServiceUrl(){ - return properties.getProperty(ENDPOINT); - } - - String getUserName(){ - return properties.getProperty(USER_NAME); - } - - String getUserPassword(){ - return properties.getProperty(USER_PASSWORD); - } - - String getMediaId() { - return properties.getProperty(MEDIA_ID); - } -} diff --git a/src/test/java/com/kaltura/client/test/helper/Config.java b/src/test/java/com/kaltura/client/test/helper/Config.java new file mode 100644 index 000000000..cf1e91b77 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/helper/Config.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.helper; + +import java.util.ResourceBundle; + +public class Config { + + private static ResourceBundle resourceBundle; + + //url properties + public static final String API_BASE_URL = "http://34.249.122.223:8080"; + public static final String API_URL_VERSION = "v4_8"; + + //db properties + // TODO: 3/19/2018 encrypt db username and password in test.properties file + public static final String DB_URL = "db_url"; + public static final String DB_USER = "db_user"; + public static final String DB_PASSWORD = "db_password"; + + //request properties + public static final int PARTNER_ID = 203; + public static final String API_REQUEST_VERSION = "4.8.1"; + + //global user properties + public static final String GLOBAL_USER_PASSWORD = "password"; + + + public static String getProperty(String propertyKey) { + if (resourceBundle == null) + resourceBundle = ResourceBundle.getBundle("test"); + return resourceBundle.getString(propertyKey); + } + + //todo global list + // TODO: 3/8/2018 talk with Elram about DB cleanup + // TODO: 3/8/2018 add relevant data assertions (include optional params) to impl services + // TODO: 3/12/2018 open conference page with all the documentation problems + // TODO: 12/MAR/2018 decide if we need that autoskip logic for tests with known opened bugs: + // https://dzone.com/articles/how-to-automatically-skip-tests-based-on-defects-s + // TODO: 3/19/2018 update readme file with project structure and list of services + // TODO: 3/19/2018 find how to run specific tests according to api version +} diff --git a/src/test/java/com/kaltura/client/test/helper/DBHelper.java b/src/test/java/com/kaltura/client/test/helper/DBHelper.java new file mode 100644 index 000000000..2a8a012d4 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/helper/DBHelper.java @@ -0,0 +1,50 @@ +package com.kaltura.client.test.helper; + +import com.microsoft.sqlserver.jdbc.SQLServerDataSource; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import static com.kaltura.client.test.helper.Config.*; + +public class DBHelper { + + private static SQLServerDataSource dataSource; + private static Connection conn; + private static Statement stam; + private static ResultSet rs; + + //selects + private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + + + public static String getActivationToken(String username) throws SQLException { + openConnection(); + rs = stam.executeQuery(String.format(ACTIVATION_TOKEN_SELECT, username)); + rs.next(); + String activationToke = rs.getString("ACTIVATION_TOKEN"); + closeConnection(); + return activationToke; + } + + private static void openConnection() throws SQLException { + dataSource = new SQLServerDataSource(); + dataSource.setUser(getProperty(DB_USER)); + dataSource.setPassword(getProperty(DB_PASSWORD)); + dataSource.setServerName(getProperty(DB_URL)); + dataSource.setApplicationIntent("ReadOnly"); + dataSource.setMultiSubnetFailover(true); + + conn = dataSource.getConnection(); + stam = conn.createStatement(); + + } + + private static void closeConnection() throws SQLException { + rs.close(); + stam.close(); + conn.close(); + } +} diff --git a/src/test/java/com/kaltura/client/test/helper/Helper.java b/src/test/java/com/kaltura/client/test/helper/Helper.java new file mode 100644 index 000000000..e18c034c7 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/helper/Helper.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.helper; + +import com.kaltura.client.types.OTTUser; + +import java.util.Random; + +public class Helper { + + //generate ottUser + public static OTTUser generateOttUser() { + long millis = System.currentTimeMillis(); + String randomString = getRandomString(); + String emailPrefix = "qaott2018" + "+"; + String emailDomain = "@gmail.com"; + String stamp = randomString + millis; + + OTTUser user = new OTTUser(); + user.setUsername(stamp); + user.setFirstName(randomString); + user.setLastName(String.valueOf(millis)); + user.setEmail(emailPrefix + stamp + emailDomain); + user.setAddress(randomString + " fake address"); + user.setCity(randomString + " fake city"); + Random r = new Random(); + user.setCountryId(r.nextInt(30 - 1) + 1); + + return user; + } + + //generate random string + public static String getRandomString() { + String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + StringBuilder sb = new StringBuilder(); + Random r = new Random(); + while (sb.length() < 12) { + int index = (int) (r.nextFloat() * chars.length()); + sb.append(chars.charAt(index)); + } + return sb.toString().toLowerCase(); + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java new file mode 100644 index 000000000..e8ebca966 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -0,0 +1,245 @@ +package com.kaltura.client.test.servicesImpl; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.kaltura.client.Logger; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.GsonParser; +import org.json.JSONObject; + +import java.util.Optional; + +import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; + +public class OttUserServiceImpl { + + private static final String SERVICE = "ottUser"; + + private static final String LOGIN_ACTION = "login"; + private static final String ANONYMOUSLOGIN_ACTION = "anonymousLogin"; + private static final String REGISTER_ACTION = "register"; + private static final String ACTIVATE_ACTION = "activate"; + private static final String DELETE_ACTION = "delete"; + private static final String LIST_ACTION = "list"; + + private static final String LOGIN_RESPONSE_SCHEMA = "KalturaLoginResponse_Schema.json"; + private static final String LOGIN_SESSION_SCHEMA = "KalturaLoginSession_Schema.json"; + private static final String OTT_USER_SCHEMA = "KalturaOttUser_Schema.json"; + + + public static void login(String username, String password, Optional udid, Optional extra_params) { + + } + +// public static T anonymousLogin(Optional udid) { +// String body = anonymousLoginRequestBuilder(udid); +// Response response = setPostRequest(body, SERVICE, ANONYMOUSLOGIN_ACTION); +// +// if (isApiException(response)) { +// return (T) getApiException(response); +// } else { +// assertThat(response.asString(), matchesJsonSchemaInClasspath(LOGIN_SESSION_SCHEMA)); +// try { +// return GsonParser.parseObject(response.asString(), (Class) LoginSession.class); +// } catch (APIException e) { +// Logger.getLogger(OttUserService.class).error("LoginSession.class parse error"); +// e.printStackTrace(); +// return null; +// } +// } +// } +// +// public static T register(OTTUser ottUser, String password) { +// String body = registerRequestBuilder(ottUser, password); +// Response response = setPostRequest(body, SERVICE, REGISTER_ACTION); +// +// if (isApiException(response)) { +// return (T) getApiException(response); +// } else { +// assertThat(response.asString(), matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); +// try { +// return GsonParser.parseObject(response.asString(), (Class) OTTUser.class); +// } catch (APIException e) { +// Logger.getLogger(OttUserService.class).error("OTTUser.class parse error"); +// e.printStackTrace(); +// return null; +// } +// } +// } +// +// // TODO: 3/15/2018 ask Max if we need to expose partnerId to the crud function level +// public static T activate(String ks, String username, String activationToken) { +// String body = activateRequestBuilder(ks, username, activationToken); +// Response response = setPostRequest(body, SERVICE, ACTIVATE_ACTION); +// +// if (isApiException(response)) { +// return (T) getApiException(response); +// } else { +// assertThat(response.asString(), matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); +// } +// try { +// return GsonParser.parseObject(response.asString(), (Class) OTTUser.class); +// } catch (APIException e) { +// Logger.getLogger(OttUserService.class).error("OTTUser parse error"); +// e.printStackTrace(); +// return null; +// } +// } +// +// public static T addRole(String ks, int roleId) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T delete(String ks) { +// String body = getBaseRequestBody(ks).toString(); +// Response response = setPostRequest(body, SERVICE, DELETE_ACTION); +// +// if (isApiException(response)) { +// return (T) getApiException(response); +// } else { +// try { +// assertThat(response.asString(), matchesJsonSchemaInClasspath(BOOLEAN_RESPONSE_SCHEMA)); +// return GsonParser.parseObject(response.asString(), (Class) Boolean.class); +// } catch (APIException e) { +// Logger.getLogger(OttUserService.class).error("Boolean.class parse error"); +// e.printStackTrace(); +// return null; +// } +// } +// } +// +// public static T get(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T getEncryptedUserId(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +///* public static T list(String ks, Optional ottUserFilter) { +// String body = listRequestBuilder(ks, ottUserFilter); +// Response response = setPostRequest(body, SERVICE, LIST_ACTION); +// +// if (isApiException(response)) { +// return (T) getApiException(response); +// } else { +// try { +// assertThat(response.asString(), matchesJsonSchemaInClasspath(BOOLEAN_RESPONSE_SCHEMA)); +// return GsonParser.parseListResponse(response.asString(), OTTUser.class); +// } catch (APIException e) { +// e.printStackTrace(); +// return null; +// } +// } +// // KalturaOTTUserListResponse +// // TODO: 3/19/2018 implement function +// return null; +// }*/ +// +// public static T loginWithPin(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T logout(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T refreshSession(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T resendActivationToken(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T resetPassword(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T setInitialPassword(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T update(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// public static T updateLoginData(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } +// +// //////////////////////// +// /////help functions///// +// //////////////////////// +// private static String loginRequestBuilder(String username, String password, Optional udid, Optional extra_params) { +// JSONObject jsonObject = new JSONObject(); +// jsonObject +// .put("partnerId", partner_id) +// .put("apiVersion", api_version) +// .put("username", username) +// .put("password", password); +// +// udid.ifPresent(s -> jsonObject.put("udid", s)); +// extra_params.ifPresent(jsonObject1 -> jsonObject.put("extra_params", jsonObject1)); +//// String argument = optionalArgument.or("reasonable default"); +// +// return jsonObject.toString(); +// } +// +// private static String anonymousLoginRequestBuilder(Optional udid) { +// JSONObject jsonObject = new JSONObject(); +// jsonObject +// .put("apiVersion", api_version) +// .put("partnerId", partner_id); +// +// udid.ifPresent(s -> jsonObject.put("udid", s)); +// +// return jsonObject.toString(); +// } +// +// //TODO: add later fields "userType": OTTUserType and "dynamicData": map of StringValue if needed +// private static String registerRequestBuilder(OTTUser ottUser, String password) { +// JsonObject jsonObject = new JsonObject(); +// jsonObject.addProperty("apiVersion", api_version); +// jsonObject.addProperty("partnerId", partner_id); +// jsonObject.addProperty("password", password); +// +// JsonElement element = new Gson().fromJson(ottUser.toParams().toString(), JsonElement.class); +// jsonObject.add("user", element); +// +// return jsonObject.toString(); +// } +// +// private static String activateRequestBuilder(String ks, String username, String activationToken) { +// JSONObject jsonObject = getBaseRequestBody(ks); +// jsonObject +// .put("partnerId", partner_id) +// .put("username", username) +// .put("activationToken", activationToken); +// +// return jsonObject.toString(); +// } +// +// private static String listRequestBuilder(String ks, Optional ottUserFilter) { +// JsonObject jsonObject = getBaseRequestBodyGson(ks); +// if (ottUserFilter.isPresent()) { +// JsonElement element = new Gson().fromJson(ottUserFilter.get().toParams().toString(), JsonElement.class); +// jsonObject.add("filter", element); +// } +// return jsonObject.toString(); +// } +} + + diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java new file mode 100644 index 000000000..694a757da --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -0,0 +1,27 @@ +package com.kaltura.client.test.tests; + +import com.kaltura.client.Client; +import com.kaltura.client.Configuration; +import com.kaltura.client.test.helper.Config; +import org.testng.annotations.BeforeSuite; + +import java.util.concurrent.TimeUnit; + +import static com.kaltura.client.test.helper.Config.*; +import static org.awaitility.Awaitility.setDefaultTimeout; + +public class BaseTest { + + public static Client client; + + @BeforeSuite + public void setup() { + Configuration config = new Configuration(); + config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); + config.setAcceptGzipEncoding(false); + + client = new Client(config); + + setDefaultTimeout(15, TimeUnit.SECONDS); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java new file mode 100644 index 000000000..6ac3ed36c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -0,0 +1,61 @@ +package com.kaltura.client.test.tests; + +import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.services.OttUserService; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.test.helper.Config.*; +import static com.kaltura.client.test.helper.Helper.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; + +public class Sandbox extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response response; + + private static final String LOGIN_RESPONSE_SCHEMA = "KalturaLoginResponse_Schema.json"; + + @BeforeClass + public void sandbox_tests_setup() { + user = generateOttUser(); + OttUserService.RegisterOttUserBuilder registerOttUserBuilder = register(PARTNER_ID, user, password); + APIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); + } + + private Response sandboxLoginTest() { + final AtomicBoolean done = new AtomicBoolean(false); + + OttUserService.LoginOttUserBuilder loginOttUserBuilder = login(PARTNER_ID, user.getUsername(), password) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + assertThat(result.results.getLoginSession()).isNotNull(); + assertThat(result.results.getUser()).isNotNull(); + +// MatcherAssert.assertThat(result.results.toParams().toString(), matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); + } + response = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); + await().untilTrue(done); + + return response; + } + + @Test + private void test11() { + sandboxLoginTest(); + System.out.println(response.results.getUser().getUsername()); + } +} diff --git a/src/test/java/resources/ott.test.template.properties b/src/test/java/resources/ott.test.template.properties deleted file mode 100644 index e0360c236..000000000 --- a/src/test/java/resources/ott.test.template.properties +++ /dev/null @@ -1,5 +0,0 @@ -partnerId=@YOUR_PARTNER_ID@ -serviceUrl=@SERVICE_URL@ -userName=@USER_NAME@ -userPassword=@USER_PASSWORD@ -mediaId=@MEDIA_ID@ diff --git a/src/test/java/resources/schemas/KalturaBillingTransactionListResponse_Schema.json b/src/test/java/resources/schemas/KalturaBillingTransactionListResponse_Schema.json new file mode 100644 index 000000000..92fcfdd77 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaBillingTransactionListResponse_Schema.json @@ -0,0 +1,35 @@ +{ + "$id": "KalturaBillingTransactionListResponse", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "$ref": "KalturaBillingTransaction_Schema.json#/definitions/KalturaBillingTransaction" + } + }, + "totalCount": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaBillingTransactionListResponse" + ] + } + }, + "required": [ + "objects", + "totalCount", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaBillingTransaction_Schema.json b/src/test/java/resources/schemas/KalturaBillingTransaction_Schema.json new file mode 100644 index 000000000..58c3ed826 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaBillingTransaction_Schema.json @@ -0,0 +1,104 @@ +{ + "$id": "KalturaBillingTransaction", + "definitions": { + "KalturaBillingTransaction": { + "type": "object", + "properties": { + "userId": { + "type": "string" + }, + "userFullName": { + "type": "string" + }, + "recieptCode": { + "type": "string", + "minLength": 1 + }, + "purchasedItemName": { + "type": "string", + "minLength": 0 + }, + "purchasedItemCode": { + "type": "string", + "minLength": 1 + }, + "itemType": { + "type": "string", + "minLength": 1 + }, + "billingAction": { + "type": "string", + "minLength": 1 + }, + "price": { + "$ref": "KalturaPrice_Schema.json#/definitions/KalturaPrice" + }, + "actionDate": { + "type": "integer", + "minimum": 1 + }, + "startDate": { + "type": "integer", + "minimum": 1 + }, + "endDate": { + "type": "integer", + "minimum": 1 + }, + "paymentMethod": { + "type": "string", + "minLength": 1 + }, + "paymentMethodExtraDetails": { + "type": "string", + "minLength": 1 + }, + "isRecurring": { + "type": "boolean" + }, + "billingProviderRef": { + "type": "integer", + "minimum": 1 + }, + "purchaseId": { + "type": "integer", + "minimum": 1 + }, + "remarks": { + "type": "string", + "minLength": 0 + }, + "billingPriceType": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaBillingTransaction" + ] + } + }, + "required": [ + "recieptCode", + "purchasedItemName", + "purchasedItemCode", + "itemType", + "billingAction", + "price", + "actionDate", + "startDate", + "endDate", + "paymentMethod", + "paymentMethodExtraDetails", + "isRecurring", + "billingProviderRef", + "purchaseId", + "remarks", + "billingPriceType", + "objectType" + ] + } + }, + "$ref": "#/definitions/KalturaBillingTransaction" +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaEntitlementListResponse_Schema.json b/src/test/java/resources/schemas/KalturaEntitlementListResponse_Schema.json new file mode 100644 index 000000000..074e9a7a8 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaEntitlementListResponse_Schema.json @@ -0,0 +1,29 @@ +{ + "$id": "KalturaEntitlementListResponse", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "KalturaPpvEntitlement_Schema.json#/definitions/KalturaPpvEntitlement" + }, + { + "$ref": "KalturaSubscriptionEntitlement_Schema.json#/definitions/KalturaSubscriptionEntitlement" + } + ] + } + }, + "totalCount": {"type": "integer", "minimum": 0}, + "objectType": {"type": "string", "enum": ["KalturaEntitlementListResponse"]} + }, + "required": ["objects", "totalCount", "objectType"] + }, + "executionTime": {"type": "number"} + }, + "required": ["result"] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaHouseholdDevice_Schema.json b/src/test/java/resources/schemas/KalturaHouseholdDevice_Schema.json new file mode 100644 index 000000000..a92228ffe --- /dev/null +++ b/src/test/java/resources/schemas/KalturaHouseholdDevice_Schema.json @@ -0,0 +1,59 @@ +{ + "$id": "KalturaHouseholdDevice", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "householdId": { + "type": "integer", + "minimum": 1 + }, + "udid": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "brandId": { + "type": "integer", + "minimum": 1 + }, + "activatedOn": { + "type": "integer", + "minimum": 1 + }, + "state": { + "type": "string", + "minLength": 1 + }, + "status": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaHouseholdDevice"] + } + }, + "required": [ + "householdId", + "udid", + "name", + "brandId", + "activatedOn", + "state", + "status", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result" + ] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaHouseholdUser_Schema.json b/src/test/java/resources/schemas/KalturaHouseholdUser_Schema.json new file mode 100644 index 000000000..d0a71cc73 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaHouseholdUser_Schema.json @@ -0,0 +1,43 @@ +{ + "$id": "KalturaHouseholdUser", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "householdId": { + "type": "integer", + "minimum": 1 + }, + "userId": { + "type": "string", + "minLength": 1 + }, + "isMaster": { + "type": "boolean" + }, + "status": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaHouseholdUser"] + } + }, + "required": [ + "householdId", + "userId", + "isMaster", + "status", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result" + ] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaHousehold_Schema.json b/src/test/java/resources/schemas/KalturaHousehold_Schema.json new file mode 100644 index 000000000..7d3197459 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaHousehold_Schema.json @@ -0,0 +1,202 @@ +{ + "$id": "KalturaHousehold", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "minimum": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "minLength": 1 + }, + "externalId": { + "type": "string" + }, + "householdLimitationsId": { + "type": "integer", + "minimum": 0 + }, + "devicesLimit": { + "type": "integer", + "minimum": 0 + }, + "usersLimit": { + "type": "integer", + "minimum": 0 + }, + "concurrentLimit": { + "type": "integer", + "minimum": 0 + }, + "users": { + "type": "array", + "additionalItems": false, + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaBaseOTTUser"] + } + }, + "required": [ + "id", + "objectType" + ] + } + }, + "masterUsers": { + "type": "array", + "additionalItems": false, + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaBaseOTTUser"] + } + }, + "required": [ + "id", + "objectType" + ] + } + }, + "defaultUsers": { + "type": "array", + "additionalItems": false, + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaBaseOTTUser"] + } + }, + "required": [ + "id", + "objectType" + ] + } + }, + "pendingUsers": { + "type": "array", + "additionalItems": false + }, + "regionId": { + "type": "integer", + "minimum": 0 + }, + "state": { + "type": "string", + "minLength": 1 + }, + "isFrequencyEnabled": { + "type": "boolean" + }, + "frequencyNextDeviceAction": { + "type": "integer" + }, + "frequencyNextUserAction": { + "type": "integer" + }, + "restriction": { + "type": "string", + "minLength": 1 + }, + "deviceFamilies": { + "type": "array", + "additionalItems": false, + "items": { + "type": "object", + "properties": { + "devices": { + "type": "array", + "additionalItems": false + }, + "id": { + "type": "integer", + "minimum": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "deviceLimit": { + "type": "integer", + "minimum": 0 + }, + "concurrentLimit": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": ["KalturaDeviceFamily"] + } + }, + "required": [ + "devices", + "id", + "name", + "deviceLimit", + "concurrentLimit", + "objectType" + ] + } + }, + "objectType": { + "type": "string", + "enum": ["KalturaHousehold"] + } + }, + "required": [ + "name", + "description", + "externalId", + "householdLimitationsId", + "devicesLimit", + "usersLimit", + "concurrentLimit", + "users", + "masterUsers", + "defaultUsers", + "pendingUsers", + "regionId", + "state", + "isFrequencyEnabled", + "frequencyNextDeviceAction", + "frequencyNextUserAction", + "restriction", + "deviceFamilies", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result" + ] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaLoginResponse_Schema.json b/src/test/java/resources/schemas/KalturaLoginResponse_Schema.json new file mode 100644 index 000000000..8feb1ef5e --- /dev/null +++ b/src/test/java/resources/schemas/KalturaLoginResponse_Schema.json @@ -0,0 +1,19 @@ +{ + "$id": "KalturaLoginResponse", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "user": {"$ref": "KalturaOttUser_Schema.json#/definitions/KalturaOTTUser"}, + "loginSession": { + "$ref": "KalturaLoginSession_Schema.json#/definitions/KalturaLoginSession" + }, + "objectType": {"type": "string", "enum": ["KalturaLoginResponse"]} + }, + "required": ["user", "loginSession", "objectType"] + }, + "executionTime": {"type": "number", "minimum": 0} + }, + "required": ["result", "executionTime"] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaLoginSession_Schema.json b/src/test/java/resources/schemas/KalturaLoginSession_Schema.json new file mode 100644 index 000000000..ece8ab0ee --- /dev/null +++ b/src/test/java/resources/schemas/KalturaLoginSession_Schema.json @@ -0,0 +1,21 @@ +{ + "$id": "KalturaLoginSession", + "definitions": { + "KalturaLoginSession": { + "type": "object", + "properties": { + "ks": {"type": "string", "minLength": 10}, + "objectType": {"type": "string", "enum": ["KalturaLoginSession"]} + }, + "required": ["ks", "objectType"] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/KalturaLoginSession" + } + }, + "executionTime": {"type": "number"}, + "required": ["result", "executionTime"] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaMediaAsset_Schema.json b/src/test/java/resources/schemas/KalturaMediaAsset_Schema.json new file mode 100644 index 000000000..77baf7981 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaMediaAsset_Schema.json @@ -0,0 +1,221 @@ +{ + "$id": "KalturaMediaAsset", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "catchUpBuffer": { + "type": "integer", + "minimum": 0 + }, + "trickPlayBuffer": { + "type": "integer", + "minimum": 0 + }, + "enableRecordingPlaybackNonEntitledChannel": { + "type": "boolean" + }, + "entryId": { + "type": "string", + "minLength": 1 + }, + "id": { + "type": "integer", + "minimum": 1 + }, + "type": { + "type": "integer", + "minimum": 1 + }, + "name": { + "type": "string", + "minLength": 1 + }, + "description": { + "type": "string", + "minLength": 1 + }, + "images": { + "type": "array", + "additionalItems": false, + "items": { + "type": "object", + "properties": { + "ratio": { + "type": "string", + "minLength": 1 + }, + "width": { + "type": "integer", + "minimum": 1 + }, + "height": { + "type": "integer", + "minimum": 1 + }, + "url": { + "type": "string", + "minLength": 1 + }, + "version": { + "type": "integer", + "minimum": 0 + }, + "id": { + "type": "string", + "minLength": 1 + }, + "isDefault": { + "type": "boolean" + }, + "objectType": { + "type": "string", + "minLength": 1 + } + } + } + }, + "mediaFiles": { + "type": "array", + "additionalItems": false, + "items": { + "type": "object", + "properties": { + "assetId": { + "type": "integer", + "minimum": 1 + }, + "id": { + "type": "integer", + "minimum": 1 + }, + "type": { + "type": "string", + "minLength": 1 + }, + "url": { + "type": "string", + "minLength": 1 + }, + "duration": { + "type": "integer", + "minimum": 1 + }, + "externalId": { + "type": "string", + "minLength": 1 + }, + "fileSize": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "minLength": 1 + } + } + } + }, + "metas": { + "type": "object", + "properties": { + "synopsis": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "minLength": 1 + } + } + }, + "Release year1": { + "type": "object", + "properties": { + "value": { + "type": "integer", + "minimum": 1 + }, + "objectType": { + "type": "string", + "minLength": 1 + } + } + } + } + }, + "tags": { + "type": "object", + "properties": { + "Free": { + "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + }, + "Genre": { + "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + }, + "Parental Rating": { + "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + }, + "Director": { + "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + }, + "Country": { + "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + }, + "Series name": { + "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + } + } + }, + "startDate": { + "type": "integer", + "minimum": 1 + }, + "endDate": { + "type": "integer", + "minimum": 1 + }, + "enableCdvr": { + "type": "boolean" + }, + "enableCatchUp": { + "type": "boolean" + }, + "enableStartOver": { + "type": "boolean" + }, + "enableTrickPlay": { + "type": "boolean" + }, + "objectType": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "entryId", + "id", + "type", + "name", + "description", + "images", + "mediaFiles", + "metas", + "tags", + "startDate", + "endDate", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result" + ] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaMultilingualStringValueArray_Schema.json b/src/test/java/resources/schemas/KalturaMultilingualStringValueArray_Schema.json new file mode 100644 index 000000000..dc2b5a08f --- /dev/null +++ b/src/test/java/resources/schemas/KalturaMultilingualStringValueArray_Schema.json @@ -0,0 +1,32 @@ +{ + "$id": "KalturaMediaAsset", + "definitions": { + "KalturaMultilingualStringValueArray": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "additionalItems": false, + "items": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaMultilingualStringValue"] + } + } + } + }, + "objectType": { + "type": "string", + "minLength": 1 + } + } + } + }, + "$ref": "#/definitions/KalturaMultilingualStringValueArray" +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaOttUser_Schema.json b/src/test/java/resources/schemas/KalturaOttUser_Schema.json new file mode 100644 index 000000000..36f2b89d2 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaOttUser_Schema.json @@ -0,0 +1,51 @@ +{ + "$id": "KalturaOTTUser", + "definitions": { + "KalturaOTTUser": { + "type": "object", + "properties": { + "householdId": {"type": "integer", "minimum": 0}, + "email": {"type": "string", "minLength": 5}, + "country": { + "type": "object", + "properties": { + "id": {"type": "integer", "minimum": 0}, + "name": {"type": "string", "minLength": 0}, + "code": {"type": "string", "minLength": 0}, + "objectType": {"type": "string", "enum": ["KalturaCountry"]} + }, + "required": ["id", "name", "code", "objectType"] + }, + "countryId": {"type": "integer", "minimum": 0}, + "userType": { + "type": "object", + "properties": { + "description": {"type": "string", "minLength": 0}, + "objectType": {"type": "string", "enum": ["KalturaOTTUserType"]} + }, + "required": ["description", "objectType"] + }, + "dynamicData": {"type": "object"}, + "isHouseholdMaster": {"type": "boolean"}, + "suspentionState": {"type": "string", "minLength": 1}, + "suspensionState": {"type": "string", "minLength": 1}, + "userState": {"type": "string", "minLength": 1}, + "id": {"type": "string", "minLength": 1}, + "username": {"type": "string", "minLength": 1}, + "firstName": {"type": "string", "minLength": 1}, + "lastName": {"type": "string", "minLength": 1}, + "objectType": {"type": "string", "enum": ["KalturaOTTUser"]} + }, + "required": ["householdId", "email", "countryId", "dynamicData", "isHouseholdMaster", "suspentionState", + "suspensionState", "userState", "id", "username", "firstName", "lastName", "objectType"] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/KalturaOTTUser" + }, + "executionTime": {"type": "number"} + }, + "required": ["result", "executionTime"] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaPpvEntitlement_Schema.json b/src/test/java/resources/schemas/KalturaPpvEntitlement_Schema.json new file mode 100644 index 000000000..52f1d2249 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaPpvEntitlement_Schema.json @@ -0,0 +1,110 @@ +{ + "$id": "KalturaPpvEntitlement", + "definitions": { + "KalturaPpvEntitlement": { + "type": "object", + "properties": { + "mediaFileId": { + "type": "integer", + "minimum": 1 + }, + "mediaId": { + "type": "integer", + "minimum": 1 + }, + "id": { + "type": "integer", + "minimum": 1 + }, + "type": { + "type": "string", + "enum": [ + "ppv" + ] + }, + "productId": { + "type": "string", + "minLength": 1 + }, + "currentUses": { + "type": "integer", + "minimum": 0 + }, + "endDate": { + "type": "integer", + "minimum": 1 + }, + "currentDate": { + "type": "integer", + "minimum": 1 + }, + "lastViewDate": { + "type": "integer", + "minimum": 1 + }, + "purchaseDate": { + "type": "integer", + "minimum": 1 + }, + "purchaseId": { + "type": "integer", + "minimum": 1 + }, + "paymentMethod": { + "type": "string", + "minLength": 1 + }, + "deviceUdid": { + "type": "string", + "minLength": 5 + }, + "deviceName": { + "type": "string", + "minLength": 5 + }, + "isCancelationWindowEnabled": { + "type": "boolean" + }, + "maxUses": { + "type": "integer", + "minimum": 0 + }, + "isRenewable": { + "type": "boolean" + }, + "isInGracePeriod": { + "type": "boolean" + }, + "householdId": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string" + } + }, + "required": [ + "mediaFileId", + "mediaId", + "id", + "type", + "productId", + "currentUses", + "endDate", + "currentDate", + "lastViewDate", + "purchaseDate", + "purchaseId", + "paymentMethod", + "deviceUdid", + "deviceName", + "isCancelationWindowEnabled", + "maxUses", + "isRenewable", + "isInGracePeriod", + "householdId" + ] + } + }, + "$ref": "#/definitions/KalturaPpvEntitlement" +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaPpvPrice_Schema.json b/src/test/java/resources/schemas/KalturaPpvPrice_Schema.json new file mode 100644 index 000000000..a679b600f --- /dev/null +++ b/src/test/java/resources/schemas/KalturaPpvPrice_Schema.json @@ -0,0 +1,169 @@ +{ + "$id": "KalturaPpvPrice", + "definitions": { + "KalturaPpvPrice": { + "type": "object", + "properties": { + "fileId": { + "type": "integer", + "minimum": 0 + }, + "ppvModuleId": { + "type": "string", + "minLength": 1 + }, + "isSubscriptionOnly": { + "type": "boolean" + }, + "fullPrice": { + "type": "object", + "properties": { + "amount": { + "type": "integer", + "minimum": 0 + }, + "currency": { + "type": "string", + "minLength": 1 + }, + "currencySign": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "amount", + "currency", + "currencySign", + "objectType" + ] + }, + "subscriptionId": { + "type": "string", + "minLength": 1 + }, + "ppvDescriptions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "language": { + "type": "string", + "minLength": 1 + }, + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "language", + "value", + "objectType" + ] + } + }, + "purchaseUserId": { + "type": "string", + "minLength": 0 + }, + "purchasedMediaFileId": { + "type": "integer", + "minimum": 0 + }, + "relatedMediaFileIds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "value", + "objectType" + ] + } + }, + "startDate": { + "type": "integer", + "minimum": 0 + }, + "endDate": { + "type": "integer", + "minimum": 0 + }, + "discountEndDate": { + "type": "integer", + "minimum": 0 + }, + "firstDeviceName": { + "type": "string", + "minLength": 0 + }, + "isInCancelationPeriod": { + "type": "boolean" + }, + "ppvProductCode": { + "type": "string", + "minLength": 0 + }, + "productId": { + "type": "string", + "minLength": 1 + }, + "productType": { + "type": "string", + "minLength": 1 + }, + "price": { + "$ref": "KalturaPrice_Schema.json#/definitions/KalturaPrice" + }, + "purchaseStatus": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaPpvPrice"] + } + }, + "required": [ + "fileId", + "ppvModuleId", + "isSubscriptionOnly", + "fullPrice", + "ppvDescriptions", + "purchaseUserId", + "purchasedMediaFileId", + "relatedMediaFileIds", + "startDate", + "endDate", + "discountEndDate", + "firstDeviceName", + "isInCancelationPeriod", + "ppvProductCode", + "productId", + "productType", + "price", + "purchaseStatus", + "objectType" + ] + } + }, + "$ref": "#/definitions/KalturaPpvPrice" +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaPrice_Schema.json b/src/test/java/resources/schemas/KalturaPrice_Schema.json new file mode 100644 index 000000000..d611a9197 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaPrice_Schema.json @@ -0,0 +1,35 @@ +{ + "$id": "KalturaPrice", + "definitions": { + "KalturaPrice": { + "type": "object", + "properties": { + "amount": { + "type": "number", + "minimum": 0 + }, + "currency": { + "type": "string", + "minLength": 1 + }, + "currencySign": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaPrice" + ] + } + }, + "required": [ + "amount", + "currency", + "currencySign", + "objectType" + ] + } + }, + "$ref": "#/definitions/KalturaPrice" +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaProductPriceListResponse_Schema.json b/src/test/java/resources/schemas/KalturaProductPriceListResponse_Schema.json new file mode 100644 index 000000000..3db9aaab3 --- /dev/null +++ b/src/test/java/resources/schemas/KalturaProductPriceListResponse_Schema.json @@ -0,0 +1,38 @@ +{ + "$id": "KalturaProductPriceListResponse", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "anyOf": [ + { "$ref": "KalturaSubscriptionPrice_Schema.json#/definitions/KalturaSubscriptionPrice" }, + { "$ref": "KalturaPpvPrice_Schema.json#/definitions/KalturaPpvPrice" } + ] + }}, + "totalCount": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": ["KalturaProductPriceListResponse"] + } + }, + "required": [ + "objects", + "totalCount", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result" + ] +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaSubscriptionEntitlement_Schema.json b/src/test/java/resources/schemas/KalturaSubscriptionEntitlement_Schema.json new file mode 100644 index 000000000..69b2d27df --- /dev/null +++ b/src/test/java/resources/schemas/KalturaSubscriptionEntitlement_Schema.json @@ -0,0 +1,135 @@ +{ + "$id": "KalturaSubscriptionEntitlement", + "definitions": { + "KalturaSubscriptionEntitlement": { + "type": "object", + "properties": { + "nextRenewalDate": { + "type": "integer", + "minimum": 0 + }, + "isRenewableForPurchase": { + "type": "boolean" + }, + "isRenewable": { + "type": "boolean" + }, + "isInGracePeriod": { + "type": "boolean" + }, + "paymentGatewayId": { + "type": "integer", + "minimum": 0 + }, + "unifiedPaymentId": { + "type": "integer", + "minimum": 0 + }, + "isSuspended": { + "type": "boolean" + }, + "id": { + "type": "integer", + "minimum": 1 + }, + "type": { + "type": "string", + "minLength": 1 + }, + "productId": { + "type": "string", + "minLength": 1 + }, + "currentUses": { + "type": "integer", + "minimum": 0 + }, + "endDate": { + "type": "integer", + "minimum": 1 + }, + "currentDate": { + "type": "integer", + "minimum": 1 + }, + "lastViewDate": { + "type": "integer", + "minimum": 0 + }, + "purchaseDate": { + "type": "integer", + "minimum": 0 + }, + "purchaseId": { + "type": "integer", + "minimum": 0 + }, + "paymentMethod": { + "type": "string", + "minLength": 1 + }, + "deviceUdid": { + "type": "string", + "minLength": 1 + }, + "deviceName": { + "type": "string", + "minLength": 1 + }, + "isCancelationWindowEnabled": { + "type": "boolean" + }, + "maxUses": { + "type": "integer", + "minimum": 0 + }, + "mediaFileId": { + "type": "integer", + "minimum": 0 + }, + "mediaId": { + "type": "integer", + "minimum": 0 + }, + "householdId": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaSubscriptionEntitlement" + ] + } + }, + "required": [ + "nextRenewalDate", + "isRenewableForPurchase", + "isRenewable", + "isInGracePeriod", + "paymentGatewayId", + "unifiedPaymentId", + "isSuspended", + "id", + "type", + "productId", + "currentUses", + "endDate", + "currentDate", + "lastViewDate", + "purchaseDate", + "purchaseId", + "paymentMethod", + "deviceUdid", + "deviceName", + "isCancelationWindowEnabled", + "maxUses", + "mediaFileId", + "mediaId", + "householdId", + "objectType" + ] + } + }, + "$ref": "#/definitions/KalturaSubscriptionEntitlement" +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaSubscriptionPrice_Schema.json b/src/test/java/resources/schemas/KalturaSubscriptionPrice_Schema.json new file mode 100644 index 000000000..1df8a46dd --- /dev/null +++ b/src/test/java/resources/schemas/KalturaSubscriptionPrice_Schema.json @@ -0,0 +1,42 @@ +{ + "$id": "KalturaSubscriptionPrice", + "definitions": { + "KalturaSubscriptionPrice": { + "type": "object", + "properties": { + "price": { + "$ref": "KalturaPrice_Schema.json#/definitions/KalturaPrice" + }, + "purchaseStatus": { + "type": "string", + "minLength": 1 + }, + "endDate": { + "type": "integer", + "minimum": 0 + }, + "productId": { + "type": "string", + "minLength": 1 + }, + "productType": { + "type": "string", + "minLength": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaSubscriptionPrice"] + } + }, + "required": [ + "price", + "purchaseStatus", + "endDate", + "productId", + "productType", + "objectType" + ] + } + }, + "$ref": "#/definitions/KalturaSubscriptionPrice" +} \ No newline at end of file diff --git a/src/test/java/resources/schemas/KalturaTransaction_Schema.json b/src/test/java/resources/schemas/KalturaTransaction_Schema.json new file mode 100644 index 000000000..63b5f4c9d --- /dev/null +++ b/src/test/java/resources/schemas/KalturaTransaction_Schema.json @@ -0,0 +1,54 @@ +{ + "$id": "KalturaTransaction", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "paymentGatewayReferenceId": { + "type": "string", + "minLength": 1 + }, + "paymentGatewayResponseId": { + "type": "string", + "minLength": 1 + }, + "state": { + "type": "string", + "minLength": 1 + }, + "failReasonCode": { + "type": "integer", + "minimum": 0 + }, + "createdAt": { + "type": "integer", + "minimum": 1 + }, + "objectType": { + "type": "string", + "enum": ["KalturaTransaction"] + } + }, + "required": [ + "id", + "paymentGatewayReferenceId", + "paymentGatewayResponseId", + "state", + "failReasonCode", + "createdAt", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result" + ] +} \ No newline at end of file diff --git a/src/test/java/resources/testng.xml b/src/test/java/resources/testng.xml new file mode 100644 index 000000000..34aa11e6b --- /dev/null +++ b/src/test/java/resources/testng.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file From ed4181b25d5f1fa28fd55ee96be1bd6fd4e0ef2d Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 22 Mar 2018 11:44:41 +0200 Subject: [PATCH 002/605] move tests from old repo - part 2 --- .../kaltura/client/APIOkRequestsExecutor.java | 4 +- .../test/servicesImpl/OttUserServiceImpl.java | 184 +++++++----------- .../kaltura/client/test/tests/Sandbox.java | 4 +- .../ottUserTests/AnonymousLoginTests.java | 24 +++ .../ottUserTests/LoginTests.java | 58 ++++++ 5 files changed, 153 insertions(+), 121 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java diff --git a/src/main/java/com/kaltura/client/APIOkRequestsExecutor.java b/src/main/java/com/kaltura/client/APIOkRequestsExecutor.java index 0489d0db8..154210836 100644 --- a/src/main/java/com/kaltura/client/APIOkRequestsExecutor.java +++ b/src/main/java/com/kaltura/client/APIOkRequestsExecutor.java @@ -320,7 +320,7 @@ public boolean isEmpty() { } @SuppressWarnings("rawtypes") - private ResponseElement onGotResponse(Response response, RequestElement action) { + protected ResponseElement onGotResponse(Response response, RequestElement action) { String requestId = getRequestId(response); if (!response.isSuccessful()) { // in case response has failure status @@ -342,7 +342,7 @@ private ResponseElement onGotResponse(Response response, RequestElement action) } } - private String getRequestId(Response response) { + protected String getRequestId(Response response) { try { return response.request().tag().toString(); } catch (NullPointerException e) { diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index e8ebca966..2b9078951 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -1,74 +1,85 @@ package com.kaltura.client.test.servicesImpl; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.kaltura.client.Logger; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.GsonParser; -import org.json.JSONObject; +import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.LoginSession; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.StringValue; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; -import java.util.Optional; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; -import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.OttUserService.login; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; public class OttUserServiceImpl { - private static final String SERVICE = "ottUser"; - - private static final String LOGIN_ACTION = "login"; - private static final String ANONYMOUSLOGIN_ACTION = "anonymousLogin"; - private static final String REGISTER_ACTION = "register"; - private static final String ACTIVATE_ACTION = "activate"; - private static final String DELETE_ACTION = "delete"; - private static final String LIST_ACTION = "list"; - private static final String LOGIN_RESPONSE_SCHEMA = "KalturaLoginResponse_Schema.json"; private static final String LOGIN_SESSION_SCHEMA = "KalturaLoginSession_Schema.json"; private static final String OTT_USER_SCHEMA = "KalturaOttUser_Schema.json"; + private static Response loginResponse; + private static Response ottUserResponse; + private static Response loginSessionResponse; + + + public static Response loginImpl(int partnerId, String username, String password, Map extraParams, String udid) { + final AtomicBoolean done = new AtomicBoolean(false); - public static void login(String username, String password, Optional udid, Optional extra_params) { + LoginOttUserBuilder loginOttUserBuilder = login(partnerId, username, password, extraParams, udid) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions +// MatcherAssert.assertThat(result.results.toParams().toString(), matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); + } + loginResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); + await().untilTrue(done); + return loginResponse; } -// public static T anonymousLogin(Optional udid) { -// String body = anonymousLoginRequestBuilder(udid); -// Response response = setPostRequest(body, SERVICE, ANONYMOUSLOGIN_ACTION); -// -// if (isApiException(response)) { -// return (T) getApiException(response); -// } else { -// assertThat(response.asString(), matchesJsonSchemaInClasspath(LOGIN_SESSION_SCHEMA)); -// try { -// return GsonParser.parseObject(response.asString(), (Class) LoginSession.class); -// } catch (APIException e) { -// Logger.getLogger(OttUserService.class).error("LoginSession.class parse error"); -// e.printStackTrace(); -// return null; -// } -// } -// } -// -// public static T register(OTTUser ottUser, String password) { -// String body = registerRequestBuilder(ottUser, password); -// Response response = setPostRequest(body, SERVICE, REGISTER_ACTION); -// -// if (isApiException(response)) { -// return (T) getApiException(response); -// } else { -// assertThat(response.asString(), matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); -// try { -// return GsonParser.parseObject(response.asString(), (Class) OTTUser.class); -// } catch (APIException e) { -// Logger.getLogger(OttUserService.class).error("OTTUser.class parse error"); -// e.printStackTrace(); -// return null; -// } -// } -// } -// -// // TODO: 3/15/2018 ask Max if we need to expose partnerId to the crud function level + public static Response registerImpl(int partnerId, OTTUser user, String password) { + final AtomicBoolean done = new AtomicBoolean(false); + + RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, user, password) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + ottUserResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); + await().untilTrue(done); + + return ottUserResponse; + } + + public static Response anonymousLoginImpl(int partnerId, String udid) { + final AtomicBoolean done = new AtomicBoolean(false); + + AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = anonymousLogin(partnerId, udid) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + loginSessionResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); + await().untilTrue(done); + + return loginSessionResponse; + } + + // public static T activate(String ks, String username, String activationToken) { // String body = activateRequestBuilder(ks, username, activationToken); // Response response = setPostRequest(body, SERVICE, ACTIVATE_ACTION); @@ -179,67 +190,6 @@ public static void login(String username, String password, Optional udid // // TODO: 3/19/2018 implement function // return null; // } -// -// //////////////////////// -// /////help functions///// -// //////////////////////// -// private static String loginRequestBuilder(String username, String password, Optional udid, Optional extra_params) { -// JSONObject jsonObject = new JSONObject(); -// jsonObject -// .put("partnerId", partner_id) -// .put("apiVersion", api_version) -// .put("username", username) -// .put("password", password); -// -// udid.ifPresent(s -> jsonObject.put("udid", s)); -// extra_params.ifPresent(jsonObject1 -> jsonObject.put("extra_params", jsonObject1)); -//// String argument = optionalArgument.or("reasonable default"); -// -// return jsonObject.toString(); -// } -// -// private static String anonymousLoginRequestBuilder(Optional udid) { -// JSONObject jsonObject = new JSONObject(); -// jsonObject -// .put("apiVersion", api_version) -// .put("partnerId", partner_id); -// -// udid.ifPresent(s -> jsonObject.put("udid", s)); -// -// return jsonObject.toString(); -// } -// -// //TODO: add later fields "userType": OTTUserType and "dynamicData": map of StringValue if needed -// private static String registerRequestBuilder(OTTUser ottUser, String password) { -// JsonObject jsonObject = new JsonObject(); -// jsonObject.addProperty("apiVersion", api_version); -// jsonObject.addProperty("partnerId", partner_id); -// jsonObject.addProperty("password", password); -// -// JsonElement element = new Gson().fromJson(ottUser.toParams().toString(), JsonElement.class); -// jsonObject.add("user", element); -// -// return jsonObject.toString(); -// } -// -// private static String activateRequestBuilder(String ks, String username, String activationToken) { -// JSONObject jsonObject = getBaseRequestBody(ks); -// jsonObject -// .put("partnerId", partner_id) -// .put("username", username) -// .put("activationToken", activationToken); -// -// return jsonObject.toString(); -// } -// -// private static String listRequestBuilder(String ks, Optional ottUserFilter) { -// JsonObject jsonObject = getBaseRequestBodyGson(ks); -// if (ottUserFilter.isPresent()) { -// JsonElement element = new Gson().fromJson(ottUserFilter.get().toParams().toString(), JsonElement.class); -// jsonObject.add("filter", element); -// } -// return jsonObject.toString(); -// } } diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index 6ac3ed36c..ef2577279 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -29,14 +29,14 @@ public class Sandbox extends BaseTest { @BeforeClass public void sandbox_tests_setup() { user = generateOttUser(); - OttUserService.RegisterOttUserBuilder registerOttUserBuilder = register(PARTNER_ID, user, password); + RegisterOttUserBuilder registerOttUserBuilder = register(PARTNER_ID, user, password); APIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); } private Response sandboxLoginTest() { final AtomicBoolean done = new AtomicBoolean(false); - OttUserService.LoginOttUserBuilder loginOttUserBuilder = login(PARTNER_ID, user.getUsername(), password) + LoginOttUserBuilder loginOttUserBuilder = login(PARTNER_ID, user.getUsername(), password) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { assertThat(result.results.getLoginSession()).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java new file mode 100644 index 000000000..d9958b3c8 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -0,0 +1,24 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginSession; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.helper.Config.PARTNER_ID; +import static org.assertj.core.api.Assertions.assertThat; + +public class AnonymousLoginTests extends BaseTest { + + @Description("ottUser/action/anonymousLogin - anonymousLogin") + @Test() + public void anonymousLoginTest() { + Response loginSessionResponse = OttUserServiceImpl.anonymousLoginImpl(PARTNER_ID, null); + assertThat(loginSessionResponse.error).isNull(); + assertThat(loginSessionResponse.results.getKs()).isNotNull(); + } + + // TODO: 3/15/2018 add tests with wrong partnerId +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java new file mode 100644 index 000000000..894cc5889 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -0,0 +1,58 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.helper.Helper; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.helper.Config.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.helper.Config.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; +import static org.assertj.core.api.Assertions.assertThat; + +public class LoginTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response loginResponse; + + @BeforeClass + public void ottUser_tests_setup() { + user = Helper.generateOttUser(); + registerImpl(PARTNER_ID, user, password); + } + + // login tests + @Description("ottUser/action/login - login") + @Test + private void login() { + loginResponse = loginImpl(PARTNER_ID, user.getUsername(), password, null, null); + assertThat(loginResponse.error).isNull(); + assertThat(loginResponse.results.getLoginSession()).isNotNull(); + assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); + } + + @Description("ottUser/action/login - login with wrong password") + @Test + public void login_with_wrong_password() { + loginResponse = loginImpl(PARTNER_ID, user.getUsername(), password + "1", null, null); + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo("1011"); + assertThat(loginResponse.error.getMessage()).isEqualTo("Wrong username or password"); + } + + @Description("ottUser/action/login - login with wrong username") + @Test + public void login_with_wrong_username() { + loginResponse = loginImpl(PARTNER_ID, user.getUsername() + "1", password, null, null); + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo("2000"); + assertThat(loginResponse.error.getMessage()).isEqualTo("User does not exist"); + } +} From c6fc41f71bc5c8aeb8eb4b73a30295ea543d128b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 22 Mar 2018 15:34:55 +0200 Subject: [PATCH 003/605] get apiException list from api schema xml: https://api-preprod.ott.kaltura.com/v4_8/clientlibs/KalturaClient.xml --- .../kaltura/client/test/helper/Config.java | 1 + .../kaltura/client/test/helper/Helper.java | 49 +++++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 25 ++++++++- .../kaltura/client/test/tests/Sandbox.java | 54 +------------------ .../ottUserTests/AnonymousLoginTests.java | 12 ++++- .../ottUserTests/LoginTests.java | 21 +++++--- 6 files changed, 100 insertions(+), 62 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/helper/Config.java b/src/test/java/com/kaltura/client/test/helper/Config.java index cf1e91b77..462fc7961 100644 --- a/src/test/java/com/kaltura/client/test/helper/Config.java +++ b/src/test/java/com/kaltura/client/test/helper/Config.java @@ -38,4 +38,5 @@ public static String getProperty(String propertyKey) { // https://dzone.com/articles/how-to-automatically-skip-tests-based-on-defects-s // TODO: 3/19/2018 update readme file with project structure and list of services // TODO: 3/19/2018 find how to run specific tests according to api version + // TODO: 3/22/2018 ask Elram where to open the apiException meesage not equal to description issue } diff --git a/src/test/java/com/kaltura/client/test/helper/Helper.java b/src/test/java/com/kaltura/client/test/helper/Helper.java index e18c034c7..f6d166f2e 100644 --- a/src/test/java/com/kaltura/client/test/helper/Helper.java +++ b/src/test/java/com/kaltura/client/test/helper/Helper.java @@ -1,11 +1,28 @@ package com.kaltura.client.test.helper; +import com.kaltura.client.types.APIException; import com.kaltura.client.types.OTTUser; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.Random; +import static com.kaltura.client.test.helper.Config.API_URL_VERSION; + public class Helper { + private static final String API_SCHEMA_URL = "https://api-preprod.ott.kaltura.com/" + API_URL_VERSION + "/clientlibs/KalturaClient.xml"; + private static List exceptions; + //generate ottUser public static OTTUser generateOttUser() { long millis = System.currentTimeMillis(); @@ -38,4 +55,36 @@ public static String getRandomString() { } return sb.toString().toLowerCase(); } + + //generate apiException list base on the api schema + public static List getApiExceptionList() { + if (exceptions == null) { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = null; + try { + db = dbf.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } + Document doc = null; + try { + doc = db.parse(new URL(API_SCHEMA_URL).openStream()); + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + NodeList nodeList = doc.getElementsByTagName("error"); + + exceptions = new ArrayList<>(); + + for (int i = 0; i < nodeList.getLength(); i++) { + Element element = (Element) nodeList.item(i); + APIException exception = new APIException(null, element.getAttribute("description"), element.getAttribute("code")); + exceptions.add(exception); + } + } + return exceptions; + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 694a757da..c442ac6e8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,17 +2,24 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; -import com.kaltura.client.test.helper.Config; +import com.kaltura.client.ILogger; +import com.kaltura.client.Logger; +import com.kaltura.client.test.helper.Helper; +import com.kaltura.client.types.APIException; import org.testng.annotations.BeforeSuite; +import java.util.List; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.helper.Config.*; +import static com.kaltura.client.test.helper.Config.API_BASE_URL; +import static com.kaltura.client.test.helper.Config.API_URL_VERSION; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { + protected static ILogger logger = Logger.getLogger("java-test"); public static Client client; + private List exceptions; @BeforeSuite public void setup() { @@ -23,5 +30,19 @@ public void setup() { client = new Client(config); setDefaultTimeout(15, TimeUnit.SECONDS); + + exceptions = Helper.getApiExceptionList(); } + + + public APIException getAPIExceptionFromList(int code) { + for (APIException exception : exceptions) { + if (exception.getCode().equals(String.valueOf(code))) { + return exception; + } + } + logger.error("No such error code in the API schema"); + return null; + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index ef2577279..6f875ec7b 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -1,61 +1,11 @@ package com.kaltura.client.test.tests; -import com.kaltura.client.APIOkRequestsExecutor; -import com.kaltura.client.services.OttUserService; -import com.kaltura.client.types.LoginResponse; -import com.kaltura.client.types.OTTUser; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.test.helper.Config.*; -import static com.kaltura.client.test.helper.Helper.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; - public class Sandbox extends BaseTest { - private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; - - private Response response; - - private static final String LOGIN_RESPONSE_SCHEMA = "KalturaLoginResponse_Schema.json"; - - @BeforeClass - public void sandbox_tests_setup() { - user = generateOttUser(); - RegisterOttUserBuilder registerOttUserBuilder = register(PARTNER_ID, user, password); - APIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); - } - - private Response sandboxLoginTest() { - final AtomicBoolean done = new AtomicBoolean(false); - - LoginOttUserBuilder loginOttUserBuilder = login(PARTNER_ID, user.getUsername(), password) - .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - assertThat(result.results.getLoginSession()).isNotNull(); - assertThat(result.results.getUser()).isNotNull(); - -// MatcherAssert.assertThat(result.results.toParams().toString(), matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); - } - response = result; - done.set(true); - }); - APIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); - await().untilTrue(done); - - return response; - } - @Test - private void test11() { - sandboxLoginTest(); - System.out.println(response.results.getUser().getUsername()); + private void test() { + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index d9958b3c8..dfe5b45f0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -14,11 +14,19 @@ public class AnonymousLoginTests extends BaseTest { @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() - public void anonymousLoginTest() { + public void anonymousLogin() { Response loginSessionResponse = OttUserServiceImpl.anonymousLoginImpl(PARTNER_ID, null); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); } - // TODO: 3/15/2018 add tests with wrong partnerId + @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") + @Test() + public void anonymousLogin_with_wrong_partnerId() { + Response loginSessionResponse = OttUserServiceImpl.anonymousLoginImpl(PARTNER_ID + 1, null); + + assertThat(loginSessionResponse.results).isNull(); + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 894cc5889..ca0c56734 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -38,21 +38,30 @@ private void login() { assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); } - @Description("ottUser/action/login - login with wrong password") + @Description("ottUser/action/login - login with wrong password - error 1011") @Test public void login_with_wrong_password() { loginResponse = loginImpl(PARTNER_ID, user.getUsername(), password + "1", null, null); + assertThat(loginResponse.results).isNull(); - assertThat(loginResponse.error.getCode()).isEqualTo("1011"); - assertThat(loginResponse.error.getMessage()).isEqualTo("Wrong username or password"); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); } - @Description("ottUser/action/login - login with wrong username") + @Description("ottUser/action/login - login with wrong username - error 2000") @Test public void login_with_wrong_username() { loginResponse = loginImpl(PARTNER_ID, user.getUsername() + "1", password, null, null); + + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); + } + + @Description("ottUser/action/login - login with wrong partnerId - error 500006") + @Test() + public void login_with_wrong_partnerId() { + loginResponse = loginImpl(PARTNER_ID + 1, user.getUsername(), password, null, null); + assertThat(loginResponse.results).isNull(); - assertThat(loginResponse.error.getCode()).isEqualTo("2000"); - assertThat(loginResponse.error.getMessage()).isEqualTo("User does not exist"); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); } } From ac8d74bfb3ca15c6673f2335364c1e5994b46d26 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 25 Mar 2018 15:51:23 +0300 Subject: [PATCH 004/605] add createHousehold() util --- KalturaMainTest.launch | 21 ---- KalturaTestSuite.launch | 25 ----- .../kaltura/client/test/helper/DBHelper.java | 62 +++++++--- .../kaltura/client/test/helper/Helper.java | 2 +- .../helper/{Config.java => Properties.java} | 23 ++-- .../HouseholdDeviceServiceImpl.java | 40 +++++++ .../servicesImpl/HouseholdServiceImpl.java | 39 +++++++ .../HouseholdUserServiceImpl.java | 39 +++++++ .../test/servicesImpl/OttUserServiceImpl.java | 106 ++++++++++-------- .../kaltura/client/test/tests/BaseTest.java | 15 ++- .../ottUserTests/ActivateTests.java | 42 +++++++ .../ottUserTests/AddRoleTests.java | 14 +++ .../ottUserTests/AnonymousLoginTests.java | 2 +- .../ottUserTests/DeleteTests.java | 8 ++ .../ottUserTests/LoginTests.java | 6 +- .../client/test/tests/utils/Utils.java | 58 ++++++++++ ...BillingTransactionListResponse_Schema.json | 0 .../KalturaBillingTransaction_Schema.json | 0 ...KalturaEntitlementListResponse_Schema.json | 0 .../KalturaHouseholdDevice_Schema.json | 0 .../schemas/KalturaHouseholdUser_Schema.json | 0 .../schemas/KalturaHousehold_Schema.json | 0 .../schemas/KalturaLoginResponse_Schema.json | 0 .../schemas/KalturaLoginSession_Schema.json | 0 .../schemas/KalturaMediaAsset_Schema.json | 0 ...raMultilingualStringValueArray_Schema.json | 0 .../schemas/KalturaOttUser_Schema.json | 0 .../schemas/KalturaPpvEntitlement_Schema.json | 0 .../schemas/KalturaPpvPrice_Schema.json | 0 .../schemas/KalturaPrice_Schema.json | 0 ...alturaProductPriceListResponse_Schema.json | 0 ...KalturaSubscriptionEntitlement_Schema.json | 0 .../KalturaSubscriptionPrice_Schema.json | 0 .../schemas/KalturaTransaction_Schema.json | 0 src/test/{java => }/resources/testng.xml | 0 35 files changed, 378 insertions(+), 124 deletions(-) delete mode 100644 KalturaMainTest.launch delete mode 100644 KalturaTestSuite.launch rename src/test/java/com/kaltura/client/test/helper/{Config.java => Properties.java} (72%) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/utils/Utils.java rename src/test/{java => }/resources/schemas/KalturaBillingTransactionListResponse_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaBillingTransaction_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaEntitlementListResponse_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaHouseholdDevice_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaHouseholdUser_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaHousehold_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaLoginResponse_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaLoginSession_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaMediaAsset_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaMultilingualStringValueArray_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaOttUser_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaPpvEntitlement_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaPpvPrice_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaPrice_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaProductPriceListResponse_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaSubscriptionEntitlement_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaSubscriptionPrice_Schema.json (100%) rename src/test/{java => }/resources/schemas/KalturaTransaction_Schema.json (100%) rename src/test/{java => }/resources/testng.xml (100%) diff --git a/KalturaMainTest.launch b/KalturaMainTest.launch deleted file mode 100644 index 2bc32abcd..000000000 --- a/KalturaMainTest.launch +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/KalturaTestSuite.launch b/KalturaTestSuite.launch deleted file mode 100644 index 887a42e2f..000000000 --- a/KalturaTestSuite.launch +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/java/com/kaltura/client/test/helper/DBHelper.java b/src/test/java/com/kaltura/client/test/helper/DBHelper.java index 2a8a012d4..54c5dd2ca 100644 --- a/src/test/java/com/kaltura/client/test/helper/DBHelper.java +++ b/src/test/java/com/kaltura/client/test/helper/DBHelper.java @@ -1,13 +1,14 @@ package com.kaltura.client.test.helper; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; +import com.microsoft.sqlserver.jdbc.SQLServerException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import static com.kaltura.client.test.helper.Config.*; +import static com.kaltura.client.test.helper.Properties.*; public class DBHelper { @@ -20,16 +21,30 @@ public class DBHelper { private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; - public static String getActivationToken(String username) throws SQLException { + public static String getActivationToken(String username) { openConnection(); - rs = stam.executeQuery(String.format(ACTIVATION_TOKEN_SELECT, username)); - rs.next(); - String activationToke = rs.getString("ACTIVATION_TOKEN"); + try { + rs = stam.executeQuery(String.format(ACTIVATION_TOKEN_SELECT, username)); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + String activationToken = null; + try { + activationToken = rs.getString("ACTIVATION_TOKEN"); + } catch (SQLException e) { + e.printStackTrace(); +// Logger.getLogger(DBHelper.class).error("activationToken can't be null"); + } closeConnection(); - return activationToke; + return activationToken; } - private static void openConnection() throws SQLException { + private static void openConnection() { dataSource = new SQLServerDataSource(); dataSource.setUser(getProperty(DB_USER)); dataSource.setPassword(getProperty(DB_PASSWORD)); @@ -37,14 +52,33 @@ private static void openConnection() throws SQLException { dataSource.setApplicationIntent("ReadOnly"); dataSource.setMultiSubnetFailover(true); - conn = dataSource.getConnection(); - stam = conn.createStatement(); - + try { + conn = dataSource.getConnection(); + } catch (SQLServerException e) { + e.printStackTrace(); + } + try { + stam = conn.createStatement(); + } catch (SQLException e) { + e.printStackTrace(); + } } - private static void closeConnection() throws SQLException { - rs.close(); - stam.close(); - conn.close(); + private static void closeConnection() { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + stam.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } } } diff --git a/src/test/java/com/kaltura/client/test/helper/Helper.java b/src/test/java/com/kaltura/client/test/helper/Helper.java index f6d166f2e..42672a9c0 100644 --- a/src/test/java/com/kaltura/client/test/helper/Helper.java +++ b/src/test/java/com/kaltura/client/test/helper/Helper.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.Random; -import static com.kaltura.client.test.helper.Config.API_URL_VERSION; +import static com.kaltura.client.test.helper.Properties.API_URL_VERSION; public class Helper { diff --git a/src/test/java/com/kaltura/client/test/helper/Config.java b/src/test/java/com/kaltura/client/test/helper/Properties.java similarity index 72% rename from src/test/java/com/kaltura/client/test/helper/Config.java rename to src/test/java/com/kaltura/client/test/helper/Properties.java index 462fc7961..60c35d139 100644 --- a/src/test/java/com/kaltura/client/test/helper/Config.java +++ b/src/test/java/com/kaltura/client/test/helper/Properties.java @@ -1,32 +1,37 @@ package com.kaltura.client.test.helper; -import java.util.ResourceBundle; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.OTTUser; -public class Config { +import java.util.ResourceBundle; - private static ResourceBundle resourceBundle; +public class Properties { - //url properties + // Url properties public static final String API_BASE_URL = "http://34.249.122.223:8080"; public static final String API_URL_VERSION = "v4_8"; - //db properties + // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file public static final String DB_URL = "db_url"; public static final String DB_USER = "db_user"; public static final String DB_PASSWORD = "db_password"; - //request properties + // Request properties public static final int PARTNER_ID = 203; public static final String API_REQUEST_VERSION = "4.8.1"; - //global user properties + // Global user properties public static final String GLOBAL_USER_PASSWORD = "password"; + // Automation shared household + public static Household sharedHousehold; + public static OTTUser administratorUser, managerUser, operatorUser, masterUser; + public static String administratorUserKS, managerUserKS, operatorUserKS, masterUserKS; + public static String getProperty(String propertyKey) { - if (resourceBundle == null) - resourceBundle = ResourceBundle.getBundle("test"); + ResourceBundle resourceBundle = ResourceBundle.getBundle("test"); return resourceBundle.getString(propertyKey); } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java new file mode 100644 index 000000000..6dbdfc009 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -0,0 +1,40 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.types.HouseholdDevice; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.HouseholdDeviceService.AddHouseholdDeviceBuilder; +import static com.kaltura.client.services.HouseholdDeviceService.add; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class HouseholdDeviceServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response householdDeviceResponse; + + + //add + public static Response addImpl(String ks, HouseholdDevice householdDevice) { + + AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = add(householdDevice) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + client.setKs(ks); + householdDeviceResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(addHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdDeviceResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java new file mode 100644 index 000000000..05e2bbe1f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -0,0 +1,39 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.types.Household; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.HouseholdService.AddHouseholdBuilder; +import static com.kaltura.client.services.HouseholdService.add; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class HouseholdServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response householdResponse; + + + //add + public static Response addImpl(String ks, Household household) { + AddHouseholdBuilder addHouseholdBuilder = add(household) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + client.setKs(ks); + householdResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(addHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java new file mode 100644 index 000000000..5f760958e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -0,0 +1,39 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.HouseholdUserService.AddHouseholdUserBuilder; +import static com.kaltura.client.services.HouseholdUserService.add; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class HouseholdUserServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response householdUserResponse; + + + //add + public static Response addImpl(String ks, HouseholdUser householdUser) { + AddHouseholdUserBuilder addHouseholdUserBuilder = add(householdUser) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + client.setKs(ks); + householdUserResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(addHouseholdUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdUserResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 2b9078951..09cb9ebe0 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -18,6 +18,8 @@ public class OttUserServiceImpl { + private static final AtomicBoolean done = new AtomicBoolean(false); + private static final String LOGIN_RESPONSE_SCHEMA = "KalturaLoginResponse_Schema.json"; private static final String LOGIN_SESSION_SCHEMA = "KalturaLoginSession_Schema.json"; private static final String OTT_USER_SCHEMA = "KalturaOttUser_Schema.json"; @@ -25,11 +27,11 @@ public class OttUserServiceImpl { private static Response loginResponse; private static Response ottUserResponse; private static Response loginSessionResponse; + private static Response booleanResponse; + //login public static Response loginImpl(int partnerId, String username, String password, Map extraParams, String udid) { - final AtomicBoolean done = new AtomicBoolean(false); - LoginOttUserBuilder loginOttUserBuilder = login(partnerId, username, password, extraParams, udid) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { @@ -41,13 +43,13 @@ public static Response loginImpl(int partnerId, String username, }); APIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); await().untilTrue(done); + done.set(false); return loginResponse; } + //register public static Response registerImpl(int partnerId, OTTUser user, String password) { - final AtomicBoolean done = new AtomicBoolean(false); - RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, user, password) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { @@ -58,13 +60,13 @@ public static Response registerImpl(int partnerId, OTTUser user, String }); APIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); await().untilTrue(done); + done.set(false); return ottUserResponse; } + //anonymousLogin public static Response anonymousLoginImpl(int partnerId, String udid) { - final AtomicBoolean done = new AtomicBoolean(false); - AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = anonymousLogin(partnerId, udid) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { @@ -75,51 +77,63 @@ public static Response anonymousLoginImpl(int partnerId, String ud }); APIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); await().untilTrue(done); + done.set(false); return loginSessionResponse; } + //activate + public static Response activateImpl(int partnerId, String username, String activationToken) { + ActivateOttUserBuilder activateOttUserBuilder = activate(partnerId, username, activationToken) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + ottUserResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(activateOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); -// public static T activate(String ks, String username, String activationToken) { -// String body = activateRequestBuilder(ks, username, activationToken); -// Response response = setPostRequest(body, SERVICE, ACTIVATE_ACTION); -// -// if (isApiException(response)) { -// return (T) getApiException(response); -// } else { -// assertThat(response.asString(), matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); -// } -// try { -// return GsonParser.parseObject(response.asString(), (Class) OTTUser.class); -// } catch (APIException e) { -// Logger.getLogger(OttUserService.class).error("OTTUser parse error"); -// e.printStackTrace(); -// return null; -// } -// } -// -// public static T addRole(String ks, int roleId) { -// // TODO: 3/19/2018 implement function -// return null; -// } -// -// public static T delete(String ks) { -// String body = getBaseRequestBody(ks).toString(); -// Response response = setPostRequest(body, SERVICE, DELETE_ACTION); -// -// if (isApiException(response)) { -// return (T) getApiException(response); -// } else { -// try { -// assertThat(response.asString(), matchesJsonSchemaInClasspath(BOOLEAN_RESPONSE_SCHEMA)); -// return GsonParser.parseObject(response.asString(), (Class) Boolean.class); -// } catch (APIException e) { -// Logger.getLogger(OttUserService.class).error("Boolean.class parse error"); -// e.printStackTrace(); -// return null; -// } -// } -// } + return ottUserResponse; + } + + //addRole + public static Response addRoleImpl(String ks, int roleId) { + AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(roleId) + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + booleanResponse = result; + client.setKs(ks); + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + //delete + public static Response deleteImpl(String ks) { + DeleteOttUserBuilder deleteOttUserBuilder = delete() + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + booleanResponse = result; + client.setKs(ks); + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } // // public static T get(String ks) { // // TODO: 3/19/2018 implement function diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c442ac6e8..cd2457db3 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -5,14 +5,15 @@ import com.kaltura.client.ILogger; import com.kaltura.client.Logger; import com.kaltura.client.test.helper.Helper; +import com.kaltura.client.test.tests.utils.Utils; import com.kaltura.client.types.APIException; import org.testng.annotations.BeforeSuite; import java.util.List; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.helper.Config.API_BASE_URL; -import static com.kaltura.client.test.helper.Config.API_URL_VERSION; +import static com.kaltura.client.test.helper.Properties.API_BASE_URL; +import static com.kaltura.client.test.helper.Properties.API_URL_VERSION; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -23,18 +24,24 @@ public class BaseTest { @BeforeSuite public void setup() { + + // Set client Configuration config = new Configuration(); config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); config.setAcceptGzipEncoding(false); - client = new Client(config); + // Set default awaitility timeout setDefaultTimeout(15, TimeUnit.SECONDS); + // Get api exception list from schema xml exceptions = Helper.getApiExceptionList(); - } + // Generate shared tests data + Utils.createHouseHold(); + } + // Help functions public APIException getAPIExceptionFromList(int code) { for (APIException exception : exceptions) { if (exception.getCode().equals(String.valueOf(code))) { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java new file mode 100644 index 000000000..68c7687b7 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -0,0 +1,42 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.enums.UserState; +import com.kaltura.client.test.helper.DBHelper; +import com.kaltura.client.test.helper.Helper; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + +public class ActivateTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + @BeforeClass + public void ottUser_activate_tests_setup() { + user = Helper.generateOttUser(); + registerImpl(PARTNER_ID, user, password); + loginImpl(PARTNER_ID, user.getUsername(), password, null, null); + } + + @Description("ottUser/action/activate - activate") + @Test + private void activate() { + String activationToken = DBHelper.getActivationToken(user.getUsername()); + if (activationToken == null) + fail("activationToken can't be null"); + + Response ottUserResponse = activateImpl(PARTNER_ID, user.getUsername(),activationToken); + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java new file mode 100644 index 000000000..33172eb5e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -0,0 +1,14 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.Test; + +public class AddRoleTests extends BaseTest { + + @Description("ottUser/action/addRole - addRole") + @Test + private void addRole() { + // TODO: 3/25/2018 implement addRole test + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index dfe5b45f0..75e441939 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -7,7 +7,7 @@ import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.Test; -import static com.kaltura.client.test.helper.Config.PARTNER_ID; +import static com.kaltura.client.test.helper.Properties.PARTNER_ID; import static org.assertj.core.api.Assertions.assertThat; public class AnonymousLoginTests extends BaseTest { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java new file mode 100644 index 000000000..4bd10f7a9 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -0,0 +1,8 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.tests.BaseTest; + +public class DeleteTests extends BaseTest { + + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index ca0c56734..ab4d82a7f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -9,8 +9,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.helper.Config.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.helper.Config.PARTNER_ID; +import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.helper.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; import static org.assertj.core.api.Assertions.assertThat; @@ -23,7 +23,7 @@ public class LoginTests extends BaseTest { private Response loginResponse; @BeforeClass - public void ottUser_tests_setup() { + public void ottUser_login_tests_setup() { user = Helper.generateOttUser(); registerImpl(PARTNER_ID, user, password); } diff --git a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java new file mode 100644 index 000000000..d1e5d12a8 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java @@ -0,0 +1,58 @@ +package com.kaltura.client.test.tests.utils; + +import com.kaltura.client.test.servicesImpl.HouseholdDeviceServiceImpl; +import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; +import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; + +import static com.kaltura.client.test.helper.Helper.generateOttUser; +import static com.kaltura.client.test.helper.Properties.*; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; + +public class Utils { + + public static void createHouseHold() { + + // create, register and save master user + Response masterUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + masterUser = masterUserResponse.results; + + // login master user and save ks + Response loginResponse = loginImpl(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + masterUserKS = loginResponse.results.getLoginSession().getKs(); + + // create, add and save household + Household household = new Household(); + household.setName(masterUser.getFirstName() + "'s Domain"); + household.setDescription(masterUser.getLastName() + "Description"); + HouseholdServiceImpl.addImpl(masterUserKS, household); + sharedHousehold = household; + + // create, register and add non-master user to household + Response secondUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + OTTUser secondUser = secondUserResponse.results; +// loginImpl(PARTNER_ID, secondUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + HouseholdUser householdUser = new HouseholdUser(); + householdUser.setUserId(secondUser.getId()); + householdUser.setIsMaster(false); + HouseholdUserServiceImpl.addImpl(masterUserKS, householdUser); + + // create, add and save household device + long uniqueString = System.currentTimeMillis(); + HouseholdDevice householdDevice = new HouseholdDevice(); + householdDevice.setUdid(String.valueOf(uniqueString)); + householdDevice.setBrandId(1); + householdDevice.setName(String.valueOf(uniqueString) + "device"); + HouseholdDeviceServiceImpl.addImpl(masterUserKS, householdDevice); + + // login as master using household device + loginResponse = loginImpl(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, householdDevice.getUdid()); + masterUserKS = loginResponse.results.getLoginSession().getKs(); + +// // set PG to HH +// String operatorKs = operatorUserKs; +// HouseholdPaymentGatewayService.setChargeID(operatorKs, masterUser.getId(), default_payment_gateway_external_id,"1234"); + } +} diff --git a/src/test/java/resources/schemas/KalturaBillingTransactionListResponse_Schema.json b/src/test/resources/schemas/KalturaBillingTransactionListResponse_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaBillingTransactionListResponse_Schema.json rename to src/test/resources/schemas/KalturaBillingTransactionListResponse_Schema.json diff --git a/src/test/java/resources/schemas/KalturaBillingTransaction_Schema.json b/src/test/resources/schemas/KalturaBillingTransaction_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaBillingTransaction_Schema.json rename to src/test/resources/schemas/KalturaBillingTransaction_Schema.json diff --git a/src/test/java/resources/schemas/KalturaEntitlementListResponse_Schema.json b/src/test/resources/schemas/KalturaEntitlementListResponse_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaEntitlementListResponse_Schema.json rename to src/test/resources/schemas/KalturaEntitlementListResponse_Schema.json diff --git a/src/test/java/resources/schemas/KalturaHouseholdDevice_Schema.json b/src/test/resources/schemas/KalturaHouseholdDevice_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaHouseholdDevice_Schema.json rename to src/test/resources/schemas/KalturaHouseholdDevice_Schema.json diff --git a/src/test/java/resources/schemas/KalturaHouseholdUser_Schema.json b/src/test/resources/schemas/KalturaHouseholdUser_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaHouseholdUser_Schema.json rename to src/test/resources/schemas/KalturaHouseholdUser_Schema.json diff --git a/src/test/java/resources/schemas/KalturaHousehold_Schema.json b/src/test/resources/schemas/KalturaHousehold_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaHousehold_Schema.json rename to src/test/resources/schemas/KalturaHousehold_Schema.json diff --git a/src/test/java/resources/schemas/KalturaLoginResponse_Schema.json b/src/test/resources/schemas/KalturaLoginResponse_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaLoginResponse_Schema.json rename to src/test/resources/schemas/KalturaLoginResponse_Schema.json diff --git a/src/test/java/resources/schemas/KalturaLoginSession_Schema.json b/src/test/resources/schemas/KalturaLoginSession_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaLoginSession_Schema.json rename to src/test/resources/schemas/KalturaLoginSession_Schema.json diff --git a/src/test/java/resources/schemas/KalturaMediaAsset_Schema.json b/src/test/resources/schemas/KalturaMediaAsset_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaMediaAsset_Schema.json rename to src/test/resources/schemas/KalturaMediaAsset_Schema.json diff --git a/src/test/java/resources/schemas/KalturaMultilingualStringValueArray_Schema.json b/src/test/resources/schemas/KalturaMultilingualStringValueArray_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaMultilingualStringValueArray_Schema.json rename to src/test/resources/schemas/KalturaMultilingualStringValueArray_Schema.json diff --git a/src/test/java/resources/schemas/KalturaOttUser_Schema.json b/src/test/resources/schemas/KalturaOttUser_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaOttUser_Schema.json rename to src/test/resources/schemas/KalturaOttUser_Schema.json diff --git a/src/test/java/resources/schemas/KalturaPpvEntitlement_Schema.json b/src/test/resources/schemas/KalturaPpvEntitlement_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaPpvEntitlement_Schema.json rename to src/test/resources/schemas/KalturaPpvEntitlement_Schema.json diff --git a/src/test/java/resources/schemas/KalturaPpvPrice_Schema.json b/src/test/resources/schemas/KalturaPpvPrice_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaPpvPrice_Schema.json rename to src/test/resources/schemas/KalturaPpvPrice_Schema.json diff --git a/src/test/java/resources/schemas/KalturaPrice_Schema.json b/src/test/resources/schemas/KalturaPrice_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaPrice_Schema.json rename to src/test/resources/schemas/KalturaPrice_Schema.json diff --git a/src/test/java/resources/schemas/KalturaProductPriceListResponse_Schema.json b/src/test/resources/schemas/KalturaProductPriceListResponse_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaProductPriceListResponse_Schema.json rename to src/test/resources/schemas/KalturaProductPriceListResponse_Schema.json diff --git a/src/test/java/resources/schemas/KalturaSubscriptionEntitlement_Schema.json b/src/test/resources/schemas/KalturaSubscriptionEntitlement_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaSubscriptionEntitlement_Schema.json rename to src/test/resources/schemas/KalturaSubscriptionEntitlement_Schema.json diff --git a/src/test/java/resources/schemas/KalturaSubscriptionPrice_Schema.json b/src/test/resources/schemas/KalturaSubscriptionPrice_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaSubscriptionPrice_Schema.json rename to src/test/resources/schemas/KalturaSubscriptionPrice_Schema.json diff --git a/src/test/java/resources/schemas/KalturaTransaction_Schema.json b/src/test/resources/schemas/KalturaTransaction_Schema.json similarity index 100% rename from src/test/java/resources/schemas/KalturaTransaction_Schema.json rename to src/test/resources/schemas/KalturaTransaction_Schema.json diff --git a/src/test/java/resources/testng.xml b/src/test/resources/testng.xml similarity index 100% rename from src/test/java/resources/testng.xml rename to src/test/resources/testng.xml From 4ea45668ab64242df40fdababe379b635cb3c03b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 26 Mar 2018 12:11:14 +0300 Subject: [PATCH 005/605] debug Service Forbidden in HouseholdServiceImpl.addImpl --- .../client/test/helper/Properties.java | 32 ++++--- .../HouseholdUserServiceImpl.java | 23 ++++- .../test/servicesImpl/OttUserServiceImpl.java | 83 ++++++++++--------- .../kaltura/client/test/tests/BaseTest.java | 21 +++-- .../ottUserTests/DeleteTests.java | 24 ++++++ .../servicesTests/ottUserTests/GetTests.java | 41 +++++++++ .../servicesTests/ottUserTests/ListTests.java | 23 +++++ .../client/test/tests/utils/Utils.java | 66 ++++++++------- 8 files changed, 226 insertions(+), 87 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java diff --git a/src/test/java/com/kaltura/client/test/helper/Properties.java b/src/test/java/com/kaltura/client/test/helper/Properties.java index 60c35d139..f379b9ca3 100644 --- a/src/test/java/com/kaltura/client/test/helper/Properties.java +++ b/src/test/java/com/kaltura/client/test/helper/Properties.java @@ -1,37 +1,47 @@ package com.kaltura.client.test.helper; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.OTTUser; - import java.util.ResourceBundle; public class Properties { + private static ResourceBundle resourceBundle; + // Url properties public static final String API_BASE_URL = "http://34.249.122.223:8080"; public static final String API_URL_VERSION = "v4_8"; // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file - public static final String DB_URL = "db_url"; - public static final String DB_USER = "db_user"; - public static final String DB_PASSWORD = "db_password"; + static final String DB_URL = "db_url"; + static final String DB_USER = "db_user"; + static final String DB_PASSWORD = "db_password"; // Request properties public static final int PARTNER_ID = 203; public static final String API_REQUEST_VERSION = "4.8.1"; // Global user properties + public static final String ADMINISTRATOR_USERNAME = "administrator_user_username"; + public static final String ADMINISTRATOR_PASSWORD = "administrator_user_password"; + + public static final String OPERATOR_USERNAME = "operator_user_username"; + public static final String OPERATOR_PASSWORD = "operator_user_password"; + + public static final String MANAGER_USERNAME = "manager_user_username"; + public static final String MANAGER_PASSWORD = "manager_user_password"; + public static final String GLOBAL_USER_PASSWORD = "password"; - // Automation shared household - public static Household sharedHousehold; - public static OTTUser administratorUser, managerUser, operatorUser, masterUser; - public static String administratorUserKS, managerUserKS, operatorUserKS, masterUserKS; +// // Automation shared household +// public static Household sharedHousehold; +// public static OTTUser administratorUser, managerUser, operatorUser, masterUser; +// public static String administratorUserKS, managerUserKS, operatorUserKS, masterUserKS; public static String getProperty(String propertyKey) { - ResourceBundle resourceBundle = ResourceBundle.getBundle("test"); + if (resourceBundle == null) + resourceBundle = ResourceBundle.getBundle("test"); + return resourceBundle.getString(propertyKey); } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index 5f760958e..9b32d5e0d 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -2,13 +2,14 @@ import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.types.HouseholdUserFilter; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; import java.util.concurrent.atomic.AtomicBoolean; -import static com.kaltura.client.services.HouseholdUserService.AddHouseholdUserBuilder; -import static com.kaltura.client.services.HouseholdUserService.add; +import static com.kaltura.client.services.HouseholdUserService.*; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -17,6 +18,7 @@ public class HouseholdUserServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response householdUserResponse; + private static Response> householdUserListResponse; //add @@ -36,4 +38,21 @@ public static Response addImpl(String ks, HouseholdUser household return householdUserResponse; } + + public static Response> listImpl(String ks, HouseholdUserFilter householdUserFilter) { + ListHouseholdUserBuilder listHouseholdUserBuilder = list(householdUserFilter) + .setCompletion((ApiCompletion>) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + client.setKs(ks); + householdUserListResponse = result; + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(listHouseholdUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdUserListResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 09cb9ebe0..51b97a298 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -1,10 +1,7 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.APIOkRequestsExecutor; -import com.kaltura.client.types.LoginResponse; -import com.kaltura.client.types.LoginSession; -import com.kaltura.client.types.OTTUser; -import com.kaltura.client.types.StringValue; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; @@ -28,6 +25,7 @@ public class OttUserServiceImpl { private static Response ottUserResponse; private static Response loginSessionResponse; private static Response booleanResponse; + private static Response> ottUserListResponse; //login @@ -100,7 +98,7 @@ public static Response activateImpl(int partnerId, String username, Str } //addRole - public static Response addRoleImpl(String ks, int roleId) { + public static Response addRoleImpl(String ks, int userId, int roleId) { AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(roleId) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { @@ -108,6 +106,7 @@ public static Response addRoleImpl(String ks, int roleId) { } booleanResponse = result; client.setKs(ks); + client.setUserId(userId); done.set(true); }); APIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); @@ -118,7 +117,7 @@ public static Response addRoleImpl(String ks, int roleId) { } //delete - public static Response deleteImpl(String ks) { + public static Response deleteImpl(String ks, int userId) { DeleteOttUserBuilder deleteOttUserBuilder = delete() .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { @@ -126,6 +125,7 @@ public static Response deleteImpl(String ks) { } booleanResponse = result; client.setKs(ks); + client.setUserId(userId); done.set(true); }); APIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); @@ -134,37 +134,41 @@ public static Response deleteImpl(String ks) { return booleanResponse; } -// -// public static T get(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } -// -// public static T getEncryptedUserId(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } -// -///* public static T list(String ks, Optional ottUserFilter) { -// String body = listRequestBuilder(ks, ottUserFilter); -// Response response = setPostRequest(body, SERVICE, LIST_ACTION); -// -// if (isApiException(response)) { -// return (T) getApiException(response); -// } else { -// try { -// assertThat(response.asString(), matchesJsonSchemaInClasspath(BOOLEAN_RESPONSE_SCHEMA)); -// return GsonParser.parseListResponse(response.asString(), OTTUser.class); -// } catch (APIException e) { -// e.printStackTrace(); -// return null; -// } -// } -// // KalturaOTTUserListResponse -// // TODO: 3/19/2018 implement function -// return null; -// }*/ -// + + public static Response getImpl(String ks) { + GetOttUserBuilder getOttUserBuilder = get() + .setCompletion((ApiCompletion) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + ottUserResponse = result; + client.setKs(ks); + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ottUserResponse; + } + + public static Response> listImpl(String ks, OTTUserFilter ottUserFilter) { + ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) + .setCompletion((ApiCompletion>) result -> { + if (result.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + ottUserListResponse = result; + client.setKs(ks); + done.set(true); + }); + APIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ottUserListResponse; + } + // public static T loginWithPin(String ks) { // // TODO: 3/19/2018 implement function // return null; @@ -204,6 +208,11 @@ public static Response deleteImpl(String ks) { // // TODO: 3/19/2018 implement function // return null; // } +// +// public static T getEncryptedUserId(String ks) { +// // TODO: 3/19/2018 implement function +// return null; +// } } diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index cd2457db3..509105b96 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -5,15 +5,15 @@ import com.kaltura.client.ILogger; import com.kaltura.client.Logger; import com.kaltura.client.test.helper.Helper; -import com.kaltura.client.test.tests.utils.Utils; import com.kaltura.client.types.APIException; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; import java.util.List; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.helper.Properties.API_BASE_URL; -import static com.kaltura.client.test.helper.Properties.API_URL_VERSION; +import static com.kaltura.client.test.helper.Properties.*; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -21,6 +21,9 @@ public class BaseTest { protected static ILogger logger = Logger.getLogger("java-test"); public static Client client; private List exceptions; + private Response loginResponse; + + public static String administratorKS, operatorKS, managerKS; @BeforeSuite public void setup() { @@ -30,6 +33,7 @@ public void setup() { config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); config.setAcceptGzipEncoding(false); client = new Client(config); + client.setApiVersion(API_REQUEST_VERSION); // Set default awaitility timeout setDefaultTimeout(15, TimeUnit.SECONDS); @@ -37,8 +41,15 @@ public void setup() { // Get api exception list from schema xml exceptions = Helper.getApiExceptionList(); - // Generate shared tests data - Utils.createHouseHold(); +/* // Login with shared users + loginResponse = loginImpl(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); + administratorKS = loginResponse.results.getLoginSession().getKs(); + + loginResponse = loginImpl(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); + operatorKS = loginResponse.results.getLoginSession().getKs(); + + loginResponse = loginImpl(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); + managerKS = loginResponse.results.getLoginSession().getKs();*/ } // Help functions diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 4bd10f7a9..0fcf3443d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -1,8 +1,32 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.utils.Utils; +import com.kaltura.client.types.Household; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; public class DeleteTests extends BaseTest { + @BeforeClass + public void ottUser_login_tests_setup() { + +// HouseholdUserFilter filter = new HouseholdUserFilter(); +// filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); +// +// Response> users = HouseholdUserServiceImpl.listImpl(administratorKS, filter); +// System.out.println(users.results.getTotalCount()); + } + + @Description("ottUser/action/delete - delete") + @Test + private void delete() { + Household household = Utils.createHouseHold(2, 0); + System.out.println(household.getId()); + +// deleteImpl(adminKS, Integer.parseInt(user.getId())); + // TODO: 3/25/2018 finish test + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java new file mode 100644 index 000000000..4b712b7e7 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.helper.Helper; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.getImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; +import static org.assertj.core.api.Assertions.assertThat; + +public class GetTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response loginResponse; + + @BeforeClass + public void ottUser_login_tests_setup() { + user = Helper.generateOttUser(); + registerImpl(PARTNER_ID, user, password); + loginResponse = loginImpl(PARTNER_ID, user.getUsername(), password, null, null); + } + + // get tests + @Description("ottUser/action/get - get") + @Test + private void get() { + Response ottUserResponse = getImpl(loginResponse.results.getLoginSession().getKs()); + assertThat(loginResponse.error).isNull(); + assertThat(ottUserResponse.results).isEqualToComparingFieldByField(user); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java new file mode 100644 index 000000000..337282a26 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -0,0 +1,23 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.utils.Utils; +import com.kaltura.client.types.Household; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.Test; + +public class ListTests extends BaseTest { + + @Description("ottUser/action/list - list") + @Test + public void list() { + Household household = Utils.createHouseHold(3, 1); + household.getId(); + + // TODO: 3/25/2018 finish test impl +// listImpl() +// +// assertThat(loginResponse.results).isNull(); +// assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java index d1e5d12a8..63f5e2034 100644 --- a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java +++ b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java @@ -1,55 +1,57 @@ package com.kaltura.client.test.tests.utils; -import com.kaltura.client.test.servicesImpl.HouseholdDeviceServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; -import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import static com.kaltura.client.test.helper.Helper.generateOttUser; -import static com.kaltura.client.test.helper.Properties.*; +import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.helper.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; public class Utils { - public static void createHouseHold() { + public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold) { - // create, register and save master user + // create and register Response masterUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); - masterUser = masterUserResponse.results; + OTTUser masterUser = masterUserResponse.results; - // login master user and save ks + // login master user Response loginResponse = loginImpl(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); - masterUserKS = loginResponse.results.getLoginSession().getKs(); + String masterUserKS = loginResponse.results.getLoginSession().getKs(); - // create, add and save household + // create and add household Household household = new Household(); household.setName(masterUser.getFirstName() + "'s Domain"); household.setDescription(masterUser.getLastName() + "Description"); HouseholdServiceImpl.addImpl(masterUserKS, household); - sharedHousehold = household; - - // create, register and add non-master user to household - Response secondUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); - OTTUser secondUser = secondUserResponse.results; -// loginImpl(PARTNER_ID, secondUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); - HouseholdUser householdUser = new HouseholdUser(); - householdUser.setUserId(secondUser.getId()); - householdUser.setIsMaster(false); - HouseholdUserServiceImpl.addImpl(masterUserKS, householdUser); - - // create, add and save household device - long uniqueString = System.currentTimeMillis(); - HouseholdDevice householdDevice = new HouseholdDevice(); - householdDevice.setUdid(String.valueOf(uniqueString)); - householdDevice.setBrandId(1); - householdDevice.setName(String.valueOf(uniqueString) + "device"); - HouseholdDeviceServiceImpl.addImpl(masterUserKS, householdDevice); - - // login as master using household device - loginResponse = loginImpl(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, householdDevice.getUdid()); - masterUserKS = loginResponse.results.getLoginSession().getKs(); +// +// // create, register and add non-master user to household +// for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { +// Response additionalUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); +// OTTUser additionalUser = additionalUserResponse.results; +// HouseholdUser householdUser = new HouseholdUser(); +// householdUser.setUserId(additionalUser.getId()); +// householdUser.setIsMaster(false); +// HouseholdUserServiceImpl.addImpl(masterUserKS, householdUser); +// } +// +// // create, add and save household device +// for (int i = 0; i < numberOfDevicesInHousehold; i++) { +// long uniqueString = System.currentTimeMillis(); +// HouseholdDevice householdDevice = new HouseholdDevice(); +// householdDevice.setUdid(String.valueOf(uniqueString)); +// Random r = new Random(); +// householdDevice.setBrandId(r.nextInt(30 - 1) + 1); +// householdDevice.setName(String.valueOf(uniqueString) + "device"); +// HouseholdDeviceServiceImpl.addImpl(masterUserKS, householdDevice); +// } + + return household; // // set PG to HH // String operatorKs = operatorUserKs; From 93cd422cd0d773266e913ca38f5bbd192091cad3 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 26 Mar 2018 15:09:09 +0300 Subject: [PATCH 006/605] fix for createHousehold util --- .../HouseholdDeviceServiceImpl.java | 3 +- .../servicesImpl/HouseholdServiceImpl.java | 3 +- .../HouseholdUserServiceImpl.java | 6 +- .../test/servicesImpl/OttUserServiceImpl.java | 20 ++++-- .../ottUserTests/DeleteTests.java | 14 ++--- .../client/test/tests/utils/Utils.java | 63 ++++++++++--------- 6 files changed, 61 insertions(+), 48 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index 6dbdfc009..c5741d153 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -27,10 +27,11 @@ public static Response addImpl(String ks, HouseholdDevice house if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions } - client.setKs(ks); householdDeviceResponse = result; done.set(true); }); + + addHouseholdDeviceBuilder.setKs(ks); APIOkRequestsExecutor.getExecutor().queue(addHouseholdDeviceBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 05e2bbe1f..6316e2261 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -26,10 +26,11 @@ public static Response addImpl(String ks, Household household) { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions } - client.setKs(ks); householdResponse = result; done.set(true); }); + + addHouseholdBuilder.setKs(ks); APIOkRequestsExecutor.getExecutor().queue(addHouseholdBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index 9b32d5e0d..b35447da2 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -28,10 +28,11 @@ public static Response addImpl(String ks, HouseholdUser household if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions } - client.setKs(ks); householdUserResponse = result; done.set(true); }); + + addHouseholdUserBuilder.setKs(ks); APIOkRequestsExecutor.getExecutor().queue(addHouseholdUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -45,10 +46,11 @@ public static Response> listImpl(String ks, Househol if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions } - client.setKs(ks); householdUserListResponse = result; done.set(true); }); + + listHouseholdUserBuilder.setKs(ks); APIOkRequestsExecutor.getExecutor().queue(listHouseholdUserBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 51b97a298..0f148e179 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -39,6 +39,7 @@ public static Response loginImpl(int partnerId, String username, loginResponse = result; done.set(true); }); + APIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -56,6 +57,7 @@ public static Response registerImpl(int partnerId, OTTUser user, String ottUserResponse = result; done.set(true); }); + APIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -73,6 +75,7 @@ public static Response anonymousLoginImpl(int partnerId, String ud loginSessionResponse = result; done.set(true); }); + APIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -90,6 +93,7 @@ public static Response activateImpl(int partnerId, String username, Str ottUserResponse = result; done.set(true); }); + APIOkRequestsExecutor.getExecutor().queue(activateOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -105,10 +109,11 @@ public static Response addRoleImpl(String ks, int userId, int roleId) { // TODO: 3/22/2018 fix schema assertions } booleanResponse = result; - client.setKs(ks); - client.setUserId(userId); done.set(true); }); + + addRoleOttUserBuilder.setKs(ks); + addRoleOttUserBuilder.setUserId(userId); APIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -124,10 +129,11 @@ public static Response deleteImpl(String ks, int userId) { // TODO: 3/22/2018 fix schema assertions } booleanResponse = result; - client.setKs(ks); - client.setUserId(userId); done.set(true); }); + + deleteOttUserBuilder.setKs(ks); + deleteOttUserBuilder.setUserId(userId); APIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -142,9 +148,10 @@ public static Response getImpl(String ks) { // TODO: 3/22/2018 fix schema assertions } ottUserResponse = result; - client.setKs(ks); done.set(true); }); + + getOttUserBuilder.setKs(ks); APIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -159,9 +166,10 @@ public static Response> listImpl(String ks, OTTUserFilter // TODO: 3/22/2018 fix schema assertions } ottUserListResponse = result; - client.setKs(ks); done.set(true); }); + + listOttUserBuilder.setKs(ks); APIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 0fcf3443d..8549022df 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -12,19 +12,19 @@ public class DeleteTests extends BaseTest { @BeforeClass public void ottUser_login_tests_setup() { - -// HouseholdUserFilter filter = new HouseholdUserFilter(); -// filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); -// -// Response> users = HouseholdUserServiceImpl.listImpl(administratorKS, filter); -// System.out.println(users.results.getTotalCount()); } @Description("ottUser/action/delete - delete") @Test private void delete() { Household household = Utils.createHouseHold(2, 0); - System.out.println(household.getId()); + System.out.println(String.valueOf(household.getId())); + +// HouseholdUserFilter filter = new HouseholdUserFilter(); +// filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); +// +// Response> users = HouseholdUserServiceImpl.listImpl(administratorKS, filter); +// System.out.println(users.results.getTotalCount()); // deleteImpl(adminKS, Integer.parseInt(user.getId())); // TODO: 3/25/2018 finish test diff --git a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java index 63f5e2034..6c9564164 100644 --- a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java +++ b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java @@ -1,11 +1,13 @@ package com.kaltura.client.test.tests.utils; +import com.kaltura.client.test.servicesImpl.HouseholdDeviceServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.LoginResponse; -import com.kaltura.client.types.OTTUser; +import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import java.util.Random; + import static com.kaltura.client.test.helper.Helper.generateOttUser; import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.helper.Properties.PARTNER_ID; @@ -22,39 +24,38 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO // login master user Response loginResponse = loginImpl(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + masterUser = loginResponse.results.getUser(); String masterUserKS = loginResponse.results.getLoginSession().getKs(); // create and add household Household household = new Household(); - household.setName(masterUser.getFirstName() + "'s Domain"); - household.setDescription(masterUser.getLastName() + "Description"); - HouseholdServiceImpl.addImpl(masterUserKS, household); -// -// // create, register and add non-master user to household -// for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { -// Response additionalUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); -// OTTUser additionalUser = additionalUserResponse.results; -// HouseholdUser householdUser = new HouseholdUser(); -// householdUser.setUserId(additionalUser.getId()); -// householdUser.setIsMaster(false); -// HouseholdUserServiceImpl.addImpl(masterUserKS, householdUser); -// } -// -// // create, add and save household device -// for (int i = 0; i < numberOfDevicesInHousehold; i++) { -// long uniqueString = System.currentTimeMillis(); -// HouseholdDevice householdDevice = new HouseholdDevice(); -// householdDevice.setUdid(String.valueOf(uniqueString)); -// Random r = new Random(); -// householdDevice.setBrandId(r.nextInt(30 - 1) + 1); -// householdDevice.setName(String.valueOf(uniqueString) + "device"); -// HouseholdDeviceServiceImpl.addImpl(masterUserKS, householdDevice); -// } + household.setName(masterUser.getFirstName() + "s Domain"); + household.setDescription(masterUser.getLastName() + " Description"); + + Response householdResponse = HouseholdServiceImpl.addImpl(masterUserKS, household); + household = householdResponse.results; + + // create, register and add non-master user to household + for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { + Response additionalUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + OTTUser additionalUser = additionalUserResponse.results; + HouseholdUser householdUser = new HouseholdUser(); + householdUser.setUserId(additionalUser.getId()); + householdUser.setIsMaster(false); + HouseholdUserServiceImpl.addImpl(masterUserKS, householdUser); + } + + // create, add and save household device + for (int i = 0; i < numberOfDevicesInHousehold; i++) { + long uniqueString = System.currentTimeMillis(); + HouseholdDevice householdDevice = new HouseholdDevice(); + householdDevice.setUdid(String.valueOf(uniqueString)); + Random r = new Random(); + householdDevice.setBrandId(r.nextInt(30 - 1) + 1); + householdDevice.setName(String.valueOf(uniqueString) + "device"); + HouseholdDeviceServiceImpl.addImpl(masterUserKS, householdDevice); + } return household; - -// // set PG to HH -// String operatorKs = operatorUserKs; -// HouseholdPaymentGatewayService.setChargeID(operatorKs, masterUser.getId(), default_payment_gateway_external_id,"1234"); } } From bd192d3fc99201a574721957b77ed47d67220635 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 27 Mar 2018 11:15:00 +0300 Subject: [PATCH 007/605] ottUser delete test --- .../kaltura/client/test/helper/Helper.java | 17 +++- .../servicesImpl/HouseholdServiceImpl.java | 20 ++++- .../test/servicesImpl/OttUserServiceImpl.java | 8 +- .../kaltura/client/test/tests/BaseTest.java | 32 ++----- .../ottUserTests/AnonymousLoginTests.java | 1 + .../ottUserTests/DeleteTests.java | 84 ++++++++++++++++--- .../servicesTests/ottUserTests/GetTests.java | 4 +- .../ottUserTests/LoginTests.java | 5 +- 8 files changed, 126 insertions(+), 45 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/helper/Helper.java b/src/test/java/com/kaltura/client/test/helper/Helper.java index 42672a9c0..0c596a01c 100644 --- a/src/test/java/com/kaltura/client/test/helper/Helper.java +++ b/src/test/java/com/kaltura/client/test/helper/Helper.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.helper; +import com.kaltura.client.Logger; import com.kaltura.client.types.APIException; import com.kaltura.client.types.OTTUser; import org.w3c.dom.Document; @@ -56,8 +57,22 @@ public static String getRandomString() { return sb.toString().toLowerCase(); } + //get api exception + public static APIException getAPIExceptionFromList(int code) { + getApiExceptionList(); + + for (APIException exception : exceptions) { + if (exception.getCode().equals(String.valueOf(code))) { + return exception; + } + } + + Logger.getLogger(Helper.class).error("No such error code in the API schema"); + return null; + } + //generate apiException list base on the api schema - public static List getApiExceptionList() { + private static List getApiExceptionList() { if (exceptions == null) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 6316e2261..971cee784 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -7,8 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean; -import static com.kaltura.client.services.HouseholdService.AddHouseholdBuilder; -import static com.kaltura.client.services.HouseholdService.add; +import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -17,6 +16,7 @@ public class HouseholdServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response householdResponse; + private static Response booleanResponse; //add @@ -37,4 +37,20 @@ public static Response addImpl(String ks, Household household) { return householdResponse; } + + //delete + public static Response deleteImpl(String ks, int householdId) { + DeleteHouseholdBuilder deleteHouseholdBuilder = delete(householdId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + deleteHouseholdBuilder.setKs(ks); + APIOkRequestsExecutor.getExecutor().queue(deleteHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 0f148e179..3d0cd0162 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -6,6 +6,7 @@ import com.kaltura.client.utils.response.base.Response; import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.OttUserService.*; @@ -122,7 +123,7 @@ public static Response addRoleImpl(String ks, int userId, int roleId) { } //delete - public static Response deleteImpl(String ks, int userId) { + public static Response deleteImpl(String ks, Integer userId) { DeleteOttUserBuilder deleteOttUserBuilder = delete() .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { @@ -134,6 +135,7 @@ public static Response deleteImpl(String ks, int userId) { deleteOttUserBuilder.setKs(ks); deleteOttUserBuilder.setUserId(userId); + APIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -141,7 +143,7 @@ public static Response deleteImpl(String ks, int userId) { return booleanResponse; } - public static Response getImpl(String ks) { + public static Response getImpl(String ks, Optional userId) { GetOttUserBuilder getOttUserBuilder = get() .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { @@ -152,6 +154,8 @@ public static Response getImpl(String ks) { }); getOttUserBuilder.setKs(ks); + userId.ifPresent(getOttUserBuilder::setUserId); + APIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 509105b96..5a24cc92b 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -4,23 +4,20 @@ import com.kaltura.client.Configuration; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; -import com.kaltura.client.test.helper.Helper; -import com.kaltura.client.types.APIException; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; -import java.util.List; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.helper.Properties.*; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { protected static ILogger logger = Logger.getLogger("java-test"); public static Client client; - private List exceptions; private Response loginResponse; public static String administratorKS, operatorKS, managerKS; @@ -38,29 +35,14 @@ public void setup() { // Set default awaitility timeout setDefaultTimeout(15, TimeUnit.SECONDS); - // Get api exception list from schema xml - exceptions = Helper.getApiExceptionList(); - -/* // Login with shared users + // Login with shared users loginResponse = loginImpl(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); administratorKS = loginResponse.results.getLoginSession().getKs(); - loginResponse = loginImpl(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); - operatorKS = loginResponse.results.getLoginSession().getKs(); - - loginResponse = loginImpl(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); - managerKS = loginResponse.results.getLoginSession().getKs();*/ +// loginResponse = loginImpl(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); +// operatorKS = loginResponse.results.getLoginSession().getKs(); +// +// loginResponse = loginImpl(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); +// managerKS = loginResponse.results.getLoginSession().getKs(); } - - // Help functions - public APIException getAPIExceptionFromList(int code) { - for (APIException exception : exceptions) { - if (exception.getCode().equals(String.valueOf(code))) { - return exception; - } - } - logger.error("No such error code in the API schema"); - return null; - } - } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 75e441939..1857320cd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -7,6 +7,7 @@ import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.Test; +import static com.kaltura.client.test.helper.Helper.getAPIExceptionFromList; import static com.kaltura.client.test.helper.Properties.PARTNER_ID; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 8549022df..fd257f17e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -1,32 +1,92 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; +import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.utils.Utils; -import com.kaltura.client.types.Household; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.test.helper.Helper.generateOttUser; +import static com.kaltura.client.test.helper.Helper.getAPIExceptionFromList; +import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.*; +import static org.assertj.core.api.Assertions.assertThat; + public class DeleteTests extends BaseTest { - @BeforeClass - public void ottUser_login_tests_setup() { + private Household household; + private List users; + @BeforeClass + public void ottUser_delete_tests_setup() { + household = Utils.createHouseHold(2, 0); + HouseholdUserFilter filter = new HouseholdUserFilter(); + filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); + Response> usersResponse = HouseholdUserServiceImpl.listImpl(administratorKS, filter); + users = usersResponse.results.getObjects(); } @Description("ottUser/action/delete - delete") @Test private void delete() { - Household household = Utils.createHouseHold(2, 0); - System.out.println(String.valueOf(household.getId())); + Response ottUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + OTTUser user = ottUserResponse.results; + + Response booleanResponse = deleteImpl(administratorKS, Integer.valueOf(user.getId())); + boolean result = booleanResponse.results; + assertThat(result).isTrue(); + + ottUserResponse = getImpl(administratorKS, Optional.of(Integer.valueOf(user.getId()))); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); + assertThat(ottUserResponse.results).isNull(); + } -// HouseholdUserFilter filter = new HouseholdUserFilter(); -// filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); -// -// Response> users = HouseholdUserServiceImpl.listImpl(administratorKS, filter); -// System.out.println(users.results.getTotalCount()); + @Description("ottUser/action/delete - delete master user") + @Test(enabled = true) + private void delete_master_user() { + HouseholdUser householdUser = new HouseholdUser(); -// deleteImpl(adminKS, Integer.parseInt(user.getId())); - // TODO: 3/25/2018 finish test + for (HouseholdUser user : users) { + if (user.getIsMaster() != null && user.getIsMaster()) { + householdUser = user; + break; + } + } + + Response booleanResponse = deleteImpl(administratorKS, Integer.valueOf(householdUser.getUserId())); + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2031).getCode()); + } + + @Description("ottUser/action/delete - delete default user") + @Test(enabled = true) + private void delete_default_user() { + HouseholdUser householdUser = new HouseholdUser(); + + for (HouseholdUser user : users) { + if (user.getIsDefault() != null && user.getIsDefault()) { + householdUser = user; + break; + } + } + + Response booleanResponse = deleteImpl(administratorKS, Integer.valueOf(householdUser.getUserId())); + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2030).getCode()); } + + @AfterClass + private void ottUser_delete_tests_tearDown() { + HouseholdServiceImpl.deleteImpl(administratorKS, Math.toIntExact(household.getId())); + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 4b712b7e7..bda78a1d2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -9,6 +9,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Optional; + import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.helper.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.getImpl; @@ -34,7 +36,7 @@ public void ottUser_login_tests_setup() { @Description("ottUser/action/get - get") @Test private void get() { - Response ottUserResponse = getImpl(loginResponse.results.getLoginSession().getKs()); + Response ottUserResponse = getImpl(loginResponse.results.getLoginSession().getKs(), Optional.empty()); assertThat(loginResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToComparingFieldByField(user); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index ab4d82a7f..04ecb39dc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.test.helper.Helper; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -9,6 +8,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.test.helper.Helper.generateOttUser; +import static com.kaltura.client.test.helper.Helper.getAPIExceptionFromList; import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.helper.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; @@ -24,7 +25,7 @@ public class LoginTests extends BaseTest { @BeforeClass public void ottUser_login_tests_setup() { - user = Helper.generateOttUser(); + user = generateOttUser(); registerImpl(PARTNER_ID, user, password); } From f24f0e0ae31face9c0f8119640dbef6b3e7e1826 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 27 Mar 2018 12:28:43 +0300 Subject: [PATCH 008/605] Added CustomAPIOkRequestsExecutor that allow to get response body after execution --- .../client/CustomAPIOkRequestsExecutor.java | 54 +++++++++++++++++++ .../test/servicesImpl/OttUserServiceImpl.java | 27 +++++----- 2 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java diff --git a/src/main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java b/src/main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java new file mode 100644 index 000000000..b5cb1f5e6 --- /dev/null +++ b/src/main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java @@ -0,0 +1,54 @@ +package com.kaltura.client; + +import com.kaltura.client.utils.ErrorElement; +import com.kaltura.client.utils.request.ExecutedRequest; +import com.kaltura.client.utils.request.RequestElement; +import com.kaltura.client.utils.response.base.ResponseElement; +import okhttp3.*; +import java.io.IOException; + +/** + * @hide + */ +// that class was implemented to get access to full response body as it's superclass APIOkRequestsExecutor doesn't allow to do it +public class CustomAPIOkRequestsExecutor extends APIOkRequestsExecutor { + + + public static final String TAG = "CustomAPIOkRequestsExecutor"; + private static ILogger logger = Logger.getLogger(TAG); + protected static CustomAPIOkRequestsExecutor self; + + public static String fullResponseAsString = ""; + + public static CustomAPIOkRequestsExecutor getExecutor() { + if (self == null) { + self = new CustomAPIOkRequestsExecutor(); + } + return self; + } + + @SuppressWarnings("rawtypes") + @Override + protected ResponseElement onGotResponse(Response response, RequestElement action) { + String requestId = getRequestId(response); + + if (!response.isSuccessful()) { // in case response has failure status + return new ExecutedRequest().requestId(requestId).error(ErrorElement.fromCode(response.code(), response.message())).success(false); + + } else { + String responseString = null; + try { + responseString = response.body().string(); + } catch (IOException e) { + e.printStackTrace(); + logger.error("failed to retrieve the response body!"); + } + + logger.debug("response body:\n" + responseString); + + fullResponseAsString = responseString.substring(0); + + return new ExecutedRequest().requestId(requestId).response(responseString).code(response.code()).success(responseString != null); + } + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 3d0cd0162..fb0b26dba 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -1,24 +1,24 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.CustomAPIOkRequestsExecutor; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; - +import org.hamcrest.MatcherAssert; import java.util.Map; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; - import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.tests.BaseTest.client; +import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; public class OttUserServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static final String LOGIN_RESPONSE_SCHEMA = "KalturaLoginResponse_Schema.json"; + private static final String LOGIN_RESPONSE_SCHEMA = "schemas/KalturaLoginResponse_Schema.json"; private static final String LOGIN_SESSION_SCHEMA = "KalturaLoginSession_Schema.json"; private static final String OTT_USER_SCHEMA = "KalturaOttUser_Schema.json"; @@ -41,8 +41,11 @@ public static Response loginImpl(int partnerId, String username, done.set(true); }); - APIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); await().untilTrue(done); + if (done.get()) { + MatcherAssert.assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); + } done.set(false); return loginResponse; @@ -59,7 +62,7 @@ public static Response registerImpl(int partnerId, OTTUser user, String done.set(true); }); - APIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -77,7 +80,7 @@ public static Response anonymousLoginImpl(int partnerId, String ud done.set(true); }); - APIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -95,7 +98,7 @@ public static Response activateImpl(int partnerId, String username, Str done.set(true); }); - APIOkRequestsExecutor.getExecutor().queue(activateOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(activateOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -115,7 +118,7 @@ public static Response addRoleImpl(String ks, int userId, int roleId) { addRoleOttUserBuilder.setKs(ks); addRoleOttUserBuilder.setUserId(userId); - APIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -136,7 +139,7 @@ public static Response deleteImpl(String ks, Integer userId) { deleteOttUserBuilder.setKs(ks); deleteOttUserBuilder.setUserId(userId); - APIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -156,7 +159,7 @@ public static Response getImpl(String ks, Optional userId) { getOttUserBuilder.setKs(ks); userId.ifPresent(getOttUserBuilder::setUserId); - APIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -174,7 +177,7 @@ public static Response> listImpl(String ks, OTTUserFilter }); listOttUserBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); + CustomAPIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); From fc87b361fce6a486d3c6a66f54f0ff6c907a1465 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 27 Mar 2018 12:30:15 +0300 Subject: [PATCH 009/605] change action method names (remove impl) --- .../HouseholdDeviceServiceImpl.java | 7 ++- .../servicesImpl/HouseholdServiceImpl.java | 10 ++-- .../HouseholdUserServiceImpl.java | 10 ++-- .../test/servicesImpl/OttUserServiceImpl.java | 46 +++++++++---------- .../servicesImpl/UserRoleServiceImpl.java | 43 +++++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 8 ++-- .../ottUserTests/ActivateTests.java | 7 +-- .../ottUserTests/AddRoleTests.java | 41 ++++++++++++++++- .../ottUserTests/AnonymousLoginTests.java | 4 +- .../ottUserTests/DeleteTests.java | 15 +++--- .../servicesTests/ottUserTests/GetTests.java | 12 ++--- .../servicesTests/ottUserTests/ListTests.java | 2 +- .../ottUserTests/LoginTests.java | 14 +++--- .../client/test/tests/utils/Utils.java | 16 +++---- 14 files changed, 158 insertions(+), 77 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index c5741d153..27bea32a4 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.services.HouseholdDeviceService; import com.kaltura.client.types.HouseholdDevice; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; @@ -8,7 +9,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.HouseholdDeviceService.AddHouseholdDeviceBuilder; -import static com.kaltura.client.services.HouseholdDeviceService.add; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -20,9 +20,8 @@ public class HouseholdDeviceServiceImpl { //add - public static Response addImpl(String ks, HouseholdDevice householdDevice) { - - AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = add(householdDevice) + public static Response add(String ks, HouseholdDevice householdDevice) { + AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 971cee784..73e9a39f9 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -1,10 +1,12 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.types.Household; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.HouseholdService.*; @@ -20,8 +22,8 @@ public class HouseholdServiceImpl { //add - public static Response addImpl(String ks, Household household) { - AddHouseholdBuilder addHouseholdBuilder = add(household) + public static Response add(String ks, Household household) { + AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions @@ -39,8 +41,8 @@ public static Response addImpl(String ks, Household household) { } //delete - public static Response deleteImpl(String ks, int householdId) { - DeleteHouseholdBuilder deleteHouseholdBuilder = delete(householdId) + public static Response delete(String ks, @Nullable int householdId) { + DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(householdId) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index b35447da2..873dfdd27 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -1,12 +1,14 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.services.HouseholdUserService; import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.types.HouseholdUserFilter; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.HouseholdUserService.*; @@ -22,8 +24,8 @@ public class HouseholdUserServiceImpl { //add - public static Response addImpl(String ks, HouseholdUser householdUser) { - AddHouseholdUserBuilder addHouseholdUserBuilder = add(householdUser) + public static Response add(String ks, HouseholdUser householdUser) { + AddHouseholdUserBuilder addHouseholdUserBuilder = HouseholdUserService.add(householdUser) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions @@ -40,8 +42,8 @@ public static Response addImpl(String ks, HouseholdUser household return householdUserResponse; } - public static Response> listImpl(String ks, HouseholdUserFilter householdUserFilter) { - ListHouseholdUserBuilder listHouseholdUserBuilder = list(householdUserFilter) + public static Response> list(String ks, @Nullable HouseholdUserFilter householdUserFilter) { + ListHouseholdUserBuilder listHouseholdUserBuilder = HouseholdUserService.list(householdUserFilter) .setCompletion((ApiCompletion>) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 3d0cd0162..54fec5bc8 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -1,16 +1,17 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.Map; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -30,8 +31,8 @@ public class OttUserServiceImpl { //login - public static Response loginImpl(int partnerId, String username, String password, Map extraParams, String udid) { - LoginOttUserBuilder loginOttUserBuilder = login(partnerId, username, password, extraParams, udid) + public static Response login(int partnerId, String username, String password, @Nullable Map extraParams, @Nullable String udid) { + LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, username, password, extraParams, udid) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions @@ -49,8 +50,8 @@ public static Response loginImpl(int partnerId, String username, } //register - public static Response registerImpl(int partnerId, OTTUser user, String password) { - RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, user, password) + public static Response register(int partnerId, OTTUser user, String password) { + RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, password) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions @@ -67,8 +68,8 @@ public static Response registerImpl(int partnerId, OTTUser user, String } //anonymousLogin - public static Response anonymousLoginImpl(int partnerId, String udid) { - AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = anonymousLogin(partnerId, udid) + public static Response anonymousLogin(int partnerId, @Nullable String udid) { + AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions @@ -85,8 +86,8 @@ public static Response anonymousLoginImpl(int partnerId, String ud } //activate - public static Response activateImpl(int partnerId, String username, String activationToken) { - ActivateOttUserBuilder activateOttUserBuilder = activate(partnerId, username, activationToken) + public static Response activate(int partnerId, String username, String activationToken) { + ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, username, activationToken) .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions @@ -103,18 +104,16 @@ public static Response activateImpl(int partnerId, String username, Str } //addRole - public static Response addRoleImpl(String ks, int userId, int roleId) { - AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(roleId) + public static Response addRole(String ks, Optional userId, int roleId) { + AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(roleId) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } booleanResponse = result; done.set(true); }); addRoleOttUserBuilder.setKs(ks); - addRoleOttUserBuilder.setUserId(userId); + userId.ifPresent(addRoleOttUserBuilder::setUserId); + APIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -123,18 +122,15 @@ public static Response addRoleImpl(String ks, int userId, int roleId) { } //delete - public static Response deleteImpl(String ks, Integer userId) { - DeleteOttUserBuilder deleteOttUserBuilder = delete() + public static Response delete(String ks, Optional userId) { + DeleteOttUserBuilder deleteOttUserBuilder = OttUserService.delete() .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } booleanResponse = result; done.set(true); }); deleteOttUserBuilder.setKs(ks); - deleteOttUserBuilder.setUserId(userId); + userId.ifPresent(deleteOttUserBuilder::setUserId); APIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); await().untilTrue(done); @@ -143,8 +139,8 @@ public static Response deleteImpl(String ks, Integer userId) { return booleanResponse; } - public static Response getImpl(String ks, Optional userId) { - GetOttUserBuilder getOttUserBuilder = get() + public static Response get(String ks, Optional userId) { + GetOttUserBuilder getOttUserBuilder = OttUserService.get() .setCompletion((ApiCompletion) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions @@ -163,8 +159,8 @@ public static Response getImpl(String ks, Optional userId) { return ottUserResponse; } - public static Response> listImpl(String ks, OTTUserFilter ottUserFilter) { - ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) + public static Response> list(String ks, @Nullable OTTUserFilter ottUserFilter) { + ListOttUserBuilder listOttUserBuilder = OttUserService.list(ottUserFilter) .setCompletion((ApiCompletion>) result -> { if (result.isSuccess()) { // TODO: 3/22/2018 fix schema assertions diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java new file mode 100644 index 000000000..2946e54fd --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java @@ -0,0 +1,43 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.services.UserRoleService; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.UserRole; +import com.kaltura.client.types.UserRoleFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.UserRoleService.ListUserRoleBuilder; +import static com.kaltura.client.test.tests.BaseTest.*; +import static org.awaitility.Awaitility.await; + +public class UserRoleServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> userRoleListResponse; + + //list + public static Response> list(String ks, @Nullable UserRoleFilter filter) { + ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(filter) + .setCompletion((ApiCompletion>) result -> { + if (result.isSuccess()) { + // TODO: 3/27/2018 fix schema assertions + } + userRoleListResponse = result; + done.set(true); + }); + + listUserRoleBuilder.setKs(ks); + + APIOkRequestsExecutor.getExecutor().queue(listUserRoleBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userRoleListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 5a24cc92b..dc19337d2 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.helper.Properties.*; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -36,13 +36,13 @@ public void setup() { setDefaultTimeout(15, TimeUnit.SECONDS); // Login with shared users - loginResponse = loginImpl(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); + loginResponse = login(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); administratorKS = loginResponse.results.getLoginSession().getKs(); -// loginResponse = loginImpl(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); +// loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); // operatorKS = loginResponse.results.getLoginSession().getKs(); // -// loginResponse = loginImpl(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); +// loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); // managerKS = loginResponse.results.getLoginSession().getKs(); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index 68c7687b7..5d56e1118 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.enums.UserState; import com.kaltura.client.test.helper.DBHelper; import com.kaltura.client.test.helper.Helper; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -24,8 +25,8 @@ public class ActivateTests extends BaseTest { @BeforeClass public void ottUser_activate_tests_setup() { user = Helper.generateOttUser(); - registerImpl(PARTNER_ID, user, password); - loginImpl(PARTNER_ID, user.getUsername(), password, null, null); + register(PARTNER_ID, user, password); + login(PARTNER_ID, user.getUsername(), password, null, null); } @Description("ottUser/action/activate - activate") @@ -35,7 +36,7 @@ private void activate() { if (activationToken == null) fail("activationToken can't be null"); - Response ottUserResponse = activateImpl(PARTNER_ID, user.getUsername(),activationToken); + Response ottUserResponse = OttUserServiceImpl.activate(PARTNER_ID, user.getUsername(),activationToken); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index 33172eb5e..b0934c923 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -1,14 +1,51 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.servicesImpl.UserRoleServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.UserRole; +import com.kaltura.client.types.UserRoleFilter; +import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.test.helper.Helper.generateOttUser; +import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; + public class AddRoleTests extends BaseTest { + private OTTUser user; + + @BeforeClass + private void ottUser_addRole_tests_setup() { + user = generateOttUser(); + Response ottUserResponse = register(PARTNER_ID, user, GLOBAL_USER_PASSWORD); + user = ottUserResponse.results; + } + @Description("ottUser/action/addRole - addRole") - @Test + @Test(enabled = false) + // TODO: 3/27/2018 finish and fix test private void addRole() { - // TODO: 3/25/2018 implement addRole test + OttUserServiceImpl.addRole(administratorKS, Optional.of(Integer.valueOf(user.getId())), 3); + + UserRoleFilter filter = new UserRoleFilter(); + filter.setIdIn(user.getId()); + + Response> userRoleListResponse = UserRoleServiceImpl.list(administratorKS, filter); + List userRoles = userRoleListResponse.results.getObjects(); + + for (UserRole userRole : userRoles) { + System.out.println(userRole.getId().toString()); + } + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 1857320cd..4c923045f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -16,7 +16,7 @@ public class AnonymousLoginTests extends BaseTest { @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() public void anonymousLogin() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLoginImpl(PARTNER_ID, null); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(PARTNER_ID, null); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); } @@ -24,7 +24,7 @@ public void anonymousLogin() { @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") @Test() public void anonymousLogin_with_wrong_partnerId() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLoginImpl(PARTNER_ID + 1, null); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(PARTNER_ID + 1, null); assertThat(loginSessionResponse.results).isNull(); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index fd257f17e..11e962965 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -2,6 +2,7 @@ import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.utils.Utils; import com.kaltura.client.types.*; @@ -31,21 +32,21 @@ public void ottUser_delete_tests_setup() { household = Utils.createHouseHold(2, 0); HouseholdUserFilter filter = new HouseholdUserFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); - Response> usersResponse = HouseholdUserServiceImpl.listImpl(administratorKS, filter); + Response> usersResponse = HouseholdUserServiceImpl.list(administratorKS, filter); users = usersResponse.results.getObjects(); } @Description("ottUser/action/delete - delete") @Test private void delete() { - Response ottUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); OTTUser user = ottUserResponse.results; - Response booleanResponse = deleteImpl(administratorKS, Integer.valueOf(user.getId())); + Response booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(user.getId()))); boolean result = booleanResponse.results; assertThat(result).isTrue(); - ottUserResponse = getImpl(administratorKS, Optional.of(Integer.valueOf(user.getId()))); + ottUserResponse = get(administratorKS, Optional.of(Integer.valueOf(user.getId()))); assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); assertThat(ottUserResponse.results).isNull(); } @@ -62,7 +63,7 @@ private void delete_master_user() { } } - Response booleanResponse = deleteImpl(administratorKS, Integer.valueOf(householdUser.getUserId())); + Response booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(householdUser.getUserId()))); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2031).getCode()); } @@ -79,14 +80,14 @@ private void delete_default_user() { } } - Response booleanResponse = deleteImpl(administratorKS, Integer.valueOf(householdUser.getUserId())); + Response booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(householdUser.getUserId()))); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2030).getCode()); } @AfterClass private void ottUser_delete_tests_tearDown() { - HouseholdServiceImpl.deleteImpl(administratorKS, Math.toIntExact(household.getId())); + HouseholdServiceImpl.delete(administratorKS, Math.toIntExact(household.getId())); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index bda78a1d2..9f103bf49 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.test.helper.Helper; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -13,9 +14,8 @@ import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.helper.Properties.PARTNER_ID; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.getImpl; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static org.assertj.core.api.Assertions.assertThat; public class GetTests extends BaseTest { @@ -28,15 +28,15 @@ public class GetTests extends BaseTest { @BeforeClass public void ottUser_login_tests_setup() { user = Helper.generateOttUser(); - registerImpl(PARTNER_ID, user, password); - loginResponse = loginImpl(PARTNER_ID, user.getUsername(), password, null, null); + register(PARTNER_ID, user, password); + loginResponse = login(PARTNER_ID, user.getUsername(), password, null, null); } // get tests @Description("ottUser/action/get - get") @Test private void get() { - Response ottUserResponse = getImpl(loginResponse.results.getLoginSession().getKs(), Optional.empty()); + Response ottUserResponse = OttUserServiceImpl.get(loginResponse.results.getLoginSession().getKs(), Optional.empty()); assertThat(loginResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToComparingFieldByField(user); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index 337282a26..381a07ffe 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -15,7 +15,7 @@ public void list() { household.getId(); // TODO: 3/25/2018 finish test impl -// listImpl() +// list() // // assertThat(loginResponse.results).isNull(); // assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 04ecb39dc..f909c0b08 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -12,8 +13,7 @@ import static com.kaltura.client.test.helper.Helper.getAPIExceptionFromList; import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.helper.Properties.PARTNER_ID; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static org.assertj.core.api.Assertions.assertThat; public class LoginTests extends BaseTest { @@ -26,14 +26,14 @@ public class LoginTests extends BaseTest { @BeforeClass public void ottUser_login_tests_setup() { user = generateOttUser(); - registerImpl(PARTNER_ID, user, password); + register(PARTNER_ID, user, password); } // login tests @Description("ottUser/action/login - login") @Test private void login() { - loginResponse = loginImpl(PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); @@ -42,7 +42,7 @@ private void login() { @Description("ottUser/action/login - login with wrong password - error 1011") @Test public void login_with_wrong_password() { - loginResponse = loginImpl(PARTNER_ID, user.getUsername(), password + "1", null, null); + loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password + "1", null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); @@ -51,7 +51,7 @@ public void login_with_wrong_password() { @Description("ottUser/action/login - login with wrong username - error 2000") @Test public void login_with_wrong_username() { - loginResponse = loginImpl(PARTNER_ID, user.getUsername() + "1", password, null, null); + loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername() + "1", password, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); @@ -60,7 +60,7 @@ public void login_with_wrong_username() { @Description("ottUser/action/login - login with wrong partnerId - error 500006") @Test() public void login_with_wrong_partnerId() { - loginResponse = loginImpl(PARTNER_ID + 1, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(PARTNER_ID + 1, user.getUsername(), password, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java index 6c9564164..1f3146271 100644 --- a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java +++ b/src/test/java/com/kaltura/client/test/tests/utils/Utils.java @@ -11,19 +11,19 @@ import static com.kaltura.client.test.helper.Helper.generateOttUser; import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.helper.Properties.PARTNER_ID; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.loginImpl; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.registerImpl; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; public class Utils { public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold) { // create and register - Response masterUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response masterUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); OTTUser masterUser = masterUserResponse.results; // login master user - Response loginResponse = loginImpl(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + Response loginResponse = login(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); masterUser = loginResponse.results.getUser(); String masterUserKS = loginResponse.results.getLoginSession().getKs(); @@ -32,17 +32,17 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO household.setName(masterUser.getFirstName() + "s Domain"); household.setDescription(masterUser.getLastName() + " Description"); - Response householdResponse = HouseholdServiceImpl.addImpl(masterUserKS, household); + Response householdResponse = HouseholdServiceImpl.add(masterUserKS, household); household = householdResponse.results; // create, register and add non-master user to household for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { - Response additionalUserResponse = registerImpl(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response additionalUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); OTTUser additionalUser = additionalUserResponse.results; HouseholdUser householdUser = new HouseholdUser(); householdUser.setUserId(additionalUser.getId()); householdUser.setIsMaster(false); - HouseholdUserServiceImpl.addImpl(masterUserKS, householdUser); + HouseholdUserServiceImpl.add(masterUserKS, householdUser); } // create, add and save household device @@ -53,7 +53,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO Random r = new Random(); householdDevice.setBrandId(r.nextInt(30 - 1) + 1); householdDevice.setName(String.valueOf(uniqueString) + "device"); - HouseholdDeviceServiceImpl.addImpl(masterUserKS, householdDevice); + HouseholdDeviceServiceImpl.add(masterUserKS, householdDevice); } return household; From 5988282dd4e146a0bb55bd16b8613af3bdb51571 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 27 Mar 2018 13:03:54 +0300 Subject: [PATCH 010/605] schema assertion fix --- .../client/test/servicesImpl/OttUserServiceImpl.java | 9 +++------ .../java/com/kaltura/client/test/tests/BaseTest.java | 3 --- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 38a296f00..8b49306d7 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -34,20 +34,17 @@ public class OttUserServiceImpl { public static Response login(int partnerId, String username, String password, @Nullable Map extraParams, @Nullable String udid) { LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, username, password, extraParams, udid) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions -// MatcherAssert.assertThat(result.results.toParams().toString(), matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); - } loginResponse = result; done.set(true); }); CustomAPIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); await().untilTrue(done); - if (done.get()) { + done.set(false); + + if (loginResponse.isSuccess()) { MatcherAssert.assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); } - done.set(false); return loginResponse; } diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index dc19337d2..9ac9a73d8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,8 +2,6 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; -import com.kaltura.client.ILogger; -import com.kaltura.client.Logger; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; @@ -16,7 +14,6 @@ public class BaseTest { - protected static ILogger logger = Logger.getLogger("java-test"); public static Client client; private Response loginResponse; From d62decef64e03537ac52434ca3c94fc13a986839 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 27 Mar 2018 13:06:20 +0300 Subject: [PATCH 011/605] refactored CustomAPIOkRequestsExecutor --- .../test/TestAPIOkRequestsExecutor.java} | 15 ++++++++------ .../test/servicesImpl/OttUserServiceImpl.java | 20 +++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) rename src/{main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java => test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java} (77%) diff --git a/src/main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java similarity index 77% rename from src/main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java rename to src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index b5cb1f5e6..d2a33650b 100644 --- a/src/main/java/com/kaltura/client/CustomAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -1,5 +1,8 @@ -package com.kaltura.client; +package com.kaltura.client.test; +import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.ILogger; +import com.kaltura.client.Logger; import com.kaltura.client.utils.ErrorElement; import com.kaltura.client.utils.request.ExecutedRequest; import com.kaltura.client.utils.request.RequestElement; @@ -11,18 +14,18 @@ * @hide */ // that class was implemented to get access to full response body as it's superclass APIOkRequestsExecutor doesn't allow to do it -public class CustomAPIOkRequestsExecutor extends APIOkRequestsExecutor { +public class TestAPIOkRequestsExecutor extends APIOkRequestsExecutor { - public static final String TAG = "CustomAPIOkRequestsExecutor"; + public static final String TAG = "TestAPIOkRequestsExecutor"; private static ILogger logger = Logger.getLogger(TAG); - protected static CustomAPIOkRequestsExecutor self; + protected static TestAPIOkRequestsExecutor self; public static String fullResponseAsString = ""; - public static CustomAPIOkRequestsExecutor getExecutor() { + public static TestAPIOkRequestsExecutor getExecutor() { if (self == null) { - self = new CustomAPIOkRequestsExecutor(); + self = new TestAPIOkRequestsExecutor(); } return self; } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 38a296f00..1d30606de 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -1,6 +1,6 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.CustomAPIOkRequestsExecutor; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.services.OttUserService; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; @@ -42,10 +42,10 @@ public static Response login(int partnerId, String username, Stri done.set(true); }); - CustomAPIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); await().untilTrue(done); if (done.get()) { - MatcherAssert.assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); + MatcherAssert.assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); } done.set(false); @@ -63,7 +63,7 @@ public static Response register(int partnerId, OTTUser user, String pas done.set(true); }); - CustomAPIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -81,7 +81,7 @@ public static Response anonymousLogin(int partnerId, @Nullable Str done.set(true); }); - CustomAPIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -99,7 +99,7 @@ public static Response activate(int partnerId, String username, String done.set(true); }); - CustomAPIOkRequestsExecutor.getExecutor().queue(activateOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(activateOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -117,7 +117,7 @@ public static Response addRole(String ks, Optional userId, int addRoleOttUserBuilder.setKs(ks); userId.ifPresent(addRoleOttUserBuilder::setUserId); - CustomAPIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -135,7 +135,7 @@ public static Response delete(String ks, Optional userId) { deleteOttUserBuilder.setKs(ks); userId.ifPresent(deleteOttUserBuilder::setUserId); - CustomAPIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -155,7 +155,7 @@ public static Response get(String ks, Optional userId) { getOttUserBuilder.setKs(ks); userId.ifPresent(getOttUserBuilder::setUserId); - CustomAPIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -173,7 +173,7 @@ public static Response> list(String ks, @Nullable OTTUserF }); listOttUserBuilder.setKs(ks); - CustomAPIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); From 4e041a6435fed9f9c5a2ebe4ece2d9b90d91171a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 27 Mar 2018 13:30:34 +0300 Subject: [PATCH 012/605] move schema assertion location --- .../HouseholdDeviceServiceImpl.java | 7 +-- .../servicesImpl/HouseholdServiceImpl.java | 7 +-- .../HouseholdUserServiceImpl.java | 14 +++--- .../test/servicesImpl/OttUserServiceImpl.java | 45 +++++++++++-------- .../servicesImpl/UserRoleServiceImpl.java | 8 ++-- 5 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index 27bea32a4..0e561f3cc 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -23,9 +23,6 @@ public class HouseholdDeviceServiceImpl { public static Response add(String ks, HouseholdDevice householdDevice) { AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } householdDeviceResponse = result; done.set(true); }); @@ -35,6 +32,10 @@ public static Response add(String ks, HouseholdDevice household await().untilTrue(done); done.set(false); + if (householdDeviceResponse.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + return householdDeviceResponse; } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 73e9a39f9..96a2e43b3 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -25,9 +25,6 @@ public class HouseholdServiceImpl { public static Response add(String ks, Household household) { AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } householdResponse = result; done.set(true); }); @@ -37,6 +34,10 @@ public static Response add(String ks, Household household) { await().untilTrue(done); done.set(false); + if (householdResponse.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + return householdResponse; } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index 873dfdd27..972b6b363 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -27,9 +27,6 @@ public class HouseholdUserServiceImpl { public static Response add(String ks, HouseholdUser householdUser) { AddHouseholdUserBuilder addHouseholdUserBuilder = HouseholdUserService.add(householdUser) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } householdUserResponse = result; done.set(true); }); @@ -39,15 +36,16 @@ public static Response add(String ks, HouseholdUser householdUser await().untilTrue(done); done.set(false); + if (householdUserResponse.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + return householdUserResponse; } public static Response> list(String ks, @Nullable HouseholdUserFilter householdUserFilter) { ListHouseholdUserBuilder listHouseholdUserBuilder = HouseholdUserService.list(householdUserFilter) .setCompletion((ApiCompletion>) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } householdUserListResponse = result; done.set(true); }); @@ -57,6 +55,10 @@ public static Response> list(String ks, @Nullable Ho await().untilTrue(done); done.set(false); + if (householdUserListResponse.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + return householdUserListResponse; } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 8b49306d7..dffd700e4 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -5,23 +5,25 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; -import org.hamcrest.MatcherAssert; + import javax.annotation.Nullable; import java.util.Map; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; + import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.tests.BaseTest.client; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; +import static org.hamcrest.MatcherAssert.assertThat; public class OttUserServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static final String LOGIN_RESPONSE_SCHEMA = "schemas/KalturaLoginResponse_Schema.json"; - private static final String LOGIN_SESSION_SCHEMA = "KalturaLoginSession_Schema.json"; - private static final String OTT_USER_SCHEMA = "KalturaOttUser_Schema.json"; + private static final String LOGIN_SESSION_SCHEMA = "schemas/KalturaLoginSession_Schema.json"; + private static final String OTT_USER_SCHEMA = "schemas/KalturaOttUser_Schema.json"; private static Response loginResponse; private static Response ottUserResponse; @@ -43,7 +45,7 @@ public static Response login(int partnerId, String username, Stri done.set(false); if (loginResponse.isSuccess()) { - MatcherAssert.assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); + assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); } return loginResponse; @@ -53,9 +55,6 @@ public static Response login(int partnerId, String username, Stri public static Response register(int partnerId, OTTUser user, String password) { RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, password) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } ottUserResponse = result; done.set(true); }); @@ -64,6 +63,10 @@ public static Response register(int partnerId, OTTUser user, String pas await().untilTrue(done); done.set(false); + if (ottUserResponse.isSuccess()) { + assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); + } + return ottUserResponse; } @@ -71,9 +74,6 @@ public static Response register(int partnerId, OTTUser user, String pas public static Response anonymousLogin(int partnerId, @Nullable String udid) { AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } loginSessionResponse = result; done.set(true); }); @@ -82,6 +82,10 @@ public static Response anonymousLogin(int partnerId, @Nullable Str await().untilTrue(done); done.set(false); + if (loginSessionResponse.isSuccess()) { + assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_SESSION_SCHEMA)); + } + return loginSessionResponse; } @@ -89,9 +93,6 @@ public static Response anonymousLogin(int partnerId, @Nullable Str public static Response activate(int partnerId, String username, String activationToken) { ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, username, activationToken) .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } ottUserResponse = result; done.set(true); }); @@ -100,6 +101,10 @@ public static Response activate(int partnerId, String username, String await().untilTrue(done); done.set(false); + if (ottUserResponse.isSuccess()) { + assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); + } + return ottUserResponse; } @@ -142,9 +147,6 @@ public static Response delete(String ks, Optional userId) { public static Response get(String ks, Optional userId) { GetOttUserBuilder getOttUserBuilder = OttUserService.get() .setCompletion((ApiCompletion) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } ottUserResponse = result; done.set(true); }); @@ -156,15 +158,16 @@ public static Response get(String ks, Optional userId) { await().untilTrue(done); done.set(false); + if (ottUserResponse.isSuccess()) { + assertThat(CustomAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); + } + return ottUserResponse; } public static Response> list(String ks, @Nullable OTTUserFilter ottUserFilter) { ListOttUserBuilder listOttUserBuilder = OttUserService.list(ottUserFilter) .setCompletion((ApiCompletion>) result -> { - if (result.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } ottUserListResponse = result; done.set(true); }); @@ -174,6 +177,10 @@ public static Response> list(String ks, @Nullable OTTUserF await().untilTrue(done); done.set(false); + if (ottUserListResponse.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + return ottUserListResponse; } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java index 2946e54fd..08d6dd571 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java @@ -25,19 +25,19 @@ public class UserRoleServiceImpl { public static Response> list(String ks, @Nullable UserRoleFilter filter) { ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(filter) .setCompletion((ApiCompletion>) result -> { - if (result.isSuccess()) { - // TODO: 3/27/2018 fix schema assertions - } userRoleListResponse = result; done.set(true); }); listUserRoleBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(listUserRoleBuilder.build(client)); await().untilTrue(done); done.set(false); + if (userRoleListResponse.isSuccess()) { + // TODO: 3/27/2018 fix schema assertions + } + return userRoleListResponse; } } From f757870e9ad39748bd21df6b01fc8ee416cff2db Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 27 Mar 2018 13:34:48 +0300 Subject: [PATCH 013/605] TestAPIOkRequestsExecutor --- .../test/servicesImpl/HouseholdDeviceServiceImpl.java | 4 ++-- .../client/test/servicesImpl/HouseholdServiceImpl.java | 9 +++++---- .../test/servicesImpl/HouseholdUserServiceImpl.java | 9 +++++---- .../client/test/servicesImpl/UserRoleServiceImpl.java | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index 0e561f3cc..d07ed7dc9 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.services.HouseholdDeviceService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.HouseholdDevice; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; @@ -28,7 +28,7 @@ public static Response add(String ks, HouseholdDevice household }); addHouseholdDeviceBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(addHouseholdDeviceBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdDeviceBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 96a2e43b3..d029c8dc6 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.Household; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; @@ -9,7 +9,8 @@ import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; -import static com.kaltura.client.services.HouseholdService.*; +import static com.kaltura.client.services.HouseholdService.AddHouseholdBuilder; +import static com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -30,7 +31,7 @@ public static Response add(String ks, Household household) { }); addHouseholdBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(addHouseholdBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -50,7 +51,7 @@ public static Response delete(String ks, @Nullable int householdId) { }); deleteHouseholdBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(deleteHouseholdBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(deleteHouseholdBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index 972b6b363..aacd525b1 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.services.HouseholdUserService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.types.HouseholdUserFilter; import com.kaltura.client.types.ListResponse; @@ -11,7 +11,8 @@ import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; -import static com.kaltura.client.services.HouseholdUserService.*; +import static com.kaltura.client.services.HouseholdUserService.AddHouseholdUserBuilder; +import static com.kaltura.client.services.HouseholdUserService.ListHouseholdUserBuilder; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -32,7 +33,7 @@ public static Response add(String ks, HouseholdUser householdUser }); addHouseholdUserBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(addHouseholdUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -51,7 +52,7 @@ public static Response> list(String ks, @Nullable Ho }); listHouseholdUserBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(listHouseholdUserBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdUserBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java index 08d6dd571..0b83695c7 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.services.UserRoleService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.UserRole; import com.kaltura.client.types.UserRoleFilter; @@ -12,7 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.UserRoleService.ListUserRoleBuilder; -import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class UserRoleServiceImpl { @@ -30,7 +30,7 @@ public static Response> list(String ks, @Nullable UserRol }); listUserRoleBuilder.setKs(ks); - APIOkRequestsExecutor.getExecutor().queue(listUserRoleBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(listUserRoleBuilder.build(client)); await().untilTrue(done); done.set(false); From 9f29b02fc6498307d629ea784a53de48f9e1197a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 27 Mar 2018 14:55:10 +0300 Subject: [PATCH 014/605] Added draft for test case "listSubscriptionTest" --- .../servicesImpl/ProductPriceServiceImpl.java | 44 +++++++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 4 +- .../productPriceTests/ListTests.java | 27 ++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java new file mode 100644 index 000000000..cd8e0ac22 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java @@ -0,0 +1,44 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.services.ProductPriceService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.ProductPriceService.*; +import static com.kaltura.client.test.tests.BaseTest.client; +import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; +import static org.awaitility.Awaitility.await; +import static org.hamcrest.MatcherAssert.assertThat; + +public class ProductPriceServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static final String LIST_RESPONSE_SCHEMA = "schemas/KalturaProductPriceListResponse_Schema.json"; + + private static Response> productPriceResponse; + + //list + public static Response> list(String ks, ProductPriceFilter filter, Optional currency) { + ListProductPriceBuilder productPriceBuilder = ProductPriceService.list(filter) + .setCompletion((ApiCompletion>) result -> { + productPriceResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (productPriceResponse.isSuccess()) { + assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LIST_RESPONSE_SCHEMA)); + } + + return productPriceResponse; + } +} + + diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 9ac9a73d8..deabfee42 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -36,8 +36,8 @@ public void setup() { loginResponse = login(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); administratorKS = loginResponse.results.getLoginSession().getKs(); -// loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); -// operatorKS = loginResponse.results.getLoginSession().getKs(); + loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); + operatorKS = loginResponse.results.getLoginSession().getKs(); // // loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); // managerKS = loginResponse.results.getLoginSession().getKs(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java new file mode 100644 index 000000000..9e857725a --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -0,0 +1,27 @@ +package com.kaltura.client.test.tests.servicesTests.productPriceTests; + +import com.kaltura.client.enums.PurchaseStatus; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.ProductPrice; +import com.kaltura.client.types.ProductPriceFilter; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.Test; +import java.util.Optional; +import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; +import static org.assertj.core.api.Assertions.assertThat; + +public class ListTests extends BaseTest { + + @Description("productPrice/action/list - subscription test by Operator without currency") + @Test(enabled = false) // as used in feature tests + public void listSubscriptionTest() { + ProductPriceFilter filter = new ProductPriceFilter(); + // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); + Response> productPriceList = list(operatorKS, filter, Optional.empty()); + // TODO: fix! assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(five_min_renewable_subscription_id); + assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount() > 0); + } +} From c5e1a6106881aa9936e160cd477d11a39f4868f1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 27 Mar 2018 15:27:25 +0300 Subject: [PATCH 015/605] change in utils strucure --- .../client/test/{helper => }/Properties.java | 8 +-- .../test/servicesImpl/OttUserServiceImpl.java | 24 ++++----- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../ottUserTests/ActivateTests.java | 17 +++--- .../ottUserTests/AddRoleTests.java | 6 +-- .../ottUserTests/AnonymousLoginTests.java | 8 +-- .../ottUserTests/DeleteTests.java | 53 +++++++------------ .../servicesTests/ottUserTests/GetTests.java | 11 ++-- .../servicesTests/ottUserTests/ListTests.java | 18 +++++-- .../ottUserTests/LoginTests.java | 16 +++--- .../Helper.java => utils/BaseUtils.java} | 36 +++---------- .../DBHelper.java => utils/DBUtils.java} | 8 +-- .../Utils.java => utils/HouseholdUtils.java} | 50 +++++++++++++++-- .../client/test/utils/OttUserUtils.java | 29 ++++++++++ src/test/resources/testng.xml | 4 +- 15 files changed, 166 insertions(+), 124 deletions(-) rename src/test/java/com/kaltura/client/test/{helper => }/Properties.java (92%) rename src/test/java/com/kaltura/client/test/{helper/Helper.java => utils/BaseUtils.java} (69%) rename src/test/java/com/kaltura/client/test/{helper/DBHelper.java => utils/DBUtils.java} (91%) rename src/test/java/com/kaltura/client/test/{tests/utils/Utils.java => utils/HouseholdUtils.java} (58%) create mode 100644 src/test/java/com/kaltura/client/test/utils/OttUserUtils.java diff --git a/src/test/java/com/kaltura/client/test/helper/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java similarity index 92% rename from src/test/java/com/kaltura/client/test/helper/Properties.java rename to src/test/java/com/kaltura/client/test/Properties.java index f379b9ca3..ace28c65e 100644 --- a/src/test/java/com/kaltura/client/test/helper/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -1,4 +1,4 @@ -package com.kaltura.client.test.helper; +package com.kaltura.client.test; import java.util.ResourceBundle; @@ -12,9 +12,9 @@ public class Properties { // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file - static final String DB_URL = "db_url"; - static final String DB_USER = "db_user"; - static final String DB_PASSWORD = "db_password"; + public static final String DB_URL = "db_url"; + public static final String DB_USER = "db_user"; + public static final String DB_PASSWORD = "db_password"; // Request properties public static final int PARTNER_ID = 203; diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index f647471fb..db058cd37 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -188,42 +188,42 @@ public static Response> list(String ks, @Nullable OTTUserF // // TODO: 3/19/2018 implement function // return null; // } -// + // public static T logout(String ks) { // // TODO: 3/19/2018 implement function // return null; // } -// -// public static T refreshSession(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } -// + + public static void refreshSession(String ks) { + // TODO: 3/19/2018 check why missing from client library + + } + // public static T resendActivationToken(String ks) { // // TODO: 3/19/2018 implement function // return null; // } -// + // public static T resetPassword(String ks) { // // TODO: 3/19/2018 implement function // return null; // } -// + // public static T setInitialPassword(String ks) { // // TODO: 3/19/2018 implement function // return null; // } -// + // public static T update(String ks) { // // TODO: 3/19/2018 implement function // return null; // } -// + // public static T updateLoginData(String ks) { // // TODO: 3/19/2018 implement function // return null; // } -// + // public static T getEncryptedUserId(String ks) { // // TODO: 3/19/2018 implement function // return null; diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 9ac9a73d8..1b106ceb8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.helper.Properties.*; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static org.awaitility.Awaitility.setDefaultTimeout; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index 5d56e1118..104906534 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -1,19 +1,20 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.enums.UserState; -import com.kaltura.client.test.helper.DBHelper; -import com.kaltura.client.test.helper.Helper; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.DBUtils; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.helper.Properties.PARTNER_ID; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.*; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -23,8 +24,8 @@ public class ActivateTests extends BaseTest { private String password = GLOBAL_USER_PASSWORD; @BeforeClass - public void ottUser_activate_tests_setup() { - user = Helper.generateOttUser(); + private void ottUser_activate_tests_setup() { + user = generateOttUser(); register(PARTNER_ID, user, password); login(PARTNER_ID, user.getUsername(), password, null, null); } @@ -32,7 +33,7 @@ public void ottUser_activate_tests_setup() { @Description("ottUser/action/activate - activate") @Test private void activate() { - String activationToken = DBHelper.getActivationToken(user.getUsername()); + String activationToken = DBUtils.getActivationToken(user.getUsername()); if (activationToken == null) fail("activationToken can't be null"); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index b0934c923..9cf2b75ff 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -15,10 +15,10 @@ import java.util.List; import java.util.Optional; -import static com.kaltura.client.test.helper.Helper.generateOttUser; -import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class AddRoleTests extends BaseTest { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 4c923045f..ba4bf875e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -7,15 +7,15 @@ import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.Test; -import static com.kaltura.client.test.helper.Helper.getAPIExceptionFromList; -import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.Properties.PARTNER_ID; import static org.assertj.core.api.Assertions.assertThat; public class AnonymousLoginTests extends BaseTest { @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() - public void anonymousLogin() { + private void anonymousLogin() { Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(PARTNER_ID, null); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); @@ -23,7 +23,7 @@ public void anonymousLogin() { @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") @Test() - public void anonymousLogin_with_wrong_partnerId() { + private void anonymousLogin_with_wrong_partnerId() { Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(PARTNER_ID + 1, null); assertThat(loginSessionResponse.results).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 11e962965..3728617c2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -1,39 +1,38 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; -import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.tests.utils.Utils; -import com.kaltura.client.types.*; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.List; import java.util.Optional; -import static com.kaltura.client.test.helper.Helper.generateOttUser; -import static com.kaltura.client.test.helper.Helper.getAPIExceptionFromList; -import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.helper.Properties.PARTNER_ID; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.*; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.get; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.HouseholdUtils.getDefaultUserFromHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUserFromHousehold; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class DeleteTests extends BaseTest { private Household household; - private List users; + private Response booleanResponse; @BeforeClass - public void ottUser_delete_tests_setup() { - household = Utils.createHouseHold(2, 0); - HouseholdUserFilter filter = new HouseholdUserFilter(); - filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); - Response> usersResponse = HouseholdUserServiceImpl.list(administratorKS, filter); - users = usersResponse.results.getObjects(); + private void ottUser_delete_tests_setup() { + household = HouseholdUtils.createHouseHold(2, 0); } @Description("ottUser/action/delete - delete") @@ -54,16 +53,9 @@ private void delete() { @Description("ottUser/action/delete - delete master user") @Test(enabled = true) private void delete_master_user() { - HouseholdUser householdUser = new HouseholdUser(); + HouseholdUser masterUser = getMasterUserFromHousehold(household); + booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(masterUser.getUserId()))); - for (HouseholdUser user : users) { - if (user.getIsMaster() != null && user.getIsMaster()) { - householdUser = user; - break; - } - } - - Response booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(householdUser.getUserId()))); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2031).getCode()); } @@ -71,16 +63,9 @@ private void delete_master_user() { @Description("ottUser/action/delete - delete default user") @Test(enabled = true) private void delete_default_user() { - HouseholdUser householdUser = new HouseholdUser(); - - for (HouseholdUser user : users) { - if (user.getIsDefault() != null && user.getIsDefault()) { - householdUser = user; - break; - } - } + HouseholdUser defaultUser = getDefaultUserFromHousehold(household); + booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(defaultUser.getUserId()))); - Response booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(householdUser.getUserId()))); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2030).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 9f103bf49..8fb94296f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.test.helper.Helper; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; @@ -12,10 +11,11 @@ import java.util.Optional; -import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class GetTests extends BaseTest { @@ -26,8 +26,8 @@ public class GetTests extends BaseTest { private Response loginResponse; @BeforeClass - public void ottUser_login_tests_setup() { - user = Helper.generateOttUser(); + private void ottUser_login_tests_setup() { + user = generateOttUser(); register(PARTNER_ID, user, password); loginResponse = login(PARTNER_ID, user.getUsername(), password, null, null); } @@ -36,6 +36,7 @@ public void ottUser_login_tests_setup() { @Description("ottUser/action/get - get") @Test private void get() { + // TODO: 3/27/2018 fix get test Response ottUserResponse = OttUserServiceImpl.get(loginResponse.results.getLoginSession().getKs(), Optional.empty()); assertThat(loginResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToComparingFieldByField(user); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index 381a07ffe..0097993a6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -1,19 +1,27 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.tests.utils.Utils; +import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.Household; import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class ListTests extends BaseTest { - @Description("ottUser/action/list - list") + private Household household; + + @BeforeClass + private void ottUser_list_tests_setup() { + household = HouseholdUtils.createHouseHold(4, 1); + } + + @Description("ottUser/action/list - list from master ks") @Test - public void list() { - Household household = Utils.createHouseHold(3, 1); - household.getId(); + private void list_from_master_ks() { +// OTTUser masterUser = BaseUtils.getMasterUserFromHousehold(household); +// OttUserServiceImpl.list(administratorKS, ) // TODO: 3/25/2018 finish test impl // list() // diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index f909c0b08..0e5539de4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -9,11 +9,11 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.helper.Helper.generateOttUser; -import static com.kaltura.client.test.helper.Helper.getAPIExceptionFromList; -import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class LoginTests extends BaseTest { @@ -24,7 +24,7 @@ public class LoginTests extends BaseTest { private Response loginResponse; @BeforeClass - public void ottUser_login_tests_setup() { + private void ottUser_login_tests_setup() { user = generateOttUser(); register(PARTNER_ID, user, password); } @@ -41,7 +41,7 @@ private void login() { @Description("ottUser/action/login - login with wrong password - error 1011") @Test - public void login_with_wrong_password() { + private void login_with_wrong_password() { loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password + "1", null, null); assertThat(loginResponse.results).isNull(); @@ -50,7 +50,7 @@ public void login_with_wrong_password() { @Description("ottUser/action/login - login with wrong username - error 2000") @Test - public void login_with_wrong_username() { + private void login_with_wrong_username() { loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername() + "1", password, null, null); assertThat(loginResponse.results).isNull(); @@ -59,7 +59,7 @@ public void login_with_wrong_username() { @Description("ottUser/action/login - login with wrong partnerId - error 500006") @Test() - public void login_with_wrong_partnerId() { + private void login_with_wrong_partnerId() { loginResponse = OttUserServiceImpl.login(PARTNER_ID + 1, user.getUsername(), password, null, null); assertThat(loginResponse.results).isNull(); diff --git a/src/test/java/com/kaltura/client/test/helper/Helper.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java similarity index 69% rename from src/test/java/com/kaltura/client/test/helper/Helper.java rename to src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 0c596a01c..f179074f1 100644 --- a/src/test/java/com/kaltura/client/test/helper/Helper.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -1,8 +1,7 @@ -package com.kaltura.client.test.helper; +package com.kaltura.client.test.utils; import com.kaltura.client.Logger; import com.kaltura.client.types.APIException; -import com.kaltura.client.types.OTTUser; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -17,35 +16,15 @@ import java.util.List; import java.util.Random; -import static com.kaltura.client.test.helper.Properties.API_URL_VERSION; +import static com.kaltura.client.test.Properties.API_URL_VERSION; -public class Helper { +public class BaseUtils { private static final String API_SCHEMA_URL = "https://api-preprod.ott.kaltura.com/" + API_URL_VERSION + "/clientlibs/KalturaClient.xml"; private static List exceptions; - //generate ottUser - public static OTTUser generateOttUser() { - long millis = System.currentTimeMillis(); - String randomString = getRandomString(); - String emailPrefix = "qaott2018" + "+"; - String emailDomain = "@gmail.com"; - String stamp = randomString + millis; - OTTUser user = new OTTUser(); - user.setUsername(stamp); - user.setFirstName(randomString); - user.setLastName(String.valueOf(millis)); - user.setEmail(emailPrefix + stamp + emailDomain); - user.setAddress(randomString + " fake address"); - user.setCity(randomString + " fake city"); - Random r = new Random(); - user.setCountryId(r.nextInt(30 - 1) + 1); - - return user; - } - - //generate random string + // generate random string public static String getRandomString() { String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; StringBuilder sb = new StringBuilder(); @@ -57,7 +36,7 @@ public static String getRandomString() { return sb.toString().toLowerCase(); } - //get api exception + // get api exception public static APIException getAPIExceptionFromList(int code) { getApiExceptionList(); @@ -67,11 +46,11 @@ public static APIException getAPIExceptionFromList(int code) { } } - Logger.getLogger(Helper.class).error("No such error code in the API schema"); + Logger.getLogger(BaseUtils.class).error("No such error code in the API schema"); return null; } - //generate apiException list base on the api schema + // generate apiException list base on the api schema private static List getApiExceptionList() { if (exceptions == null) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -101,5 +80,4 @@ private static List getApiExceptionList() { } return exceptions; } - } diff --git a/src/test/java/com/kaltura/client/test/helper/DBHelper.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java similarity index 91% rename from src/test/java/com/kaltura/client/test/helper/DBHelper.java rename to src/test/java/com/kaltura/client/test/utils/DBUtils.java index 54c5dd2ca..db8c1a953 100644 --- a/src/test/java/com/kaltura/client/test/helper/DBHelper.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -1,4 +1,4 @@ -package com.kaltura.client.test.helper; +package com.kaltura.client.test.utils; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; @@ -8,9 +8,9 @@ import java.sql.SQLException; import java.sql.Statement; -import static com.kaltura.client.test.helper.Properties.*; +import static com.kaltura.client.test.Properties.*; -public class DBHelper { +public class DBUtils extends BaseUtils { private static SQLServerDataSource dataSource; private static Connection conn; @@ -38,7 +38,7 @@ public static String getActivationToken(String username) { activationToken = rs.getString("ACTIVATION_TOKEN"); } catch (SQLException e) { e.printStackTrace(); -// Logger.getLogger(DBHelper.class).error("activationToken can't be null"); +// Logger.getLogger(DBUtils.class).error("activationToken can't be null"); } closeConnection(); return activationToken; diff --git a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java similarity index 58% rename from src/test/java/com/kaltura/client/test/tests/utils/Utils.java rename to src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 1f3146271..8c4e32a78 100644 --- a/src/test/java/com/kaltura/client/test/tests/utils/Utils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -1,21 +1,25 @@ -package com.kaltura.client.test.tests.utils; +package com.kaltura.client.test.utils; +import com.kaltura.client.Logger; import com.kaltura.client.test.servicesImpl.HouseholdDeviceServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import java.util.List; import java.util.Random; -import static com.kaltura.client.test.helper.Helper.generateOttUser; -import static com.kaltura.client.test.helper.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.helper.Properties.PARTNER_ID; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.tests.BaseTest.administratorKS; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; -public class Utils { +public class HouseholdUtils extends BaseUtils { + // create household public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold) { // create and register @@ -58,4 +62,40 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO return household; } + + // get users list from given household + public static List getUsersListFromHouseHold(Household household) { + HouseholdUserFilter filter = new HouseholdUserFilter(); + filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); + Response> usersResponse = HouseholdUserServiceImpl.list(administratorKS, filter); + return usersResponse.results.getObjects(); + } + + // get master user from given household + public static HouseholdUser getMasterUserFromHousehold(Household household) { + List users = getUsersListFromHouseHold(household); + + for (HouseholdUser user : users) { + if (user.getIsMaster() != null && user.getIsMaster()) { + return user; + } + } + + Logger.getLogger(BaseUtils.class).error("can't find master user in household"); + return null; + } + + // get default user from given household + public static HouseholdUser getDefaultUserFromHousehold(Household household) { + List users = getUsersListFromHouseHold(household); + + for (HouseholdUser user : users) { + if (user.getIsDefault() != null && user.getIsDefault()) { + return user; + } + } + + Logger.getLogger(BaseUtils.class).error("can't find default user in household"); + return null; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java new file mode 100644 index 000000000..1abd58464 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -0,0 +1,29 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.types.OTTUser; + +import java.util.Random; + +public class OttUserUtils extends BaseUtils { + + // generate ottUser + public static OTTUser generateOttUser() { + long millis = System.currentTimeMillis(); + String randomString = getRandomString(); + String emailPrefix = "qaott2018" + "+"; + String emailDomain = "@gmail.com"; + String stamp = randomString + millis; + + OTTUser user = new OTTUser(); + user.setUsername(stamp); + user.setFirstName(randomString); + user.setLastName(String.valueOf(millis)); + user.setEmail(emailPrefix + stamp + emailDomain); + user.setAddress(randomString + " fake address"); + user.setCity(randomString + " fake city"); + Random r = new Random(); + user.setCountryId(r.nextInt(30 - 1) + 1); + + return user; + } +} diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 34aa11e6b..af43863a2 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -3,8 +3,8 @@ - - + + \ No newline at end of file From 7ce76d6defa9868dba216aff6eca0c571d97407a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 28 Mar 2018 10:42:37 +0300 Subject: [PATCH 016/605] ottUser/action/list tests --- .../kaltura/client/test/tests/BaseTest.java | 4 +- .../ottUserTests/AddRoleTests.java | 4 +- .../ottUserTests/DeleteTests.java | 10 +-- .../servicesTests/ottUserTests/ListTests.java | 84 +++++++++++++++++-- .../client/test/utils/HouseholdUtils.java | 4 +- .../client/test/utils/OttUserUtils.java | 9 ++ 6 files changed, 95 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 1b106ceb8..f552e0b38 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -17,7 +17,7 @@ public class BaseTest { public static Client client; private Response loginResponse; - public static String administratorKS, operatorKS, managerKS; + public static String administratorKs, operatorKS, managerKS; @BeforeSuite public void setup() { @@ -34,7 +34,7 @@ public void setup() { // Login with shared users loginResponse = login(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); - administratorKS = loginResponse.results.getLoginSession().getKs(); + administratorKs = loginResponse.results.getLoginSession().getKs(); // loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); // operatorKS = loginResponse.results.getLoginSession().getKs(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index 9cf2b75ff..019944cd4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -35,12 +35,12 @@ private void ottUser_addRole_tests_setup() { @Test(enabled = false) // TODO: 3/27/2018 finish and fix test private void addRole() { - OttUserServiceImpl.addRole(administratorKS, Optional.of(Integer.valueOf(user.getId())), 3); + OttUserServiceImpl.addRole(administratorKs, Optional.of(Integer.valueOf(user.getId())), 3); UserRoleFilter filter = new UserRoleFilter(); filter.setIdIn(user.getId()); - Response> userRoleListResponse = UserRoleServiceImpl.list(administratorKS, filter); + Response> userRoleListResponse = UserRoleServiceImpl.list(administratorKs, filter); List userRoles = userRoleListResponse.results.getObjects(); for (UserRole userRole : userRoles) { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 3728617c2..b2d6a2536 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -41,11 +41,11 @@ private void delete() { Response ottUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); OTTUser user = ottUserResponse.results; - Response booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(user.getId()))); + Response booleanResponse = OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(user.getId()))); boolean result = booleanResponse.results; assertThat(result).isTrue(); - ottUserResponse = get(administratorKS, Optional.of(Integer.valueOf(user.getId()))); + ottUserResponse = get(administratorKs, Optional.of(Integer.valueOf(user.getId()))); assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); assertThat(ottUserResponse.results).isNull(); } @@ -54,7 +54,7 @@ private void delete() { @Test(enabled = true) private void delete_master_user() { HouseholdUser masterUser = getMasterUserFromHousehold(household); - booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(masterUser.getUserId()))); + booleanResponse = OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(masterUser.getUserId()))); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2031).getCode()); @@ -64,7 +64,7 @@ private void delete_master_user() { @Test(enabled = true) private void delete_default_user() { HouseholdUser defaultUser = getDefaultUserFromHousehold(household); - booleanResponse = OttUserServiceImpl.delete(administratorKS, Optional.of(Integer.valueOf(defaultUser.getUserId()))); + booleanResponse = OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(defaultUser.getUserId()))); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2030).getCode()); @@ -72,7 +72,7 @@ private void delete_default_user() { @AfterClass private void ottUser_delete_tests_tearDown() { - HouseholdServiceImpl.delete(administratorKS, Math.toIntExact(household.getId())); + HouseholdServiceImpl.delete(administratorKs, Math.toIntExact(household.getId())); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index 0097993a6..ef51f6b9b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -2,30 +2,96 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.types.Household; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.list; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUserFromHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.OttUserUtils.getUserNameFromId; +import static org.assertj.core.api.Assertions.assertThat; + public class ListTests extends BaseTest { private Household household; + private int numberOfUsersInHousehold = 4; + private Response> householdUserListResponse; @BeforeClass private void ottUser_list_tests_setup() { - household = HouseholdUtils.createHouseHold(4, 1); + household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, 1); } @Description("ottUser/action/list - list from master ks") @Test private void list_from_master_ks() { + HouseholdUser masterUser = getMasterUserFromHousehold(household); + + Response loginResponse = login(PARTNER_ID, getUserNameFromId(Integer.parseInt(masterUser.getUserId())), + GLOBAL_USER_PASSWORD, null, null); + String masterUserKs = loginResponse.results.getLoginSession().getKs(); + + householdUserListResponse = list(masterUserKs, null); + List users = householdUserListResponse.results.getObjects(); + + assertThat(loginResponse.error).isNull(); + assertThat(users.size()).isEqualTo(numberOfUsersInHousehold + 1); + } + + @Description("ottUser/action/list - get list with filter using idIn") + @Test + private void list_with_filter_idIn() { + List householdUsers = getUsersListFromHouseHold(household); + + OTTUserFilter filter = new OTTUserFilter(); + String idIn = householdUsers.get(0).getUserId() + "," + householdUsers.get(1).getUserId(); + filter.setIdIn(idIn); + + householdUserListResponse = list(administratorKs, filter); + List users = householdUserListResponse.results.getObjects(); + + assertThat(householdUserListResponse.error).isNull(); + assertThat(users.size()).isEqualTo(2); + } + + @Description("ottUser/action/list - get list with filter using usernameEqual") + @Test + private void list_withd_filter_usernameEqual() { + List householdUsers = getUsersListFromHouseHold(household); + + OTTUserFilter filter = new OTTUserFilter(); + String usernameEqual = getUserNameFromId(Integer.valueOf(householdUsers.get(0).getUserId())); + + filter.setUsernameEqual(usernameEqual); + + householdUserListResponse = list(administratorKs, filter); + List users = householdUserListResponse.results.getObjects(); + + assertThat(householdUserListResponse.error).isNull(); + assertThat(users.size()).isEqualTo(1); + } + + @Description("ottUser/action/list - get list with not valid filter") + @Test + private void list_with_not_valid_filter() { + List householdUsers = getUsersListFromHouseHold(household); + + OTTUserFilter filter = new OTTUserFilter(); + filter.setIdIn(householdUsers.get(0).getUserId()); + filter.setUsernameEqual(getUserNameFromId(Integer.valueOf(householdUsers.get(1).getUserId()))); + + householdUserListResponse = list(administratorKs, filter); -// OTTUser masterUser = BaseUtils.getMasterUserFromHousehold(household); -// OttUserServiceImpl.list(administratorKS, ) - // TODO: 3/25/2018 finish test impl -// list() -// -// assertThat(loginResponse.results).isNull(); -// assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); + assertThat(householdUserListResponse.results).isNull(); + assertThat(householdUserListResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500038).getCode()); } } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 8c4e32a78..57961e296 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -14,7 +14,7 @@ import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; -import static com.kaltura.client.test.tests.BaseTest.administratorKS; +import static com.kaltura.client.test.tests.BaseTest.administratorKs; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class HouseholdUtils extends BaseUtils { @@ -67,7 +67,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO public static List getUsersListFromHouseHold(Household household) { HouseholdUserFilter filter = new HouseholdUserFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); - Response> usersResponse = HouseholdUserServiceImpl.list(administratorKS, filter); + Response> usersResponse = HouseholdUserServiceImpl.list(administratorKs, filter); return usersResponse.results.getObjects(); } diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 1abd58464..3c99e98a6 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -1,7 +1,11 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import java.util.Optional; import java.util.Random; public class OttUserUtils extends BaseUtils { @@ -26,4 +30,9 @@ public static OTTUser generateOttUser() { return user; } + + public static String getUserNameFromId(int userId) { + Response userResponse = OttUserServiceImpl.get(BaseTest.administratorKs, Optional.of(userId)); + return userResponse.results.getUsername(); + } } From 1c920f1948974d3b379ee7736b5a2c32d36b3455 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 28 Mar 2018 16:22:04 +0300 Subject: [PATCH 017/605] Ingest example in Sandbox() --- pom.xml | 8 +++++++ .../kaltura/client/test/tests/Sandbox.java | 23 ++++++++++++++++++- .../servicesTests/ottUserTests/GetTests.java | 9 +++++--- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index ab99100b2..00f8171dc 100644 --- a/pom.xml +++ b/pom.xml @@ -175,6 +175,14 @@ test + + io.rest-assured + rest-assured + 3.0.7 + test + + + diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index 6f875ec7b..41b027933 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -1,11 +1,32 @@ package com.kaltura.client.test.tests; +import io.restassured.RestAssured; +import io.restassured.path.xml.XmlPath; import org.testng.annotations.Test; +import static io.restassured.RestAssured.given; + public class Sandbox extends BaseTest { + String myEnvelope = "QABE - Regular-mainQABE - Regular-mainMovie_180328093854266description of 18032809385426627/03/2018 09:38:5427/03/2018 09:38:5414/10/2099 17:00:0014/10/2099 17:00:00MoviePhilippines OnlyParent Allowedsyno pino sistermeta_value190023/03/2017 12:34:56Costa Rica;IsraelGIHABCDEFShay_SeriesKSQL channel_573349]]>"; + @Test private void test() { - + RestAssured.baseURI = "http://34.249.122.223:8030/Ingest_v4_8/Service.svc?wsdl"; + + String xml = given() +// .log().all(true) + .header("SOAPAction","http://tempuri.org/IService/IngestTvinciData") + .contentType("text/xml;charset=UTF-8") + .body(myEnvelope) + .when() +// .log().all(true) + .post() + .andReturn() + .asString(); + + int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); + System.out.println("!!! " + assetId); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 8fb94296f..8f9ef0a30 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -24,12 +24,15 @@ public class GetTests extends BaseTest { private String password = GLOBAL_USER_PASSWORD; private Response loginResponse; + private Response ottUserResponse; @BeforeClass private void ottUser_login_tests_setup() { user = generateOttUser(); - register(PARTNER_ID, user, password); + ottUserResponse = register(PARTNER_ID, user, password); + loginResponse = login(PARTNER_ID, user.getUsername(), password, null, null); + user = loginResponse.results.getUser(); } // get tests @@ -37,8 +40,8 @@ private void ottUser_login_tests_setup() { @Test private void get() { // TODO: 3/27/2018 fix get test - Response ottUserResponse = OttUserServiceImpl.get(loginResponse.results.getLoginSession().getKs(), Optional.empty()); + ottUserResponse = OttUserServiceImpl.get(loginResponse.results.getLoginSession().getKs(), Optional.empty()); assertThat(loginResponse.error).isNull(); - assertThat(ottUserResponse.results).isEqualToComparingFieldByField(user); + assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); } } From 81ea586cf87d47feb6daf7fb9267ec75c9f5a769 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 29 Mar 2018 16:35:30 +0300 Subject: [PATCH 018/605] add ottUser logoutTests, registerTests, loginWithPinTests --- .../com/kaltura/client/test/Properties.java | 5 - .../test/servicesImpl/OttUserServiceImpl.java | 59 +++++++--- .../servicesImpl/UserLoginPinServiceImpl.java | 103 ++++++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 38 +++++++ .../kaltura/client/test/tests/Sandbox.java | 1 - .../ottUserTests/AnonymousLoginTests.java | 1 + .../servicesTests/ottUserTests/GetTests.java | 4 +- .../ottUserTests/LoginTests.java | 6 +- .../ottUserTests/LoginWithPinTests.java | 74 +++++++++++++ .../ottUserTests/LogoutTests.java | 52 +++++++++ .../ottUserTests/RegisterTests.java | 40 +++++++ 11 files changed, 355 insertions(+), 28 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index ace28c65e..aa92b6231 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -32,11 +32,6 @@ public class Properties { public static final String GLOBAL_USER_PASSWORD = "password"; -// // Automation shared household -// public static Household sharedHousehold; -// public static OTTUser administratorUser, managerUser, operatorUser, masterUser; -// public static String administratorUserKS, managerUserKS, operatorUserKS, masterUserKS; - public static String getProperty(String propertyKey) { if (resourceBundle == null) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index db058cd37..a89bd4a14 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.services.OttUserService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; @@ -32,7 +32,7 @@ public class OttUserServiceImpl { private static Response> ottUserListResponse; - //login + // login public static Response login(int partnerId, String username, String password, @Nullable Map extraParams, @Nullable String udid) { LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, username, password, extraParams, udid) .setCompletion((ApiCompletion) result -> { @@ -51,7 +51,7 @@ public static Response login(int partnerId, String username, Stri return loginResponse; } - //register + // register public static Response register(int partnerId, OTTUser user, String password) { RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, password) .setCompletion((ApiCompletion) result -> { @@ -70,7 +70,7 @@ public static Response register(int partnerId, OTTUser user, String pas return ottUserResponse; } - //anonymousLogin + // anonymousLogin public static Response anonymousLogin(int partnerId, @Nullable String udid) { AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid) .setCompletion((ApiCompletion) result -> { @@ -89,7 +89,7 @@ public static Response anonymousLogin(int partnerId, @Nullable Str return loginSessionResponse; } - //activate + // activate public static Response activate(int partnerId, String username, String activationToken) { ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, username, activationToken) .setCompletion((ApiCompletion) result -> { @@ -108,7 +108,7 @@ public static Response activate(int partnerId, String username, String return ottUserResponse; } - //addRole + // addRole public static Response addRole(String ks, Optional userId, int roleId) { AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(roleId) .setCompletion((ApiCompletion) result -> { @@ -126,7 +126,7 @@ public static Response addRole(String ks, Optional userId, int return booleanResponse; } - //delete + // delete public static Response delete(String ks, Optional userId) { DeleteOttUserBuilder deleteOttUserBuilder = OttUserService.delete() .setCompletion((ApiCompletion) result -> { @@ -144,6 +144,7 @@ public static Response delete(String ks, Optional userId) { return booleanResponse; } + // get public static Response get(String ks, Optional userId) { GetOttUserBuilder getOttUserBuilder = OttUserService.get() .setCompletion((ApiCompletion) result -> { @@ -165,6 +166,7 @@ public static Response get(String ks, Optional userId) { return ottUserResponse; } + // list public static Response> list(String ks, @Nullable OTTUserFilter ottUserFilter) { ListOttUserBuilder listOttUserBuilder = OttUserService.list(ottUserFilter) .setCompletion((ApiCompletion>) result -> { @@ -184,19 +186,42 @@ public static Response> list(String ks, @Nullable OTTUserF return ottUserListResponse; } -// public static T loginWithPin(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } + // loginWithPin + public static Response loginWithPin(int partnerId, String pin, @Nullable String udid, String secret) { -// public static T logout(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = OttUserService.loginWithPin(partnerId, pin, udid, secret) + .setCompletion((ApiCompletion) result -> { + loginResponse = result; + done.set(true); + }); - public static void refreshSession(String ks) { - // TODO: 3/19/2018 check why missing from client library + TestAPIOkRequestsExecutor.getExecutor().queue(loginWithPinOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + if (loginResponse.isSuccess()) { + assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); + } + + return loginResponse; + } + + // logout + public static Response logout(String ks, Optional userId) { + LogoutOttUserBuilder logoutOttUserBuilder = OttUserService.logout() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + logoutOttUserBuilder.setKs(ks); + userId.ifPresent(logoutOttUserBuilder::setUserId); + + TestAPIOkRequestsExecutor.getExecutor().queue(logoutOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; } // public static T resendActivationToken(String ks) { diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java new file mode 100644 index 000000000..5769e442f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java @@ -0,0 +1,103 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.services.UserLoginPinService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.UserLoginPin; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.UserLoginPinService.*; +import static com.kaltura.client.services.UserLoginPinService.AddUserLoginPinBuilder; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class UserLoginPinServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response userLoginPinResponse; + private static Response booleanResponse; + + // add + public static Response add(String ks, int userId, @Nullable String secret) { + AddUserLoginPinBuilder addUserLoginPinBuilder = UserLoginPinService.add(secret) + .setCompletion((ApiCompletion) result -> { + userLoginPinResponse = result; + done.set(true); + }); + + addUserLoginPinBuilder.setKs(ks); + addUserLoginPinBuilder.setUserId(userId); + + TestAPIOkRequestsExecutor.getExecutor().queue(addUserLoginPinBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (userLoginPinResponse.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + + return userLoginPinResponse; + } + + // delete + public static Response delete(String ks, int userId, String pinCode) { + DeleteUserLoginPinBuilder deleteUserLoginPinBuilder = UserLoginPinService.delete(pinCode) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + deleteUserLoginPinBuilder.setKs(ks); + deleteUserLoginPinBuilder.setUserId(userId); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserLoginPinBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // deleteAll + public static Response deleteAll(String ks, int userId) { + DeleteAllUserLoginPinBuilder deleteAllUserLoginPinBuilder = UserLoginPinService.deleteAll() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + deleteAllUserLoginPinBuilder.setKs(ks); + deleteAllUserLoginPinBuilder.setUserId(userId); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteAllUserLoginPinBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // update + public static Response update(String ks, int userId, String secret, String pinCode) { + UpdateUserLoginPinBuilder updateUserLoginPinBuilder = UserLoginPinService.update(pinCode, secret) + .setCompletion((ApiCompletion) result -> { + userLoginPinResponse = result; + done.set(true); + }); + + updateUserLoginPinBuilder.setKs(ks); + updateUserLoginPinBuilder.setUserId(userId); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateUserLoginPinBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (userLoginPinResponse.isSuccess()) { + // TODO: 3/22/2018 fix schema assertions + } + + return userLoginPinResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index f552e0b38..d60dc3795 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,14 +2,21 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; +import com.kaltura.client.Logger; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; +import java.util.List; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; +import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.OttUserUtils.getUserNameFromId; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -19,8 +26,15 @@ public class BaseTest { public static String administratorKs, operatorKS, managerKS; + // shared household + public static Household sharedHousehold; + public static HouseholdUser sharedMasterUser, sharedUser; + public static String sharedMasterUserKs, sharedUserKs; + + @BeforeSuite public void setup() { + Logger.getLogger(BaseTest.class).debug("Start Setup!"); // Set client Configuration config = new Configuration(); @@ -41,5 +55,29 @@ public void setup() { // // loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); // managerKS = loginResponse.results.getLoginSession().getKs(); + + // Set project shared HH and users +// initSharedHousehold(); + + Logger.getLogger(BaseTest.class).debug("Finish Setup!"); + } + + private void initSharedHousehold() { + sharedHousehold = createHouseHold(2, 2); + List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); + for (HouseholdUser user : sharedHouseholdUsers) { + if (user.getIsMaster() != null && user.getIsMaster()) { + sharedMasterUser = user; + } + if (user.getIsMaster() == null && user.getIsDefault() == null) { + sharedUser = user; + } + } + + loginResponse = login(PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedMasterUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); + sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); + + loginResponse = login(PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); + sharedUserKs = loginResponse.results.getLoginSession().getKs(); } } diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index 41b027933..350e81d34 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -27,6 +27,5 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); - } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index ba4bf875e..044b3e7ef 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -17,6 +17,7 @@ public class AnonymousLoginTests extends BaseTest { @Test() private void anonymousLogin() { Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(PARTNER_ID, null); + assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 8f9ef0a30..b54c73906 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -28,8 +28,8 @@ public class GetTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { - user = generateOttUser(); - ottUserResponse = register(PARTNER_ID, user, password); + ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; loginResponse = login(PARTNER_ID, user.getUsername(), password, null, null); user = loginResponse.results.getUser(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 0e5539de4..53d2dbd16 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -25,15 +25,15 @@ public class LoginTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { - user = generateOttUser(); - register(PARTNER_ID, user, password); + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; } - // login tests @Description("ottUser/action/login - login") @Test private void login() { loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java new file mode 100644 index 000000000..d76adc04c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -0,0 +1,74 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.servicesImpl.UserLoginPinServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.UserLoginPin; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class LoginWithPinTests extends BaseTest { + + private OTTUser user; + + private Response loginResponse; + private Response userLoginPinResponse; + + private final String SECRET = "secret"; + + @BeforeClass + private void ottUser_login_tests_setup() { + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + user = ottUserResponse.results; + } + + @Description("ottUser/action/loginWithPin - loginWithPin with secret") + @Test + private void loginWithPin_with_secret() throws InterruptedException { + userLoginPinResponse = UserLoginPinServiceImpl.add(administratorKs, Integer.parseInt(user.getId()), SECRET); + + String pin = userLoginPinResponse.results.getPinCode(); + loginResponse = OttUserServiceImpl.loginWithPin(PARTNER_ID, pin, null, SECRET); + + assertThat(loginResponse.error).isNull(); + assertThat(loginResponse.results.getLoginSession()).isNotNull(); + assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); + } + + @Description("ottUser/action/loginWithPin - loginWithPin with wrong secret - error 2008") + @Test + private void loginWithPin_with_wrong_secret() { + userLoginPinResponse = UserLoginPinServiceImpl.add(administratorKs, Integer.parseInt(user.getId()), SECRET); + + String pin = userLoginPinResponse.results.getPinCode(); + loginResponse = OttUserServiceImpl.loginWithPin(PARTNER_ID, pin, null, SECRET + 1); + + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2008).getCode()); + } + + @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") + @Test + private void loginWithPin_with_expired_pinCode() { + userLoginPinResponse = UserLoginPinServiceImpl.add(administratorKs, Integer.parseInt(user.getId()), SECRET); + + String pin = userLoginPinResponse.results.getPinCode(); + // sleep for 1.5 minutes + try { Thread.sleep(120000); } catch (InterruptedException e) { e.printStackTrace(); } + loginResponse = OttUserServiceImpl.loginWithPin(PARTNER_ID, pin, null, SECRET); + + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2004).getCode()); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java new file mode 100644 index 000000000..d14a18ccb --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java @@ -0,0 +1,52 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Optional; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class LogoutTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response loginResponse; + private Response booleanResponse; + + + @BeforeClass + private void ottUser_logout_tests_setup() { + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; + } + + @Description("ottUser/action/logout - logout") + @Test + private void logout() { + loginResponse = login(PARTNER_ID, user.getUsername(), password, null, null); + String ks = loginResponse.results.getLoginSession().getKs(); + + booleanResponse = OttUserServiceImpl.logout(ks, Optional.empty()); + assertThat(booleanResponse.error).isNull(); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + Response ottUserResponse = OttUserServiceImpl.get(ks, Optional.empty()); + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500016).getCode()); + } + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java new file mode 100644 index 000000000..01434826e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java @@ -0,0 +1,40 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class RegisterTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response ottUserResponse; + + @BeforeClass + private void ottUser_login_tests_setup() { + user = generateOttUser(); + } + + // login tests + @Description("ottUser/action/register - register") + @Test + private void register() { + ottUserResponse = OttUserServiceImpl.register(PARTNER_ID, user, password); + + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results.getUsername()).isEqualTo(user.getUsername()); + // TODO: 3/28/2018 add relevant assertions + } + + // TODO: 3/29/2018 add relevant scenarios +} From 1996ca1d411b5c430cf8ac52093e10fd6e0c7cdf Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 1 Apr 2018 13:21:40 +0300 Subject: [PATCH 019/605] added tests to ottUser service --- .../test/servicesImpl/OttUserServiceImpl.java | 205 ++++++++++++------ .../kaltura/client/test/tests/BaseTest.java | 10 +- .../ottUserTests/ActivateTests.java | 3 - .../ottUserTests/GetEncryptedUserIdTests.java | 39 ++++ .../ResendActivationTokenTests.java | 42 ++++ .../ottUserTests/ResetPasswordTests.java | 42 ++++ .../ottUserTests/SetInitialPasswordTests.java | 6 + .../ottUserTests/UpdateTests.java | 93 ++++++++ .../kaltura/client/test/utils/DBUtils.java | 3 +- .../client/test/utils/OttUserUtils.java | 5 +- 10 files changed, 366 insertions(+), 82 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index a89bd4a14..10d4989fa 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -30,65 +30,9 @@ public class OttUserServiceImpl { private static Response loginSessionResponse; private static Response booleanResponse; private static Response> ottUserListResponse; + private static Response stringValueResponse; - // login - public static Response login(int partnerId, String username, String password, @Nullable Map extraParams, @Nullable String udid) { - LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, username, password, extraParams, udid) - .setCompletion((ApiCompletion) result -> { - loginResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - if (loginResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); - } - - return loginResponse; - } - - // register - public static Response register(int partnerId, OTTUser user, String password) { - RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, password) - .setCompletion((ApiCompletion) result -> { - ottUserResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - if (ottUserResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); - } - - return ottUserResponse; - } - - // anonymousLogin - public static Response anonymousLogin(int partnerId, @Nullable String udid) { - AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid) - .setCompletion((ApiCompletion) result -> { - loginSessionResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - if (loginSessionResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_SESSION_SCHEMA)); - } - - return loginSessionResponse; - } - // activate public static Response activate(int partnerId, String username, String activationToken) { ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, username, activationToken) @@ -126,6 +70,25 @@ public static Response addRole(String ks, Optional userId, int return booleanResponse; } + // anonymousLogin + public static Response anonymousLogin(int partnerId, @Nullable String udid) { + AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid) + .setCompletion((ApiCompletion) result -> { + loginSessionResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (loginSessionResponse.isSuccess()) { + assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_SESSION_SCHEMA)); + } + + return loginSessionResponse; + } + // delete public static Response delete(String ks, Optional userId) { DeleteOttUserBuilder deleteOttUserBuilder = OttUserService.delete() @@ -166,6 +129,29 @@ public static Response get(String ks, Optional userId) { return ottUserResponse; } + // getEncryptedUserId + public static Response getEncryptedUserId(String ks, int userId) { + GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = OttUserService.getEncryptedUserId() + .setCompletion((ApiCompletion) result -> { + stringValueResponse = result; + done.set(true); + }); + + getEncryptedUserIdOttUserBuilder.setKs(ks); + getEncryptedUserIdOttUserBuilder.setUserId(userId); + + TestAPIOkRequestsExecutor.getExecutor().queue(getEncryptedUserIdOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (stringValueResponse.isSuccess()) { + // TODO: 4/1/2018 add schema assertion +// assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(stringValueResponse)); + } + + return stringValueResponse; + } + // list public static Response> list(String ks, @Nullable OTTUserFilter ottUserFilter) { ListOttUserBuilder listOttUserBuilder = OttUserService.list(ottUserFilter) @@ -186,6 +172,25 @@ public static Response> list(String ks, @Nullable OTTUserF return ottUserListResponse; } + // login + public static Response login(int partnerId, String username, String password, @Nullable Map extraParams, @Nullable String udid) { + LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, username, password, extraParams, udid) + .setCompletion((ApiCompletion) result -> { + loginResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (loginResponse.isSuccess()) { + assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); + } + + return loginResponse; + } + // loginWithPin public static Response loginWithPin(int partnerId, String pin, @Nullable String udid, String secret) { @@ -224,24 +229,83 @@ public static Response logout(String ks, Optional userId) { return booleanResponse; } -// public static T resendActivationToken(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } + // register + public static Response register(int partnerId, OTTUser user, String password) { + RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, password) + .setCompletion((ApiCompletion) result -> { + ottUserResponse = result; + done.set(true); + }); -// public static T resetPassword(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } + TestAPIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (ottUserResponse.isSuccess()) { + assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); + } -// public static T setInitialPassword(String ks) { + return ottUserResponse; + } + + // resendActivationToken + public static Response resendActivationToken(int partnerId, String username) { + ResendActivationTokenOttUserBuilder resendActivationTokenOttUserBuilder = OttUserService.resendActivationToken(partnerId, username) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(resendActivationTokenOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // resetPassword + public static Response resetPassword(int partnerId, String ks, String username) { + ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, username) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + resetPasswordOttUserBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(resetPasswordOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + +// // setInitialPassword +// public static void setInitialPassword(String ks) { // // TODO: 3/19/2018 implement function -// return null; // } -// public static T update(String ks) { + public static Response update(String ks, OTTUser user, @Nullable String id) { + UpdateOttUserBuilder updateOttUserBuilder = OttUserService.update(user, id) + .setCompletion((ApiCompletion) result -> { + ottUserResponse = result; + done.set(true); + }); + + updateOttUserBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (ottUserResponse.isSuccess()) { + assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); + } + + return ottUserResponse; + } + +// public static void updateDynamicData() { // // TODO: 3/19/2018 implement function -// return null; // } // public static T updateLoginData(String ks) { @@ -249,9 +313,8 @@ public static Response logout(String ks, Optional userId) { // return null; // } -// public static T getEncryptedUserId(String ks) { +// public static void updatePassword() { // // TODO: 3/19/2018 implement function -// return null; // } } diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index d60dc3795..d377b4b07 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -24,7 +24,7 @@ public class BaseTest { public static Client client; private Response loginResponse; - public static String administratorKs, operatorKS, managerKS; + public static String administratorKs, operatorKs, managerKs; // shared household public static Household sharedHousehold; @@ -44,17 +44,17 @@ public void setup() { client.setApiVersion(API_REQUEST_VERSION); // Set default awaitility timeout - setDefaultTimeout(15, TimeUnit.SECONDS); + setDefaultTimeout(20, TimeUnit.SECONDS); // Login with shared users loginResponse = login(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); administratorKs = loginResponse.results.getLoginSession().getKs(); // loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); -// operatorKS = loginResponse.results.getLoginSession().getKs(); -// +// operatorKs = loginResponse.results.getLoginSession().getKs(); + // loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); -// managerKS = loginResponse.results.getLoginSession().getKs(); +// managerKs = loginResponse.results.getLoginSession().getKs(); // Set project shared HH and users // initSharedHousehold(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index 104906534..c07e13069 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -16,7 +16,6 @@ import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; public class ActivateTests extends BaseTest { @@ -34,8 +33,6 @@ private void ottUser_activate_tests_setup() { @Test private void activate() { String activationToken = DBUtils.getActivationToken(user.getUsername()); - if (activationToken == null) - fail("activationToken can't be null"); Response ottUserResponse = OttUserServiceImpl.activate(PARTNER_ID, user.getUsername(),activationToken); assertThat(ottUserResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java new file mode 100644 index 000000000..de52e3a46 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java @@ -0,0 +1,39 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.StringValue; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class GetEncryptedUserIdTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response stringValueResponse; + + @BeforeClass + private void ottUser_getEncryptedUserId_tests_setup() { + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; + } + + @Description("ottUser/action/getEncryptedUserId - getEncryptedUserId") + @Test + private void getEncryptedUserId() { + stringValueResponse = OttUserServiceImpl.getEncryptedUserId(administratorKs, Integer.parseInt(user.getId())); + + assertThat(stringValueResponse.error).isNull(); + assertThat(stringValueResponse.results.getValue()).isNotNull(); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java new file mode 100644 index 000000000..b07a88b29 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -0,0 +1,42 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.DBUtils; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class ResendActivationTokenTests extends BaseTest { + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + @BeforeClass + private void ottUser_resendActivationToken_tests_setup() { + user = generateOttUser(); + register(PARTNER_ID, user, password); + login(PARTNER_ID, user.getUsername(), password, null, null); + } + + @Description("ottUser/action/resendActivationToken - resendActivationToken") + @Test(enabled = false) // TODO: 4/1/2018 find how to tag test as bug (bug BEO-4908) + private void resendActivationToken() { + String activationToken = DBUtils.getActivationToken(user.getUsername()); + + Response booleanResponse = OttUserServiceImpl.resendActivationToken(PARTNER_ID, user.getUsername()); + assertThat(booleanResponse.error).isNull(); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + String resentActivationToken = DBUtils.getActivationToken(user.getUsername()); + assertThat(activationToken).isNotEqualTo(resentActivationToken); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java new file mode 100644 index 000000000..ae25db5ee --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java @@ -0,0 +1,42 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class ResetPasswordTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response booleanResponse; + + @BeforeClass + private void ottUser_resetPassword_tests_setup() { + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; + } + + @Description("ottUser/action/resetPassword - resetPassword") + @Test(enabled = false) + private void resetPassword() { + booleanResponse = OttUserServiceImpl.resetPassword(PARTNER_ID, administratorKs, user.getUsername()); + + assertThat(booleanResponse.error).isNull(); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + // TODO: 4/1/2018 finsih the test after bug BEO-4884 will be fixed + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java new file mode 100644 index 000000000..fafd7f6a1 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java @@ -0,0 +1,6 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.tests.BaseTest; + +public class SetInitialPasswordTests extends BaseTest { +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java new file mode 100644 index 000000000..cc4133210 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -0,0 +1,93 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Optional; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + + +public class UpdateTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + private String originalUserEmail; + + private Response ottUserResponse; + + @BeforeClass + private void ottUser_update_tests_setup() { + ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; + originalUserEmail = user.getEmail(); + } + + @Description("ottUser/action/update - update") + @Test + private void update() { + // get self ks + Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + String ks = loginResponse.results.getLoginSession().getKs(); + + // update + String newUserInfo = "abc"; + + user.setFirstName(newUserInfo); + user.setLastName(newUserInfo); + ottUserResponse = OttUserServiceImpl.update(ks, user, null); + + assertThat(ottUserResponse.error).isNull(); + + // get user after update + ottUserResponse = OttUserServiceImpl.get(ks, Optional.empty()); + user = ottUserResponse.results; + + // assert + assertThat(ottUserResponse.error).isNull(); + assertThat(user.getFirstName()).isEqualTo(newUserInfo); + assertThat(user.getLastName()).isEqualTo(newUserInfo); + assertThat(user.getEmail()).isEqualTo(originalUserEmail); + } + + @Description("ottUser/action/update - update with administratorKs") + @Test + private void update_with_administratorKs() { + + // update + String newUserInfo = "def"; + + user.setFirstName(newUserInfo); + user.setLastName(newUserInfo); +// user.setAffiliateCode(null); + ottUserResponse = OttUserServiceImpl.update(administratorKs, user, user.getId()); + + assertThat(ottUserResponse.error).isNull(); + + // get user after update + ottUserResponse = OttUserServiceImpl.get(administratorKs, Optional.of(Integer.valueOf(user.getId()))); + user = ottUserResponse.results; + + // assert + assertThat(ottUserResponse.error).isNull(); + assertThat(user.getFirstName()).isEqualTo(newUserInfo); + assertThat(user.getLastName()).isEqualTo(newUserInfo); + assertThat(user.getEmail()).isEqualTo(originalUserEmail); + } + + @AfterClass + private void ottUser_update_tests_tearDown() { + OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(user.getId()))); + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index db8c1a953..e3ed0b13c 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Logger; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; @@ -38,7 +39,7 @@ public static String getActivationToken(String username) { activationToken = rs.getString("ACTIVATION_TOKEN"); } catch (SQLException e) { e.printStackTrace(); -// Logger.getLogger(DBUtils.class).error("activationToken can't be null"); + Logger.getLogger(DBUtils.class).error("activationToken can't be null"); } closeConnection(); return activationToken; diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 3c99e98a6..90e41f86f 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -1,13 +1,14 @@ package com.kaltura.client.test.utils; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; -import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import java.util.Optional; import java.util.Random; +import static com.kaltura.client.test.tests.BaseTest.administratorKs; + public class OttUserUtils extends BaseUtils { // generate ottUser @@ -32,7 +33,7 @@ public static OTTUser generateOttUser() { } public static String getUserNameFromId(int userId) { - Response userResponse = OttUserServiceImpl.get(BaseTest.administratorKs, Optional.of(userId)); + Response userResponse = OttUserServiceImpl.get(administratorKs, Optional.of(userId)); return userResponse.results.getUsername(); } } From 20032013e60f8922744a527034c374f88811bfcf Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 1 Apr 2018 14:26:57 +0300 Subject: [PATCH 020/605] enabled shared operator user --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 4 ++-- .../test/tests/servicesTests/productPriceTests/ListTests.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index d377b4b07..6280ffe81 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -50,8 +50,8 @@ public void setup() { loginResponse = login(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); administratorKs = loginResponse.results.getLoginSession().getKs(); -// loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); -// operatorKs = loginResponse.results.getLoginSession().getKs(); + loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); + operatorKs = loginResponse.results.getLoginSession().getKs(); // loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); // managerKs = loginResponse.results.getLoginSession().getKs(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 9e857725a..4ddfee259 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -19,7 +19,7 @@ public class ListTests extends BaseTest { public void listSubscriptionTest() { ProductPriceFilter filter = new ProductPriceFilter(); // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); - Response> productPriceList = list(operatorKS, filter, Optional.empty()); + Response> productPriceList = list(operatorKs, filter, Optional.empty()); // TODO: fix! assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(five_min_renewable_subscription_id); assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.FOR_PURCHASE); assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount() > 0); From 3be6dea9498238340a4d4b446c28eac5596a9dc4 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 1 Apr 2018 14:56:26 +0300 Subject: [PATCH 021/605] Added logs for request headers --- .../java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index d2a33650b..050ecdfe2 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -33,6 +33,7 @@ public static TestAPIOkRequestsExecutor getExecutor() { @SuppressWarnings("rawtypes") @Override protected ResponseElement onGotResponse(Response response, RequestElement action) { + logger.debug("Request Headers\n" + action.getHeaders().toString()); String requestId = getRequestId(response); if (!response.isSuccessful()) { // in case response has failure status From 52c1df101cb0c30426c10961033ebbb0840ff41f Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 1 Apr 2018 16:16:31 +0300 Subject: [PATCH 022/605] log response headers to get Kaltura-Session --- .../test/TestAPIOkRequestsExecutor.java | 3 +- .../test/servicesImpl/OttUserServiceImpl.java | 50 ++++++++++++++++--- .../ResendActivationTokenTests.java | 8 +-- .../ottUserTests/SetInitialPasswordTests.java | 2 + .../ottUserTests/UpdateDynamicDataTests.java | 45 +++++++++++++++++ 5 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 050ecdfe2..d3fbe932a 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -33,7 +33,7 @@ public static TestAPIOkRequestsExecutor getExecutor() { @SuppressWarnings("rawtypes") @Override protected ResponseElement onGotResponse(Response response, RequestElement action) { - logger.debug("Request Headers\n" + action.getHeaders().toString()); +// logger.debug("request headers\n" + action.getHeaders().toString()); String requestId = getRequestId(response); if (!response.isSuccessful()) { // in case response has failure status @@ -49,6 +49,7 @@ protected ResponseElement onGotResponse(Response response, RequestElement action } logger.debug("response body:\n" + responseString); + logger.debug("response headers:\n" + response.headers()); fullResponseAsString = responseString.substring(0); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 10d4989fa..6f9a24201 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -31,6 +31,7 @@ public class OttUserServiceImpl { private static Response booleanResponse; private static Response> ottUserListResponse; private static Response stringValueResponse; + private static Response ottUserDynamicDataResponse; // activate @@ -279,11 +280,26 @@ public static Response resetPassword(int partnerId, String ks, String u return booleanResponse; } -// // setInitialPassword -// public static void setInitialPassword(String ks) { -// // TODO: 3/19/2018 implement function -// } + // setInitialPassword + public static Response setInitialPassword(int partnerId, String token, String password) { + SetInitialPasswordOttUserBuilder setInitialPasswordOttUserBuilder = OttUserService.setInitialPassword(partnerId, token, password) + .setCompletion((ApiCompletion) result -> { + ottUserResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(setInitialPasswordOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (ottUserResponse.isSuccess()) { + assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); + } + return ottUserResponse; + } + + // update public static Response update(String ks, OTTUser user, @Nullable String id) { UpdateOttUserBuilder updateOttUserBuilder = OttUserService.update(user, id) .setCompletion((ApiCompletion) result -> { @@ -304,15 +320,35 @@ public static Response update(String ks, OTTUser user, @Nullable String return ottUserResponse; } -// public static void updateDynamicData() { -// // TODO: 3/19/2018 implement function -// } + // updateDynamicData + public static Response updateDynamicData(String ks, Optional userId, String key, StringValue value) { + UpdateDynamicDataOttUserBuilder updateDynamicDataOttUserBuilder = OttUserService.updateDynamicData(key, value) + .setCompletion((ApiCompletion) result -> { + ottUserDynamicDataResponse = result; + done.set(true); + }); + + updateDynamicDataOttUserBuilder.setKs(ks); + userId.ifPresent(updateDynamicDataOttUserBuilder::setUserId); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateDynamicDataOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + if (ottUserDynamicDataResponse.isSuccess()) { + // TODO: 4/1/2018 add schema assertion + } + + return ottUserDynamicDataResponse; + } + // updateLoginData // public static T updateLoginData(String ks) { // // TODO: 3/19/2018 implement function // return null; // } + // updatePassword // public static void updatePassword() { // // TODO: 3/19/2018 implement function // } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java index b07a88b29..d33f03493 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.DBUtils; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; @@ -28,15 +27,12 @@ private void ottUser_resendActivationToken_tests_setup() { } @Description("ottUser/action/resendActivationToken - resendActivationToken") - @Test(enabled = false) // TODO: 4/1/2018 find how to tag test as bug (bug BEO-4908) + @Test(enabled = true) private void resendActivationToken() { - String activationToken = DBUtils.getActivationToken(user.getUsername()); - Response booleanResponse = OttUserServiceImpl.resendActivationToken(PARTNER_ID, user.getUsername()); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); - String resentActivationToken = DBUtils.getActivationToken(user.getUsername()); - assertThat(activationToken).isNotEqualTo(resentActivationToken); + // TODO: 4/1/2018 can't be completely tests until we verify emails } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java index fafd7f6a1..82c075a04 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java @@ -3,4 +3,6 @@ import com.kaltura.client.test.tests.BaseTest; public class SetInitialPasswordTests extends BaseTest { + + // TODO: 4/1/2018 implemente tests } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java new file mode 100644 index 000000000..b8c300fb4 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java @@ -0,0 +1,45 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.OTTUserDynamicData; +import com.kaltura.client.types.StringValue; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Optional; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class UpdateDynamicDataTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response ottUserDynamicDataResponse; + + @BeforeClass + private void ottUser_updateDynamicData_tests_setup() { + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; + } + + @Description("ottUser/action/updateDynamicData - updateDynamicData") + @Test + private void updateDynamicData() { + StringValue value = new StringValue(); + value.setValue("value1"); + + ottUserDynamicDataResponse = OttUserServiceImpl.updateDynamicData(administratorKs, Optional.of(Integer.valueOf(user.getId())), "key1", value); + assertThat(ottUserDynamicDataResponse.error).isNull(); + assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo("value1"); + assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo("key1"); + } +} From 73770c2d1d95a2b9f9ae508da2327e3ebc16e674 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 1 Apr 2018 16:49:42 +0300 Subject: [PATCH 023/605] add updateLoginData --- .../test/servicesImpl/OttUserServiceImpl.java | 19 +++++-- .../ottUserTests/UpdateLoginDataTests.java | 53 +++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index 6f9a24201..c47e2e112 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -343,10 +343,21 @@ public static Response updateDynamicData(String ks, Optional } // updateLoginData -// public static T updateLoginData(String ks) { -// // TODO: 3/19/2018 implement function -// return null; -// } + public static Response updateLoginData(String ks, String username, String oldPassword, String newPassword) { + UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(username, oldPassword, newPassword) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + updateLoginDataOttUserBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateLoginDataOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } // updatePassword // public static void updatePassword() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java new file mode 100644 index 000000000..dc4550655 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -0,0 +1,53 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; + +public class UpdateLoginDataTests extends BaseTest { + + private OTTUser user; + private String password = GLOBAL_USER_PASSWORD; + + private Response booleanResponse; + + @BeforeClass + private void ottUser_updateLoginData_tests_setup() { + Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + user = ottUserResponse.results; + } + + @Description("ottUser/action/updateLoginData - updateLoginData") + @Test + private void updateLoginData() { + Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + String ks = loginResponse.results.getLoginSession().getKs(); + + booleanResponse = OttUserServiceImpl.updateLoginData(ks, user.getUsername(), password, password + 1); + + assertThat(booleanResponse.error).isNull(); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // try login with old password + loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); + + // try login with new password + loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password + 1, null, null); + assertThat(loginResponse.error).isNull(); + assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); + } +} From 7514659fbafd6fd3d64b7263d4533bba8026c09c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 1 Apr 2018 16:51:47 +0300 Subject: [PATCH 024/605] add updateLoginData with administratorKs --- .../ottUserTests/UpdateLoginDataTests.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index dc4550655..86497d3c1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -50,4 +50,23 @@ private void updateLoginData() { assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } + + @Description("ottUser/action/updateLoginData - updateLoginData with administratorKs") + @Test + private void updateLoginData_with_administratorKs() { + booleanResponse = OttUserServiceImpl.updateLoginData(administratorKs, user.getUsername(), password, password + 1); + + assertThat(booleanResponse.error).isNull(); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // try login with old password + Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); + + // try login with new password + loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password + 1, null, null); + assertThat(loginResponse.error).isNull(); + assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); + } } From b9f858fd741f8f2721feb91ec8b53c04d168b6b7 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 1 Apr 2018 16:57:06 +0300 Subject: [PATCH 025/605] add UpdatePasswordTests --- .../test/servicesImpl/OttUserServiceImpl.java | 24 ++++++++++++++----- .../ottUserTests/UpdatePasswordTests.java | 7 ++++++ 2 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdatePasswordTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index c47e2e112..b7c1803bb 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -330,15 +330,15 @@ public static Response updateDynamicData(String ks, Optional updateDynamicDataOttUserBuilder.setKs(ks); userId.ifPresent(updateDynamicDataOttUserBuilder::setUserId); - + TestAPIOkRequestsExecutor.getExecutor().queue(updateDynamicDataOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); - + if (ottUserDynamicDataResponse.isSuccess()) { // TODO: 4/1/2018 add schema assertion } - + return ottUserDynamicDataResponse; } @@ -360,9 +360,21 @@ public static Response updateLoginData(String ks, String username, Stri } // updatePassword -// public static void updatePassword() { -// // TODO: 3/19/2018 implement function -// } + public static Response updatePassword(String ks, int partnerId, String username) { + ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, username) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + resetPasswordOttUserBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(resetPasswordOttUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdatePasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdatePasswordTests.java new file mode 100644 index 000000000..a3ade05e3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdatePasswordTests.java @@ -0,0 +1,7 @@ +package com.kaltura.client.test.tests.servicesTests.ottUserTests; + +import com.kaltura.client.test.tests.BaseTest; + +public class UpdatePasswordTests extends BaseTest { + // TODO: 4/1/2018 implement tests +} From 4d106f7efbc123f2304e0a59a86e5d75ac979cf0 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 2 Apr 2018 11:32:44 +0300 Subject: [PATCH 026/605] turn off response headers logging --- .../test/TestAPIOkRequestsExecutor.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index d3fbe932a..10c677c3b 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -7,7 +7,8 @@ import com.kaltura.client.utils.request.ExecutedRequest; import com.kaltura.client.utils.request.RequestElement; import com.kaltura.client.utils.response.base.ResponseElement; -import okhttp3.*; +import okhttp3.Response; + import java.io.IOException; /** @@ -33,7 +34,10 @@ public static TestAPIOkRequestsExecutor getExecutor() { @SuppressWarnings("rawtypes") @Override protected ResponseElement onGotResponse(Response response, RequestElement action) { + + // print request headers // logger.debug("request headers\n" + action.getHeaders().toString()); + String requestId = getRequestId(response); if (!response.isSuccessful()) { // in case response has failure status @@ -48,12 +52,27 @@ protected ResponseElement onGotResponse(Response response, RequestElement action logger.error("failed to retrieve the response body!"); } + // print response body logger.debug("response body:\n" + responseString); - logger.debug("response headers:\n" + response.headers()); - fullResponseAsString = responseString.substring(0); + // print response headers +// logger.debug("response headers:\n" + response.headers()); + + fullResponseAsString = responseString; + + ResponseElement responseElement = new ExecutedRequest().requestId(requestId).response(responseString).code(response.code()).success(responseString != null); + com.kaltura.client.utils.response.base.Response response1 = action.parseResponse(responseElement); + + String s1 = "schemas/"; + String s2 = response1.results.getClass().getSimpleName(); + String s3 = ".json"; + + String schema = s1 + s2 + s3; + System.out.println("here!!! " + schema); + +// assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(schema)); - return new ExecutedRequest().requestId(requestId).response(responseString).code(response.code()).success(responseString != null); + return responseElement; } } } From a269c6a812d66d031bf3a5e2885f99a7c9d12382 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 2 Apr 2018 15:30:45 +0300 Subject: [PATCH 027/605] Added draft of ingest PPV util --- .../com/kaltura/client/test/Properties.java | 25 +++++ .../productPriceTests/ListTests.java | 6 ++ .../kaltura/client/test/utils/BaseUtils.java | 6 ++ .../client/test/utils/IngestPPVUtils.java | 94 +++++++++++++++++++ .../client/test/utils/IngestVODUtils.java | 16 ++++ 5 files changed, 147 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index aa92b6231..f6361c3ae 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -9,6 +9,8 @@ public class Properties { // Url properties public static final String API_BASE_URL = "http://34.249.122.223:8080"; public static final String API_URL_VERSION = "v4_8"; + public static final String SOAP_BASE_URL = "http://34.249.122.223:8030"; + public static final String INGEST_REPORT_URL = "http://34.249.122.223:5823"; // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file @@ -32,6 +34,29 @@ public class Properties { public static final String GLOBAL_USER_PASSWORD = "password"; + // file types + public static final String WEB_FILE_TYPE = "web_file_type"; + public static final String MOBILE_FILE_TYPE = "mobile_file_type"; + + // ingest + public static final String INGEST_USER_NAME = "ingest_user_username"; + public static final String INGEST_USER_PASSWORD = "ingest_user_password"; + + public static final String INGEST_ACTION_INSERT = "insert"; + + // price codes + public static final String AMOUNT_4_99_EUR = "amount_4_99_eur"; // 4.99 + public static final String CURRENCY_EUR = "EUR"; + + // usage modules + public static final String ONE_DAY_USAGE_MODULE = "one_day_usage_module"; // module has 1 Day life cycles, 0 maximum views and 5 minute waiver + + // product codes + public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; + + // discount modules + public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; + public static String getProperty(String propertyKey) { if (resourceBundle == null) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 4ddfee259..53fe6d1a0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -2,13 +2,16 @@ import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.IngestPPVUtils; import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.Ppv; import com.kaltura.client.types.ProductPrice; import com.kaltura.client.types.ProductPriceFilter; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.Test; import java.util.Optional; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; import static org.assertj.core.api.Assertions.assertThat; @@ -18,6 +21,9 @@ public class ListTests extends BaseTest { @Test(enabled = false) // as used in feature tests public void listSubscriptionTest() { ProductPriceFilter filter = new ProductPriceFilter(); + Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), + Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, + getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE)); // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); Response> productPriceList = list(operatorKs, filter, Optional.empty()); // TODO: fix! assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(five_min_renewable_subscription_id); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index f179074f1..c380e4b22 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; import static com.kaltura.client.test.Properties.API_URL_VERSION; @@ -23,6 +24,11 @@ public class BaseUtils { private static final String API_SCHEMA_URL = "https://api-preprod.ott.kaltura.com/" + API_URL_VERSION + "/clientlibs/KalturaClient.xml"; private static List exceptions; + // generate string containing prefix and random long suffix + public static String getRandomValue(String prefix, long maxValue) { + long randomLongValue = ThreadLocalRandom.current().nextLong(maxValue); + return prefix + randomLongValue; + } // generate random string public static String getRandomString() { diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java new file mode 100644 index 000000000..95da2c834 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -0,0 +1,94 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.types.*; +import io.restassured.RestAssured; +import io.restassured.response.Response; +import java.util.HashMap; +import static com.kaltura.client.test.Properties.*; +import static io.restassured.path.xml.XmlPath.from; + +public class IngestPPVUtils extends BaseUtils { + + // ingest new PPV + public static Ppv ingestPPV(String action, boolean isActive, String description, String discount, + double price, String currency, String usageModule, boolean isSubscriptionOnly, + boolean isFirstDeviceLimitation, String productCode, String firstFileType, + String secondFileType) { + String ppvCode = getRandomValue("PPV_", 9999999999L); + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headermap = new HashMap<>(); + headermap.put("Content-Type", "text/xml;charset=UTF-8"); + headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestBusinessModules\""); + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + Response resp = RestAssured.given() + .log().all() + .headers(headermap) + .body(reqBody) + .post(url); + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + System.out.println("ReportId = " + reportId); + + url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + System.out.println(resp.asString()); + System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + // TODO: complete it + Ppv ppv = new Ppv(); + //ppv.setDescriptions(); + /*PriceDetails priceDetails = new PriceDetails(); + Price price1 = new Price(); + price1.setAmount(price); + price1.setCurrency(currency); + priceDetails.setPrice(price1); + ppv.setPrice(priceDetails);*/ + /*UsageModule usageModule1 = new UsageModule(); + usageModule1.setName(usageModule); + ppv.setUsageModule(usageModule1);*/ + //ppv.setIsSubscriptionOnly(isSubscriptionOnly); + //ppv.setFirstDeviceLimitation(isFirstDeviceLimitation); + //ppv.setProductCode(productCode); + + return null; + } + + private static String buildIngestPpvXML(String action, String ppvCode, boolean isActive, String description, String discount, + double price, String currency, String usageModule, boolean isSubscriptionOnly, + boolean isFirstDeviceLimitation, String productCode, String firstFileType, + String secondFileType) { + return "\n" + + " \n" + + " \n" + + " \n" + + " " + description + "\n" + + " \n" + + " \n" + + " " + price + "\n" + + " " + currency + "\n" + + " \n" + + " " + usageModule + "\n" + + " " + discount + "\n" + + " \n" + + " " + isSubscriptionOnly + "\n" + + " " + isFirstDeviceLimitation + "\n" + + " " + productCode + "\n" + + " \n" + + " " + firstFileType + "\n" + + " " + secondFileType + "\n" + + " \n" + + " \n" + + " \n" + + "\n"; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java new file mode 100644 index 000000000..d3541eef5 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -0,0 +1,16 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.types.MediaAsset; + +public class IngestVODUtils extends BaseUtils { + + // ingest new VOD (Media) + public static MediaAsset ingestVOD() { + String mediaNamePrefix = "Media"; + String mediaType = "Media" ; + + // TODO: complete it + + return null; + } +} From 38402b22f61a60d1c34f0f6abbe9db2aece39ba4 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 2 Apr 2018 16:35:16 +0300 Subject: [PATCH 028/605] moved schema assertion to TestAPIOkRequestsExcutor --- .../com/kaltura/client/test/Properties.java | 1 + .../test/TestAPIOkRequestsExecutor.java | 31 +++++++---- .../HouseholdDeviceServiceImpl.java | 6 +-- .../servicesImpl/HouseholdServiceImpl.java | 8 +-- .../HouseholdUserServiceImpl.java | 11 +--- .../test/servicesImpl/OttUserServiceImpl.java | 51 ------------------- .../servicesImpl/ProductPriceServiceImpl.java | 18 +++---- .../servicesImpl/UserLoginPinServiceImpl.java | 8 --- .../servicesImpl/UserRoleServiceImpl.java | 4 -- .../kaltura/client/test/tests/Sandbox.java | 5 +- .../ottUserTests/LoginWithPinTests.java | 2 +- .../ResendActivationTokenTests.java | 2 +- .../ottUserTests/UpdateLoginDataTests.java | 16 +++--- .../ottUserTests/UpdateTests.java | 2 +- ...on_Schema.json => BillingTransaction.json} | 8 +-- src/test/resources/schemas/Boolean.json | 9 ++++ ...raHousehold_Schema.json => Household.json} | 0 ...evice_Schema.json => HouseholdDevice.json} | 0 ...oldUser_Schema.json => HouseholdUser.json} | 15 ++---- ...n => ListResponse_BillingTransaction.json} | 4 +- ...ema.json => ListResponse_Entitlement.json} | 0 .../schemas/ListResponse_HouseholdUser.json | 35 +++++++++++++ .../schemas/ListResponse_OTTUser.json | 35 +++++++++++++ ...ma.json => ListResponse_ProductPrice.json} | 0 ...esponse_Schema.json => LoginResponse.json} | 6 +-- ...nSession_Schema.json => LoginSession.json} | 6 +-- ...MediaAsset_Schema.json => MediaAsset.json} | 0 ...json => MultilingualStringValueArray.json} | 0 ...alturaOttUser_Schema.json => OTTUser.json} | 6 +-- .../resources/schemas/OTTUserDynamicData.json | 40 +++++++++++++++ ...lement_Schema.json => PpvEntitlement.json} | 0 ...turaPpvPrice_Schema.json => PpvPrice.json} | 0 .../{KalturaPrice_Schema.json => Price.json} | 0 src/test/resources/schemas/StringValue.json | 27 ++++++++++ ...hema.json => SubscriptionEntitlement.json} | 0 ...ice_Schema.json => SubscriptionPrice.json} | 0 ...ansaction_Schema.json => Transaction.json} | 0 src/test/resources/schemas/UserLoginPin.json | 37 ++++++++++++++ 38 files changed, 248 insertions(+), 145 deletions(-) rename src/test/resources/schemas/{KalturaBillingTransaction_Schema.json => BillingTransaction.json} (91%) create mode 100644 src/test/resources/schemas/Boolean.json rename src/test/resources/schemas/{KalturaHousehold_Schema.json => Household.json} (100%) rename src/test/resources/schemas/{KalturaHouseholdDevice_Schema.json => HouseholdDevice.json} (100%) rename src/test/resources/schemas/{KalturaHouseholdUser_Schema.json => HouseholdUser.json} (75%) rename src/test/resources/schemas/{KalturaBillingTransactionListResponse_Schema.json => ListResponse_BillingTransaction.json} (79%) rename src/test/resources/schemas/{KalturaEntitlementListResponse_Schema.json => ListResponse_Entitlement.json} (100%) create mode 100644 src/test/resources/schemas/ListResponse_HouseholdUser.json create mode 100644 src/test/resources/schemas/ListResponse_OTTUser.json rename src/test/resources/schemas/{KalturaProductPriceListResponse_Schema.json => ListResponse_ProductPrice.json} (100%) rename src/test/resources/schemas/{KalturaLoginResponse_Schema.json => LoginResponse.json} (65%) rename src/test/resources/schemas/{KalturaLoginSession_Schema.json => LoginSession.json} (78%) rename src/test/resources/schemas/{KalturaMediaAsset_Schema.json => MediaAsset.json} (100%) rename src/test/resources/schemas/{KalturaMultilingualStringValueArray_Schema.json => MultilingualStringValueArray.json} (100%) rename src/test/resources/schemas/{KalturaOttUser_Schema.json => OTTUser.json} (95%) create mode 100644 src/test/resources/schemas/OTTUserDynamicData.json rename src/test/resources/schemas/{KalturaPpvEntitlement_Schema.json => PpvEntitlement.json} (100%) rename src/test/resources/schemas/{KalturaPpvPrice_Schema.json => PpvPrice.json} (100%) rename src/test/resources/schemas/{KalturaPrice_Schema.json => Price.json} (100%) create mode 100644 src/test/resources/schemas/StringValue.json rename src/test/resources/schemas/{KalturaSubscriptionEntitlement_Schema.json => SubscriptionEntitlement.json} (100%) rename src/test/resources/schemas/{KalturaSubscriptionPrice_Schema.json => SubscriptionPrice.json} (100%) rename src/test/resources/schemas/{KalturaTransaction_Schema.json => Transaction.json} (100%) create mode 100644 src/test/resources/schemas/UserLoginPin.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index aa92b6231..3d15f5231 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -49,4 +49,5 @@ public static String getProperty(String propertyKey) { // TODO: 3/19/2018 update readme file with project structure and list of services // TODO: 3/19/2018 find how to run specific tests according to api version // TODO: 3/22/2018 ask Elram where to open the apiException meesage not equal to description issue + // TODO: 4/2/2018 integrate allure reports and annotate known issues / bugs } diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 10c677c3b..b406f944f 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -3,6 +3,7 @@ import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.ErrorElement; import com.kaltura.client.utils.request.ExecutedRequest; import com.kaltura.client.utils.request.RequestElement; @@ -11,6 +12,9 @@ import java.io.IOException; +import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; +import static org.hamcrest.MatcherAssert.assertThat; + /** * @hide */ @@ -22,8 +26,6 @@ public class TestAPIOkRequestsExecutor extends APIOkRequestsExecutor { private static ILogger logger = Logger.getLogger(TAG); protected static TestAPIOkRequestsExecutor self; - public static String fullResponseAsString = ""; - public static TestAPIOkRequestsExecutor getExecutor() { if (self == null) { self = new TestAPIOkRequestsExecutor(); @@ -33,7 +35,7 @@ public static TestAPIOkRequestsExecutor getExecutor() { @SuppressWarnings("rawtypes") @Override - protected ResponseElement onGotResponse(Response response, RequestElement action) { + protected ResponseElement onGotResponse(Response response, RequestElement action) { // print request headers // logger.debug("request headers\n" + action.getHeaders().toString()); @@ -58,19 +60,26 @@ protected ResponseElement onGotResponse(Response response, RequestElement action // print response headers // logger.debug("response headers:\n" + response.headers()); - fullResponseAsString = responseString; - ResponseElement responseElement = new ExecutedRequest().requestId(requestId).response(responseString).code(response.code()).success(responseString != null); com.kaltura.client.utils.response.base.Response response1 = action.parseResponse(responseElement); - String s1 = "schemas/"; - String s2 = response1.results.getClass().getSimpleName(); - String s3 = ".json"; + if (response1.isSuccess()) { + String s1 = "schemas/"; + String s3 = ".json"; + String s2 = response1.results.getClass().getSimpleName(); - String schema = s1 + s2 + s3; - System.out.println("here!!! " + schema); + if (s2.equals("ListResponse")) { + com.kaltura.client.utils.response.base.Response listResponse = response1; + String s = listResponse.results.getObjects().get(0).getClass().getSimpleName(); + s2 = s2 + "_" + s; + } -// assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(schema)); + String schema = s1 + s2 + s3; + + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Start " + schema + " schema assertion!"); + assertThat(responseString, matchesJsonSchemaInClasspath(schema)); + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Finish " + schema + " schema assertion!"); + } return responseElement; } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index d07ed7dc9..738a50534 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -19,7 +19,7 @@ public class HouseholdDeviceServiceImpl { private static Response householdDeviceResponse; - //add + // add public static Response add(String ks, HouseholdDevice householdDevice) { AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice) .setCompletion((ApiCompletion) result -> { @@ -32,10 +32,6 @@ public static Response add(String ks, HouseholdDevice household await().untilTrue(done); done.set(false); - if (householdDeviceResponse.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } - return householdDeviceResponse; } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index d029c8dc6..164d81699 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -22,7 +22,7 @@ public class HouseholdServiceImpl { private static Response booleanResponse; - //add + // add public static Response add(String ks, Household household) { AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household) .setCompletion((ApiCompletion) result -> { @@ -35,14 +35,10 @@ public static Response add(String ks, Household household) { await().untilTrue(done); done.set(false); - if (householdResponse.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } - return householdResponse; } - //delete + // delete public static Response delete(String ks, @Nullable int householdId) { DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(householdId) .setCompletion((ApiCompletion) result -> { diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index aacd525b1..72e3de0fd 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -24,7 +24,7 @@ public class HouseholdUserServiceImpl { private static Response> householdUserListResponse; - //add + // add public static Response add(String ks, HouseholdUser householdUser) { AddHouseholdUserBuilder addHouseholdUserBuilder = HouseholdUserService.add(householdUser) .setCompletion((ApiCompletion) result -> { @@ -37,13 +37,10 @@ public static Response add(String ks, HouseholdUser householdUser await().untilTrue(done); done.set(false); - if (householdUserResponse.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } - return householdUserResponse; } + // list public static Response> list(String ks, @Nullable HouseholdUserFilter householdUserFilter) { ListHouseholdUserBuilder listHouseholdUserBuilder = HouseholdUserService.list(householdUserFilter) .setCompletion((ApiCompletion>) result -> { @@ -56,10 +53,6 @@ public static Response> list(String ks, @Nullable Ho await().untilTrue(done); done.set(false); - if (householdUserListResponse.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } - return householdUserListResponse; } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index b7c1803bb..d4b19326e 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -13,18 +13,12 @@ import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.tests.BaseTest.client; -import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; -import static org.hamcrest.MatcherAssert.assertThat; public class OttUserServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static final String LOGIN_RESPONSE_SCHEMA = "schemas/KalturaLoginResponse_Schema.json"; - private static final String LOGIN_SESSION_SCHEMA = "schemas/KalturaLoginSession_Schema.json"; - private static final String OTT_USER_SCHEMA = "schemas/KalturaOttUser_Schema.json"; - private static Response loginResponse; private static Response ottUserResponse; private static Response loginSessionResponse; @@ -46,10 +40,6 @@ public static Response activate(int partnerId, String username, String await().untilTrue(done); done.set(false); - if (ottUserResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); - } - return ottUserResponse; } @@ -83,10 +73,6 @@ public static Response anonymousLogin(int partnerId, @Nullable Str await().untilTrue(done); done.set(false); - if (loginSessionResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_SESSION_SCHEMA)); - } - return loginSessionResponse; } @@ -123,10 +109,6 @@ public static Response get(String ks, Optional userId) { await().untilTrue(done); done.set(false); - if (ottUserResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); - } - return ottUserResponse; } @@ -145,11 +127,6 @@ public static Response getEncryptedUserId(String ks, int userId) { await().untilTrue(done); done.set(false); - if (stringValueResponse.isSuccess()) { - // TODO: 4/1/2018 add schema assertion -// assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(stringValueResponse)); - } - return stringValueResponse; } @@ -166,10 +143,6 @@ public static Response> list(String ks, @Nullable OTTUserF await().untilTrue(done); done.set(false); - if (ottUserListResponse.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } - return ottUserListResponse; } @@ -185,10 +158,6 @@ public static Response login(int partnerId, String username, Stri await().untilTrue(done); done.set(false); - if (loginResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); - } - return loginResponse; } @@ -205,10 +174,6 @@ public static Response loginWithPin(int partnerId, String pin, @N await().untilTrue(done); done.set(false); - if (loginResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LOGIN_RESPONSE_SCHEMA)); - } - return loginResponse; } @@ -242,10 +207,6 @@ public static Response register(int partnerId, OTTUser user, String pas await().untilTrue(done); done.set(false); - if (ottUserResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); - } - return ottUserResponse; } @@ -292,10 +253,6 @@ public static Response setInitialPassword(int partnerId, String token, await().untilTrue(done); done.set(false); - if (ottUserResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); - } - return ottUserResponse; } @@ -313,10 +270,6 @@ public static Response update(String ks, OTTUser user, @Nullable String await().untilTrue(done); done.set(false); - if (ottUserResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(OTT_USER_SCHEMA)); - } - return ottUserResponse; } @@ -335,10 +288,6 @@ public static Response updateDynamicData(String ks, Optional await().untilTrue(done); done.set(false); - if (ottUserDynamicDataResponse.isSuccess()) { - // TODO: 4/1/2018 add schema assertion - } - return ottUserDynamicDataResponse; } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java index cd8e0ac22..51c30949c 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java @@ -2,26 +2,26 @@ import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.ProductPrice; +import com.kaltura.client.types.ProductPriceFilter; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; + import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; -import static com.kaltura.client.services.ProductPriceService.*; + +import static com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import static com.kaltura.client.test.tests.BaseTest.client; -import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; -import static org.hamcrest.MatcherAssert.assertThat; public class ProductPriceServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static final String LIST_RESPONSE_SCHEMA = "schemas/KalturaProductPriceListResponse_Schema.json"; - private static Response> productPriceResponse; - //list + // list public static Response> list(String ks, ProductPriceFilter filter, Optional currency) { ListProductPriceBuilder productPriceBuilder = ProductPriceService.list(filter) .setCompletion((ApiCompletion>) result -> { @@ -33,10 +33,6 @@ public static Response> list(String ks, ProductPriceF await().untilTrue(done); done.set(false); - if (productPriceResponse.isSuccess()) { - assertThat(TestAPIOkRequestsExecutor.fullResponseAsString, matchesJsonSchemaInClasspath(LIST_RESPONSE_SCHEMA)); - } - return productPriceResponse; } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java index 5769e442f..34a80559d 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java @@ -36,10 +36,6 @@ public static Response add(String ks, int userId, @Nullable String await().untilTrue(done); done.set(false); - if (userLoginPinResponse.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } - return userLoginPinResponse; } @@ -94,10 +90,6 @@ public static Response update(String ks, int userId, String secret await().untilTrue(done); done.set(false); - if (userLoginPinResponse.isSuccess()) { - // TODO: 3/22/2018 fix schema assertions - } - return userLoginPinResponse; } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java index 0b83695c7..0867255b0 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java @@ -34,10 +34,6 @@ public static Response> list(String ks, @Nullable UserRol await().untilTrue(done); done.set(false); - if (userRoleListResponse.isSuccess()) { - // TODO: 3/27/2018 fix schema assertions - } - return userRoleListResponse; } } diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index 350e81d34..a2e6a16cc 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -6,11 +6,11 @@ import static io.restassured.RestAssured.given; -public class Sandbox extends BaseTest { +public class Sandbox { String myEnvelope = "QABE - Regular-mainQABE - Regular-mainMovie_180328093854266description of 18032809385426627/03/2018 09:38:5427/03/2018 09:38:5414/10/2099 17:00:0014/10/2099 17:00:00MoviePhilippines OnlyParent Allowedsyno pino sistermeta_value190023/03/2017 12:34:56Costa Rica;IsraelGIHABCDEFShay_SeriesKSQL channel_573349]]>"; - @Test + @Test(enabled = false) private void test() { RestAssured.baseURI = "http://34.249.122.223:8030/Ingest_v4_8/Service.svc?wsdl"; @@ -28,4 +28,5 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java index d76adc04c..8ae9ac985 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -59,7 +59,7 @@ private void loginWithPin_with_wrong_secret() { } @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") - @Test + @Test(enabled = true) private void loginWithPin_with_expired_pinCode() { userLoginPinResponse = UserLoginPinServiceImpl.add(administratorKs, Integer.parseInt(user.getId()), SECRET); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java index d33f03493..713a3c99f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -27,7 +27,7 @@ private void ottUser_resendActivationToken_tests_setup() { } @Description("ottUser/action/resendActivationToken - resendActivationToken") - @Test(enabled = true) + @Test(enabled = false) private void resendActivationToken() { Response booleanResponse = OttUserServiceImpl.resendActivationToken(PARTNER_ID, user.getUsername()); assertThat(booleanResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index 86497d3c1..8dff34235 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; @@ -18,20 +17,16 @@ public class UpdateLoginDataTests extends BaseTest { - private OTTUser user; private String password = GLOBAL_USER_PASSWORD; - private Response booleanResponse; - - @BeforeClass - private void ottUser_updateLoginData_tests_setup() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); - user = ottUserResponse.results; - } + private Response ottUserResponse; @Description("ottUser/action/updateLoginData - updateLoginData") @Test private void updateLoginData() { + ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + OTTUser user = ottUserResponse.results; + Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); String ks = loginResponse.results.getLoginSession().getKs(); @@ -54,6 +49,9 @@ private void updateLoginData() { @Description("ottUser/action/updateLoginData - updateLoginData with administratorKs") @Test private void updateLoginData_with_administratorKs() { + ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + OTTUser user = ottUserResponse.results; + booleanResponse = OttUserServiceImpl.updateLoginData(administratorKs, user.getUsername(), password, password + 1); assertThat(booleanResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index cc4133210..d72532dac 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -62,7 +62,7 @@ private void update() { } @Description("ottUser/action/update - update with administratorKs") - @Test + @Test(enabled = false) // TODO: 4/2/2018 bug BEO-4919 private void update_with_administratorKs() { // update diff --git a/src/test/resources/schemas/KalturaBillingTransaction_Schema.json b/src/test/resources/schemas/BillingTransaction.json similarity index 91% rename from src/test/resources/schemas/KalturaBillingTransaction_Schema.json rename to src/test/resources/schemas/BillingTransaction.json index 58c3ed826..6eed2e2db 100644 --- a/src/test/resources/schemas/KalturaBillingTransaction_Schema.json +++ b/src/test/resources/schemas/BillingTransaction.json @@ -1,7 +1,7 @@ { - "$id": "KalturaBillingTransaction", + "$id": "BillingTransaction", "definitions": { - "KalturaBillingTransaction": { + "BillingTransaction": { "type": "object", "properties": { "userId": { @@ -31,7 +31,7 @@ "minLength": 1 }, "price": { - "$ref": "KalturaPrice_Schema.json#/definitions/KalturaPrice" + "$ref": "Price.json#/definitions/Price" }, "actionDate": { "type": "integer", @@ -100,5 +100,5 @@ ] } }, - "$ref": "#/definitions/KalturaBillingTransaction" + "$ref": "#/definitions/BillingTransaction" } \ No newline at end of file diff --git a/src/test/resources/schemas/Boolean.json b/src/test/resources/schemas/Boolean.json new file mode 100644 index 000000000..46f936b44 --- /dev/null +++ b/src/test/resources/schemas/Boolean.json @@ -0,0 +1,9 @@ +{ + "$id": "Boolean.json", + "type": "object", + "properties": { + "result": {"type": "boolean", "enum": [true]}, + "executionTime": {"type": "number", "minimum": 0} + }, + "required": ["result", "executionTime"] +} \ No newline at end of file diff --git a/src/test/resources/schemas/KalturaHousehold_Schema.json b/src/test/resources/schemas/Household.json similarity index 100% rename from src/test/resources/schemas/KalturaHousehold_Schema.json rename to src/test/resources/schemas/Household.json diff --git a/src/test/resources/schemas/KalturaHouseholdDevice_Schema.json b/src/test/resources/schemas/HouseholdDevice.json similarity index 100% rename from src/test/resources/schemas/KalturaHouseholdDevice_Schema.json rename to src/test/resources/schemas/HouseholdDevice.json diff --git a/src/test/resources/schemas/KalturaHouseholdUser_Schema.json b/src/test/resources/schemas/HouseholdUser.json similarity index 75% rename from src/test/resources/schemas/KalturaHouseholdUser_Schema.json rename to src/test/resources/schemas/HouseholdUser.json index d0a71cc73..f08a44fa3 100644 --- a/src/test/resources/schemas/KalturaHouseholdUser_Schema.json +++ b/src/test/resources/schemas/HouseholdUser.json @@ -1,8 +1,7 @@ { - "$id": "KalturaHouseholdUser", - "type": "object", - "properties": { - "result": { + "$id": "HouseholdUser", + "definitions": { + "HouseholdUser": { "type": "object", "properties": { "householdId": { @@ -28,16 +27,10 @@ "required": [ "householdId", "userId", - "isMaster", "status", "objectType" ] - }, - "executionTime": { - "type": "number" } }, - "required": [ - "result" - ] + "ref": "#/definitions/HouseholdUser" } \ No newline at end of file diff --git a/src/test/resources/schemas/KalturaBillingTransactionListResponse_Schema.json b/src/test/resources/schemas/ListResponse_BillingTransaction.json similarity index 79% rename from src/test/resources/schemas/KalturaBillingTransactionListResponse_Schema.json rename to src/test/resources/schemas/ListResponse_BillingTransaction.json index 92fcfdd77..8750b898e 100644 --- a/src/test/resources/schemas/KalturaBillingTransactionListResponse_Schema.json +++ b/src/test/resources/schemas/ListResponse_BillingTransaction.json @@ -1,5 +1,5 @@ { - "$id": "KalturaBillingTransactionListResponse", + "$id": "ListResponse_BillingTransaction", "type": "object", "properties": { "result": { @@ -8,7 +8,7 @@ "objects": { "type": "array", "items": { - "$ref": "KalturaBillingTransaction_Schema.json#/definitions/KalturaBillingTransaction" + "$ref": "BillingTransaction.json#/definitions/BillingTransaction" } }, "totalCount": { diff --git a/src/test/resources/schemas/KalturaEntitlementListResponse_Schema.json b/src/test/resources/schemas/ListResponse_Entitlement.json similarity index 100% rename from src/test/resources/schemas/KalturaEntitlementListResponse_Schema.json rename to src/test/resources/schemas/ListResponse_Entitlement.json diff --git a/src/test/resources/schemas/ListResponse_HouseholdUser.json b/src/test/resources/schemas/ListResponse_HouseholdUser.json new file mode 100644 index 000000000..5204f0587 --- /dev/null +++ b/src/test/resources/schemas/ListResponse_HouseholdUser.json @@ -0,0 +1,35 @@ +{ + "$id": "ListResponse_HouseholdUser", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "$ref": "HouseholdUser.json#/definitions/HouseholdUser" + } + }, + "totalCount": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaHouseholdUserListResponse" + ] + } + }, + "required": [ + "objects", + "totalCount", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse_OTTUser.json b/src/test/resources/schemas/ListResponse_OTTUser.json new file mode 100644 index 000000000..a20290e7b --- /dev/null +++ b/src/test/resources/schemas/ListResponse_OTTUser.json @@ -0,0 +1,35 @@ +{ + "$id": "ListResponse_OTTUser", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "$ref": "OTTUser.json#/definitions/OTTUser" + } + }, + "totalCount": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaOTTUserListResponse" + ] + } + }, + "required": [ + "objects", + "totalCount", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/KalturaProductPriceListResponse_Schema.json b/src/test/resources/schemas/ListResponse_ProductPrice.json similarity index 100% rename from src/test/resources/schemas/KalturaProductPriceListResponse_Schema.json rename to src/test/resources/schemas/ListResponse_ProductPrice.json diff --git a/src/test/resources/schemas/KalturaLoginResponse_Schema.json b/src/test/resources/schemas/LoginResponse.json similarity index 65% rename from src/test/resources/schemas/KalturaLoginResponse_Schema.json rename to src/test/resources/schemas/LoginResponse.json index 8feb1ef5e..833f8402f 100644 --- a/src/test/resources/schemas/KalturaLoginResponse_Schema.json +++ b/src/test/resources/schemas/LoginResponse.json @@ -1,13 +1,13 @@ { - "$id": "KalturaLoginResponse", + "$id": "LoginResponse", "type": "object", "properties": { "result": { "type": "object", "properties": { - "user": {"$ref": "KalturaOttUser_Schema.json#/definitions/KalturaOTTUser"}, + "user": {"$ref": "OttUser.json#/definitions/OTTUser"}, "loginSession": { - "$ref": "KalturaLoginSession_Schema.json#/definitions/KalturaLoginSession" + "$ref": "LoginSession.json#/definitions/LoginSession" }, "objectType": {"type": "string", "enum": ["KalturaLoginResponse"]} }, diff --git a/src/test/resources/schemas/KalturaLoginSession_Schema.json b/src/test/resources/schemas/LoginSession.json similarity index 78% rename from src/test/resources/schemas/KalturaLoginSession_Schema.json rename to src/test/resources/schemas/LoginSession.json index ece8ab0ee..52f87bde9 100644 --- a/src/test/resources/schemas/KalturaLoginSession_Schema.json +++ b/src/test/resources/schemas/LoginSession.json @@ -1,7 +1,7 @@ { - "$id": "KalturaLoginSession", + "$id": "LoginSession", "definitions": { - "KalturaLoginSession": { + "LoginSession": { "type": "object", "properties": { "ks": {"type": "string", "minLength": 10}, @@ -13,7 +13,7 @@ "type": "object", "properties": { "result": { - "$ref": "#/definitions/KalturaLoginSession" + "$ref": "#/definitions/LoginSession" } }, "executionTime": {"type": "number"}, diff --git a/src/test/resources/schemas/KalturaMediaAsset_Schema.json b/src/test/resources/schemas/MediaAsset.json similarity index 100% rename from src/test/resources/schemas/KalturaMediaAsset_Schema.json rename to src/test/resources/schemas/MediaAsset.json diff --git a/src/test/resources/schemas/KalturaMultilingualStringValueArray_Schema.json b/src/test/resources/schemas/MultilingualStringValueArray.json similarity index 100% rename from src/test/resources/schemas/KalturaMultilingualStringValueArray_Schema.json rename to src/test/resources/schemas/MultilingualStringValueArray.json diff --git a/src/test/resources/schemas/KalturaOttUser_Schema.json b/src/test/resources/schemas/OTTUser.json similarity index 95% rename from src/test/resources/schemas/KalturaOttUser_Schema.json rename to src/test/resources/schemas/OTTUser.json index 36f2b89d2..41ea9045d 100644 --- a/src/test/resources/schemas/KalturaOttUser_Schema.json +++ b/src/test/resources/schemas/OTTUser.json @@ -1,7 +1,7 @@ { - "$id": "KalturaOTTUser", + "$id": "OTTUser", "definitions": { - "KalturaOTTUser": { + "OTTUser": { "type": "object", "properties": { "householdId": {"type": "integer", "minimum": 0}, @@ -43,7 +43,7 @@ "type": "object", "properties": { "result": { - "$ref": "#/definitions/KalturaOTTUser" + "$ref": "#/definitions/OTTUser" }, "executionTime": {"type": "number"} }, diff --git a/src/test/resources/schemas/OTTUserDynamicData.json b/src/test/resources/schemas/OTTUserDynamicData.json new file mode 100644 index 000000000..732486093 --- /dev/null +++ b/src/test/resources/schemas/OTTUserDynamicData.json @@ -0,0 +1,40 @@ +{ + "$id": "OTTUserDynamicData", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "userId": { + "type": "string", + "minLength": 0 + }, + "key": { + "type": "string", + "minLength": 0 + }, + "value": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/KalturaPpvEntitlement_Schema.json b/src/test/resources/schemas/PpvEntitlement.json similarity index 100% rename from src/test/resources/schemas/KalturaPpvEntitlement_Schema.json rename to src/test/resources/schemas/PpvEntitlement.json diff --git a/src/test/resources/schemas/KalturaPpvPrice_Schema.json b/src/test/resources/schemas/PpvPrice.json similarity index 100% rename from src/test/resources/schemas/KalturaPpvPrice_Schema.json rename to src/test/resources/schemas/PpvPrice.json diff --git a/src/test/resources/schemas/KalturaPrice_Schema.json b/src/test/resources/schemas/Price.json similarity index 100% rename from src/test/resources/schemas/KalturaPrice_Schema.json rename to src/test/resources/schemas/Price.json diff --git a/src/test/resources/schemas/StringValue.json b/src/test/resources/schemas/StringValue.json new file mode 100644 index 000000000..e7132a381 --- /dev/null +++ b/src/test/resources/schemas/StringValue.json @@ -0,0 +1,27 @@ +{ + "$id": "StringValue", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "value", + "objectType" + ] + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/KalturaSubscriptionEntitlement_Schema.json b/src/test/resources/schemas/SubscriptionEntitlement.json similarity index 100% rename from src/test/resources/schemas/KalturaSubscriptionEntitlement_Schema.json rename to src/test/resources/schemas/SubscriptionEntitlement.json diff --git a/src/test/resources/schemas/KalturaSubscriptionPrice_Schema.json b/src/test/resources/schemas/SubscriptionPrice.json similarity index 100% rename from src/test/resources/schemas/KalturaSubscriptionPrice_Schema.json rename to src/test/resources/schemas/SubscriptionPrice.json diff --git a/src/test/resources/schemas/KalturaTransaction_Schema.json b/src/test/resources/schemas/Transaction.json similarity index 100% rename from src/test/resources/schemas/KalturaTransaction_Schema.json rename to src/test/resources/schemas/Transaction.json diff --git a/src/test/resources/schemas/UserLoginPin.json b/src/test/resources/schemas/UserLoginPin.json new file mode 100644 index 000000000..59eb9d867 --- /dev/null +++ b/src/test/resources/schemas/UserLoginPin.json @@ -0,0 +1,37 @@ +{ + "$id": "UserLoginPin", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "pinCode": { + "type": "string", + "minLength": 0 + }, + "expirationTime": { + "type": "integer", + "minimum": 0 + }, + "userId": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "pinCode", + "expirationTime", + "userId", + "objectType" + ] + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From e891f92449c1883461b8522349c1b135a9897a99 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 3 Apr 2018 09:06:22 +0300 Subject: [PATCH 029/605] Added test case listWithoutRequiredFieldsTest() --- .../servicesImpl/ProductPriceServiceImpl.java | 4 ++++ .../productPriceTests/ListTests.java | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java index 51c30949c..9be366ea1 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java @@ -23,6 +23,10 @@ public class ProductPriceServiceImpl { // list public static Response> list(String ks, ProductPriceFilter filter, Optional currency) { + client.setKs(ks); + if (currency.isPresent()) { + client.setCurrency(currency.get()); + } ListProductPriceBuilder productPriceBuilder = ProductPriceService.list(filter) .setCompletion((ApiCompletion>) result -> { productPriceResponse = result; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 53fe6d1a0..40dc86d50 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -3,16 +3,14 @@ import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.IngestPPVUtils; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.Ppv; -import com.kaltura.client.types.ProductPrice; -import com.kaltura.client.types.ProductPriceFilter; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.Test; import java.util.Optional; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class ListTests extends BaseTest { @@ -30,4 +28,16 @@ public void listSubscriptionTest() { assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.FOR_PURCHASE); assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount() > 0); } + + @Description("productPrice/action/list - without required fields (subscriptionIdIn, collectionIdIn and fileIdIn are empty)") + @Test() + public void listWithoutRequiredFieldsTest() { + ProductPriceFilter filter = new ProductPriceFilter(); + Response> productPriceResponse = list(operatorKs, filter, Optional.empty()); + // TODO: should we create enums for error codes and their messages? A: Yes if library doesn't contain them + assertThat(productPriceResponse.results).isNull(); + assertThat(productPriceResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500056).getCode()); + assertThat(productPriceResponse.error.getMessage()).isEqualToIgnoringCase( + "One of the arguments [KalturaProductPriceFilter.subscriptionIdIn, KalturaProductPriceFilter.fileIdIn, KalturaProductPriceFilter.collectionIdIn] must have a value"); + } } From baa58ec34e2cb823682413ebd3b13c7340574ea1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 3 Apr 2018 14:03:59 +0300 Subject: [PATCH 030/605] no message --- .../client/test/servicesImpl/ProductPriceServiceImpl.java | 1 + .../com/kaltura/client/test/utils/IngestPPVUtils.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java index 51c30949c..162e3f22a 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java @@ -29,6 +29,7 @@ public static Response> list(String ks, ProductPriceF done.set(true); }); + // TODO: 4/2/2018 ask Max for what Optional currency TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 95da2c834..4cdcf7e18 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -19,8 +19,9 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; HashMap headermap = new HashMap<>(); headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestBusinessModules\""); - String reqBody = "\n" + + headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + + String reqBody = "\n" + " \n" + " \n" + " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + @@ -29,11 +30,13 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, " ]]>\n" + " \n" + ""; + Response resp = RestAssured.given() .log().all() .headers(headermap) .body(reqBody) .post(url); + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); System.out.println("ReportId = " + reportId); @@ -41,6 +44,7 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, resp = RestAssured.given() .log().all() .get(url); + System.out.println(resp.asString()); System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); From 47650c24518cde0e1a7dac11576d6cd76a588052 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 3 Apr 2018 14:34:16 +0300 Subject: [PATCH 031/605] Added draft for test case ppvTest() --- .../test/servicesImpl/AssetServiceImpl.java | 37 ++++++++++++ .../servicesImpl/EntitlementServiceImpl.java | 40 +++++++++++++ .../servicesImpl/TransactionServiceImpl.java | 37 ++++++++++++ .../productPriceTests/ListTests.java | 57 ++++++++++++++++++- .../client/test/utils/PurchaseUtils.java | 56 ++++++++++++++++++ 5 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java new file mode 100644 index 000000000..353f0a505 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; +import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.AssetService.GetAssetBuilder; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class AssetServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response assetResponse; + + // list + public static Response getAsset(String ks, String id, AssetReferenceType assetReferenceType) { + client.setKs(ks); + GetAssetBuilder assetBuilder = AssetService.get(id, assetReferenceType) + .setCompletion((ApiCompletion) result -> { + assetResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(assetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetResponse; + } +} + + diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java new file mode 100644 index 000000000..39c91be8c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java @@ -0,0 +1,40 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class EntitlementServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> entitlementResponse; + + // list + public static Response> list(String ks, EntitlementFilter filter, Optional pager) { + client.setKs(ks); + if (pager.isPresent()) { + // TODO: find how to work with pager + } + ListEntitlementBuilder productPriceBuilder = EntitlementService.list(filter) + .setCompletion((ApiCompletion>) result -> { + entitlementResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return entitlementResponse; + } +} + + diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java new file mode 100644 index 000000000..24c907947 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.services.TransactionService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Purchase; +import com.kaltura.client.types.Transaction; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; +import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class TransactionServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response purchaseResponse; + + // list + public static Response purchase(String ks, Purchase purchase) { + client.setKs(ks); + PurchaseTransactionBuilder purchaseBuilder = TransactionService.purchase(purchase) + .setCompletion((ApiCompletion) result -> { + purchaseResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(purchaseBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return purchaseResponse; + } +} + + diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 40dc86d50..a11b8ed35 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -1,11 +1,17 @@ package com.kaltura.client.test.tests.servicesTests.productPriceTests; -import com.kaltura.client.enums.PurchaseStatus; +import com.kaltura.client.enums.*; +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.ProductPriceService; +import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; +import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.IngestPPVUtils; +import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.Optional; import static com.kaltura.client.test.Properties.*; @@ -15,6 +21,17 @@ public class ListTests extends BaseTest { + private EntitlementFilter entitlementPpvsFilter; + + @BeforeClass + public void beforeClass() { + entitlementPpvsFilter = new EntitlementFilter(); + entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); + entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); + entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + entitlementPpvsFilter.setIsExpiredEqual(false); + } + @Description("productPrice/action/list - subscription test by Operator without currency") @Test(enabled = false) // as used in feature tests public void listSubscriptionTest() { @@ -40,4 +57,42 @@ public void listWithoutRequiredFieldsTest() { assertThat(productPriceResponse.error.getMessage()).isEqualToIgnoringCase( "One of the arguments [KalturaProductPriceFilter.subscriptionIdIn, KalturaProductPriceFilter.fileIdIn, KalturaProductPriceFilter.collectionIdIn] must have a value"); } + + @Description("productPrice/action/list - ppv test") + @Test(enabled = false) // as requires ingest VOD + public void ppvTest() { + Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, Optional.empty()); + assertThat(entitlementListBeforePurchase.results.getTotalCount() == 0); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + // TODO: needed ingest VOD ppFilter.setFileIdIn(String.valueOf(shared_vod_web_file_id)); + ppFilter.setIsLowest(false); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); + assertThat(productPriceListBeforePurchase.results.getTotalCount() == 1); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType() == TransactionType.PPV); + // TODO: needed ingest VOD assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId() == shared_vod_web_file_id); + + // TODO: needed ingest VOD PurchaseUtils.purchasePpv(sharedMasterUserKs, Optional.empty(), Optional.of(shared_vod_web_file_id), Optional.empty()); + + Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, Optional.empty()); + assertThat(entitlementListAfterPurchase.results.getTotalCount() == 1); + // TODO: needed ingest VOD assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId() == shared_vod_web_file_id); + // TODO: needed ingest VOD assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId() == media_id_2); + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate() > + entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod().equals(PaymentMethodType.OFFLINE) || + entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod().equals(PaymentMethodType.UNKNOWN)); + + Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); + assertThat(productPriceListAfterPurchase.results.getTotalCount() == 1); + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.PPV_PURCHASED); + // TODO: needed ingest VOD assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId() == shared_vod_web_file_id); + + // TODO: needed ingest VOD ppFilter.setFileIdIn(String.valueOf(shared_vod_mobile_file_id)); + Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount() == 1); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.PPV_PURCHASED); + // TODO: needed ingest VOD assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId() == shared_vod_mobile_file_id); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java new file mode 100644 index 000000000..bf6a2531c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -0,0 +1,56 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.enums.ProductPriceOrderBy; +import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; +import com.kaltura.client.test.servicesImpl.TransactionServiceImpl; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public class PurchaseUtils { + + public static Map purchasePpvDetailsMap; + + // TODO: 14/MAR/2018 add return + public static void purchasePpv(String ks, Optional mediaId, Optional fileId, Optional inCurrency) { + purchasePpvDetailsMap = new HashMap<>(); + int paymentGatewayId = 0; + + int internalFileId =-1; + if (fileId.isPresent()) { + internalFileId = fileId.get(); + } else { + Response mediaAsset = AssetServiceImpl.getAsset(ks, String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); + internalFileId = mediaAsset.results.getMediaFiles().get(0).getId(); + } + + ProductPriceFilter filter = new ProductPriceFilter(); + filter.setOrderBy(ProductPriceOrderBy.PRODUCT_ID_ASC.getValue()); + filter.setFileIdIn(String.valueOf(internalFileId)); + filter.setIsLowest(false); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(ks, filter, inCurrency); + String currency = inCurrency.isPresent() ? inCurrency.get() : productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getCurrency(); + double price = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getAmount(); + String ppvModuleId = ((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getPpvModuleId(); + + Purchase purchase = new Purchase(); + purchase.setProductId(Integer.valueOf(ppvModuleId)); + purchase.setContentId(internalFileId); + purchase.setCurrency(currency); + purchase.setPrice(price); + purchase.setProductType(Optional.of(TransactionType.PPV).get()); + purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); + TransactionServiceImpl.purchase(ks, purchase); + + // TODO: complete the purchase ppv test + purchasePpvDetailsMap.put("price", String.valueOf(price)); + purchasePpvDetailsMap.put("currency", currency); + purchasePpvDetailsMap.put("ppvModuleId", ppvModuleId); + purchasePpvDetailsMap.put("fileId", String.valueOf(internalFileId)); + } +} From 30e46a8ba1559f09de8b3854261fae895a1922e4 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 3 Apr 2018 15:42:58 +0300 Subject: [PATCH 032/605] Completed method IngestPPVUtils.ingestPPV() --- .../productPriceTests/ListTests.java | 6 +-- .../client/test/utils/IngestPPVUtils.java | 41 +++++++++++-------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index a11b8ed35..bda064599 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -36,9 +36,6 @@ public void beforeClass() { @Test(enabled = false) // as used in feature tests public void listSubscriptionTest() { ProductPriceFilter filter = new ProductPriceFilter(); - Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), - Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, - getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE)); // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); Response> productPriceList = list(operatorKs, filter, Optional.empty()); // TODO: fix! assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(five_min_renewable_subscription_id); @@ -61,6 +58,9 @@ public void listWithoutRequiredFieldsTest() { @Description("productPrice/action/list - ppv test") @Test(enabled = false) // as requires ingest VOD public void ppvTest() { + /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), + Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, + getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, Optional.empty()); assertThat(entitlementListBeforePurchase.results.getTotalCount() == 0); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 95da2c834..7e9249a65 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -3,7 +3,9 @@ import com.kaltura.client.types.*; import io.restassured.RestAssured; import io.restassured.response.Response; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import static com.kaltura.client.test.Properties.*; import static io.restassured.path.xml.XmlPath.from; @@ -41,26 +43,31 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, resp = RestAssured.given() .log().all() .get(url); - System.out.println(resp.asString()); - System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + //System.out.println(resp.asString()); + //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); - // TODO: complete it Ppv ppv = new Ppv(); - //ppv.setDescriptions(); - /*PriceDetails priceDetails = new PriceDetails(); - Price price1 = new Price(); - price1.setAmount(price); - price1.setCurrency(currency); - priceDetails.setPrice(price1); - ppv.setPrice(priceDetails);*/ - /*UsageModule usageModule1 = new UsageModule(); - usageModule1.setName(usageModule); - ppv.setUsageModule(usageModule1);*/ - //ppv.setIsSubscriptionOnly(isSubscriptionOnly); - //ppv.setFirstDeviceLimitation(isFirstDeviceLimitation); - //ppv.setProductCode(productCode); + ppv.setId(id); + List descriptions = new ArrayList<>(); + TranslationToken translationToken = new TranslationToken(); + translationToken.setValue(description); + descriptions.add(translationToken); + ppv.setDescriptions(descriptions); + PriceDetails priceDetails = new PriceDetails(); + Price priceObj = new Price(); + priceObj.setAmount(price); + priceObj.setCurrency(currency); + priceDetails.setPrice(priceObj); + ppv.setPrice(priceDetails); + UsageModule usageModuleObj = new UsageModule(); + usageModuleObj.setName(usageModule); + ppv.setUsageModule(usageModuleObj); + ppv.setIsSubscriptionOnly(isSubscriptionOnly); + ppv.setFirstDeviceLimitation(isFirstDeviceLimitation); + ppv.setProductCode(productCode); - return null; + return ppv; } private static String buildIngestPpvXML(String action, String ppvCode, boolean isActive, String description, String discount, From df138e6da3e1c62905d178a123a944f4e3d1987a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 4 Apr 2018 13:33:40 +0300 Subject: [PATCH 033/605] Added method ingestPPVWithDefaultValues() --- .../client/test/utils/IngestPPVUtils.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 7e9249a65..920fa9ad0 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -6,11 +6,37 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Optional; import static com.kaltura.client.test.Properties.*; import static io.restassured.path.xml.XmlPath.from; public class IngestPPVUtils extends BaseUtils { + + // way to ingest PPV using predefined default values for any of input parameters + public static Ppv ingestPPVWithDefaultValues(Optional action, Optional isActive, Optional description, + Optional discount, Optional price, Optional currency, + Optional usageModule, Optional isSubscriptionOnly, + Optional isFirstDeviceLimitation, Optional productCode, + Optional firstFileType, Optional secondFileType) { + String actionValue = action.isPresent() ? action.get() : "insert"; + boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; + String descriptionValue = description.isPresent() ? description.get() : "My ingest PPV"; + String discountValue = discount.isPresent() ? discount.get() : getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME); + double priceValue = price.isPresent() ? price.get() : Double.valueOf(getProperty(AMOUNT_4_99_EUR)); + String currencyValue = currency.isPresent() ? currency.get() : getProperty(CURRENCY_EUR); + String usageModuleValue = usageModule.isPresent() ? usageModule.get() : getProperty(ONE_DAY_USAGE_MODULE); + boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; + boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; + String productCodeValue = productCode.isPresent() ? productCode.get() : getProperty(DEFAULT_PRODUCT_CODE); + String firstFileTypeValue = firstFileType.isPresent() ? firstFileType.get() : getProperty(WEB_FILE_TYPE); + String secondFileTypeValue = secondFileType.isPresent() ? secondFileType.get() : getProperty(MOBILE_FILE_TYPE); + + return ingestPPV(actionValue, isActiveValue, descriptionValue, discountValue, priceValue, currencyValue, + usageModuleValue, isSubscriptionOnlyValue, isFirstDeviceLimitationValue, productCodeValue, + firstFileTypeValue, secondFileTypeValue); + } + // ingest new PPV public static Ppv ingestPPV(String action, boolean isActive, String description, String discount, double price, String currency, String usageModule, boolean isSubscriptionOnly, From b85e6905cc3cf741965010ac832c17ddb137f327 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 5 Apr 2018 15:06:31 +0300 Subject: [PATCH 034/605] Added util for ingest VOD --- .../com/kaltura/client/test/Properties.java | 7 + .../productPriceTests/ListTests.java | 6 + .../kaltura/client/test/utils/BaseUtils.java | 19 ++- .../client/test/utils/IngestPPVUtils.java | 2 +- .../client/test/utils/IngestVODUtils.java | 153 +++++++++++++++++- 5 files changed, 179 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 776aa73ae..5557ef51a 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -34,6 +34,11 @@ public class Properties { public static final String GLOBAL_USER_PASSWORD = "password"; + // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts + public static final String MOVIE_MEDIA_TYPE = "Movie"; + public static final String EPISODE_MEDIA_TYPE = "Episode"; + public static final String LINEAR_MEDIA_TYPE = "Linear"; + // file types public static final String WEB_FILE_TYPE = "web_file_type"; public static final String MOBILE_FILE_TYPE = "mobile_file_type"; @@ -44,6 +49,8 @@ public class Properties { public static final String INGEST_ACTION_INSERT = "insert"; + public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + // price codes public static final String AMOUNT_4_99_EUR = "amount_4_99_eur"; // 4.99 public static final String CURRENCY_EUR = "EUR"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index bda064599..7e936997a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -7,6 +7,7 @@ import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.IngestPPVUtils; +import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -30,6 +31,11 @@ public void beforeClass() { entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); entitlementPpvsFilter.setIsExpiredEqual(false); + + MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + System.out.println("INGESTED VOD: " + mediaAsset.getId()); } @Description("productPrice/action/list - subscription test by Operator without currency") diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index c380e4b22..dd7aa743d 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -6,13 +6,15 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.net.URL; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; @@ -24,6 +26,21 @@ public class BaseUtils { private static final String API_SCHEMA_URL = "https://api-preprod.ott.kaltura.com/" + API_URL_VERSION + "/clientlibs/KalturaClient.xml"; private static List exceptions; + // to get e.g. yesterday date in specific date format need call the method so: getOffsetDateInFormat(-1, pattern); + public static String getOffsetDateInFormat(int offsetDay, String pattern) { + DateFormat dateFormat = new SimpleDateFormat(pattern); + Calendar cal = Calendar.getInstance(); + if (offsetDay != 0) { + cal.add(Calendar.DATE, offsetDay); + } + return dateFormat.format(cal.getTime()); + } + + // generate current data String in specified format + public static String getCurrentDataInFormat(String pattern) { + return getOffsetDateInFormat(0, pattern); + } + // generate string containing prefix and random long suffix public static String getRandomValue(String prefix, long maxValue) { long randomLongValue = ThreadLocalRandom.current().nextLong(maxValue); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 920fa9ad0..0f71f5ace 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -63,7 +63,7 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, .body(reqBody) .post(url); String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - System.out.println("ReportId = " + reportId); + //System.out.println("ReportId = " + reportId); url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; resp = RestAssured.given() diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index d3541eef5..99ce08ead 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -1,16 +1,157 @@ package com.kaltura.client.test.utils; import com.kaltura.client.types.MediaAsset; +import io.restassured.RestAssured; +import io.restassured.response.Response; +import java.util.HashMap; +import java.util.Optional; +import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.Properties.INGEST_USER_PASSWORD; +import static com.kaltura.client.test.Properties.getProperty; +import static io.restassured.path.xml.XmlPath.from; public class IngestVODUtils extends BaseUtils { - // ingest new VOD (Media) - public static MediaAsset ingestVOD() { - String mediaNamePrefix = "Media"; - String mediaType = "Media" ; + // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project + public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, + Optional thumbUrl, Optional description, Optional catalogStartDate, + Optional catalogEndDate, Optional startDate, Optional endDate, + Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { + String coguidValue = coguid.isPresent() ? coguid.get() : getCurrentDataInFormat("yyMMddHHmmssSS"); + String nameValue = name.isPresent() ? name.get() : MOVIE_MEDIA_TYPE + "_" + coguidValue; + String thumbUrlValue = thumbUrl.isPresent() ? thumbUrl.get() : INGEST_VOD_DEFAULT_THUMB; + String descriptionValue = description.isPresent() ? description.get() : "description of " + coguidValue; + String catalogStartDateValue = catalogStartDate.isPresent() ? catalogStartDate.get() : getOffsetDateInFormat( -1, "dd/MM/yyyy hh:mm:ss"); + String catalogEndDateValue = catalogEndDate.isPresent() ? catalogEndDate.get() : "14/10/2099 17:00:00"; + String startDateValue = startDate.isPresent() ? startDate.get() : getOffsetDateInFormat( -1, "dd/MM/yyyy hh:mm:ss"); + String endDateValue = endDate.isPresent() ? endDate.get() : "14/10/2099 17:00:00"; + String mediaTypeValue = mediaType.isPresent() ? mediaType.get() : MOVIE_MEDIA_TYPE; + String ppvWebNameValue = ppvWebName.isPresent() ? ppvWebName.get() : "Shai_Regression_PPV"; // TODO: update on any generated value + String ppvMobileNameValue = ppvMobileName.isPresent() ? ppvMobileName.get() : "Shai_Regression_PPV"; // TODO: update on any generated value + // TODO: check if ingest url is the same for all ingest actions + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headermap = new HashMap<>(); + headermap.put("Content-Type", "text/xml;charset=UTF-8"); + headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + Response resp = RestAssured.given() + .log().all() + .headers(headermap) + .body(reqBody) + .post(url); + //System.out.println("RESPONSE: " + resp.asString()); + String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - // TODO: complete it + MediaAsset mediaAsset = new MediaAsset(); + mediaAsset.setName(nameValue); + mediaAsset.setId(Long.valueOf(id)); + mediaAsset.setDescription(descriptionValue); + //mediaAsset.setStartDate(startDate); + //mediaAsset.setEndDate(endDate); + return mediaAsset; + } - return null; + private static String buildIngestVodXml(Optional coguid, boolean isActive, String name, String thumbUrl, + String description, String catalogStartDate, String catalogEndDate, + String startDate, String endDate, String mediaType, String ppvWebName, + String ppvMobileName) { + return "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " " + name + "\n" + + " \n" + + " \n" + + " \n" + + " " + description + "\n" + + " \n" + + " \n" + + " " + catalogStartDate + "\n" + + " " + startDate + "\n" + + " " + catalogEndDate + "\n" + + " " + endDate + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " " + mediaType + "\n" + + " \n" + + //" ${#TestCase#i_geo_block_rule}\n" + + //" Parent Allowed\n" + + //" ${#TestCase#i_device_block_rule}\n" + + " \n" + + " \n" + + " \n" + + //" \n" + + //" \n" + + //" syno pino sister\n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_meta_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_double_meta_value}\n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_date_meta_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" Costa Rica;Israel\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" GIH\n" + + //" \n" + + //" \n" + + //" ABC\n" + + //" \n" + + //" \n" + + //" DEF\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" Shay_Series\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_tag_free_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_parental_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_tag_value}\n" + + //" \n" + + //" \n" + + //" \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; } } From 6d1a8229bf24392b7dc34bd5778d4f786e00bea2 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 8 Apr 2018 13:21:23 +0300 Subject: [PATCH 035/605] Added logic for ingest VOD --- .../test/servicesImpl/AssetServiceImpl.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 22 ++++++++++---- .../productPriceTests/ListTests.java | 25 ++++++++-------- .../client/test/utils/IngestVODUtils.java | 30 ++++++++++++++++--- .../client/test/utils/PurchaseUtils.java | 2 +- 5 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java index 353f0a505..06dc44e09 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java @@ -18,7 +18,7 @@ public class AssetServiceImpl { private static Response assetResponse; // list - public static Response getAsset(String ks, String id, AssetReferenceType assetReferenceType) { + public static Response get(String ks, String id, AssetReferenceType assetReferenceType) { client.setKs(ks); GetAssetBuilder assetBuilder = AssetService.get(id, assetReferenceType) .setCompletion((ApiCompletion) result -> { diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 6280ffe81..c2dc19a6f 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,16 +3,17 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.HouseholdUser; -import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.test.utils.IngestVODUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; @@ -23,14 +24,17 @@ public class BaseTest { public static Client client; private Response loginResponse; + private Response loginSession; - public static String administratorKs, operatorKs, managerKs; + public static String administratorKs, operatorKs, managerKs, anonymousKs; // shared household public static Household sharedHousehold; public static HouseholdUser sharedMasterUser, sharedUser; public static String sharedMasterUserKs, sharedUserKs; + // shared VOD + public static MediaAsset mediaAsset; @BeforeSuite public void setup() { @@ -56,8 +60,16 @@ public void setup() { // loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); // managerKs = loginResponse.results.getLoginSession().getKs(); + loginSession = anonymousLogin(PARTNER_ID, null); + anonymousKs = loginSession.results.getKs(); + // Set project shared HH and users -// initSharedHousehold(); + initSharedHousehold(); + + mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + System.out.println("INGESTED VOD: " + mediaAsset.getId()); Logger.getLogger(BaseTest.class).debug("Finish Setup!"); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 7e936997a..3d2f077a4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -32,10 +32,6 @@ public void beforeClass() { entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); entitlementPpvsFilter.setIsExpiredEqual(false); - MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); - System.out.println("INGESTED VOD: " + mediaAsset.getId()); } @Description("productPrice/action/list - subscription test by Operator without currency") @@ -62,7 +58,7 @@ public void listWithoutRequiredFieldsTest() { } @Description("productPrice/action/list - ppv test") - @Test(enabled = false) // as requires ingest VOD + @Test(enabled = false) // as failed public void ppvTest() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, @@ -71,20 +67,23 @@ public void ppvTest() { assertThat(entitlementListBeforePurchase.results.getTotalCount() == 0); ProductPriceFilter ppFilter = new ProductPriceFilter(); - // TODO: needed ingest VOD ppFilter.setFileIdIn(String.valueOf(shared_vod_web_file_id)); + int webMediaFileId = mediaAsset.getMediaFiles().get(0).getId(); + int mobileMediaFileId = mediaAsset.getMediaFiles().get(1).getId(); + ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); ppFilter.setIsLowest(false); Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); assertThat(productPriceListBeforePurchase.results.getTotalCount() == 1); assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.FOR_PURCHASE); assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType() == TransactionType.PPV); - // TODO: needed ingest VOD assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId() == shared_vod_web_file_id); + assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId() == webMediaFileId); - // TODO: needed ingest VOD PurchaseUtils.purchasePpv(sharedMasterUserKs, Optional.empty(), Optional.of(shared_vod_web_file_id), Optional.empty()); + PurchaseUtils.purchasePpv(sharedMasterUserKs, Optional.empty(), Optional.of(webMediaFileId), Optional.empty()); Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, Optional.empty()); + System.out.println(entitlementListAfterPurchase.results.getTotalCount()); assertThat(entitlementListAfterPurchase.results.getTotalCount() == 1); - // TODO: needed ingest VOD assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId() == shared_vod_web_file_id); - // TODO: needed ingest VOD assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId() == media_id_2); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId() == webMediaFileId); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId() == mediaAsset.getId().intValue()); assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate() > entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod().equals(PaymentMethodType.OFFLINE) || @@ -93,12 +92,12 @@ public void ppvTest() { Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); assertThat(productPriceListAfterPurchase.results.getTotalCount() == 1); assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.PPV_PURCHASED); - // TODO: needed ingest VOD assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId() == shared_vod_web_file_id); + assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId() == webMediaFileId); - // TODO: needed ingest VOD ppFilter.setFileIdIn(String.valueOf(shared_vod_mobile_file_id)); + ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount() == 1); assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.PPV_PURCHASED); - // TODO: needed ingest VOD assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId() == shared_vod_mobile_file_id); + assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId() == mobileMediaFileId); } } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index 99ce08ead..0f23e4637 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -1,14 +1,24 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.types.APIException; +import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.RestAssured; -import io.restassured.response.Response; import java.util.HashMap; import java.util.Optional; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import com.kaltura.client.utils.response.base.Response; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.Properties.INGEST_USER_PASSWORD; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.tests.BaseTest.anonymousKs; import static io.restassured.path.xml.XmlPath.from; +import static org.awaitility.Awaitility.await; +import static org.awaitility.Awaitility.fieldIn; +import static org.hamcrest.Matchers.equalTo; public class IngestVODUtils extends BaseUtils { @@ -37,12 +47,12 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op " \n" + " \n" + " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + - " \n" + " \n" + ""; - Response resp = RestAssured.given() + io.restassured.response.Response resp = RestAssured.given() .log().all() .headers(headermap) .body(reqBody) @@ -56,10 +66,22 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op mediaAsset.setDescription(descriptionValue); //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); + + await().atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); + Response mediaAssetDetails = AssetServiceImpl.get(anonymousKs, id, AssetReferenceType.MEDIA); + mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); return mediaAsset; } - private static String buildIngestVodXml(Optional coguid, boolean isActive, String name, String thumbUrl, + private static Callable isDataReturned(String mediaId) { + return new Callable() { + public Boolean call() throws Exception { + return AssetServiceImpl.get(anonymousKs, mediaId, AssetReferenceType.MEDIA).error == null; + } + }; + } + + private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName) { diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index bf6a2531c..6ada28339 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -25,7 +25,7 @@ public static void purchasePpv(String ks, Optional mediaId, Optional mediaAsset = AssetServiceImpl.getAsset(ks, String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); + Response mediaAsset = AssetServiceImpl.get(ks, String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); internalFileId = mediaAsset.results.getMediaFiles().get(0).getId(); } From 83908db713d0c164186655043a0dfdd454aab597 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 8 Apr 2018 13:40:50 +0300 Subject: [PATCH 036/605] skip schema asserion if totalCount == 0 --- pom.xml | 16 ++++++++-------- .../client/test/TestAPIOkRequestsExecutor.java | 9 ++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index d04f9ec8a..5caf1f411 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ jar 1.8 - 1.8.10 + 1.8.13 @@ -84,13 +84,13 @@ commons-codec commons-codec - 1.4 + 1.11 org.json json - 20090211 + 20180130 @@ -104,19 +104,19 @@ com.squareup.okhttp3 okhttp - 3.4.1 + 3.10.0 com.squareup.okio okio - 1.9.0 + 1.14.0 log4j log4j - 1.2.15 + 1.2.17 com.sun.jmx @@ -137,7 +137,7 @@ org.testng testng - 6.11 + 6.14.2 test @@ -186,7 +186,7 @@ io.qameta.allure allure-testng - 2.0-BETA18 + 2.6.0 test diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index b406f944f..380035bb3 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -70,17 +70,20 @@ protected ResponseElement onGotResponse(Response response, RequestElement action if (s2.equals("ListResponse")) { com.kaltura.client.utils.response.base.Response listResponse = response1; + if (listResponse.results.getTotalCount() == 0) { + return null; + } + String s = listResponse.results.getObjects().get(0).getClass().getSimpleName(); s2 = s2 + "_" + s; } String schema = s1 + s2 + s3; - Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Start " + schema + " schema assertion!"); + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Start " + s2 + " schema assertion!"); assertThat(responseString, matchesJsonSchemaInClasspath(schema)); - Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Finish " + schema + " schema assertion!"); + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Finish " + s2 + " schema assertion!"); } - return responseElement; } } From 6468e26d73749378bd7408908ed450c81d67c7eb Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 8 Apr 2018 13:59:15 +0300 Subject: [PATCH 037/605] turn off allure integrarion --- pom.xml | 66 +++++++++---------- .../test/TestAPIOkRequestsExecutor.java | 2 +- .../productPriceTests/ListTests.java | 9 +-- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/pom.xml b/pom.xml index 5caf1f411..892604b72 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ jar 1.8 - 1.8.13 + @@ -183,12 +183,12 @@ test - - io.qameta.allure - allure-testng - 2.6.0 - test - + + + + + + @@ -223,22 +223,22 @@ org.apache.maven.plugins maven-surefire-plugin 2.18.1 - - - src/testng.xml - - true - - -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" - - - - - org.aspectj - aspectjweaver - ${aspectj.version} - - + + + + + + + + + + + + + + + + @@ -302,15 +302,15 @@ - - true - - - io.qameta.allure - allure-maven - 2.8 - - - + + + + + + + + + + diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 380035bb3..14c5b9e0d 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -71,7 +71,7 @@ protected ResponseElement onGotResponse(Response response, RequestElement action if (s2.equals("ListResponse")) { com.kaltura.client.utils.response.base.Response listResponse = response1; if (listResponse.results.getTotalCount() == 0) { - return null; + return responseElement; } String s = listResponse.results.getObjects().get(0).getClass().getSimpleName(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 3d2f077a4..7e23d09a0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -1,21 +1,18 @@ package com.kaltura.client.test.tests.servicesTests.productPriceTests; import com.kaltura.client.enums.*; -import com.kaltura.client.services.EntitlementService; -import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.IngestPPVUtils; -import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + import java.util.Optional; -import static com.kaltura.client.test.Properties.*; + import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -58,7 +55,7 @@ public void listWithoutRequiredFieldsTest() { } @Description("productPrice/action/list - ppv test") - @Test(enabled = false) // as failed + @Test(enabled = true) // as failed public void ppvTest() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, From b5d4cf34f2d0966446d7dbc8798d14b645bcb5f5 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 8 Apr 2018 16:38:57 +0300 Subject: [PATCH 038/605] remove client.setKs() usage --- pom.xml | 72 ++++++++++--------- .../test/TestAPIOkRequestsExecutor.java | 4 +- .../test/servicesImpl/AssetServiceImpl.java | 3 +- .../servicesImpl/EntitlementServiceImpl.java | 22 +++--- .../servicesImpl/ProductPriceServiceImpl.java | 10 +-- .../servicesImpl/TransactionServiceImpl.java | 3 +- .../kaltura/client/test/tests/BaseTest.java | 5 +- .../servicesTests/ottUserTests/GetTests.java | 1 - .../productPriceTests/ListTests.java | 46 ++++++------ 9 files changed, 90 insertions(+), 76 deletions(-) diff --git a/pom.xml b/pom.xml index 892604b72..dc2bad763 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ jar 1.8 - + 1.8.10 @@ -183,12 +183,18 @@ test - - - - - - + + io.qameta.allure + allure-testng + 2.6.0 + test + + + + com.fasterxml.jackson.core + jackson-databind + 2.9.5 + @@ -223,22 +229,22 @@ org.apache.maven.plugins maven-surefire-plugin 2.18.1 - - - - - - - - - - - - - - - - + + + src/testng.xml + + true + + -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" + + + + + org.aspectj + aspectjweaver + ${aspectj.version} + + @@ -302,15 +308,15 @@ - - - - - - - - - - + + true + + + io.qameta.allure + allure-maven + 2.9 + + + diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 14c5b9e0d..49abfa47a 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -79,10 +79,8 @@ protected ResponseElement onGotResponse(Response response, RequestElement action } String schema = s1 + s2 + s3; - - Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Start " + s2 + " schema assertion!"); + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(schema); assertThat(responseString, matchesJsonSchemaInClasspath(schema)); - Logger.getLogger(TestAPIOkRequestsExecutor.class).debug("Finish " + s2 + " schema assertion!"); } return responseElement; } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java index 06dc44e09..8212be5ac 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java @@ -19,13 +19,14 @@ public class AssetServiceImpl { // list public static Response get(String ks, String id, AssetReferenceType assetReferenceType) { - client.setKs(ks); GetAssetBuilder assetBuilder = AssetService.get(id, assetReferenceType) .setCompletion((ApiCompletion) result -> { assetResponse = result; done.set(true); }); + assetBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(assetBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java index 39c91be8c..18948b9d2 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java @@ -2,11 +2,16 @@ import com.kaltura.client.services.EntitlementService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Entitlement; +import com.kaltura.client.types.EntitlementFilter; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; -import java.util.Optional; + +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; + import static com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -18,17 +23,18 @@ public class EntitlementServiceImpl { private static Response> entitlementResponse; // list - public static Response> list(String ks, EntitlementFilter filter, Optional pager) { - client.setKs(ks); - if (pager.isPresent()) { - // TODO: find how to work with pager - } - ListEntitlementBuilder productPriceBuilder = EntitlementService.list(filter) + public static Response> list(String ks, EntitlementFilter filter, @Nullable FilterPager pager) { + ListEntitlementBuilder productPriceBuilder = EntitlementService.list(filter, pager) .setCompletion((ApiCompletion>) result -> { entitlementResponse = result; done.set(true); }); + productPriceBuilder.setKs(ks); +// if (pager.isPresent()) { +// // TODO: find how to work with pager +// } + TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java index d5965752a..2731baed8 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java @@ -23,17 +23,17 @@ public class ProductPriceServiceImpl { // list public static Response> list(String ks, ProductPriceFilter filter, Optional currency) { - client.setKs(ks); - if (currency.isPresent()) { - client.setCurrency(currency.get()); - } + // TODO: 4/2/2018 ask Max why change client.ks insted of roductPriceBuilder.setKs(ks); ListProductPriceBuilder productPriceBuilder = ProductPriceService.list(filter) .setCompletion((ApiCompletion>) result -> { productPriceResponse = result; done.set(true); }); - // TODO: 4/2/2018 ask Max for what Optional currency + // TODO: 4/2/2018 ask Max for what Optional currency + productPriceBuilder.setKs(ks); + currency.ifPresent(productPriceBuilder::setCurrency); + TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java index 24c907947..2d8d539c0 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java @@ -19,13 +19,14 @@ public class TransactionServiceImpl { // list public static Response purchase(String ks, Purchase purchase) { - client.setKs(ks); PurchaseTransactionBuilder purchaseBuilder = TransactionService.purchase(purchase) .setCompletion((ApiCompletion) result -> { purchaseResponse = result; done.set(true); }); + purchaseBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(purchaseBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c2dc19a6f..965950422 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -66,9 +66,8 @@ public void setup() { // Set project shared HH and users initSharedHousehold(); - mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); System.out.println("INGESTED VOD: " + mediaAsset.getId()); Logger.getLogger(BaseTest.class).debug("Finish Setup!"); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index b54c73906..dffafdb66 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -39,7 +39,6 @@ private void ottUser_login_tests_setup() { @Description("ottUser/action/get - get") @Test private void get() { - // TODO: 3/27/2018 fix get test ottUserResponse = OttUserServiceImpl.get(loginResponse.results.getLoginSession().getKs(), Optional.empty()); assertThat(loginResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 7e23d09a0..4156851a1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -55,13 +55,13 @@ public void listWithoutRequiredFieldsTest() { } @Description("productPrice/action/list - ppv test") - @Test(enabled = true) // as failed + @Test(enabled = true) public void ppvTest() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ - Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, Optional.empty()); - assertThat(entitlementListBeforePurchase.results.getTotalCount() == 0); + Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, null); + assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); int webMediaFileId = mediaAsset.getMediaFiles().get(0).getId(); @@ -69,32 +69,36 @@ public void ppvTest() { ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); ppFilter.setIsLowest(false); Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); - assertThat(productPriceListBeforePurchase.results.getTotalCount() == 1); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType() == TransactionType.PPV); - assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId() == webMediaFileId); + // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) + assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); PurchaseUtils.purchasePpv(sharedMasterUserKs, Optional.empty(), Optional.of(webMediaFileId), Optional.empty()); - Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, Optional.empty()); + Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, null); System.out.println(entitlementListAfterPurchase.results.getTotalCount()); - assertThat(entitlementListAfterPurchase.results.getTotalCount() == 1); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId() == webMediaFileId); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId() == mediaAsset.getId().intValue()); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate() > - entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod().equals(PaymentMethodType.OFFLINE) || - entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod().equals(PaymentMethodType.UNKNOWN)); + assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(mediaAsset.getId().intValue()); + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) + .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); + +// MatcherAssert.assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod(), +// anyOf(is(PaymentMethodType.OFFLINE), is(PaymentMethodType.UNKNOWN))); + + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); - assertThat(productPriceListAfterPurchase.results.getTotalCount() == 1); - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId() == webMediaFileId); + assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount() == 1); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId() == mobileMediaFileId); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); } } From f47d347a0b760d7257492d009f8b2d8ccc72fe5a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 9 Apr 2018 08:42:39 +0300 Subject: [PATCH 039/605] Added initial logic related using PG by created HH --- src/test/java/com/kaltura/client/test/Properties.java | 9 +++++++++ .../java/com/kaltura/client/test/tests/BaseTest.java | 2 +- .../tests/servicesTests/ottUserTests/DeleteTests.java | 2 +- .../test/tests/servicesTests/ottUserTests/ListTests.java | 2 +- .../com/kaltura/client/test/utils/HouseholdUtils.java | 7 ++++++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 5557ef51a..02a6d9139 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -64,6 +64,15 @@ public class Properties { // discount modules public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; + // PG adapter data + public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; + public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; + public static final String PG_DEFAULT_SHARED_SECRET = "123456"; + public static final int PG_DEFAULT_PENDING_INTERVAL = 0; + public static final int PG_DEFAULT_PENDING_RETRIES = 0; + public static final int PG_DEFAULT_RENEW_INTERVAL_MINUTES = 15; + public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; + public static final String PG_DEFAULT_PG_SETTINGS = "{}"; public static String getProperty(String propertyKey) { if (resourceBundle == null) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c2dc19a6f..33dfd1743 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -75,7 +75,7 @@ public void setup() { } private void initSharedHousehold() { - sharedHousehold = createHouseHold(2, 2); + sharedHousehold = createHouseHold(2, 2, false); List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); for (HouseholdUser user : sharedHouseholdUsers) { if (user.getIsMaster() != null && user.getIsMaster()) { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index b2d6a2536..c4f786a84 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -32,7 +32,7 @@ public class DeleteTests extends BaseTest { @BeforeClass private void ottUser_delete_tests_setup() { - household = HouseholdUtils.createHouseHold(2, 0); + household = HouseholdUtils.createHouseHold(2, 0, false); } @Description("ottUser/action/delete - delete") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index ef51f6b9b..f9c6f9bdd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -28,7 +28,7 @@ public class ListTests extends BaseTest { @BeforeClass private void ottUser_list_tests_setup() { - household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, 1); + household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, 1, false); } @Description("ottUser/action/list - list from master ks") diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 57961e296..0e62f9768 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -15,12 +15,13 @@ import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.tests.BaseTest.administratorKs; +import static com.kaltura.client.test.tests.BaseTest.client; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class HouseholdUtils extends BaseUtils { // create household - public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold) { + public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold, boolean isPreparePG) { // create and register Response masterUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); @@ -60,6 +61,10 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO HouseholdDeviceServiceImpl.add(masterUserKS, householdDevice); } + if (isPreparePG) { + + } + return household; } From 14c156438a42c8ebc408225688936bd7fe246f1c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 9 Apr 2018 11:30:56 +0300 Subject: [PATCH 040/605] Added new class to serviceImpl - "BookmarkServiceImpl" --- .../servicesImpl/BookmarkServiceImpl.java | 57 +++++++++++++++++++ .../servicesTests/bookmarkTests/AddTests.java | 24 ++++++++ .../ottUserTests/ActivateTests.java | 1 + 3 files changed, 82 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java new file mode 100644 index 000000000..a0278412a --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java @@ -0,0 +1,57 @@ +package com.kaltura.client.test.servicesImpl; + + +import com.kaltura.client.services.BookmarkService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Bookmark; +import com.kaltura.client.types.BookmarkFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; +import static com.kaltura.client.services.BookmarkService.ListBookmarkBuilder; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class BookmarkServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + private static Response booleanResponse; + private static Response> bookmarkListResponse; + + + // Bookmark/action/add + public static Response add(String ks, Bookmark bookmark) { + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + addBookmarkBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(addBookmarkBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // Bookmark/action/list + public static Response> list (String ks, BookmarkFilter bookmarkFilter) { + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setCompletion((ApiCompletion>) result -> { + bookmarkListResponse = result; + done.set(true); + }); + + listBookmarkBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(listBookmarkBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return bookmarkListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java new file mode 100644 index 000000000..8b58e9ec7 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -0,0 +1,24 @@ +package com.kaltura.client.test.tests.servicesTests.bookmarkTests; + +import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.Bookmark; +import com.kaltura.client.utils.response.base.Response; +import com.sun.org.glassfish.gmbal.Description; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddTests extends BaseTest { + + @Description("bookmark/action/add - add") + @Test + private void add() { + Bookmark bookmark = new Bookmark(); + + Response booleanResponse = BookmarkServiceImpl.add(administratorKs, bookmark); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + assertThat(booleanResponse.error).isNull(); + + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index c07e13069..aa986d119 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.DBUtils; +import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import com.sun.org.glassfish.gmbal.Description; From 2ce222d31a7b2e98d6964eefff6e599d13951726 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 9 Apr 2018 12:22:00 +0300 Subject: [PATCH 041/605] add allure reports --- .gitignore | 1 + pom.xml | 22 ++++++++++++------- .../test/TestAPIOkRequestsExecutor.java | 2 +- .../ottUserTests/ActivateTests.java | 2 +- .../ottUserTests/AddRoleTests.java | 2 +- .../ottUserTests/AnonymousLoginTests.java | 2 +- .../ottUserTests/DeleteTests.java | 2 +- .../ottUserTests/GetEncryptedUserIdTests.java | 2 +- .../servicesTests/ottUserTests/GetTests.java | 2 +- .../servicesTests/ottUserTests/ListTests.java | 2 +- .../ottUserTests/LoginTests.java | 2 +- .../ottUserTests/LoginWithPinTests.java | 2 +- .../ottUserTests/LogoutTests.java | 2 +- .../ottUserTests/RegisterTests.java | 2 +- .../ResendActivationTokenTests.java | 2 +- .../ottUserTests/ResetPasswordTests.java | 2 +- .../ottUserTests/UpdateDynamicDataTests.java | 2 +- .../ottUserTests/UpdateLoginDataTests.java | 2 +- .../ottUserTests/UpdateTests.java | 2 +- .../productPriceTests/ListTests.java | 5 +---- src/test/resources/allure.properties | 3 +++ src/test/resources/testng.xml | 8 ++++++- 22 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 src/test/resources/allure.properties diff --git a/.gitignore b/.gitignore index 44320543b..48771c4ef 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ build target/ src/test/java/resources/test.properties allure-results/ +.allure/ diff --git a/pom.xml b/pom.xml index dc2bad763..71b0eda08 100644 --- a/pom.xml +++ b/pom.xml @@ -230,9 +230,16 @@ maven-surefire-plugin 2.18.1 + + + usedefaultlisteners + false + + - src/testng.xml + src\test\resources\testng.xml + ${project.basedir}/target true -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" @@ -305,18 +312,17 @@ - - - - - true - io.qameta.allure allure-maven 2.9 + + ${basedir}/target/allure-report + + + - + diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 49abfa47a..3dfbdd829 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -79,7 +79,7 @@ protected ResponseElement onGotResponse(Response response, RequestElement action } String schema = s1 + s2 + s3; - Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(schema); + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); assertThat(responseString, matchesJsonSchemaInClasspath(schema)); } return responseElement; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index c07e13069..de6fc9757 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -6,7 +6,7 @@ import com.kaltura.client.test.utils.DBUtils; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index 019944cd4..01bd687c0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -8,7 +8,7 @@ import com.kaltura.client.types.UserRole; import com.kaltura.client.types.UserRoleFilter; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 044b3e7ef..325b8f540 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -4,7 +4,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginSession; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.Test; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index b2d6a2536..db2f7512e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -8,7 +8,7 @@ import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java index de52e3a46..5345173ad 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index dffafdb66..5e34d00b5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index ef51f6b9b..da4e631db 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -4,7 +4,7 @@ import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 53d2dbd16..af80ca87d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java index 8ae9ac985..07927f382 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -7,7 +7,7 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.UserLoginPin; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java index d14a18ccb..f57031bf9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java @@ -6,7 +6,7 @@ import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java index 01434826e..3fb52ad70 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java @@ -4,7 +4,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java index 713a3c99f..afdef6637 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -4,7 +4,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java index ae25db5ee..c54fdcc8c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java index b8c300fb4..a0e73f9ef 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java @@ -6,7 +6,7 @@ import com.kaltura.client.types.OTTUserDynamicData; import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index 8dff34235..73ca40c1a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.Test; import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index d72532dac..e235fed7e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 4156851a1..5b4e66ed4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -7,7 +7,7 @@ import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -85,9 +85,6 @@ public void ppvTest() { assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); -// MatcherAssert.assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod(), -// anyOf(is(PaymentMethodType.OFFLINE), is(PaymentMethodType.UNKNOWN))); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); diff --git a/src/test/resources/allure.properties b/src/test/resources/allure.properties new file mode 100644 index 000000000..e37bada0f --- /dev/null +++ b/src/test/resources/allure.properties @@ -0,0 +1,3 @@ +allure.results.directory=target/allure-results +allure.link.issue.pattern=https://example.org/issue/{} +allure.link.tms.pattern=https://example.org/tms/{} \ No newline at end of file diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index af43863a2..4969d7a26 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -4,7 +4,13 @@ - + + + + + + + \ No newline at end of file From 55a56c80ccbe60fb05f8ae7d2f842dcb3881faa2 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 9 Apr 2018 13:33:31 +0300 Subject: [PATCH 042/605] Updated JSON validation schemas --- .../resources/schemas/ListResponse_Entitlement.json | 4 ++-- .../resources/schemas/ListResponse_ProductPrice.json | 4 ++-- src/test/resources/schemas/MediaAsset.json | 12 ++++++------ src/test/resources/schemas/PpvPrice.json | 2 +- src/test/resources/schemas/SubscriptionPrice.json | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/resources/schemas/ListResponse_Entitlement.json b/src/test/resources/schemas/ListResponse_Entitlement.json index 074e9a7a8..cdd2b8fba 100644 --- a/src/test/resources/schemas/ListResponse_Entitlement.json +++ b/src/test/resources/schemas/ListResponse_Entitlement.json @@ -10,10 +10,10 @@ "items": { "anyOf": [ { - "$ref": "KalturaPpvEntitlement_Schema.json#/definitions/KalturaPpvEntitlement" + "$ref": "PpvEntitlement.json#/definitions/KalturaPpvEntitlement" }, { - "$ref": "KalturaSubscriptionEntitlement_Schema.json#/definitions/KalturaSubscriptionEntitlement" + "$ref": "SubscriptionEntitlement.json#/definitions/KalturaSubscriptionEntitlement" } ] } diff --git a/src/test/resources/schemas/ListResponse_ProductPrice.json b/src/test/resources/schemas/ListResponse_ProductPrice.json index 3db9aaab3..2a3531793 100644 --- a/src/test/resources/schemas/ListResponse_ProductPrice.json +++ b/src/test/resources/schemas/ListResponse_ProductPrice.json @@ -9,8 +9,8 @@ "type": "array", "items": { "anyOf": [ - { "$ref": "KalturaSubscriptionPrice_Schema.json#/definitions/KalturaSubscriptionPrice" }, - { "$ref": "KalturaPpvPrice_Schema.json#/definitions/KalturaPpvPrice" } + { "$ref": "SubscriptionPrice.json#/definitions/KalturaSubscriptionPrice" }, + { "$ref": "PpvPrice.json#/definitions/KalturaPpvPrice" } ] }}, "totalCount": { diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index 77baf7981..61f2f58e0 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -152,22 +152,22 @@ "type": "object", "properties": { "Free": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" }, "Genre": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" }, "Parental Rating": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" }, "Director": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" }, "Country": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" }, "Series name": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" } } }, diff --git a/src/test/resources/schemas/PpvPrice.json b/src/test/resources/schemas/PpvPrice.json index a679b600f..85173dbce 100644 --- a/src/test/resources/schemas/PpvPrice.json +++ b/src/test/resources/schemas/PpvPrice.json @@ -131,7 +131,7 @@ "minLength": 1 }, "price": { - "$ref": "KalturaPrice_Schema.json#/definitions/KalturaPrice" + "$ref": "Price.json#/definitions/KalturaPrice" }, "purchaseStatus": { "type": "string", diff --git a/src/test/resources/schemas/SubscriptionPrice.json b/src/test/resources/schemas/SubscriptionPrice.json index 1df8a46dd..d0292a09a 100644 --- a/src/test/resources/schemas/SubscriptionPrice.json +++ b/src/test/resources/schemas/SubscriptionPrice.json @@ -5,7 +5,7 @@ "type": "object", "properties": { "price": { - "$ref": "KalturaPrice_Schema.json#/definitions/KalturaPrice" + "$ref": "Price.json#/definitions/KalturaPrice" }, "purchaseStatus": { "type": "string", From 230b80c0f80adc86e73935758b0a893b307fa578 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 9 Apr 2018 13:34:06 +0300 Subject: [PATCH 043/605] updated assertions --- .../servicesTests/productPriceTests/ListTests.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 4156851a1..e4d703e11 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -10,9 +10,7 @@ import com.sun.org.glassfish.gmbal.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import java.util.Optional; - import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -38,8 +36,8 @@ public void listSubscriptionTest() { // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); Response> productPriceList = list(operatorKs, filter, Optional.empty()); // TODO: fix! assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(five_min_renewable_subscription_id); - assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus() == PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount() > 0); + assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); } @Description("productPrice/action/list - without required fields (subscriptionIdIn, collectionIdIn and fileIdIn are empty)") @@ -55,7 +53,7 @@ public void listWithoutRequiredFieldsTest() { } @Description("productPrice/action/list - ppv test") - @Test(enabled = true) + @Test(enabled = false) // as failed public void ppvTest() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, @@ -85,9 +83,6 @@ public void ppvTest() { assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); -// MatcherAssert.assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod(), -// anyOf(is(PaymentMethodType.OFFLINE), is(PaymentMethodType.UNKNOWN))); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); From c5bc71e07153d7530384c1dbe7c5d6b7e296fb66 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 9 Apr 2018 13:34:59 +0300 Subject: [PATCH 044/605] Updated logic of validation for lists --- .../com/kaltura/client/test/TestAPIOkRequestsExecutor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 49abfa47a..d50f56868 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -75,7 +75,12 @@ protected ResponseElement onGotResponse(Response response, RequestElement action } String s = listResponse.results.getObjects().get(0).getClass().getSimpleName(); - s2 = s2 + "_" + s; + String parentClassName = listResponse.results.getObjects().get(0).getClass().getSuperclass().getSimpleName(); + if (!("ObjectBase".equals(parentClassName) || parentClassName == null)) { + s2 = s2 + "_" + parentClassName; + } else { + s2 = s2 + "_" + s; + } } String schema = s1 + s2 + s3; From 72cfb74de88d7b700bc40cf95e8dda59459a5e06 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 9 Apr 2018 15:31:54 +0300 Subject: [PATCH 045/605] Added common json validation logic for all lists --- .../test/TestAPIOkRequestsExecutor.java | 15 ----- src/test/resources/schemas/ListResponse.json | 62 +++++++++++++++++++ .../ListResponse_BillingTransaction.json | 35 ----------- .../schemas/ListResponse_Entitlement.json | 29 --------- .../schemas/ListResponse_HouseholdUser.json | 35 ----------- .../schemas/ListResponse_OTTUser.json | 35 ----------- .../schemas/ListResponse_ProductPrice.json | 38 ------------ 7 files changed, 62 insertions(+), 187 deletions(-) create mode 100644 src/test/resources/schemas/ListResponse.json delete mode 100644 src/test/resources/schemas/ListResponse_BillingTransaction.json delete mode 100644 src/test/resources/schemas/ListResponse_Entitlement.json delete mode 100644 src/test/resources/schemas/ListResponse_HouseholdUser.json delete mode 100644 src/test/resources/schemas/ListResponse_OTTUser.json delete mode 100644 src/test/resources/schemas/ListResponse_ProductPrice.json diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index aed3752fa..aa1da2cd1 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -68,21 +68,6 @@ protected ResponseElement onGotResponse(Response response, RequestElement action String s3 = ".json"; String s2 = response1.results.getClass().getSimpleName(); - if (s2.equals("ListResponse")) { - com.kaltura.client.utils.response.base.Response listResponse = response1; - if (listResponse.results.getTotalCount() == 0) { - return responseElement; - } - - String s = listResponse.results.getObjects().get(0).getClass().getSimpleName(); - String parentClassName = listResponse.results.getObjects().get(0).getClass().getSuperclass().getSimpleName(); - if (!("ObjectBase".equals(parentClassName) || parentClassName == null)) { - s2 = s2 + "_" + parentClassName; - } else { - s2 = s2 + "_" + s; - } - } - String schema = s1 + s2 + s3; Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); assertThat(responseString, matchesJsonSchemaInClasspath(schema)); diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json new file mode 100644 index 000000000..5cb7e8d0c --- /dev/null +++ b/src/test/resources/schemas/ListResponse.json @@ -0,0 +1,62 @@ +{ + "$id": "ListResponse", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "PpvEntitlement.json#/definitions/KalturaPpvEntitlement" + }, + { + "$ref": "SubscriptionEntitlement.json#/definitions/KalturaSubscriptionEntitlement" + }, + { + "$ref": "BillingTransaction.json#/definitions/BillingTransaction" + }, + { + "$ref": "HouseholdUser.json#/definitions/HouseholdUser" + }, + { + "$ref": "OTTUser.json#/definitions/OTTUser" + }, + { + "$ref": "SubscriptionPrice.json#/definitions/KalturaSubscriptionPrice" + }, + { + "$ref": "PpvPrice.json#/definitions/KalturaPpvPrice" + } + ] + } + }, + "totalCount": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaEntitlementListResponse", + "KalturaBillingTransactionListResponse", + "KalturaHouseholdUserListResponse", + "KalturaOTTUserListResponse", + "KalturaProductPriceListResponse" + ] + } + }, + "required": [ + "objects", + "totalCount", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": ["result"] +} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse_BillingTransaction.json b/src/test/resources/schemas/ListResponse_BillingTransaction.json deleted file mode 100644 index 8750b898e..000000000 --- a/src/test/resources/schemas/ListResponse_BillingTransaction.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$id": "ListResponse_BillingTransaction", - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "objects": { - "type": "array", - "items": { - "$ref": "BillingTransaction.json#/definitions/BillingTransaction" - } - }, - "totalCount": { - "type": "integer", - "minimum": 0 - }, - "objectType": { - "type": "string", - "enum": [ - "KalturaBillingTransactionListResponse" - ] - } - }, - "required": [ - "objects", - "totalCount", - "objectType" - ] - }, - "executionTime": { - "type": "number" - } - } -} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse_Entitlement.json b/src/test/resources/schemas/ListResponse_Entitlement.json deleted file mode 100644 index cdd2b8fba..000000000 --- a/src/test/resources/schemas/ListResponse_Entitlement.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$id": "KalturaEntitlementListResponse", - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "objects": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "PpvEntitlement.json#/definitions/KalturaPpvEntitlement" - }, - { - "$ref": "SubscriptionEntitlement.json#/definitions/KalturaSubscriptionEntitlement" - } - ] - } - }, - "totalCount": {"type": "integer", "minimum": 0}, - "objectType": {"type": "string", "enum": ["KalturaEntitlementListResponse"]} - }, - "required": ["objects", "totalCount", "objectType"] - }, - "executionTime": {"type": "number"} - }, - "required": ["result"] -} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse_HouseholdUser.json b/src/test/resources/schemas/ListResponse_HouseholdUser.json deleted file mode 100644 index 5204f0587..000000000 --- a/src/test/resources/schemas/ListResponse_HouseholdUser.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$id": "ListResponse_HouseholdUser", - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "objects": { - "type": "array", - "items": { - "$ref": "HouseholdUser.json#/definitions/HouseholdUser" - } - }, - "totalCount": { - "type": "integer", - "minimum": 0 - }, - "objectType": { - "type": "string", - "enum": [ - "KalturaHouseholdUserListResponse" - ] - } - }, - "required": [ - "objects", - "totalCount", - "objectType" - ] - }, - "executionTime": { - "type": "number" - } - } -} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse_OTTUser.json b/src/test/resources/schemas/ListResponse_OTTUser.json deleted file mode 100644 index a20290e7b..000000000 --- a/src/test/resources/schemas/ListResponse_OTTUser.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$id": "ListResponse_OTTUser", - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "objects": { - "type": "array", - "items": { - "$ref": "OTTUser.json#/definitions/OTTUser" - } - }, - "totalCount": { - "type": "integer", - "minimum": 0 - }, - "objectType": { - "type": "string", - "enum": [ - "KalturaOTTUserListResponse" - ] - } - }, - "required": [ - "objects", - "totalCount", - "objectType" - ] - }, - "executionTime": { - "type": "number" - } - } -} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse_ProductPrice.json b/src/test/resources/schemas/ListResponse_ProductPrice.json deleted file mode 100644 index 2a3531793..000000000 --- a/src/test/resources/schemas/ListResponse_ProductPrice.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "$id": "KalturaProductPriceListResponse", - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "objects": { - "type": "array", - "items": { - "anyOf": [ - { "$ref": "SubscriptionPrice.json#/definitions/KalturaSubscriptionPrice" }, - { "$ref": "PpvPrice.json#/definitions/KalturaPpvPrice" } - ] - }}, - "totalCount": { - "type": "integer", - "minimum": 0 - }, - "objectType": { - "type": "string", - "enum": ["KalturaProductPriceListResponse"] - } - }, - "required": [ - "objects", - "totalCount", - "objectType" - ] - }, - "executionTime": { - "type": "number" - } - }, - "required": [ - "result" - ] -} \ No newline at end of file From 258c6b9e9b8b4edc3397cad502bd8a3d2d5d88c1 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 9 Apr 2018 15:32:28 +0300 Subject: [PATCH 046/605] updated to lambda --- .../com/kaltura/client/test/utils/IngestVODUtils.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index 0f23e4637..d772c7b03 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -2,7 +2,6 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.APIException; import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.RestAssured; @@ -17,8 +16,6 @@ import static com.kaltura.client.test.tests.BaseTest.anonymousKs; import static io.restassured.path.xml.XmlPath.from; import static org.awaitility.Awaitility.await; -import static org.awaitility.Awaitility.fieldIn; -import static org.hamcrest.Matchers.equalTo; public class IngestVODUtils extends BaseUtils { @@ -74,11 +71,7 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op } private static Callable isDataReturned(String mediaId) { - return new Callable() { - public Boolean call() throws Exception { - return AssetServiceImpl.get(anonymousKs, mediaId, AssetReferenceType.MEDIA).error == null; - } - }; + return () -> AssetServiceImpl.get(anonymousKs, mediaId, AssetReferenceType.MEDIA).error == null; } private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, From b2e2a2b2260f354652cba8481fd8dc1b7b194fc3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 9 Apr 2018 15:55:46 +0300 Subject: [PATCH 047/605] Completed basic implementation of "bookmark/action/add" --- .../servicesTests/bookmarkTests/AddTests.java | 53 +++++++++++++- src/test/resources/schemas/Bookmark.json | 73 +++++++++++++++++++ .../schemas/ListResponse_Bookmark.json | 35 +++++++++ src/test/resources/schemas/MediaAsset.json | 12 +-- .../schemas/MultilingualStringValueArray.json | 4 +- 5 files changed, 166 insertions(+), 11 deletions(-) create mode 100644 src/test/resources/schemas/Bookmark.json create mode 100644 src/test/resources/schemas/ListResponse_Bookmark.json diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index 8b58e9ec7..b994e40b7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -1,24 +1,71 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.Bookmark; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; -import com.sun.org.glassfish.gmbal.Description; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static org.assertj.core.api.Assertions.assertThat; + public class AddTests extends BaseTest { + // TODO: 09/04/2018 - once implemented use asset from ingest and not hardcoded + private long assetId; + private AssetType type; + private int fileId; + private BookmarkActionType actionType; + + @BeforeClass + private void add_tests_before_class() { + assetId = mediaAsset.getId(); + type = AssetType.get("MEDIA"); + AssetReferenceType assetReferenceType = AssetReferenceType.get("MEDIA"); + Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs,String.valueOf(assetId),assetReferenceType); + fileId = assetResponse.results.getMediaFiles().get(0).getId(); + actionType = BookmarkActionType.get("FIRST_PLAY"); + } + @Description("bookmark/action/add - add") @Test private void add() { + Bookmark bookmark = new Bookmark(); + bookmark.setType(type); + bookmark.setId(String.valueOf(assetId)); + bookmark.setPosition(0); + + BookmarkPlayerData playerData = new BookmarkPlayerData(); + playerData.setAction(actionType); + playerData.setAverageBitrate(0); + playerData.setTotalBitrate(0); + playerData.setCurrentBitrate(0); - Response booleanResponse = BookmarkServiceImpl.add(administratorKs, bookmark); + playerData.setFileId((long) fileId); + + bookmark.setPlayerData(playerData); + + Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); + BookmarkFilter bookmarkFilter = new BookmarkFilter(); + bookmarkFilter.setAssetIdIn(String.valueOf(assetId)); + bookmarkFilter.setOrderBy("POSITION_ASC"); + bookmarkFilter.setAssetTypeEqual(type); + + Response> listResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + + String test123 = listResponse.results.getObjects().get(0).getId(); + assertThat (test123.equals((String.valueOf(fileId)))); + } + } diff --git a/src/test/resources/schemas/Bookmark.json b/src/test/resources/schemas/Bookmark.json new file mode 100644 index 000000000..71a7c931c --- /dev/null +++ b/src/test/resources/schemas/Bookmark.json @@ -0,0 +1,73 @@ +{ + "$id": "Bookmark", + "definitions": { + "Bookmark": { + "type": "object", + "properties": { + "user": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 0 + }, + "username": { + "type": "string", + "minLength": 0 + }, + "firstName": { + "type": "string", + "minLength": 0 + }, + "lastName": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "userId": { + "type": "string", + "minLength": 0 + }, + "position": { + "type": "integer", + "minimum": 0 + }, + "positionOwner": { + "type": "string", + "minLength": 0 + }, + "finishedWatching": { + "type": "boolean" + }, + "id": { + "type": "string", + "minLength": 0 + }, + "type": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + } + }, + + "type": "object", + "properties": { + "result": { + "type": "boolean" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} diff --git a/src/test/resources/schemas/ListResponse_Bookmark.json b/src/test/resources/schemas/ListResponse_Bookmark.json new file mode 100644 index 000000000..e3578c790 --- /dev/null +++ b/src/test/resources/schemas/ListResponse_Bookmark.json @@ -0,0 +1,35 @@ +{ + "$id": "ListResponse_Bookmark", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "$ref": "Bookmark.json#/definitions/Bookmark" + } + }, + "totalCount": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaBookmarkListResponse" + ] + } + }, + "required": [ + "objects", + "totalCount", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index 77baf7981..5ad29da6d 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -152,22 +152,22 @@ "type": "object", "properties": { "Free": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Genre": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Parental Rating": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Director": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Country": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Series name": { - "$ref": "KalturaMultilingualStringValueArray_Schema.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" } } }, diff --git a/src/test/resources/schemas/MultilingualStringValueArray.json b/src/test/resources/schemas/MultilingualStringValueArray.json index dc2b5a08f..b57313f9f 100644 --- a/src/test/resources/schemas/MultilingualStringValueArray.json +++ b/src/test/resources/schemas/MultilingualStringValueArray.json @@ -1,7 +1,7 @@ { "$id": "KalturaMediaAsset", "definitions": { - "KalturaMultilingualStringValueArray": { + "MultilingualStringValueArray": { "type": "object", "properties": { "objects": { @@ -28,5 +28,5 @@ } } }, - "$ref": "#/definitions/KalturaMultilingualStringValueArray" + "$ref": "#/definitions/MultilingualStringValueArray" } \ No newline at end of file From 02f442bd5beca7b5e34a9ec0e5b842e037323843 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 9 Apr 2018 17:40:09 +0300 Subject: [PATCH 048/605] Added additional assertions to "BookMarkTests" --- .../servicesTests/bookmarkTests/AddTests.java | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index b994e40b7..25f90fe1c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.enums.PositionOwner; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -17,15 +18,16 @@ public class AddTests extends BaseTest { - // TODO: 09/04/2018 - once implemented use asset from ingest and not hardcoded private long assetId; private AssetType type; private int fileId; private BookmarkActionType actionType; + private int position = 0; @BeforeClass private void add_tests_before_class() { assetId = mediaAsset.getId(); + type = AssetType.get("MEDIA"); AssetReferenceType assetReferenceType = AssetReferenceType.get("MEDIA"); Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs,String.valueOf(assetId),assetReferenceType); @@ -33,14 +35,14 @@ private void add_tests_before_class() { actionType = BookmarkActionType.get("FIRST_PLAY"); } - @Description("bookmark/action/add - add") + @Description("bookmark/action/add - basic functionality") @Test private void add() { Bookmark bookmark = new Bookmark(); bookmark.setType(type); bookmark.setId(String.valueOf(assetId)); - bookmark.setPosition(0); + bookmark.setPosition(position); BookmarkPlayerData playerData = new BookmarkPlayerData(); playerData.setAction(actionType); @@ -61,11 +63,28 @@ private void add() { bookmarkFilter.setOrderBy("POSITION_ASC"); bookmarkFilter.setAssetTypeEqual(type); - Response> listResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); - - String test123 = listResponse.results.getObjects().get(0).getId(); - assertThat (test123.equals((String.valueOf(fileId)))); + Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); - } + // Assertions + // *********************************************** + + // Match content of asset id + assertThat( bookmark1.getId()).isEqualTo(String.valueOf(assetId)); + + // Match content of asset position + assertThat(bookmark1.getPosition()).isEqualTo(this.position); + // verify finishedWatching = false + assertThat(bookmark1.getFinishedWatching()).isFalse(); + + // Verify positionOwner = user + assertThat(bookmark1.getPositionOwner()).isEqualTo(PositionOwner.USER); + + // Verify asset type = media + assertThat(bookmark1.getType()).isEqualTo(AssetType.MEDIA); + + // Verify total count = 1 + assertThat(bookmarkListResponse.results.getTotalCount()).isEqualTo(1); + } } From 00ceb18006337bebcb479430b04d2abfdfaf93e0 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 9 Apr 2018 23:08:15 +0300 Subject: [PATCH 049/605] no message --- .../client/test/utils/IngestPPVUtils.java | 18 ++++----- .../client/test/utils/IngestVODUtils.java | 37 ++++++++----------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 06fc998bc..f90223f4a 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -19,18 +19,18 @@ public static Ppv ingestPPVWithDefaultValues(Optional action, Optional usageModule, Optional isSubscriptionOnly, Optional isFirstDeviceLimitation, Optional productCode, Optional firstFileType, Optional secondFileType) { - String actionValue = action.isPresent() ? action.get() : "insert"; + String actionValue = action.orElse("insert"); boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; - String descriptionValue = description.isPresent() ? description.get() : "My ingest PPV"; - String discountValue = discount.isPresent() ? discount.get() : getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME); - double priceValue = price.isPresent() ? price.get() : Double.valueOf(getProperty(AMOUNT_4_99_EUR)); - String currencyValue = currency.isPresent() ? currency.get() : getProperty(CURRENCY_EUR); - String usageModuleValue = usageModule.isPresent() ? usageModule.get() : getProperty(ONE_DAY_USAGE_MODULE); + String descriptionValue = description.orElse("My ingest PPV"); + String discountValue = discount.orElseGet(() -> getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); + double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(AMOUNT_4_99_EUR))); + String currencyValue = currency.orElseGet(() -> getProperty(CURRENCY_EUR)); + String usageModuleValue = usageModule.orElseGet(() -> getProperty(ONE_DAY_USAGE_MODULE)); boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; - String productCodeValue = productCode.isPresent() ? productCode.get() : getProperty(DEFAULT_PRODUCT_CODE); - String firstFileTypeValue = firstFileType.isPresent() ? firstFileType.get() : getProperty(WEB_FILE_TYPE); - String secondFileTypeValue = secondFileType.isPresent() ? secondFileType.get() : getProperty(MOBILE_FILE_TYPE); + String productCodeValue = productCode.orElseGet(() -> getProperty(DEFAULT_PRODUCT_CODE)); + String firstFileTypeValue = firstFileType.orElseGet(() -> getProperty(WEB_FILE_TYPE)); + String secondFileTypeValue = secondFileType.orElseGet(() -> getProperty(MOBILE_FILE_TYPE)); return ingestPPV(actionValue, isActiveValue, descriptionValue, discountValue, priceValue, currencyValue, usageModuleValue, isSubscriptionOnlyValue, isFirstDeviceLimitationValue, productCodeValue, diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index 0f23e4637..78cf3eac8 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -2,23 +2,20 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.APIException; import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; + import java.util.HashMap; import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import com.kaltura.client.utils.response.base.Response; + import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.Properties.INGEST_USER_PASSWORD; -import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.anonymousKs; import static io.restassured.path.xml.XmlPath.from; import static org.awaitility.Awaitility.await; -import static org.awaitility.Awaitility.fieldIn; -import static org.hamcrest.Matchers.equalTo; public class IngestVODUtils extends BaseUtils { @@ -27,17 +24,17 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op Optional thumbUrl, Optional description, Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { - String coguidValue = coguid.isPresent() ? coguid.get() : getCurrentDataInFormat("yyMMddHHmmssSS"); - String nameValue = name.isPresent() ? name.get() : MOVIE_MEDIA_TYPE + "_" + coguidValue; - String thumbUrlValue = thumbUrl.isPresent() ? thumbUrl.get() : INGEST_VOD_DEFAULT_THUMB; - String descriptionValue = description.isPresent() ? description.get() : "description of " + coguidValue; - String catalogStartDateValue = catalogStartDate.isPresent() ? catalogStartDate.get() : getOffsetDateInFormat( -1, "dd/MM/yyyy hh:mm:ss"); - String catalogEndDateValue = catalogEndDate.isPresent() ? catalogEndDate.get() : "14/10/2099 17:00:00"; - String startDateValue = startDate.isPresent() ? startDate.get() : getOffsetDateInFormat( -1, "dd/MM/yyyy hh:mm:ss"); - String endDateValue = endDate.isPresent() ? endDate.get() : "14/10/2099 17:00:00"; - String mediaTypeValue = mediaType.isPresent() ? mediaType.get() : MOVIE_MEDIA_TYPE; - String ppvWebNameValue = ppvWebName.isPresent() ? ppvWebName.get() : "Shai_Regression_PPV"; // TODO: update on any generated value - String ppvMobileNameValue = ppvMobileName.isPresent() ? ppvMobileName.get() : "Shai_Regression_PPV"; // TODO: update on any generated value + String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); + String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); + String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); + String descriptionValue = description.orElseGet(() -> "description of " + coguidValue); + String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); + String catalogEndDateValue = catalogEndDate.orElse("14/10/2099 17:00:00"); + String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); + String endDateValue = endDate.orElse("14/10/2099 17:00:00"); + String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); + String ppvWebNameValue = ppvWebName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value + String ppvMobileNameValue = ppvMobileName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value // TODO: check if ingest url is the same for all ingest actions String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; HashMap headermap = new HashMap<>(); @@ -74,11 +71,7 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op } private static Callable isDataReturned(String mediaId) { - return new Callable() { - public Boolean call() throws Exception { - return AssetServiceImpl.get(anonymousKs, mediaId, AssetReferenceType.MEDIA).error == null; - } - }; + return () -> AssetServiceImpl.get(anonymousKs, mediaId, AssetReferenceType.MEDIA).error == null; } private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, From a15ea7e039df764dc6bd44155eca0a380fca7734 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Apr 2018 11:05:44 +0300 Subject: [PATCH 050/605] test --- src/test/java/com/kaltura/client/test/tests/Sandbox.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index a2e6a16cc..5bfc7396f 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -27,6 +27,10 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); + + + + System.out.println("!!! " + "let me push"); } } From d6d0cb0e1cfff868c83a90e3576519221d709f5b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 10 Apr 2018 11:08:20 +0300 Subject: [PATCH 051/605] Added date info for checking performance --- .../kaltura/client/test/TestAPIOkRequestsExecutor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index aa1da2cd1..60a4ee0cd 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -11,6 +11,9 @@ import okhttp3.Response; import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.hamcrest.MatcherAssert.assertThat; @@ -70,7 +73,12 @@ protected ResponseElement onGotResponse(Response response, RequestElement action String schema = s1 + s2 + s3; Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); + SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); + Date date = new Date(); + System.out.println("BEFORE VALIDATION: " + formatter.format(date)); assertThat(responseString, matchesJsonSchemaInClasspath(schema)); + date = new Date(); + System.out.println("AFTER VALIDATION: " + formatter.format(date)); } return responseElement; } From ce14d7c11acf90f13434df94978de48b5d91aad9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Apr 2018 11:28:47 +0300 Subject: [PATCH 052/605] no message --- src/test/java/com/kaltura/client/test/tests/Sandbox.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index 5bfc7396f..a2e6a16cc 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -27,10 +27,6 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); - - - - System.out.println("!!! " + "let me push"); } } From 6acb1b4860cb00f3e046eae4544a823154b4eae3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 10 Apr 2018 11:30:10 +0300 Subject: [PATCH 053/605] added intervals for checking ingest results --- src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index d772c7b03..bbf67647f 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -64,7 +64,7 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); - await().atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); + await().pollInterval(3, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); Response mediaAssetDetails = AssetServiceImpl.get(anonymousKs, id, AssetReferenceType.MEDIA); mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); return mediaAsset; From e5bd787409b7df0c1e74731548de19949e52954f Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Apr 2018 11:39:00 +0300 Subject: [PATCH 054/605] pull test --- src/test/java/com/kaltura/client/test/tests/Sandbox.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index a2e6a16cc..fd1853d3e 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -27,6 +27,7 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); + System.out.println("!!! " + "let me pull"); } } From 7855c0c162a6cef42acd3084a99af7e4dc7f9801 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Apr 2018 11:43:50 +0300 Subject: [PATCH 055/605] pull test --- src/test/java/com/kaltura/client/test/tests/Sandbox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index fd1853d3e..b60472517 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -27,7 +27,7 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); - System.out.println("!!! " + "let me pull"); + } } From 5ed1cf577df7369b13c1ce7e753a10958ea86856 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Apr 2018 12:00:51 +0300 Subject: [PATCH 056/605] pull test 2 pull test 2 --- src/test/java/com/kaltura/client/test/tests/Sandbox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index b60472517..52e29dcd7 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -27,7 +27,7 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); - + System.out.println("!!! " + "Let me pull"); } } From ee1dbf40e1fd251aa5651c9ea48ff658428b5a10 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 10 Apr 2018 13:08:40 +0300 Subject: [PATCH 057/605] Remove list response bookmark.json file --- src/test/resources/schemas/ListResponse.json | 6 +++- .../schemas/ListResponse_Bookmark.json | 35 ------------------- 2 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 src/test/resources/schemas/ListResponse_Bookmark.json diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 5cb7e8d0c..4dfb1d50a 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -29,6 +29,9 @@ }, { "$ref": "PpvPrice.json#/definitions/KalturaPpvPrice" + }, + { + "$ref": "Bookmark.json#/definitions/Bookmark" } ] } @@ -44,7 +47,8 @@ "KalturaBillingTransactionListResponse", "KalturaHouseholdUserListResponse", "KalturaOTTUserListResponse", - "KalturaProductPriceListResponse" + "KalturaProductPriceListResponse", + "KalturaBookmarkListResponse" ] } }, diff --git a/src/test/resources/schemas/ListResponse_Bookmark.json b/src/test/resources/schemas/ListResponse_Bookmark.json deleted file mode 100644 index e3578c790..000000000 --- a/src/test/resources/schemas/ListResponse_Bookmark.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$id": "ListResponse_Bookmark", - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "objects": { - "type": "array", - "items": { - "$ref": "Bookmark.json#/definitions/Bookmark" - } - }, - "totalCount": { - "type": "integer", - "minimum": 0 - }, - "objectType": { - "type": "string", - "enum": [ - "KalturaBookmarkListResponse" - ] - } - }, - "required": [ - "objects", - "totalCount", - "objectType" - ] - }, - "executionTime": { - "type": "number" - } - } -} \ No newline at end of file From e3b7a5ff72112e3d8f2d251dc2bc48c340bd70f9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 10 Apr 2018 16:23:32 +0300 Subject: [PATCH 058/605] Added new test to - "AddTests" class (bookmark) --- .../servicesTests/bookmarkTests/AddTests.java | 93 ++++++++++++++++--- 1 file changed, 79 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index 25f90fe1c..ded437ac0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -23,46 +23,57 @@ public class AddTests extends BaseTest { private int fileId; private BookmarkActionType actionType; private int position = 0; + // instantiate Bookmark object + private Bookmark bookmark = new Bookmark(); + // instantiate BookmarkPlayerData object + private BookmarkPlayerData playerData = new BookmarkPlayerData(); + // instantiate BookmarkFilter object + private BookmarkFilter bookmarkFilter = new BookmarkFilter(); @BeforeClass private void add_tests_before_class() { + // Get asset id from ingest assetId = mediaAsset.getId(); - type = AssetType.get("MEDIA"); AssetReferenceType assetReferenceType = AssetReferenceType.get("MEDIA"); Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs,String.valueOf(assetId),assetReferenceType); fileId = assetResponse.results.getMediaFiles().get(0).getId(); actionType = BookmarkActionType.get("FIRST_PLAY"); - } - - @Description("bookmark/action/add - basic functionality") - @Test - private void add() { - Bookmark bookmark = new Bookmark(); + // Initialize bookmark object parameters bookmark.setType(type); bookmark.setId(String.valueOf(assetId)); bookmark.setPosition(position); - BookmarkPlayerData playerData = new BookmarkPlayerData(); + // Initialize playerData object parameters playerData.setAction(actionType); playerData.setAverageBitrate(0); playerData.setTotalBitrate(0); playerData.setCurrentBitrate(0); - playerData.setFileId((long) fileId); - bookmark.setPlayerData(playerData); + // Initialize asset id + bookmarkFilter.setAssetIdIn(String.valueOf(assetId)); + // Initialize orderBy + bookmarkFilter.setOrderBy("POSITION_ASC"); + // Initialize asset type + bookmarkFilter.setAssetTypeEqual(type); + } + + @Description("bookmark/action/add - first play") + @Test + private void firstPlayback() { + + // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned assertThat(booleanResponse.error).isNull(); - BookmarkFilter bookmarkFilter = new BookmarkFilter(); - bookmarkFilter.setAssetIdIn(String.valueOf(assetId)); - bookmarkFilter.setOrderBy("POSITION_ASC"); - bookmarkFilter.setAssetTypeEqual(type); + // Invoke bookmark/action/list to verify insertion of bookmark position Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); @@ -86,5 +97,59 @@ private void add() { // Verify total count = 1 assertThat(bookmarkListResponse.results.getTotalCount()).isEqualTo(1); + + } + + @Description("bookmark/action/add - stop") + @Test + private void stopPlayback() { + // Set action type to "STOP" + actionType = BookmarkActionType.get("STOP"); + playerData.setAction(actionType); + position = 30; + bookmark.setPosition(position); + + // Invoke bookmark/action/add request + Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned + assertThat(booleanResponse.error).isNull(); + + // Invoke bookmark/action/list to verify insertion of bookmark position + Response> bookmarkListResponse2 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Bookmark bookmark2 = bookmarkListResponse2.results.getObjects().get(0); + + // Match content of asset position + assertThat(bookmark2.getPosition()).isEqualTo(this.position); + } + + + @Description("bookmark/action/add - finish watching") + @Test + private void FinishWatching() { + // Set action type to "FINISH" + actionType = BookmarkActionType.get("FINISH"); + playerData.setAction(actionType); + position = 60; + bookmark.setPosition(position); + + // Invoke bookmark/action/add request + Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned + assertThat(booleanResponse.error).isNull(); + + // Invoke bookmark/action/list to verify insertion of bookmark position + Response> bookmarkListResponse3 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Bookmark bookmark3 = bookmarkListResponse3.results.getObjects().get(0); + + // Assertions + // *********************************************** + + // Verify finishedWatching = true + assertThat(bookmark3.getFinishedWatching()).isTrue(); + } } From 13aad994f8f5e472e93a81ea0b10985edbc2816e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Apr 2018 21:58:39 +0300 Subject: [PATCH 059/605] continue TransactionServiceImpl & EntitlementServiceImpl --- .../servicesImpl/EntitlementServiceImpl.java | 150 ++++++++++++++++-- .../servicesImpl/ProductPriceServiceImpl.java | 2 - .../servicesImpl/SubscriptionServiceImpl.java | 41 +++++ .../servicesImpl/TransactionServiceImpl.java | 99 +++++++++++- .../kaltura/client/test/tests/Sandbox.java | 32 +++- .../servicesTests/bookmarkTests/AddTests.java | 2 +- .../entitlementTests/GrantTests.java | 12 ++ .../ottUserTests/LoginTests.java | 4 +- .../productPriceTests/ListTests.java | 6 +- src/test/resources/allure.properties | 2 +- 10 files changed, 321 insertions(+), 29 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java index 18948b9d2..e86c06a69 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java @@ -1,17 +1,16 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.enums.TransactionType; import com.kaltura.client.services.EntitlementService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Entitlement; -import com.kaltura.client.types.EntitlementFilter; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.EntitlementService.*; import static com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -20,27 +19,160 @@ public class EntitlementServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response> entitlementResponse; + private static Response> entitlementListResponse; + private static Response booleanResponse; + private static Response entitlementRenewalResponse; + private static Response entitlementResponse; // list public static Response> list(String ks, EntitlementFilter filter, @Nullable FilterPager pager) { ListEntitlementBuilder productPriceBuilder = EntitlementService.list(filter, pager) .setCompletion((ApiCompletion>) result -> { - entitlementResponse = result; + entitlementListResponse = result; done.set(true); }); productPriceBuilder.setKs(ks); -// if (pager.isPresent()) { -// // TODO: find how to work with pager -// } TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); await().untilTrue(done); done.set(false); + return entitlementListResponse; + } + + // cancel + public static Response cancel(String ks, int assetId, TransactionType transactionType) { + CancelEntitlementBuilder cancelEntitlementBuilder = EntitlementService.cancel(assetId, transactionType) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + cancelEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(cancelEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // cancelScheduledSubscription + public static Response cancelScheduledSubscription(String ks, long scheduledSubscriptionId) { + CancelScheduledSubscriptionEntitlementBuilder cancelScheduledSubscriptionEntitlementBuilder = + EntitlementService.cancelScheduledSubscription(scheduledSubscriptionId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + cancelScheduledSubscriptionEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(cancelScheduledSubscriptionEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // externalReconcile + public static Response externalReconcile(String ks) { + ExternalReconcileEntitlementBuilder externalReconcileEntitlementBuilder = + EntitlementService.externalReconcile() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + externalReconcileEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(externalReconcileEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // forceCancel + public static Response forceCancel(String ks, int assetId, TransactionType transactionType) { + ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel(assetId, transactionType) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + forceCancelEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(forceCancelEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // getNextRenewal + public static Response getNextRenewal(String ks, int id) { + GetNextRenewalEntitlementBuilder getNextRenewalEntitlementBuilder = EntitlementService.getNextRenewal(id) + .setCompletion((ApiCompletion) result -> { + entitlementRenewalResponse = result; + done.set(true); + }); + + getNextRenewalEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(getNextRenewalEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return entitlementRenewalResponse; + } + + // grant + public static Response grant(String ks, int productId, TransactionType transactionType, boolean history, @Nullable int contentId) { + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(productId, transactionType, history, contentId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + grantEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(grantEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // swap + public static Response swap(String ks, int currentProductId, int newProductId, boolean history) { + SwapEntitlementBuilder swapEntitlementBuilder = EntitlementService.swap(currentProductId, newProductId, history) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + swapEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(swapEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // update + public static Response update(String ks, int id, Entitlement entitlement) { + UpdateEntitlementBuilder updateEntitlementBuilder = EntitlementService.update(id, entitlement) + .setCompletion((ApiCompletion) result -> { + entitlementResponse = result; + done.set(true); + }); + + updateEntitlementBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(updateEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + return entitlementResponse; } + + // cancelRenewal + // TODO: 4/10/2018 implement cancelRenewal function and check why it returns Response } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java index 2731baed8..9ca53c7c6 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java @@ -23,14 +23,12 @@ public class ProductPriceServiceImpl { // list public static Response> list(String ks, ProductPriceFilter filter, Optional currency) { - // TODO: 4/2/2018 ask Max why change client.ks insted of roductPriceBuilder.setKs(ks); ListProductPriceBuilder productPriceBuilder = ProductPriceService.list(filter) .setCompletion((ApiCompletion>) result -> { productPriceResponse = result; done.set(true); }); - // TODO: 4/2/2018 ask Max for what Optional currency productPriceBuilder.setKs(ks); currency.ifPresent(productPriceBuilder::setCurrency); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java new file mode 100644 index 000000000..4b549c788 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.services.SubscriptionService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.Subscription; +import com.kaltura.client.types.SubscriptionFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class SubscriptionServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> subscriptionListResponse; + + // list + public static Response> list(String ks, SubscriptionFilter subscriptionFilter) { + ListSubscriptionBuilder listSubscriptionBuilder = SubscriptionService.list(subscriptionFilter) + .setCompletion((ApiCompletion>) result -> { + subscriptionListResponse = result; + done.set(true); + }); + + listSubscriptionBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(listSubscriptionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return subscriptionListResponse; + } + +// validateCoupon +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java index 2d8d539c0..968f252e7 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java @@ -1,12 +1,15 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.enums.TransactionType; import com.kaltura.client.services.TransactionService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Purchase; -import com.kaltura.client.types.Transaction; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; + import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.TransactionService.*; import static com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; @@ -15,13 +18,15 @@ public class TransactionServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response purchaseResponse; + private static Response transactionResponse; + private static Response longResponse; + private static Response booleanResponse; - // list + // purchase public static Response purchase(String ks, Purchase purchase) { PurchaseTransactionBuilder purchaseBuilder = TransactionService.purchase(purchase) .setCompletion((ApiCompletion) result -> { - purchaseResponse = result; + transactionResponse = result; done.set(true); }); @@ -31,8 +36,90 @@ public static Response purchase(String ks, Purchase purchase) { await().untilTrue(done); done.set(false); - return purchaseResponse; + return transactionResponse; + } + + // getPurchaseSessionId + public static Response getPurchaseSessionId(String ks, PurchaseSession purchaseSession) { + GetPurchaseSessionIdTransactionBuilder getPurchaseSessionIdTransactionBuilder = + TransactionService.getPurchaseSessionId(purchaseSession) + .setCompletion((ApiCompletion) result -> { + longResponse = result; + done.set(true); + }); + + getPurchaseSessionIdTransactionBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(getPurchaseSessionIdTransactionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return longResponse; + } + + // setWaiver + public static Response setWaiver(String ks, int assetId, TransactionType transactionType) { + SetWaiverTransactionBuilder setWaiverTransactionBuilder = TransactionService.setWaiver(assetId, transactionType) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + setWaiverTransactionBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(setWaiverTransactionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // updateStatus + // TODO: 4/10/2018 check why updateStatus returns Response + public static void updateStatus(String ks, String paymentGatewayId, String externalTransactionId, String signature, TransactionStatus transactionStatus) { + UpdateStatusTransactionBuilder updateStatusTransactionBuilder = + TransactionService.updateStatus(paymentGatewayId, externalTransactionId, signature, transactionStatus); + + updateStatusTransactionBuilder.setKs(ks); + TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusTransactionBuilder.build(client)); + } + + // upgrade + public static Response upgrade(String ks, Purchase purchase) { + UpgradeTransactionBuilder upgradeTransactionBuilder = TransactionService.upgrade(purchase) + .setCompletion((ApiCompletion) result -> { + transactionResponse = result; + done.set(true); + }); + + upgradeTransactionBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(upgradeTransactionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return transactionResponse; } + + // validateReceipt + public static Response validateReceipt(String ks, ExternalReceipt externalReceipt) { + ValidateReceiptTransactionBuilder validateReceiptTransactionBuilder = TransactionService.validateReceipt(externalReceipt) + .setCompletion((ApiCompletion) result -> { + transactionResponse = result; + done.set(true); + }); + + validateReceiptTransactionBuilder.setKs(ks); + + TestAPIOkRequestsExecutor.getExecutor().queue(validateReceiptTransactionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return transactionResponse; + } + + // downgrade + // TODO: 4/10/2018 implement downgrade function and check why it returns Response } diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index 52e29dcd7..a2bb05e94 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -1,33 +1,55 @@ package com.kaltura.client.test.tests; +import com.kaltura.client.Client; +import com.kaltura.client.Configuration; import io.restassured.RestAssured; import io.restassured.path.xml.XmlPath; import org.testng.annotations.Test; +import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.tests.BaseTest.client; import static io.restassured.RestAssured.given; public class Sandbox { - String myEnvelope = "QABE - Regular-mainQABE - Regular-mainMovie_180328093854266description of 18032809385426627/03/2018 09:38:5427/03/2018 09:38:5414/10/2099 17:00:0014/10/2099 17:00:00MoviePhilippines OnlyParent Allowedsyno pino sistermeta_value190023/03/2017 12:34:56Costa Rica;IsraelGIHABCDEFShay_SeriesKSQL channel_573349]]>"; - @Test(enabled = false) private void test() { RestAssured.baseURI = "http://34.249.122.223:8030/Ingest_v4_8/Service.svc?wsdl"; + String myEnvelope = "QABE - Regular-mainQABE - Regular-mainMovie_180328093854266description of 18032809385426627/03/2018 09:38:5427/03/2018 09:38:5414/10/2099 17:00:0014/10/2099 17:00:00MoviePhilippines OnlyParent Allowedsyno pino sistermeta_value190023/03/2017 12:34:56Costa Rica;IsraelGIHABCDEFShay_SeriesKSQL channel_573349]]>"; String xml = given() -// .log().all(true) .header("SOAPAction","http://tempuri.org/IService/IngestTvinciData") .contentType("text/xml;charset=UTF-8") .body(myEnvelope) .when() -// .log().all(true) .post() .andReturn() .asString(); int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); - System.out.println("!!! " + "Let me pull"); } + @Test + private void test2() { + Configuration config = new Configuration(); + config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); + config.setAcceptGzipEncoding(false); + + Client client = initClient(config); + + client.setKs("123"); + System.out.println(client.getKs()); + + client = initClient(config); + System.out.println(client.getKs()); + } + + private Client initClient(Configuration config) { + client = new Client(config); + client.setApiVersion(API_REQUEST_VERSION); + return client; + } + + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index 25f90fe1c..83a62a7ff 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -63,7 +63,7 @@ private void add() { bookmarkFilter.setOrderBy("POSITION_ASC"); bookmarkFilter.setAssetTypeEqual(type); - Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs, bookmarkFilter); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); // Assertions diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java new file mode 100644 index 000000000..ac7813e6a --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -0,0 +1,12 @@ +package com.kaltura.client.test.tests.servicesTests.entitlementTests; + +import com.kaltura.client.test.tests.BaseTest; +import org.testng.annotations.Test; + +public class GrantTests extends BaseTest { + + @Test(description = "entitlement/action/grant - grant") + private void grant() { +// EntitlementServiceImpl.grant() + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index af80ca87d..3286a12be 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -29,8 +29,8 @@ private void ottUser_login_tests_setup() { user = ottUserResponse.results; } - @Description("ottUser/action/login - login") - @Test +// @Issue("BEO-4933") + @Test(description = "ottUser/action/login - login") private void login() { loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 8eae84cf6..b237ff06c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -31,7 +31,7 @@ public void beforeClass() { @Description("productPrice/action/list - subscription test by Operator without currency") @Test(enabled = false) // as used in feature tests - public void listSubscriptionTest() { + public void list_subscription() { ProductPriceFilter filter = new ProductPriceFilter(); // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); Response> productPriceList = list(operatorKs, filter, Optional.empty()); @@ -42,7 +42,7 @@ public void listSubscriptionTest() { @Description("productPrice/action/list - without required fields (subscriptionIdIn, collectionIdIn and fileIdIn are empty)") @Test() - public void listWithoutRequiredFieldsTest() { + public void list_without_required_fields() { ProductPriceFilter filter = new ProductPriceFilter(); Response> productPriceResponse = list(operatorKs, filter, Optional.empty()); // TODO: should we create enums for error codes and their messages? A: Yes if library doesn't contain them @@ -54,7 +54,7 @@ public void listWithoutRequiredFieldsTest() { @Description("productPrice/action/list - ppv test") @Test(enabled = false) // as failed - public void ppvTest() { + public void ppv() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ diff --git a/src/test/resources/allure.properties b/src/test/resources/allure.properties index e37bada0f..d9ba0d4a3 100644 --- a/src/test/resources/allure.properties +++ b/src/test/resources/allure.properties @@ -1,3 +1,3 @@ allure.results.directory=target/allure-results -allure.link.issue.pattern=https://example.org/issue/{} +allure.link.issue.pattern=https://kaltura.atlassian.net/browse/{} allure.link.tms.pattern=https://example.org/tms/{} \ No newline at end of file From b776800124cae47ab589600b09e369701beaa868 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 11 Apr 2018 12:03:55 +0300 Subject: [PATCH 060/605] Added hardcoded default PG logic --- .../HouseholdPaymentGatewayServiceImpl.java | 36 +++++++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 2 +- .../client/test/utils/HouseholdUtils.java | 5 ++- .../resources/schemas/PpvEntitlement.json | 2 +- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java new file mode 100644 index 000000000..b2fe91711 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.services.HouseholdPaymentGatewayService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.HouseholdPaymentGatewayService.SetChargeIDHouseholdPaymentGatewayBuilder; +import static com.kaltura.client.test.tests.BaseTest.client; +import static org.awaitility.Awaitility.await; + +public class HouseholdPaymentGatewayServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + private static Response booleanResponse; + + // add + public static Response setChargeId(String ks, String paymentGatewayExternalId, String chargeId, + @Nullable String userId) { + SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = + new HouseholdPaymentGatewayService.SetChargeIDHouseholdPaymentGatewayBuilder(paymentGatewayExternalId, chargeId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + setChargeIDHouseholdPaymentGatewayBuilder.setKs(ks); + setChargeIDHouseholdPaymentGatewayBuilder.setUserId(Integer.valueOf(userId)); + TestAPIOkRequestsExecutor.getExecutor().queue(setChargeIDHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 662ba26e1..2abcd9780 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -74,7 +74,7 @@ public void setup() { } private void initSharedHousehold() { - sharedHousehold = createHouseHold(2, 2, false); + sharedHousehold = createHouseHold(2, 2, true); List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); for (HouseholdUser user : sharedHouseholdUsers) { if (user.getIsMaster() != null && user.getIsMaster()) { diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 0e62f9768..9175a3452 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.servicesImpl.HouseholdDeviceServiceImpl; +import com.kaltura.client.test.servicesImpl.HouseholdPaymentGatewayServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; import com.kaltura.client.types.*; @@ -16,6 +17,7 @@ import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.tests.BaseTest.administratorKs; import static com.kaltura.client.test.tests.BaseTest.client; +import static com.kaltura.client.test.tests.BaseTest.operatorKs; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class HouseholdUtils extends BaseUtils { @@ -62,7 +64,8 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO } if (isPreparePG) { - + // TODO: there should be added logic with getting and using default PG currently it all hardcoded + HouseholdPaymentGatewayServiceImpl.setChargeId(operatorKs, "0110151474255957105", "1234", masterUser.getId()); } return household; diff --git a/src/test/resources/schemas/PpvEntitlement.json b/src/test/resources/schemas/PpvEntitlement.json index 52f1d2249..8528cb568 100644 --- a/src/test/resources/schemas/PpvEntitlement.json +++ b/src/test/resources/schemas/PpvEntitlement.json @@ -97,7 +97,7 @@ "purchaseId", "paymentMethod", "deviceUdid", - "deviceName", + //"deviceName", "isCancelationWindowEnabled", "maxUses", "isRenewable", From 9176b560138576be3dee0efa3a3c49f15ee7d67c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 11 Apr 2018 13:24:14 +0300 Subject: [PATCH 061/605] Client behavior refactor --- .../test/servicesImpl/AssetServiceImpl.java | 10 +-- .../servicesImpl/BookmarkServiceImpl.java | 28 ++++---- .../servicesImpl/EntitlementServiceImpl.java | 31 +++------ .../HouseholdDeviceServiceImpl.java | 5 +- .../servicesImpl/HouseholdServiceImpl.java | 8 +-- .../HouseholdUserServiceImpl.java | 8 +-- .../test/servicesImpl/OttUserServiceImpl.java | 66 ++++++------------- .../servicesImpl/ProductPriceServiceImpl.java | 8 +-- .../servicesImpl/SubscriptionServiceImpl.java | 6 +- .../servicesImpl/TransactionServiceImpl.java | 42 ++++++------ .../servicesImpl/UserLoginPinServiceImpl.java | 23 ++----- .../servicesImpl/UserRoleServiceImpl.java | 5 +- .../kaltura/client/test/tests/BaseTest.java | 37 +++++++---- .../kaltura/client/test/tests/Sandbox.java | 27 -------- .../servicesTests/bookmarkTests/AddTests.java | 9 ++- .../ottUserTests/ActivateTests.java | 11 ++-- .../ottUserTests/AddRoleTests.java | 15 +++-- .../ottUserTests/AnonymousLoginTests.java | 15 ++++- .../ottUserTests/DeleteTests.java | 26 +++++--- .../ottUserTests/GetEncryptedUserIdTests.java | 9 ++- .../servicesTests/ottUserTests/GetTests.java | 12 ++-- .../servicesTests/ottUserTests/ListTests.java | 18 +++-- .../ottUserTests/LoginTests.java | 13 ++-- .../ottUserTests/LoginWithPinTests.java | 20 ++++-- .../ottUserTests/LogoutTests.java | 16 +++-- .../ottUserTests/RegisterTests.java | 5 +- .../ResendActivationTokenTests.java | 11 +++- .../ottUserTests/ResetPasswordTests.java | 11 +++- .../ottUserTests/UpdateDynamicDataTests.java | 25 ++++--- .../ottUserTests/UpdateLoginDataTests.java | 29 +++++--- .../ottUserTests/UpdateTests.java | 30 +++++---- .../productPriceTests/ListTests.java | 23 ++++--- .../client/test/utils/HouseholdUtils.java | 21 +++--- .../client/test/utils/IngestVODUtils.java | 5 +- .../client/test/utils/OttUserUtils.java | 8 ++- .../client/test/utils/PurchaseUtils.java | 15 +++-- 36 files changed, 336 insertions(+), 315 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java index 8212be5ac..c1b17c275 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java @@ -1,14 +1,16 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Asset; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; + import java.util.concurrent.atomic.AtomicBoolean; + import static com.kaltura.client.services.AssetService.GetAssetBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class AssetServiceImpl { @@ -18,15 +20,13 @@ public class AssetServiceImpl { private static Response assetResponse; // list - public static Response get(String ks, String id, AssetReferenceType assetReferenceType) { + public static Response get(Client client, String id, AssetReferenceType assetReferenceType) { GetAssetBuilder assetBuilder = AssetService.get(id, assetReferenceType) .setCompletion((ApiCompletion) result -> { assetResponse = result; done.set(true); }); - assetBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(assetBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java index a0278412a..3edc76fca 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.BookmarkService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.Bookmark; @@ -13,7 +14,6 @@ import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.ListBookmarkBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class BookmarkServiceImpl { @@ -24,13 +24,12 @@ public class BookmarkServiceImpl { // Bookmark/action/add - public static Response add(String ks, Bookmark bookmark) { - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - addBookmarkBuilder.setKs(ks); + public static Response add(Client client, Bookmark bookmark) { + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); TestAPIOkRequestsExecutor.getExecutor().queue(addBookmarkBuilder.build(client)); await().untilTrue(done); @@ -40,13 +39,12 @@ public static Response add(String ks, Bookmark bookmark) { } // Bookmark/action/list - public static Response> list (String ks, BookmarkFilter bookmarkFilter) { - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setCompletion((ApiCompletion>) result -> { - bookmarkListResponse = result; - done.set(true); - }); - - listBookmarkBuilder.setKs(ks); + public static Response> list(Client client, BookmarkFilter bookmarkFilter) { + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter) + .setCompletion((ApiCompletion>) result -> { + bookmarkListResponse = result; + done.set(true); + }); TestAPIOkRequestsExecutor.getExecutor().queue(listBookmarkBuilder.build(client)); await().untilTrue(done); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java index e86c06a69..544040efd 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.enums.TransactionType; import com.kaltura.client.services.EntitlementService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; @@ -11,8 +12,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.EntitlementService.*; -import static com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class EntitlementServiceImpl { @@ -25,15 +24,13 @@ public class EntitlementServiceImpl { private static Response entitlementResponse; // list - public static Response> list(String ks, EntitlementFilter filter, @Nullable FilterPager pager) { + public static Response> list(Client client, EntitlementFilter filter, @Nullable FilterPager pager) { ListEntitlementBuilder productPriceBuilder = EntitlementService.list(filter, pager) .setCompletion((ApiCompletion>) result -> { entitlementListResponse = result; done.set(true); }); - productPriceBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -42,14 +39,13 @@ public static Response> list(String ks, EntitlementFil } // cancel - public static Response cancel(String ks, int assetId, TransactionType transactionType) { + public static Response cancel(Client client, int assetId, TransactionType transactionType) { CancelEntitlementBuilder cancelEntitlementBuilder = EntitlementService.cancel(assetId, transactionType) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - cancelEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(cancelEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -58,7 +54,7 @@ public static Response cancel(String ks, int assetId, TransactionType t } // cancelScheduledSubscription - public static Response cancelScheduledSubscription(String ks, long scheduledSubscriptionId) { + public static Response cancelScheduledSubscription(Client client, long scheduledSubscriptionId) { CancelScheduledSubscriptionEntitlementBuilder cancelScheduledSubscriptionEntitlementBuilder = EntitlementService.cancelScheduledSubscription(scheduledSubscriptionId) .setCompletion((ApiCompletion) result -> { @@ -66,7 +62,6 @@ public static Response cancelScheduledSubscription(String ks, long sche done.set(true); }); - cancelScheduledSubscriptionEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(cancelScheduledSubscriptionEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -75,7 +70,7 @@ public static Response cancelScheduledSubscription(String ks, long sche } // externalReconcile - public static Response externalReconcile(String ks) { + public static Response externalReconcile(Client client) { ExternalReconcileEntitlementBuilder externalReconcileEntitlementBuilder = EntitlementService.externalReconcile() .setCompletion((ApiCompletion) result -> { @@ -83,7 +78,6 @@ public static Response externalReconcile(String ks) { done.set(true); }); - externalReconcileEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(externalReconcileEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -92,14 +86,13 @@ public static Response externalReconcile(String ks) { } // forceCancel - public static Response forceCancel(String ks, int assetId, TransactionType transactionType) { + public static Response forceCancel(Client client, int assetId, TransactionType transactionType) { ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel(assetId, transactionType) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - forceCancelEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(forceCancelEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -108,14 +101,13 @@ public static Response forceCancel(String ks, int assetId, TransactionT } // getNextRenewal - public static Response getNextRenewal(String ks, int id) { + public static Response getNextRenewal(Client client, int id) { GetNextRenewalEntitlementBuilder getNextRenewalEntitlementBuilder = EntitlementService.getNextRenewal(id) .setCompletion((ApiCompletion) result -> { entitlementRenewalResponse = result; done.set(true); }); - getNextRenewalEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(getNextRenewalEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -124,14 +116,13 @@ public static Response getNextRenewal(String ks, int id) { } // grant - public static Response grant(String ks, int productId, TransactionType transactionType, boolean history, @Nullable int contentId) { + public static Response grant(Client client, int productId, TransactionType transactionType, boolean history, @Nullable int contentId) { GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(productId, transactionType, history, contentId) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - grantEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(grantEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -140,14 +131,13 @@ public static Response grant(String ks, int productId, TransactionType } // swap - public static Response swap(String ks, int currentProductId, int newProductId, boolean history) { + public static Response swap(Client client, int currentProductId, int newProductId, boolean history) { SwapEntitlementBuilder swapEntitlementBuilder = EntitlementService.swap(currentProductId, newProductId, history) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - swapEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(swapEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -156,14 +146,13 @@ public static Response swap(String ks, int currentProductId, int newPro } // update - public static Response update(String ks, int id, Entitlement entitlement) { + public static Response update(Client client, int id, Entitlement entitlement) { UpdateEntitlementBuilder updateEntitlementBuilder = EntitlementService.update(id, entitlement) .setCompletion((ApiCompletion) result -> { entitlementResponse = result; done.set(true); }); - updateEntitlementBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(updateEntitlementBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index 738a50534..cf08969c8 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.HouseholdDeviceService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.HouseholdDevice; @@ -9,7 +10,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.HouseholdDeviceService.AddHouseholdDeviceBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class HouseholdDeviceServiceImpl { @@ -20,14 +20,13 @@ public class HouseholdDeviceServiceImpl { // add - public static Response add(String ks, HouseholdDevice householdDevice) { + public static Response add(Client client, HouseholdDevice householdDevice) { AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice) .setCompletion((ApiCompletion) result -> { householdDeviceResponse = result; done.set(true); }); - addHouseholdDeviceBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdDeviceBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 164d81699..1ebf12ecb 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.Household; @@ -11,7 +12,6 @@ import static com.kaltura.client.services.HouseholdService.AddHouseholdBuilder; import static com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class HouseholdServiceImpl { @@ -23,14 +23,13 @@ public class HouseholdServiceImpl { // add - public static Response add(String ks, Household household) { + public static Response add(Client client, Household household) { AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household) .setCompletion((ApiCompletion) result -> { householdResponse = result; done.set(true); }); - addHouseholdBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -39,14 +38,13 @@ public static Response add(String ks, Household household) { } // delete - public static Response delete(String ks, @Nullable int householdId) { + public static Response delete(Client client, @Nullable int householdId) { DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(householdId) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - deleteHouseholdBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(deleteHouseholdBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index 72e3de0fd..9787c8bf3 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.HouseholdUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.HouseholdUser; @@ -13,7 +14,6 @@ import static com.kaltura.client.services.HouseholdUserService.AddHouseholdUserBuilder; import static com.kaltura.client.services.HouseholdUserService.ListHouseholdUserBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class HouseholdUserServiceImpl { @@ -25,14 +25,13 @@ public class HouseholdUserServiceImpl { // add - public static Response add(String ks, HouseholdUser householdUser) { + public static Response add(Client client, HouseholdUser householdUser) { AddHouseholdUserBuilder addHouseholdUserBuilder = HouseholdUserService.add(householdUser) .setCompletion((ApiCompletion) result -> { householdUserResponse = result; done.set(true); }); - addHouseholdUserBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -41,14 +40,13 @@ public static Response add(String ks, HouseholdUser householdUser } // list - public static Response> list(String ks, @Nullable HouseholdUserFilter householdUserFilter) { + public static Response> list(Client client, @Nullable HouseholdUserFilter householdUserFilter) { ListHouseholdUserBuilder listHouseholdUserBuilder = HouseholdUserService.list(householdUserFilter) .setCompletion((ApiCompletion>) result -> { householdUserListResponse = result; done.set(true); }); - listHouseholdUserBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdUserBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java index d4b19326e..99d579172 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.*; @@ -8,11 +9,9 @@ import javax.annotation.Nullable; import java.util.Map; -import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class OttUserServiceImpl { @@ -29,7 +28,7 @@ public class OttUserServiceImpl { // activate - public static Response activate(int partnerId, String username, String activationToken) { + public static Response activate(Client client, int partnerId, String username, String activationToken) { ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, username, activationToken) .setCompletion((ApiCompletion) result -> { ottUserResponse = result; @@ -44,16 +43,13 @@ public static Response activate(int partnerId, String username, String } // addRole - public static Response addRole(String ks, Optional userId, int roleId) { + public static Response addRole(Client client, int roleId) { AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(roleId) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - addRoleOttUserBuilder.setKs(ks); - userId.ifPresent(addRoleOttUserBuilder::setUserId); - TestAPIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -62,7 +58,7 @@ public static Response addRole(String ks, Optional userId, int } // anonymousLogin - public static Response anonymousLogin(int partnerId, @Nullable String udid) { + public static Response anonymousLogin(Client client, int partnerId, @Nullable String udid) { AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid) .setCompletion((ApiCompletion) result -> { loginSessionResponse = result; @@ -77,16 +73,13 @@ public static Response anonymousLogin(int partnerId, @Nullable Str } // delete - public static Response delete(String ks, Optional userId) { + public static Response delete(Client client) { DeleteOttUserBuilder deleteOttUserBuilder = OttUserService.delete() .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - deleteOttUserBuilder.setKs(ks); - userId.ifPresent(deleteOttUserBuilder::setUserId); - TestAPIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -95,16 +88,13 @@ public static Response delete(String ks, Optional userId) { } // get - public static Response get(String ks, Optional userId) { + public static Response get(Client client) { GetOttUserBuilder getOttUserBuilder = OttUserService.get() .setCompletion((ApiCompletion) result -> { ottUserResponse = result; done.set(true); }); - getOttUserBuilder.setKs(ks); - userId.ifPresent(getOttUserBuilder::setUserId); - TestAPIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -113,16 +103,13 @@ public static Response get(String ks, Optional userId) { } // getEncryptedUserId - public static Response getEncryptedUserId(String ks, int userId) { + public static Response getEncryptedUserId(Client client) { GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = OttUserService.getEncryptedUserId() .setCompletion((ApiCompletion) result -> { stringValueResponse = result; done.set(true); }); - getEncryptedUserIdOttUserBuilder.setKs(ks); - getEncryptedUserIdOttUserBuilder.setUserId(userId); - TestAPIOkRequestsExecutor.getExecutor().queue(getEncryptedUserIdOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -131,14 +118,13 @@ public static Response getEncryptedUserId(String ks, int userId) { } // list - public static Response> list(String ks, @Nullable OTTUserFilter ottUserFilter) { + public static Response> list(Client client, @Nullable OTTUserFilter ottUserFilter) { ListOttUserBuilder listOttUserBuilder = OttUserService.list(ottUserFilter) .setCompletion((ApiCompletion>) result -> { ottUserListResponse = result; done.set(true); }); - listOttUserBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -147,7 +133,8 @@ public static Response> list(String ks, @Nullable OTTUserF } // login - public static Response login(int partnerId, String username, String password, @Nullable Map extraParams, @Nullable String udid) { + public static Response login(Client client, int partnerId, @Nullable String username, @Nullable String password, + @Nullable Map extraParams, @Nullable String udid) { LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, username, password, extraParams, udid) .setCompletion((ApiCompletion) result -> { loginResponse = result; @@ -162,7 +149,7 @@ public static Response login(int partnerId, String username, Stri } // loginWithPin - public static Response loginWithPin(int partnerId, String pin, @Nullable String udid, String secret) { + public static Response loginWithPin(Client client, int partnerId, String pin, @Nullable String udid, String secret) { LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = OttUserService.loginWithPin(partnerId, pin, udid, secret) .setCompletion((ApiCompletion) result -> { @@ -178,16 +165,13 @@ public static Response loginWithPin(int partnerId, String pin, @N } // logout - public static Response logout(String ks, Optional userId) { + public static Response logout(Client client) { LogoutOttUserBuilder logoutOttUserBuilder = OttUserService.logout() .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - logoutOttUserBuilder.setKs(ks); - userId.ifPresent(logoutOttUserBuilder::setUserId); - TestAPIOkRequestsExecutor.getExecutor().queue(logoutOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -196,7 +180,7 @@ public static Response logout(String ks, Optional userId) { } // register - public static Response register(int partnerId, OTTUser user, String password) { + public static Response register(Client client, int partnerId, OTTUser user, String password) { RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, password) .setCompletion((ApiCompletion) result -> { ottUserResponse = result; @@ -211,7 +195,7 @@ public static Response register(int partnerId, OTTUser user, String pas } // resendActivationToken - public static Response resendActivationToken(int partnerId, String username) { + public static Response resendActivationToken(Client client, int partnerId, String username) { ResendActivationTokenOttUserBuilder resendActivationTokenOttUserBuilder = OttUserService.resendActivationToken(partnerId, username) .setCompletion((ApiCompletion) result -> { booleanResponse = result; @@ -226,14 +210,13 @@ public static Response resendActivationToken(int partnerId, String user } // resetPassword - public static Response resetPassword(int partnerId, String ks, String username) { + public static Response resetPassword(Client client, int partnerId, String username) { ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, username) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - resetPasswordOttUserBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(resetPasswordOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -242,7 +225,7 @@ public static Response resetPassword(int partnerId, String ks, String u } // setInitialPassword - public static Response setInitialPassword(int partnerId, String token, String password) { + public static Response setInitialPassword(Client client, int partnerId, String token, String password) { SetInitialPasswordOttUserBuilder setInitialPasswordOttUserBuilder = OttUserService.setInitialPassword(partnerId, token, password) .setCompletion((ApiCompletion) result -> { ottUserResponse = result; @@ -257,15 +240,13 @@ public static Response setInitialPassword(int partnerId, String token, } // update - public static Response update(String ks, OTTUser user, @Nullable String id) { + public static Response update(Client client, OTTUser user, @Nullable String id) { UpdateOttUserBuilder updateOttUserBuilder = OttUserService.update(user, id) .setCompletion((ApiCompletion) result -> { ottUserResponse = result; done.set(true); }); - updateOttUserBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(updateOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -274,16 +255,13 @@ public static Response update(String ks, OTTUser user, @Nullable String } // updateDynamicData - public static Response updateDynamicData(String ks, Optional userId, String key, StringValue value) { + public static Response updateDynamicData(Client client, String key, StringValue value) { UpdateDynamicDataOttUserBuilder updateDynamicDataOttUserBuilder = OttUserService.updateDynamicData(key, value) .setCompletion((ApiCompletion) result -> { ottUserDynamicDataResponse = result; done.set(true); }); - updateDynamicDataOttUserBuilder.setKs(ks); - userId.ifPresent(updateDynamicDataOttUserBuilder::setUserId); - TestAPIOkRequestsExecutor.getExecutor().queue(updateDynamicDataOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -292,15 +270,13 @@ public static Response updateDynamicData(String ks, Optional } // updateLoginData - public static Response updateLoginData(String ks, String username, String oldPassword, String newPassword) { + public static Response updateLoginData(Client client, String username, String oldPassword, String newPassword) { UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(username, oldPassword, newPassword) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - updateLoginDataOttUserBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(updateLoginDataOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -309,15 +285,13 @@ public static Response updateLoginData(String ks, String username, Stri } // updatePassword - public static Response updatePassword(String ks, int partnerId, String username) { + public static Response updatePassword(Client client, int partnerId, String username) { ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, username) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - resetPasswordOttUserBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(resetPasswordOttUserBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java index 9ca53c7c6..3235362a1 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.ListResponse; @@ -8,11 +9,9 @@ import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; -import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class ProductPriceServiceImpl { @@ -22,16 +21,13 @@ public class ProductPriceServiceImpl { private static Response> productPriceResponse; // list - public static Response> list(String ks, ProductPriceFilter filter, Optional currency) { + public static Response> list(Client client, ProductPriceFilter filter) { ListProductPriceBuilder productPriceBuilder = ProductPriceService.list(filter) .setCompletion((ApiCompletion>) result -> { productPriceResponse = result; done.set(true); }); - productPriceBuilder.setKs(ks); - currency.ifPresent(productPriceBuilder::setCurrency); - TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java index 4b549c788..3083726c8 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.ListResponse; @@ -11,7 +12,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class SubscriptionServiceImpl { @@ -21,15 +21,13 @@ public class SubscriptionServiceImpl { private static Response> subscriptionListResponse; // list - public static Response> list(String ks, SubscriptionFilter subscriptionFilter) { + public static Response> list(Client client, SubscriptionFilter subscriptionFilter) { ListSubscriptionBuilder listSubscriptionBuilder = SubscriptionService.list(subscriptionFilter) .setCompletion((ApiCompletion>) result -> { subscriptionListResponse = result; done.set(true); }); - listSubscriptionBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(listSubscriptionBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java index 968f252e7..6cbb23665 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.enums.TransactionType; import com.kaltura.client.services.TransactionService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; @@ -10,8 +11,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.TransactionService.*; -import static com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class TransactionServiceImpl { @@ -23,15 +22,13 @@ public class TransactionServiceImpl { private static Response booleanResponse; // purchase - public static Response purchase(String ks, Purchase purchase) { + public static Response purchase(Client client, Purchase purchase) { PurchaseTransactionBuilder purchaseBuilder = TransactionService.purchase(purchase) .setCompletion((ApiCompletion) result -> { transactionResponse = result; done.set(true); }); - purchaseBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(purchaseBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -40,7 +37,7 @@ public static Response purchase(String ks, Purchase purchase) { } // getPurchaseSessionId - public static Response getPurchaseSessionId(String ks, PurchaseSession purchaseSession) { + public static Response getPurchaseSessionId(Client client, PurchaseSession purchaseSession) { GetPurchaseSessionIdTransactionBuilder getPurchaseSessionIdTransactionBuilder = TransactionService.getPurchaseSessionId(purchaseSession) .setCompletion((ApiCompletion) result -> { @@ -48,8 +45,6 @@ public static Response getPurchaseSessionId(String ks, PurchaseSession pur done.set(true); }); - getPurchaseSessionIdTransactionBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(getPurchaseSessionIdTransactionBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -58,15 +53,13 @@ public static Response getPurchaseSessionId(String ks, PurchaseSession pur } // setWaiver - public static Response setWaiver(String ks, int assetId, TransactionType transactionType) { + public static Response setWaiver(Client client, int assetId, TransactionType transactionType) { SetWaiverTransactionBuilder setWaiverTransactionBuilder = TransactionService.setWaiver(assetId, transactionType) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - setWaiverTransactionBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(setWaiverTransactionBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -75,25 +68,23 @@ public static Response setWaiver(String ks, int assetId, TransactionTyp } // updateStatus - // TODO: 4/10/2018 check why updateStatus returns Response - public static void updateStatus(String ks, String paymentGatewayId, String externalTransactionId, String signature, TransactionStatus transactionStatus) { - UpdateStatusTransactionBuilder updateStatusTransactionBuilder = - TransactionService.updateStatus(paymentGatewayId, externalTransactionId, signature, transactionStatus); + public static void updateStatus(Client client, String paymentGatewayId, String externalTransactionId, String signature, TransactionStatus transactionStatus) { + UpdateStatusTransactionBuilder updateStatusTransactionBuilder = TransactionService.updateStatus(paymentGatewayId, externalTransactionId, signature, transactionStatus); + updateStatusTransactionBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - updateStatusTransactionBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusTransactionBuilder.build(client)); + await().untilTrue(done); + done.set(false); } // upgrade - public static Response upgrade(String ks, Purchase purchase) { + public static Response upgrade(Client client, Purchase purchase) { UpgradeTransactionBuilder upgradeTransactionBuilder = TransactionService.upgrade(purchase) .setCompletion((ApiCompletion) result -> { transactionResponse = result; done.set(true); }); - upgradeTransactionBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(upgradeTransactionBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -102,15 +93,13 @@ public static Response upgrade(String ks, Purchase purchase) { } // validateReceipt - public static Response validateReceipt(String ks, ExternalReceipt externalReceipt) { + public static Response validateReceipt(Client client, ExternalReceipt externalReceipt) { ValidateReceiptTransactionBuilder validateReceiptTransactionBuilder = TransactionService.validateReceipt(externalReceipt) .setCompletion((ApiCompletion) result -> { transactionResponse = result; done.set(true); }); - validateReceiptTransactionBuilder.setKs(ks); - TestAPIOkRequestsExecutor.getExecutor().queue(validateReceiptTransactionBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -119,7 +108,14 @@ public static Response validateReceipt(String ks, ExternalReceipt e } // downgrade - // TODO: 4/10/2018 implement downgrade function and check why it returns Response + public static void downgrade(Client client, Purchase purchase) { + DowngradeTransactionBuilder downgradeTransactionBuilder = TransactionService.downgrade(purchase); + downgradeTransactionBuilder.setCompletion((ApiCompletion) result -> done.set(true)); + + TestAPIOkRequestsExecutor.getExecutor().queue(downgradeTransactionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java index 34a80559d..8732c9e17 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.UserLoginPinService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.UserLoginPin; @@ -10,8 +11,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.UserLoginPinService.*; -import static com.kaltura.client.services.UserLoginPinService.AddUserLoginPinBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class UserLoginPinServiceImpl { @@ -22,16 +21,13 @@ public class UserLoginPinServiceImpl { private static Response booleanResponse; // add - public static Response add(String ks, int userId, @Nullable String secret) { + public static Response add(Client client, @Nullable String secret) { AddUserLoginPinBuilder addUserLoginPinBuilder = UserLoginPinService.add(secret) .setCompletion((ApiCompletion) result -> { userLoginPinResponse = result; done.set(true); }); - addUserLoginPinBuilder.setKs(ks); - addUserLoginPinBuilder.setUserId(userId); - TestAPIOkRequestsExecutor.getExecutor().queue(addUserLoginPinBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -40,16 +36,13 @@ public static Response add(String ks, int userId, @Nullable String } // delete - public static Response delete(String ks, int userId, String pinCode) { + public static Response delete(Client client, String pinCode) { DeleteUserLoginPinBuilder deleteUserLoginPinBuilder = UserLoginPinService.delete(pinCode) .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - deleteUserLoginPinBuilder.setKs(ks); - deleteUserLoginPinBuilder.setUserId(userId); - TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserLoginPinBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -58,16 +51,13 @@ public static Response delete(String ks, int userId, String pinCode) { } // deleteAll - public static Response deleteAll(String ks, int userId) { + public static Response deleteAll(Client client) { DeleteAllUserLoginPinBuilder deleteAllUserLoginPinBuilder = UserLoginPinService.deleteAll() .setCompletion((ApiCompletion) result -> { booleanResponse = result; done.set(true); }); - deleteAllUserLoginPinBuilder.setKs(ks); - deleteAllUserLoginPinBuilder.setUserId(userId); - TestAPIOkRequestsExecutor.getExecutor().queue(deleteAllUserLoginPinBuilder.build(client)); await().untilTrue(done); done.set(false); @@ -76,16 +66,13 @@ public static Response deleteAll(String ks, int userId) { } // update - public static Response update(String ks, int userId, String secret, String pinCode) { + public static Response update(Client client, String pinCode, @Nullable String secret) { UpdateUserLoginPinBuilder updateUserLoginPinBuilder = UserLoginPinService.update(pinCode, secret) .setCompletion((ApiCompletion) result -> { userLoginPinResponse = result; done.set(true); }); - updateUserLoginPinBuilder.setKs(ks); - updateUserLoginPinBuilder.setUserId(userId); - TestAPIOkRequestsExecutor.getExecutor().queue(updateUserLoginPinBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java index 0867255b0..86ee6932e 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.servicesImpl; +import com.kaltura.client.Client; import com.kaltura.client.services.UserRoleService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.ListResponse; @@ -12,7 +13,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.UserRoleService.ListUserRoleBuilder; -import static com.kaltura.client.test.tests.BaseTest.client; import static org.awaitility.Awaitility.await; public class UserRoleServiceImpl { @@ -22,14 +22,13 @@ public class UserRoleServiceImpl { private static Response> userRoleListResponse; //list - public static Response> list(String ks, @Nullable UserRoleFilter filter) { + public static Response> list(Client client, @Nullable UserRoleFilter filter) { ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(filter) .setCompletion((ApiCompletion>) result -> { userRoleListResponse = result; done.set(true); }); - listUserRoleBuilder.setKs(ks); TestAPIOkRequestsExecutor.getExecutor().queue(listUserRoleBuilder.build(client)); await().untilTrue(done); done.set(false); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 662ba26e1..c9a65c443 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -22,7 +22,9 @@ public class BaseTest { - public static Client client; + private static Client client; + private static Configuration config; + private Response loginResponse; private Response loginSession; @@ -37,30 +39,31 @@ public class BaseTest { public static MediaAsset mediaAsset; @BeforeSuite - public void setup() { + public void base_test_before_suite() { Logger.getLogger(BaseTest.class).debug("Start Setup!"); - // Set client - Configuration config = new Configuration(); + // set configuration + config = new Configuration(); config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); config.setAcceptGzipEncoding(false); - client = new Client(config); - client.setApiVersion(API_REQUEST_VERSION); + + // set client + client = getClient(null); // Set default awaitility timeout setDefaultTimeout(20, TimeUnit.SECONDS); // Login with shared users - loginResponse = login(PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); + loginResponse = login(client, PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); administratorKs = loginResponse.results.getLoginSession().getKs(); - loginResponse = login(PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); + loginResponse = login(client, PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); operatorKs = loginResponse.results.getLoginSession().getKs(); // loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); // managerKs = loginResponse.results.getLoginSession().getKs(); - loginSession = anonymousLogin(PARTNER_ID, null); + loginSession = anonymousLogin(client, PARTNER_ID, null); anonymousKs = loginSession.results.getKs(); // Set project shared HH and users @@ -85,10 +88,22 @@ private void initSharedHousehold() { } } - loginResponse = login(PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedMasterUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); + loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedMasterUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - loginResponse = login(PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); + loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } + + public static Client getClient(String ks) { + client = new Client(config); + client.setApiVersion(API_REQUEST_VERSION); + client.setKs(ks); + return client; + } + +// @AfterTest +// public void base_test_after_test() { +// +// } } diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index a2bb05e94..797263f27 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -1,13 +1,9 @@ package com.kaltura.client.test.tests; -import com.kaltura.client.Client; -import com.kaltura.client.Configuration; import io.restassured.RestAssured; import io.restassured.path.xml.XmlPath; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.client; import static io.restassured.RestAssured.given; public class Sandbox { @@ -29,27 +25,4 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); } - - @Test - private void test2() { - Configuration config = new Configuration(); - config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); - config.setAcceptGzipEncoding(false); - - Client client = initClient(config); - - client.setKs("123"); - System.out.println(client.getKs()); - - client = initClient(config); - System.out.println(client.getKs()); - } - - private Client initClient(Configuration config) { - client = new Client(config); - client.setApiVersion(API_REQUEST_VERSION); - return client; - } - - } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index 83a62a7ff..4a26151c5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; +import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; @@ -18,6 +19,7 @@ public class AddTests extends BaseTest { + private Client client; private long assetId; private AssetType type; private int fileId; @@ -26,11 +28,12 @@ public class AddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { + client = getClient(sharedMasterUserKs); assetId = mediaAsset.getId(); type = AssetType.get("MEDIA"); AssetReferenceType assetReferenceType = AssetReferenceType.get("MEDIA"); - Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs,String.valueOf(assetId),assetReferenceType); + Response assetResponse = AssetServiceImpl.get(client,String.valueOf(assetId),assetReferenceType); fileId = assetResponse.results.getMediaFiles().get(0).getId(); actionType = BookmarkActionType.get("FIRST_PLAY"); } @@ -54,7 +57,7 @@ private void add() { bookmark.setPlayerData(playerData); - Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); @@ -63,7 +66,7 @@ private void add() { bookmarkFilter.setOrderBy("POSITION_ASC"); bookmarkFilter.setAssetTypeEqual(type); - Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs, bookmarkFilter); + Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); // Assertions diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index d04012d38..16f123073 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -1,10 +1,10 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.enums.UserState; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.DBUtils; -import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -20,14 +20,17 @@ public class ActivateTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @BeforeClass private void ottUser_activate_tests_setup() { + client = getClient(null); user = generateOttUser(); - register(PARTNER_ID, user, password); - login(PARTNER_ID, user.getUsername(), password, null, null); + + register(client, PARTNER_ID, user, password); + login(client, PARTNER_ID, user.getUsername(), password, null, null); } @Description("ottUser/action/activate - activate") @@ -35,7 +38,7 @@ private void ottUser_activate_tests_setup() { private void activate() { String activationToken = DBUtils.getActivationToken(user.getUsername()); - Response ottUserResponse = OttUserServiceImpl.activate(PARTNER_ID, user.getUsername(),activationToken); + Response ottUserResponse = OttUserServiceImpl.activate(client, PARTNER_ID, user.getUsername(),activationToken); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index 01bd687c0..968fe1d95 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.servicesImpl.UserRoleServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -13,7 +14,6 @@ import org.testng.annotations.Test; import java.util.List; -import java.util.Optional; import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; @@ -22,12 +22,14 @@ public class AddRoleTests extends BaseTest { + private Client client; private OTTUser user; @BeforeClass private void ottUser_addRole_tests_setup() { + client = getClient(null); user = generateOttUser(); - Response ottUserResponse = register(PARTNER_ID, user, GLOBAL_USER_PASSWORD); + Response ottUserResponse = register(client, PARTNER_ID, user, GLOBAL_USER_PASSWORD); user = ottUserResponse.results; } @@ -35,12 +37,17 @@ private void ottUser_addRole_tests_setup() { @Test(enabled = false) // TODO: 3/27/2018 finish and fix test private void addRole() { - OttUserServiceImpl.addRole(administratorKs, Optional.of(Integer.valueOf(user.getId())), 3); + // set client + client.setKs(administratorKs); + client.setUserId(Integer.valueOf(user.getId())); + + OttUserServiceImpl.addRole(client, 3); UserRoleFilter filter = new UserRoleFilter(); filter.setIdIn(user.getId()); - Response> userRoleListResponse = UserRoleServiceImpl.list(administratorKs, filter); + client.setUserId(null); + Response> userRoleListResponse = UserRoleServiceImpl.list(client, filter); List userRoles = userRoleListResponse.results.getObjects(); for (UserRole userRole : userRoles) { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 325b8f540..90ae97387 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -1,22 +1,31 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginSession; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class AnonymousLoginTests extends BaseTest { + private Client client; + + @BeforeClass + private void ottUser_anonymousLogin_tests_setup() { + client = getClient(null); + } + @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() private void anonymousLogin() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(PARTNER_ID, null); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, PARTNER_ID, null); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); @@ -25,7 +34,7 @@ private void anonymousLogin() { @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") @Test() private void anonymousLogin_with_wrong_partnerId() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(PARTNER_ID + 1, null); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, PARTNER_ID + 1, null); assertThat(loginSessionResponse.results).isNull(); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index d03fc70d4..19f7f24b3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -13,8 +14,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.get; @@ -27,44 +26,51 @@ public class DeleteTests extends BaseTest { + private Client client; private Household household; private Response booleanResponse; @BeforeClass private void ottUser_delete_tests_setup() { + client = getClient(administratorKs); household = HouseholdUtils.createHouseHold(2, 0, false); } @Description("ottUser/action/delete - delete") @Test private void delete() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); OTTUser user = ottUserResponse.results; - Response booleanResponse = OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(user.getId()))); + client.setUserId(Integer.valueOf(user.getId())); + Response booleanResponse = OttUserServiceImpl.delete(client); boolean result = booleanResponse.results; assertThat(result).isTrue(); - ottUserResponse = get(administratorKs, Optional.of(Integer.valueOf(user.getId()))); + ottUserResponse = get(client); assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); assertThat(ottUserResponse.results).isNull(); } - @Description("ottUser/action/delete - delete master user") + @Description("ottUser/action/delete - delete master user: error 2031") @Test(enabled = true) private void delete_master_user() { HouseholdUser masterUser = getMasterUserFromHousehold(household); - booleanResponse = OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(masterUser.getUserId()))); + + client.setUserId(Integer.valueOf(masterUser.getUserId())); + booleanResponse = OttUserServiceImpl.delete(client); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2031).getCode()); } - @Description("ottUser/action/delete - delete default user") + @Description("ottUser/action/delete - delete default user: error 2030") @Test(enabled = true) private void delete_default_user() { HouseholdUser defaultUser = getDefaultUserFromHousehold(household); - booleanResponse = OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(defaultUser.getUserId()))); + + client.setUserId(Integer.valueOf(defaultUser.getUserId())); + booleanResponse = OttUserServiceImpl.delete(client); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2030).getCode()); @@ -72,7 +78,7 @@ private void delete_default_user() { @AfterClass private void ottUser_delete_tests_tearDown() { - HouseholdServiceImpl.delete(administratorKs, Math.toIntExact(household.getId())); + HouseholdServiceImpl.delete(client, Math.toIntExact(household.getId())); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java index 5345173ad..7ce59af48 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; @@ -17,6 +18,7 @@ public class GetEncryptedUserIdTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @@ -24,14 +26,17 @@ public class GetEncryptedUserIdTests extends BaseTest { @BeforeClass private void ottUser_getEncryptedUserId_tests_setup() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); user = ottUserResponse.results; } @Description("ottUser/action/getEncryptedUserId - getEncryptedUserId") @Test private void getEncryptedUserId() { - stringValueResponse = OttUserServiceImpl.getEncryptedUserId(administratorKs, Integer.parseInt(user.getId())); + client.setKs(administratorKs); + client.setUserId(Integer.parseInt(user.getId())); + stringValueResponse = OttUserServiceImpl.getEncryptedUserId(client); assertThat(stringValueResponse.error).isNull(); assertThat(stringValueResponse.results.getValue()).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 5e34d00b5..7d7aa1ed7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; @@ -9,8 +10,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; @@ -20,6 +19,7 @@ public class GetTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @@ -28,18 +28,20 @@ public class GetTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { - ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); user = ottUserResponse.results; - loginResponse = login(PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = login(client, PARTNER_ID, user.getUsername(), password, null, null); user = loginResponse.results.getUser(); + client.setKs(loginResponse.results.getLoginSession().getKs()); } // get tests @Description("ottUser/action/get - get") @Test private void get() { - ottUserResponse = OttUserServiceImpl.get(loginResponse.results.getLoginSession().getKs(), Optional.empty()); + ottUserResponse = OttUserServiceImpl.get(client); assertThat(loginResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index 2a12e17ec..eb9a89c11 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; @@ -22,12 +23,14 @@ public class ListTests extends BaseTest { + private Client client; private Household household; private int numberOfUsersInHousehold = 4; private Response> householdUserListResponse; @BeforeClass private void ottUser_list_tests_setup() { + client = getClient(null); household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, 1, false); } @@ -36,11 +39,11 @@ private void ottUser_list_tests_setup() { private void list_from_master_ks() { HouseholdUser masterUser = getMasterUserFromHousehold(household); - Response loginResponse = login(PARTNER_ID, getUserNameFromId(Integer.parseInt(masterUser.getUserId())), + Response loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(masterUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); - String masterUserKs = loginResponse.results.getLoginSession().getKs(); - householdUserListResponse = list(masterUserKs, null); + client.setKs(loginResponse.results.getLoginSession().getKs()); + householdUserListResponse = list(client, null); List users = householdUserListResponse.results.getObjects(); assertThat(loginResponse.error).isNull(); @@ -56,7 +59,8 @@ private void list_with_filter_idIn() { String idIn = householdUsers.get(0).getUserId() + "," + householdUsers.get(1).getUserId(); filter.setIdIn(idIn); - householdUserListResponse = list(administratorKs, filter); + client.setKs(administratorKs); + householdUserListResponse = list(client, filter); List users = householdUserListResponse.results.getObjects(); assertThat(householdUserListResponse.error).isNull(); @@ -73,7 +77,8 @@ private void list_withd_filter_usernameEqual() { filter.setUsernameEqual(usernameEqual); - householdUserListResponse = list(administratorKs, filter); + client.setKs(administratorKs); + householdUserListResponse = list(client, filter); List users = householdUserListResponse.results.getObjects(); assertThat(householdUserListResponse.error).isNull(); @@ -89,7 +94,8 @@ private void list_with_not_valid_filter() { filter.setIdIn(householdUsers.get(0).getUserId()); filter.setUsernameEqual(getUserNameFromId(Integer.valueOf(householdUsers.get(1).getUserId()))); - householdUserListResponse = list(administratorKs, filter); + client.setKs(administratorKs); + householdUserListResponse = list(client, filter); assertThat(householdUserListResponse.results).isNull(); assertThat(householdUserListResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500038).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 3286a12be..083884a59 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; @@ -18,6 +19,7 @@ public class LoginTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @@ -25,14 +27,15 @@ public class LoginTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); user = ottUserResponse.results; } // @Issue("BEO-4933") @Test(description = "ottUser/action/login - login") private void login() { - loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); @@ -42,7 +45,7 @@ private void login() { @Description("ottUser/action/login - login with wrong password - error 1011") @Test private void login_with_wrong_password() { - loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password + "1", null, null); + loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password + "1", null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); @@ -51,7 +54,7 @@ private void login_with_wrong_password() { @Description("ottUser/action/login - login with wrong username - error 2000") @Test private void login_with_wrong_username() { - loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername() + "1", password, null, null); + loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername() + "1", password, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); @@ -60,7 +63,7 @@ private void login_with_wrong_username() { @Description("ottUser/action/login - login with wrong partnerId - error 500006") @Test() private void login_with_wrong_partnerId() { - loginResponse = OttUserServiceImpl.login(PARTNER_ID + 1, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(client, PARTNER_ID + 1, user.getUsername(), password, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java index 07927f382..c1a5656ed 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.servicesImpl.UserLoginPinServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -20,6 +21,7 @@ public class LoginWithPinTests extends BaseTest { + private Client emptyClient, adminClient; private OTTUser user; private Response loginResponse; @@ -29,17 +31,21 @@ public class LoginWithPinTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + emptyClient = getClient(null); + Response ottUserResponse = register(emptyClient, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); user = ottUserResponse.results; + + adminClient = getClient(administratorKs); + adminClient.setUserId(Integer.parseInt(user.getId())); } @Description("ottUser/action/loginWithPin - loginWithPin with secret") @Test private void loginWithPin_with_secret() throws InterruptedException { - userLoginPinResponse = UserLoginPinServiceImpl.add(administratorKs, Integer.parseInt(user.getId()), SECRET); + userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); String pin = userLoginPinResponse.results.getPinCode(); - loginResponse = OttUserServiceImpl.loginWithPin(PARTNER_ID, pin, null, SECRET); + loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, PARTNER_ID, pin, null, SECRET); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); @@ -49,10 +55,10 @@ private void loginWithPin_with_secret() throws InterruptedException { @Description("ottUser/action/loginWithPin - loginWithPin with wrong secret - error 2008") @Test private void loginWithPin_with_wrong_secret() { - userLoginPinResponse = UserLoginPinServiceImpl.add(administratorKs, Integer.parseInt(user.getId()), SECRET); + userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); String pin = userLoginPinResponse.results.getPinCode(); - loginResponse = OttUserServiceImpl.loginWithPin(PARTNER_ID, pin, null, SECRET + 1); + loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, PARTNER_ID, pin, null, SECRET + 1); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2008).getCode()); @@ -61,12 +67,12 @@ private void loginWithPin_with_wrong_secret() { @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") @Test(enabled = true) private void loginWithPin_with_expired_pinCode() { - userLoginPinResponse = UserLoginPinServiceImpl.add(administratorKs, Integer.parseInt(user.getId()), SECRET); + userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); String pin = userLoginPinResponse.results.getPinCode(); // sleep for 1.5 minutes try { Thread.sleep(120000); } catch (InterruptedException e) { e.printStackTrace(); } - loginResponse = OttUserServiceImpl.loginWithPin(PARTNER_ID, pin, null, SECRET); + loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, PARTNER_ID, pin, null, SECRET); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2004).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java index f57031bf9..7da2326e2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; @@ -10,8 +11,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; @@ -21,6 +20,7 @@ public class LogoutTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @@ -30,21 +30,23 @@ public class LogoutTests extends BaseTest { @BeforeClass private void ottUser_logout_tests_setup() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + + Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); user = ottUserResponse.results; } @Description("ottUser/action/logout - logout") @Test private void logout() { - loginResponse = login(PARTNER_ID, user.getUsername(), password, null, null); - String ks = loginResponse.results.getLoginSession().getKs(); + loginResponse = login(client, PARTNER_ID, user.getUsername(), password, null, null); + client.setKs(loginResponse.results.getLoginSession().getKs()); - booleanResponse = OttUserServiceImpl.logout(ks, Optional.empty()); + booleanResponse = OttUserServiceImpl.logout(client); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); - Response ottUserResponse = OttUserServiceImpl.get(ks, Optional.empty()); + Response ottUserResponse = OttUserServiceImpl.get(client); assertThat(ottUserResponse.results).isNull(); assertThat(ottUserResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500016).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java index 3fb52ad70..d0c0d7098 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; @@ -15,6 +16,7 @@ public class RegisterTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @@ -22,6 +24,7 @@ public class RegisterTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { + client = getClient(null); user = generateOttUser(); } @@ -29,7 +32,7 @@ private void ottUser_login_tests_setup() { @Description("ottUser/action/register - register") @Test private void register() { - ottUserResponse = OttUserServiceImpl.register(PARTNER_ID, user, password); + ottUserResponse = OttUserServiceImpl.register(client, PARTNER_ID, user, password); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUsername()).isEqualTo(user.getUsername()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java index afdef6637..b8881123f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; @@ -16,20 +17,24 @@ import static org.assertj.core.api.Assertions.assertThat; public class ResendActivationTokenTests extends BaseTest { + + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @BeforeClass private void ottUser_resendActivationToken_tests_setup() { + client = getClient(null); user = generateOttUser(); - register(PARTNER_ID, user, password); - login(PARTNER_ID, user.getUsername(), password, null, null); + + register(client, PARTNER_ID, user, password); + login(client, PARTNER_ID, user.getUsername(), password, null, null); } @Description("ottUser/action/resendActivationToken - resendActivationToken") @Test(enabled = false) private void resendActivationToken() { - Response booleanResponse = OttUserServiceImpl.resendActivationToken(PARTNER_ID, user.getUsername()); + Response booleanResponse = OttUserServiceImpl.resendActivationToken(client, PARTNER_ID, user.getUsername()); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java index c54fdcc8c..779d6e08e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; @@ -17,6 +18,7 @@ public class ResetPasswordTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; @@ -24,19 +26,22 @@ public class ResetPasswordTests extends BaseTest { @BeforeClass private void ottUser_resetPassword_tests_setup() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); user = ottUserResponse.results; } @Description("ottUser/action/resetPassword - resetPassword") @Test(enabled = false) private void resetPassword() { - booleanResponse = OttUserServiceImpl.resetPassword(PARTNER_ID, administratorKs, user.getUsername()); + client.setKs(administratorKs); + booleanResponse = OttUserServiceImpl.resetPassword(client, PARTNER_ID, user.getUsername()); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); - Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + client = getClient(null); + Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); // TODO: 4/1/2018 finsih the test after bug BEO-4884 will be fixed } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java index a0e73f9ef..363d3467e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; @@ -10,8 +11,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; @@ -20,26 +19,32 @@ public class UpdateDynamicDataTests extends BaseTest { + private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; - - private Response ottUserDynamicDataResponse; @BeforeClass private void ottUser_updateDynamicData_tests_setup() { - Response ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); user = ottUserResponse.results; } @Description("ottUser/action/updateDynamicData - updateDynamicData") @Test private void updateDynamicData() { + // set client + client.setKs(administratorKs); + client.setUserId(Integer.valueOf(user.getId())); + + String keyString = "key1"; + String valueString = "value1"; + StringValue value = new StringValue(); - value.setValue("value1"); + value.setValue(valueString); + Response ottUserDynamicDataResponse = OttUserServiceImpl.updateDynamicData(client, keyString, value); - ottUserDynamicDataResponse = OttUserServiceImpl.updateDynamicData(administratorKs, Optional.of(Integer.valueOf(user.getId())), "key1", value); assertThat(ottUserDynamicDataResponse.error).isNull(); - assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo("value1"); - assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo("key1"); + assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo(keyString); + assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo(valueString); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index 73ca40c1a..6f25a587e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; @@ -17,31 +18,36 @@ public class UpdateLoginDataTests extends BaseTest { + private Client client; private String password = GLOBAL_USER_PASSWORD; + private Response booleanResponse; private Response ottUserResponse; + @Description("ottUser/action/updateLoginData - updateLoginData") @Test private void updateLoginData() { - ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + + ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); OTTUser user = ottUserResponse.results; - Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); - String ks = loginResponse.results.getLoginSession().getKs(); + Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + client.setKs(loginResponse.results.getLoginSession().getKs()); - booleanResponse = OttUserServiceImpl.updateLoginData(ks, user.getUsername(), password, password + 1); + booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), password, password + 1); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password - loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password - loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password + 1, null, null); + loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password + 1, null, null); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } @@ -49,21 +55,24 @@ private void updateLoginData() { @Description("ottUser/action/updateLoginData - updateLoginData with administratorKs") @Test private void updateLoginData_with_administratorKs() { - ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(administratorKs); + + ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); OTTUser user = ottUserResponse.results; - booleanResponse = OttUserServiceImpl.updateLoginData(administratorKs, user.getUsername(), password, password + 1); + booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), password, password + 1); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password - Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); + client = getClient(null); + Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password - loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password + 1, null, null); + loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password + 1, null, null); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index e235fed7e..9cb7eb881 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -1,17 +1,17 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; @@ -21,6 +21,7 @@ public class UpdateTests extends BaseTest { + private Client client; private OTTUser user; private String password = GLOBAL_USER_PASSWORD; private String originalUserEmail; @@ -29,7 +30,8 @@ public class UpdateTests extends BaseTest { @BeforeClass private void ottUser_update_tests_setup() { - ottUserResponse = register(PARTNER_ID, generateOttUser(), password); + client = getClient(null); + ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); user = ottUserResponse.results; originalUserEmail = user.getEmail(); } @@ -38,20 +40,20 @@ private void ottUser_update_tests_setup() { @Test private void update() { // get self ks - Response loginResponse = OttUserServiceImpl.login(PARTNER_ID, user.getUsername(), password, null, null); - String ks = loginResponse.results.getLoginSession().getKs(); + Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + client.setKs(loginResponse.results.getLoginSession().getKs()); // update String newUserInfo = "abc"; user.setFirstName(newUserInfo); user.setLastName(newUserInfo); - ottUserResponse = OttUserServiceImpl.update(ks, user, null); + ottUserResponse = OttUserServiceImpl.update(client, user, null); assertThat(ottUserResponse.error).isNull(); // get user after update - ottUserResponse = OttUserServiceImpl.get(ks, Optional.empty()); + ottUserResponse = OttUserServiceImpl.get(client); user = ottUserResponse.results; // assert @@ -62,7 +64,8 @@ private void update() { } @Description("ottUser/action/update - update with administratorKs") - @Test(enabled = false) // TODO: 4/2/2018 bug BEO-4919 + @Issue("BEO-4919") + @Test(enabled = true) private void update_with_administratorKs() { // update @@ -70,13 +73,16 @@ private void update_with_administratorKs() { user.setFirstName(newUserInfo); user.setLastName(newUserInfo); -// user.setAffiliateCode(null); - ottUserResponse = OttUserServiceImpl.update(administratorKs, user, user.getId()); +// user.setAffiliateCode(null); + + client.setKs(administratorKs); + ottUserResponse = OttUserServiceImpl.update(client, user, user.getId()); assertThat(ottUserResponse.error).isNull(); // get user after update - ottUserResponse = OttUserServiceImpl.get(administratorKs, Optional.of(Integer.valueOf(user.getId()))); + client.setUserId(Integer.valueOf(user.getId())); + ottUserResponse = OttUserServiceImpl.get(client); user = ottUserResponse.results; // assert @@ -88,6 +94,6 @@ private void update_with_administratorKs() { @AfterClass private void ottUser_update_tests_tearDown() { - OttUserServiceImpl.delete(administratorKs, Optional.of(Integer.valueOf(user.getId()))); + OttUserServiceImpl.delete(client); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index b237ff06c..af32c2536 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.productPriceTests; +import com.kaltura.client.Client; import com.kaltura.client.enums.*; import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; @@ -17,10 +18,13 @@ public class ListTests extends BaseTest { + private Client client; private EntitlementFilter entitlementPpvsFilter; @BeforeClass public void beforeClass() { + client = getClient(operatorKs); + entitlementPpvsFilter = new EntitlementFilter(); entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); @@ -34,7 +38,7 @@ public void beforeClass() { public void list_subscription() { ProductPriceFilter filter = new ProductPriceFilter(); // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); - Response> productPriceList = list(operatorKs, filter, Optional.empty()); + Response> productPriceList = list(client, filter); // TODO: fix! assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(five_min_renewable_subscription_id); assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); @@ -44,7 +48,7 @@ public void list_subscription() { @Test() public void list_without_required_fields() { ProductPriceFilter filter = new ProductPriceFilter(); - Response> productPriceResponse = list(operatorKs, filter, Optional.empty()); + Response> productPriceResponse = list(client, filter); // TODO: should we create enums for error codes and their messages? A: Yes if library doesn't contain them assertThat(productPriceResponse.results).isNull(); assertThat(productPriceResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500056).getCode()); @@ -58,7 +62,10 @@ public void ppv() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ - Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, null); + client.setKs(sharedMasterUserKs); +// client.setCurrency("?"); + + Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); @@ -66,16 +73,16 @@ public void ppv() { int mobileMediaFileId = mediaAsset.getMediaFiles().get(1).getId(); ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); ppFilter.setIsLowest(false); - Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - PurchaseUtils.purchasePpv(sharedMasterUserKs, Optional.empty(), Optional.of(webMediaFileId), Optional.empty()); + PurchaseUtils.purchasePpv(client, Optional.empty(), Optional.of(webMediaFileId)); - Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(sharedMasterUserKs, entitlementPpvsFilter, null); + Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); System.out.println(entitlementListAfterPurchase.results.getTotalCount()); assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); @@ -85,13 +92,13 @@ public void ppv() { assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); - Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); + Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); - Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(sharedMasterUserKs, ppFilter, Optional.empty()); + Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(client, ppFilter); assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount()).isEqualTo(1); assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 0e62f9768..ec5fa0c7b 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Client; import com.kaltura.client.Logger; import com.kaltura.client.test.servicesImpl.HouseholdDeviceServiceImpl; import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; @@ -15,39 +16,40 @@ import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.tests.BaseTest.administratorKs; -import static com.kaltura.client.test.tests.BaseTest.client; +import static com.kaltura.client.test.tests.BaseTest.getClient; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class HouseholdUtils extends BaseUtils { // create household public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold, boolean isPreparePG) { + Client client = getClient(null); // create and register - Response masterUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response masterUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); OTTUser masterUser = masterUserResponse.results; // login master user - Response loginResponse = login(PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + Response loginResponse = login(client, PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); masterUser = loginResponse.results.getUser(); - String masterUserKS = loginResponse.results.getLoginSession().getKs(); + client.setKs(loginResponse.results.getLoginSession().getKs()); // create and add household Household household = new Household(); household.setName(masterUser.getFirstName() + "s Domain"); household.setDescription(masterUser.getLastName() + " Description"); - Response householdResponse = HouseholdServiceImpl.add(masterUserKS, household); + Response householdResponse = HouseholdServiceImpl.add(client, household); household = householdResponse.results; // create, register and add non-master user to household for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { - Response additionalUserResponse = register(PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response additionalUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); OTTUser additionalUser = additionalUserResponse.results; HouseholdUser householdUser = new HouseholdUser(); householdUser.setUserId(additionalUser.getId()); householdUser.setIsMaster(false); - HouseholdUserServiceImpl.add(masterUserKS, householdUser); + HouseholdUserServiceImpl.add(client, householdUser); } // create, add and save household device @@ -58,7 +60,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO Random r = new Random(); householdDevice.setBrandId(r.nextInt(30 - 1) + 1); householdDevice.setName(String.valueOf(uniqueString) + "device"); - HouseholdDeviceServiceImpl.add(masterUserKS, householdDevice); + HouseholdDeviceServiceImpl.add(client, householdDevice); } if (isPreparePG) { @@ -70,9 +72,10 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO // get users list from given household public static List getUsersListFromHouseHold(Household household) { + Client client = getClient(administratorKs); HouseholdUserFilter filter = new HouseholdUserFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); - Response> usersResponse = HouseholdUserServiceImpl.list(administratorKs, filter); + Response> usersResponse = HouseholdUserServiceImpl.list(client, filter); return usersResponse.results.getObjects(); } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index ced6a8c3b..e45edb3d3 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -14,6 +14,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.anonymousKs; +import static com.kaltura.client.test.tests.BaseTest.getClient; import static io.restassured.path.xml.XmlPath.from; import static org.awaitility.Awaitility.await; @@ -65,13 +66,13 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op //mediaAsset.setEndDate(endDate); await().pollInterval(3, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); - Response mediaAssetDetails = AssetServiceImpl.get(anonymousKs, id, AssetReferenceType.MEDIA); + Response mediaAssetDetails = AssetServiceImpl.get(getClient(anonymousKs), id, AssetReferenceType.MEDIA); mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); return mediaAsset; } private static Callable isDataReturned(String mediaId) { - return () -> AssetServiceImpl.get(anonymousKs, mediaId, AssetReferenceType.MEDIA).error == null; + return () -> AssetServiceImpl.get(getClient(anonymousKs), mediaId, AssetReferenceType.MEDIA).error == null; } private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 90e41f86f..4f3de82d1 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -1,10 +1,11 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; -import java.util.Optional; import java.util.Random; import static com.kaltura.client.test.tests.BaseTest.administratorKs; @@ -33,7 +34,10 @@ public static OTTUser generateOttUser() { } public static String getUserNameFromId(int userId) { - Response userResponse = OttUserServiceImpl.get(administratorKs, Optional.of(userId)); + Client client = BaseTest.getClient(administratorKs); + client.setUserId(userId); + Response userResponse = OttUserServiceImpl.get(client); + return userResponse.results.getUsername(); } } diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 6ada28339..93d4c9e50 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.enums.ProductPriceOrderBy; import com.kaltura.client.enums.TransactionType; @@ -17,7 +18,7 @@ public class PurchaseUtils { public static Map purchasePpvDetailsMap; // TODO: 14/MAR/2018 add return - public static void purchasePpv(String ks, Optional mediaId, Optional fileId, Optional inCurrency) { + public static void purchasePpv(Client client, Optional mediaId, Optional fileId) { purchasePpvDetailsMap = new HashMap<>(); int paymentGatewayId = 0; @@ -25,7 +26,7 @@ public static void purchasePpv(String ks, Optional mediaId, Optional mediaAsset = AssetServiceImpl.get(ks, String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); + Response mediaAsset = AssetServiceImpl.get(client, String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); internalFileId = mediaAsset.results.getMediaFiles().get(0).getId(); } @@ -33,23 +34,23 @@ public static void purchasePpv(String ks, Optional mediaId, Optional> productPriceListBeforePurchase = ProductPriceServiceImpl.list(ks, filter, inCurrency); - String currency = inCurrency.isPresent() ? inCurrency.get() : productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getCurrency(); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, filter); +// String currency = inCurrency.isPresent() ? inCurrency.get() : productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getCurrency(); double price = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getAmount(); String ppvModuleId = ((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getPpvModuleId(); Purchase purchase = new Purchase(); purchase.setProductId(Integer.valueOf(ppvModuleId)); purchase.setContentId(internalFileId); - purchase.setCurrency(currency); + purchase.setCurrency(client.getCurrency()); purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.PPV).get()); purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); - TransactionServiceImpl.purchase(ks, purchase); + TransactionServiceImpl.purchase(client, purchase); // TODO: complete the purchase ppv test purchasePpvDetailsMap.put("price", String.valueOf(price)); - purchasePpvDetailsMap.put("currency", currency); + purchasePpvDetailsMap.put("currency", client.getCurrency()); purchasePpvDetailsMap.put("ppvModuleId", ppvModuleId); purchasePpvDetailsMap.put("fileId", String.valueOf(internalFileId)); } From 404bdacf5f7c3239f45d845577fb6e8a240849da Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 11 Apr 2018 14:46:05 +0300 Subject: [PATCH 062/605] Added new class - "BookmarkUtils" --- .gitignore | 1 + .../servicesTests/bookmarkTests/AddTests.java | 52 ++++++++--- .../bookmarkTests/ListTests.java | 86 +++++++++++++++++++ .../client/test/utils/BookmarkUtils.java | 49 +++++++++++ 4 files changed, 174 insertions(+), 14 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java diff --git a/.gitignore b/.gitignore index 48771c4ef..e72efd19a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ target/ src/test/java/resources/test.properties allure-results/ .allure/ +log4j.log diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index ded437ac0..b975c8a3d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -1,9 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.PositionOwner; +import com.kaltura.client.enums.*; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -32,13 +29,13 @@ public class AddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - // Get asset id from ingest + // Get VOD asset id from ingest assetId = mediaAsset.getId(); - type = AssetType.get("MEDIA"); - AssetReferenceType assetReferenceType = AssetReferenceType.get("MEDIA"); + type = AssetType.get(AssetType.MEDIA.getValue()); + AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs,String.valueOf(assetId),assetReferenceType); fileId = assetResponse.results.getMediaFiles().get(0).getId(); - actionType = BookmarkActionType.get("FIRST_PLAY"); + actionType = BookmarkActionType.get(BookmarkActionType.FIRST_PLAY.getValue()); // Initialize bookmark object parameters bookmark.setType(type); @@ -56,7 +53,7 @@ private void add_tests_before_class() { // Initialize asset id bookmarkFilter.setAssetIdIn(String.valueOf(assetId)); // Initialize orderBy - bookmarkFilter.setOrderBy("POSITION_ASC"); + bookmarkFilter.setOrderBy(BookmarkOrderBy.POSITION_DESC.getValue()); // Initialize asset type bookmarkFilter.setAssetTypeEqual(type); } @@ -104,7 +101,7 @@ private void firstPlayback() { @Test private void stopPlayback() { // Set action type to "STOP" - actionType = BookmarkActionType.get("STOP"); + actionType = BookmarkActionType.get(BookmarkActionType.STOP.getValue()); playerData.setAction(actionType); position = 30; bookmark.setPosition(position); @@ -124,12 +121,36 @@ private void stopPlayback() { assertThat(bookmark2.getPosition()).isEqualTo(this.position); } + @Description("bookmark/action/add - 95% watching == finish watching") + @Test + private void watchingNinetyFive() { + position = 999; + bookmark.setPosition(position); + + // Invoke bookmark/action/add request + Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned + assertThat(booleanResponse.error).isNull(); + + // Invoke bookmark/action/list to verify insertion of bookmark position + Response> bookmarkListResponse3 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Bookmark bookmark3 = bookmarkListResponse3.results.getObjects().get(0); + + // Assertions + // *********************************************** + + // Verify finishedWatching = true + assertThat(bookmark3.getFinishedWatching()).isTrue(); + + } @Description("bookmark/action/add - finish watching") @Test private void FinishWatching() { // Set action type to "FINISH" - actionType = BookmarkActionType.get("FINISH"); + actionType = BookmarkActionType.get(BookmarkActionType.FINISH.getValue()); playerData.setAction(actionType); position = 60; bookmark.setPosition(position); @@ -142,14 +163,17 @@ private void FinishWatching() { assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse3 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); - Bookmark bookmark3 = bookmarkListResponse3.results.getObjects().get(0); + Response> bookmarkListResponse4 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Bookmark bookmark4 = bookmarkListResponse4.results.getObjects().get(0); // Assertions // *********************************************** // Verify finishedWatching = true - assertThat(bookmark3.getFinishedWatching()).isTrue(); + assertThat(bookmark4.getFinishedWatching()).isTrue(); } + + // TODO - Add test for EPG bookmark + // TODO - add test for recording bookmark } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java new file mode 100644 index 000000000..972533dcf --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java @@ -0,0 +1,86 @@ +package com.kaltura.client.test.tests.servicesTests.bookmarkTests; + +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.enums.BookmarkOrderBy; +import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BookmarkUtils; +import com.kaltura.client.types.Bookmark; +import com.kaltura.client.types.BookmarkFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ListTests extends BaseTest { + + private String assetId = "606283"; + private int fileId = 935272; + + private String assetId2 = "606282"; + private int fileId2 = 935270; + + private List assetList = new ArrayList<>(); + + @BeforeClass + private void list_tests_before_class() { + + assetList.add(assetId); + assetList.add(assetId2); + } + + @Description("bookmark/action/list - order by") + @Test + + private void BookmarkOrderBy() { + + // Bookmark asset1 + Bookmark bookmark = BookmarkUtils.addBookmark(0, assetId, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // Bookmark asset2 + Bookmark bookmark2 = BookmarkUtils.addBookmark(10, assetId2, fileId2, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Response booleanResponse2 = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark2); + assertThat(booleanResponse2.results.booleanValue()).isTrue(); + + + BookmarkFilter bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_DESC,AssetType.MEDIA, assetList); + Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + + Bookmark bookmarkObject = bookmarkListResponse.results.getObjects().get(0); + Bookmark bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); + + // Assertions + // ************************************* + + // Verify that asset2 returned first (bookmark/action/list is response is ordered by POSITION DESC) + assertThat( bookmarkObject.getId()).isEqualTo(String.valueOf(assetId2)); + assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId)); + + bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC,AssetType.MEDIA, assetList); + bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + + bookmarkObject = bookmarkListResponse.results.getObjects().get(0); + bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); + + // Assertions + // ************************************* + + // Verify that asset1 returned first (bookmark/action/list is response is ordered by POSITION DESC) + assertThat( bookmarkObject.getId()).isEqualTo(String.valueOf(assetId)); + assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId2)); + + + + + + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java b/src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java new file mode 100644 index 000000000..0e932a51d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java @@ -0,0 +1,49 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.enums.BookmarkOrderBy; +import com.kaltura.client.types.Bookmark; +import com.kaltura.client.types.BookmarkFilter; +import com.kaltura.client.types.BookmarkPlayerData; + +import java.util.List; + +public class BookmarkUtils extends BaseUtils { + + public static Bookmark addBookmark(int position, String assetId, int fileId, AssetType assetType, BookmarkActionType actionType) { + + // instantiate Bookmark object + Bookmark bookmark = new Bookmark(); + bookmark.setPosition(position); + bookmark.setId(String.valueOf(assetId)); + AssetType type = AssetType.get(assetType.getValue()); + bookmark.setType(type); + + // instantiate BookmarkPlayerData object + BookmarkPlayerData playerData = new BookmarkPlayerData(); + BookmarkActionType bookmarkactionType = BookmarkActionType.get(actionType.getValue()); + playerData.setAction(bookmarkactionType); + playerData.setAction(actionType); + playerData.setAverageBitrate(0); + playerData.setTotalBitrate(0); + playerData.setCurrentBitrate(0); + playerData.setFileId((long) fileId); + bookmark.setPlayerData(playerData); + + return bookmark; + } + + public static BookmarkFilter listBookmark(BookmarkOrderBy orderBy, AssetType assetType, List assetIds) { + // instantiate BookmarkFilter object + BookmarkFilter bookmarkFilter = new BookmarkFilter(); + bookmarkFilter.setOrderBy(orderBy.getValue()); + bookmarkFilter.setAssetTypeEqual(assetType); + String concatenatedAssetIds = String.join(",",assetIds); + bookmarkFilter.setAssetIdIn(concatenatedAssetIds); + + return bookmarkFilter; + } + + +} From a5b6353d778e4f928e4d6280920228c619a103af Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 11 Apr 2018 15:32:24 +0300 Subject: [PATCH 063/605] add domain name instead of ip --- src/test/java/com/kaltura/client/test/Properties.java | 6 +++--- .../tests/servicesTests/entitlementTests/GrantTests.java | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 02a6d9139..f6a9b1aed 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -7,10 +7,10 @@ public class Properties { private static ResourceBundle resourceBundle; // Url properties - public static final String API_BASE_URL = "http://34.249.122.223:8080"; + public static final String API_BASE_URL = "http://34.249.122.223:8080"; // "http://api-preprod.ott.kaltura.com"; // "http://34.249.122.223:8080" public static final String API_URL_VERSION = "v4_8"; - public static final String SOAP_BASE_URL = "http://34.249.122.223:8030"; - public static final String INGEST_REPORT_URL = "http://34.249.122.223:5823"; + public static final String SOAP_BASE_URL = "http://34.249.122.223:8030"; // "http://api-preprod.ott.kaltura.com:8030"; // "http://34.249.122.223:8030"; + public static final String INGEST_REPORT_URL = "http://34.249.122.223:5823"; // "http://api-preprod.ott.kaltura.com:5823"; // "http://34.249.122.223:5823"; // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index ac7813e6a..06ec8323a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -7,6 +7,11 @@ public class GrantTests extends BaseTest { @Test(description = "entitlement/action/grant - grant") private void grant() { -// EntitlementServiceImpl.grant() + + // new hh + // predefined subscription + // grant +// Client client = getClient(operatorKs); +// EntitlementServiceImpl.grant(client, ) } } From ab6993b8e2f874787afbf4f2cecabd3ff601a38a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 11 Apr 2018 16:22:49 +0300 Subject: [PATCH 064/605] change api ips to domain names for jenkins builds --- src/test/java/com/kaltura/client/test/Properties.java | 6 +++--- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 5 ----- .../tests/servicesTests/productPriceTests/ListTests.java | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index f6a9b1aed..9a66aeaad 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -7,10 +7,10 @@ public class Properties { private static ResourceBundle resourceBundle; // Url properties - public static final String API_BASE_URL = "http://34.249.122.223:8080"; // "http://api-preprod.ott.kaltura.com"; // "http://34.249.122.223:8080" + public static final String API_BASE_URL = "http://api-preprod.ott.kaltura.com"; // "http://34.249.122.223:8080" + public static final String SOAP_BASE_URL = "http://api-preprod.ott.kaltura.com:8030"; // "http://34.249.122.223:8030"; + public static final String INGEST_REPORT_URL = "http://api-preprod.ott.kaltura.com:5823"; // "http://34.249.122.223:5823"; public static final String API_URL_VERSION = "v4_8"; - public static final String SOAP_BASE_URL = "http://34.249.122.223:8030"; // "http://api-preprod.ott.kaltura.com:8030"; // "http://34.249.122.223:8030"; - public static final String INGEST_REPORT_URL = "http://34.249.122.223:5823"; // "http://api-preprod.ott.kaltura.com:5823"; // "http://34.249.122.223:5823"; // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c9a65c443..b4b185bc6 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -101,9 +101,4 @@ public static Client getClient(String ks) { client.setKs(ks); return client; } - -// @AfterTest -// public void base_test_after_test() { -// -// } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index af32c2536..24aa47f78 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -49,7 +49,7 @@ public void list_subscription() { public void list_without_required_fields() { ProductPriceFilter filter = new ProductPriceFilter(); Response> productPriceResponse = list(client, filter); - // TODO: should we create enums for error codes and their messages? A: Yes if library doesn't contain them + assertThat(productPriceResponse.results).isNull(); assertThat(productPriceResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500056).getCode()); assertThat(productPriceResponse.error.getMessage()).isEqualToIgnoringCase( @@ -62,8 +62,8 @@ public void ppv() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ + client.setKs(sharedMasterUserKs); -// client.setCurrency("?"); Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); From a7d57a8cbaaa58ed615aaf670801926b26ff6de9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 11 Apr 2018 16:50:49 +0300 Subject: [PATCH 065/605] Added new class - "AssetUtils" + Update MediaAsset.json file + MultilingualStringValueArray.json file + ListTests.java --- .../bookmarkTests/ListTests.java | 23 ++++++++------- .../kaltura/client/test/utils/AssetUtils.java | 28 +++++++++++++++++++ src/test/resources/schemas/MediaAsset.json | 16 +++++------ .../schemas/MultilingualStringValueArray.json | 1 - 4 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/AssetUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java index 972533dcf..6fecc5771 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.enums.BookmarkOrderBy; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.Bookmark; import com.kaltura.client.types.BookmarkFilter; @@ -21,18 +22,25 @@ public class ListTests extends BaseTest { - private String assetId = "606283"; - private int fileId = 935272; + private String assetId; + private int fileId; - private String assetId2 = "606282"; - private int fileId2 = 935270; + + private String assetId2; + private int fileId2; private List assetList = new ArrayList<>(); @BeforeClass private void list_tests_before_class() { - + assetId = "606283"; + List assetFileIds = AssetUtils.getAssetFileIds(assetId); + fileId = assetFileIds.get(0); assetList.add(assetId); + + assetId2 = "606282"; + List asset2FileIds = AssetUtils.getAssetFileIds(assetId2); + fileId2 = asset2FileIds.get(0); assetList.add(assetId2); } @@ -77,10 +85,5 @@ private void BookmarkOrderBy() { // Verify that asset1 returned first (bookmark/action/list is response is ordered by POSITION DESC) assertThat( bookmarkObject.getId()).isEqualTo(String.valueOf(assetId)); assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId2)); - - - - - } } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java new file mode 100644 index 000000000..d39d6344f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -0,0 +1,28 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.MediaFile; +import com.kaltura.client.utils.response.base.Response; + +import java.util.ArrayList; +import java.util.List; + +import static com.kaltura.client.test.tests.BaseTest.sharedMasterUserKs; + +public class AssetUtils extends BaseUtils { + + public static List getAssetFileIds(String assetId) { + AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); + Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs, assetId, assetReferenceType); + List mediafiles = assetResponse.results.getMediaFiles(); + System.out.println(mediafiles.size()); + List fileIdsList = new ArrayList<>(); + for (MediaFile mediaFile : mediafiles) { + fileIdsList.add(mediaFile.getId()); + } + + return fileIdsList; + } +} diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index 61f2f58e0..336f5290a 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -1,5 +1,5 @@ { - "$id": "KalturaMediaAsset", + "$id": "MediaAsset", "type": "object", "properties": { "result": { @@ -38,7 +38,6 @@ }, "images": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { @@ -78,7 +77,6 @@ }, "mediaFiles": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { @@ -152,22 +150,22 @@ "type": "object", "properties": { "Free": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Genre": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Parental Rating": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Director": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Country": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Series name": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" } } }, diff --git a/src/test/resources/schemas/MultilingualStringValueArray.json b/src/test/resources/schemas/MultilingualStringValueArray.json index b57313f9f..7cf384c28 100644 --- a/src/test/resources/schemas/MultilingualStringValueArray.json +++ b/src/test/resources/schemas/MultilingualStringValueArray.json @@ -6,7 +6,6 @@ "properties": { "objects": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { From a7f5d1d6b7b04586038ad5bbd4f3fa8c8e30fe2b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 11 Apr 2018 16:59:01 +0300 Subject: [PATCH 066/605] fix ref to OTTUser in LoginResponse schema --- .../com/kaltura/client/test/TestAPIOkRequestsExecutor.java | 1 - .../tests/servicesTests/entitlementTests/GrantTests.java | 5 ++++- src/test/resources/schemas/LoginResponse.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 60a4ee0cd..5f6d46291 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -3,7 +3,6 @@ import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; -import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.ErrorElement; import com.kaltura.client.utils.request.ExecutedRequest; import com.kaltura.client.utils.request.RequestElement; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index 06ec8323a..918be40f2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -1,13 +1,16 @@ package com.kaltura.client.test.tests.servicesTests.entitlementTests; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.types.Household; import org.testng.annotations.Test; public class GrantTests extends BaseTest { @Test(description = "entitlement/action/grant - grant") private void grant() { - + String subscriptionId = "369426"; + Household household = HouseholdUtils.createHouseHold(2, 1, false); // new hh // predefined subscription // grant diff --git a/src/test/resources/schemas/LoginResponse.json b/src/test/resources/schemas/LoginResponse.json index 833f8402f..3bc0b5ebf 100644 --- a/src/test/resources/schemas/LoginResponse.json +++ b/src/test/resources/schemas/LoginResponse.json @@ -5,7 +5,7 @@ "result": { "type": "object", "properties": { - "user": {"$ref": "OttUser.json#/definitions/OTTUser"}, + "user": {"$ref": "OTTUser.json#/definitions/OTTUser"}, "loginSession": { "$ref": "LoginSession.json#/definitions/LoginSession" }, From f6119f2a1f99836fe66630c23130d67f85e4b00b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 11 Apr 2018 17:25:48 +0300 Subject: [PATCH 067/605] Updated AddTests.java --- .../servicesTests/bookmarkTests/AddTests.java | 68 ++++++++++++------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index b975c8a3d..11d56788c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -4,12 +4,16 @@ import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + import static org.assertj.core.api.Assertions.assertThat; @@ -20,6 +24,7 @@ public class AddTests extends BaseTest { private int fileId; private BookmarkActionType actionType; private int position = 0; + private List assetList = new ArrayList<>(); // instantiate Bookmark object private Bookmark bookmark = new Bookmark(); // instantiate BookmarkPlayerData object @@ -30,32 +35,25 @@ public class AddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { // Get VOD asset id from ingest + assetId = mediaAsset.getId(); + type = AssetType.get(AssetType.MEDIA.getValue()); AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); - Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs,String.valueOf(assetId),assetReferenceType); + Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs, String.valueOf(assetId), assetReferenceType); fileId = assetResponse.results.getMediaFiles().get(0).getId(); actionType = BookmarkActionType.get(BookmarkActionType.FIRST_PLAY.getValue()); + assetList.add(String.valueOf(assetId)); // Initialize bookmark object parameters - bookmark.setType(type); - bookmark.setId(String.valueOf(assetId)); - bookmark.setPosition(position); + bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - // Initialize playerData object parameters - playerData.setAction(actionType); - playerData.setAverageBitrate(0); - playerData.setTotalBitrate(0); - playerData.setCurrentBitrate(0); - playerData.setFileId((long) fileId); - bookmark.setPlayerData(playerData); + // Initialize bookmarkFilter object parameters + bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC, AssetType.MEDIA, assetList); // Initialize asset id bookmarkFilter.setAssetIdIn(String.valueOf(assetId)); - // Initialize orderBy - bookmarkFilter.setOrderBy(BookmarkOrderBy.POSITION_DESC.getValue()); - // Initialize asset type - bookmarkFilter.setAssetTypeEqual(type); + } @Description("bookmark/action/add - first play") @@ -71,14 +69,14 @@ private void firstPlayback() { // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs, bookmarkFilter); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); // Assertions // *********************************************** // Match content of asset id - assertThat( bookmark1.getId()).isEqualTo(String.valueOf(assetId)); + assertThat(bookmark1.getId()).isEqualTo(String.valueOf(assetId)); // Match content of asset position assertThat(bookmark1.getPosition()).isEqualTo(this.position); @@ -97,11 +95,11 @@ private void firstPlayback() { } - @Description("bookmark/action/add - stop") + @Description("bookmark/action/add - pause") @Test private void stopPlayback() { - // Set action type to "STOP" - actionType = BookmarkActionType.get(BookmarkActionType.STOP.getValue()); + // Set action type to "PAUSE" + actionType = BookmarkActionType.get(BookmarkActionType.PAUSE.getValue()); playerData.setAction(actionType); position = 30; bookmark.setPosition(position); @@ -114,7 +112,7 @@ private void stopPlayback() { assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse2 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Response> bookmarkListResponse2 = BookmarkServiceImpl.list(sharedMasterUserKs, bookmarkFilter); Bookmark bookmark2 = bookmarkListResponse2.results.getObjects().get(0); // Match content of asset position @@ -124,6 +122,8 @@ private void stopPlayback() { @Description("bookmark/action/add - 95% watching == finish watching") @Test private void watchingNinetyFive() { + actionType = BookmarkActionType.get(BookmarkActionType.PLAY.getValue()); + playerData.setAction(actionType); position = 999; bookmark.setPosition(position); @@ -135,7 +135,7 @@ private void watchingNinetyFive() { assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse3 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Response> bookmarkListResponse3 = BookmarkServiceImpl.list(sharedMasterUserKs, bookmarkFilter); Bookmark bookmark3 = bookmarkListResponse3.results.getObjects().get(0); // Assertions @@ -146,9 +146,25 @@ private void watchingNinetyFive() { } + @Description("bookmark/action/add - back to start - position:0") + @Test + private void backToStart() { + actionType = BookmarkActionType.get(BookmarkActionType.STOP.getValue()); + playerData.setAction(actionType); + position = 0; + bookmark.setPosition(position); + Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + + Response> bookmarkListResponse4 = BookmarkServiceImpl.list(sharedMasterUserKs, bookmarkFilter); + Bookmark bookmark4 = bookmarkListResponse4.results.getObjects().get(0); + // Verify finishedWatching = false + assertThat(bookmark4.getFinishedWatching()).isFalse(); + } + + @Description("bookmark/action/add - finish watching") @Test - private void FinishWatching() { + private void finishWatching() { // Set action type to "FINISH" actionType = BookmarkActionType.get(BookmarkActionType.FINISH.getValue()); playerData.setAction(actionType); @@ -163,14 +179,14 @@ private void FinishWatching() { assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse4 = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); - Bookmark bookmark4 = bookmarkListResponse4.results.getObjects().get(0); + Response> bookmarkListResponse5 = BookmarkServiceImpl.list(sharedMasterUserKs, bookmarkFilter); + Bookmark bookmark5 = bookmarkListResponse5.results.getObjects().get(0); // Assertions // *********************************************** // Verify finishedWatching = true - assertThat(bookmark4.getFinishedWatching()).isTrue(); + assertThat(bookmark5.getFinishedWatching()).isTrue(); } From bc063167be92e1658223a4eb5e5468c381e7acf9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 12 Apr 2018 12:37:14 +0300 Subject: [PATCH 068/605] Add new classes to AppToken service --- .../servicesImpl/AppTokenServiceImpl.java | 33 +++++++++++++++++ .../servicesTests/appTokenTests/AddTests.java | 37 +++++++++++++++++++ .../servicesTests/bookmarkTests/AddTests.java | 22 ++++++++--- .../client/test/utils/AppTokenUtils.java | 17 +++++++++ 4 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java new file mode 100644 index 000000000..a24deca45 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java @@ -0,0 +1,33 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.AppTokenService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.AppToken; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.AppTokenService.*; +import static org.awaitility.Awaitility.await; + +public class AppTokenServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + private static Response appTokenResponse; + + public static AddAppTokenBuilder add(Client client, AppToken appToken) { + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setCompletion((ApiCompletion) result -> { + appTokenResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addAppTokenBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return addAppTokenBuilder; + } +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java new file mode 100644 index 000000000..5a66400f6 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.tests.servicesTests.appTokenTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AppTokenHashType; +import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AppTokenUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.AppToken; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddTests extends BaseTest { + + private AppTokenHashType hashType; + private String sessionUserId; + private AppToken appToken = new AppToken(); + + + @BeforeClass + private void add_tests_before_class() { + hashType = AppTokenHashType.SHA1; + sessionUserId = OttUserUtils.generateOttUser().getId(); + appToken = AppTokenUtils.addAppToken(sessionUserId,hashType ); + + + } + + @Description("appToken/action/add") + @Test + + private void addAppToken() { + Response appTokenResponse = AppTokenServiceImpl.add() + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index 11d56788c..bcabbfcd0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -46,14 +47,10 @@ private void add_tests_before_class() { assetList.add(String.valueOf(assetId)); // Initialize bookmark object parameters - bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + bookmark = BookmarkUtils.addBookmark(0, assetList.get(0), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); // Initialize bookmarkFilter object parameters bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC, AssetType.MEDIA, assetList); - - // Initialize asset id - bookmarkFilter.setAssetIdIn(String.valueOf(assetId)); - } @Description("bookmark/action/add - first play") @@ -190,6 +187,19 @@ private void finishWatching() { } + // Error validations + + @Description("bookmark/action/add - empty asset id") + @Test + private void emptyAssetId() { + bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + assertThat(booleanResponse.results).isNull(); + // Verify exception returned - code: 500003 ("Invalid Asset id") + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500003).getCode()); + } + + // TODO - Add test for EPG bookmark - // TODO - add test for recording bookmark + // TODO - Add test for recording bookmark } diff --git a/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java new file mode 100644 index 000000000..aa6f91c66 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java @@ -0,0 +1,17 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.AppTokenHashType; +import com.kaltura.client.types.AppToken; + +public class AppTokenUtils extends BaseUtils { + + public static AppToken addAppToken(String userId, AppTokenHashType appTokenHashType) { + AppToken appToken = new AppToken(); + appToken.setHashType(appTokenHashType); + appToken.sessionUserId(userId); + + return appToken; + } + + +} From ecf5022cd2eec536bf3ff4d18605ee4f2e92f4c7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 12 Apr 2018 12:42:40 +0300 Subject: [PATCH 069/605] Updated AddTests class (AppToken) --- .../client/test/tests/servicesTests/appTokenTests/AddTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java index 5a66400f6..9e793c7ad 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -17,6 +17,7 @@ public class AddTests extends BaseTest { private AppTokenHashType hashType; private String sessionUserId; private AppToken appToken = new AppToken(); + public static Client client; @BeforeClass From 774874c16e36e5a07d0d247d60f6f467461024ee Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 12 Apr 2018 14:08:24 +0300 Subject: [PATCH 070/605] no message --- .../servicesImpl/EntitlementServiceImpl.java | 3 +- .../entitlementTests/GrantTests.java | 28 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java index 544040efd..498f2e519 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java @@ -116,7 +116,8 @@ public static Response getNextRenewal(Client client, int id) } // grant - public static Response grant(Client client, int productId, TransactionType transactionType, boolean history, @Nullable int contentId) { + public static Response grant(Client client, int productId, TransactionType transactionType, boolean history, @Nullable Integer contentId) { + if (contentId == null) contentId = 0; GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(productId, transactionType, history, contentId) .setCompletion((ApiCompletion) result -> { booleanResponse = result; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index 918be40f2..f0a446f0c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -1,19 +1,33 @@ package com.kaltura.client.test.tests.servicesTests.entitlementTests; +import com.kaltura.client.Client; +import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.services.OttUserService; +import com.kaltura.client.test.Properties; +import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.types.Household; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.OTTUser; import org.testng.annotations.Test; public class GrantTests extends BaseTest { @Test(description = "entitlement/action/grant - grant") private void grant() { - String subscriptionId = "369426"; - Household household = HouseholdUtils.createHouseHold(2, 1, false); - // new hh - // predefined subscription - // grant + Client client = getClient(null); + // TODO: 4/12/2018 remove hardcoded subscription Id + int subscriptionId = 369426; + +// Household household = HouseholdUtils.createHouseHold(2, 1, false); +// HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); +// Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, OttUserUtils.getUserNameFromId(Integer.parseInt(masterUser.getUserId())), +// GLOBAL_USER_PASSWORD, null, null); + OTTUser user = OttUserUtils.generateOttUser(); + + client.setKs(administratorKs); + client.setUserId(user.getus); + EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, true, null); + // Client client = getClient(operatorKs); // EntitlementServiceImpl.grant(client, ) } From c1cfd2ee31d4f90702b6c8d1eb28ea5ee03ca993 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 12 Apr 2018 14:31:10 +0300 Subject: [PATCH 071/605] fix merge problems --- .../servicesTests/appTokenTests/AddTests.java | 4 +- .../servicesTests/bookmarkTests/AddTests.java | 176 +++++++++++++++--- .../bookmarkTests/ListTests.java | 12 +- .../kaltura/client/test/utils/AssetUtils.java | 6 +- 4 files changed, 160 insertions(+), 38 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java index 9e793c7ad..e228b08cb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -2,12 +2,10 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.AppToken; -import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -33,6 +31,6 @@ private void add_tests_before_class() { @Test private void addAppToken() { - Response appTokenResponse = AppTokenServiceImpl.add() +// Response appTokenResponse = AppTokenServiceImpl.add() } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index 4a26151c5..3e5f6acd2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -1,19 +1,21 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; import com.kaltura.client.Client; -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.PositionOwner; +import com.kaltura.client.enums.*; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -25,47 +27,49 @@ public class AddTests extends BaseTest { private int fileId; private BookmarkActionType actionType; private int position = 0; + private List assetList = new ArrayList<>(); + // instantiate Bookmark object + private Bookmark bookmark = new Bookmark(); + // instantiate BookmarkPlayerData object + private BookmarkPlayerData playerData = new BookmarkPlayerData(); + // instantiate BookmarkFilter object + private BookmarkFilter bookmarkFilter = new BookmarkFilter(); @BeforeClass private void add_tests_before_class() { client = getClient(sharedMasterUserKs); - assetId = mediaAsset.getId(); - type = AssetType.get("MEDIA"); - AssetReferenceType assetReferenceType = AssetReferenceType.get("MEDIA"); - Response assetResponse = AssetServiceImpl.get(client,String.valueOf(assetId),assetReferenceType); - fileId = assetResponse.results.getMediaFiles().get(0).getId(); - actionType = BookmarkActionType.get("FIRST_PLAY"); - } + // Get VOD asset id from ingest - @Description("bookmark/action/add - basic functionality") - @Test - private void add() { + assetId = mediaAsset.getId(); - Bookmark bookmark = new Bookmark(); - bookmark.setType(type); - bookmark.setId(String.valueOf(assetId)); - bookmark.setPosition(position); + type = AssetType.get(AssetType.MEDIA.getValue()); + AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); + Response assetResponse = AssetServiceImpl.get(client, String.valueOf(assetId), assetReferenceType); + fileId = assetResponse.results.getMediaFiles().get(0).getId(); + actionType = BookmarkActionType.get(BookmarkActionType.FIRST_PLAY.getValue()); - BookmarkPlayerData playerData = new BookmarkPlayerData(); - playerData.setAction(actionType); - playerData.setAverageBitrate(0); - playerData.setTotalBitrate(0); - playerData.setCurrentBitrate(0); + assetList.add(String.valueOf(assetId)); + // Initialize bookmark object parameters + bookmark = BookmarkUtils.addBookmark(0, assetList.get(0), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - playerData.setFileId((long) fileId); + // Initialize bookmarkFilter object parameters + bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC, AssetType.MEDIA, assetList); + } - bookmark.setPlayerData(playerData); + @Description("bookmark/action/add - first play") + @Test + private void firstPlayback() { + // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned assertThat(booleanResponse.error).isNull(); - BookmarkFilter bookmarkFilter = new BookmarkFilter(); - bookmarkFilter.setAssetIdIn(String.valueOf(assetId)); - bookmarkFilter.setOrderBy("POSITION_ASC"); - bookmarkFilter.setAssetTypeEqual(type); + // Invoke bookmark/action/list to verify insertion of bookmark position Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); @@ -73,7 +77,7 @@ private void add() { // *********************************************** // Match content of asset id - assertThat( bookmark1.getId()).isEqualTo(String.valueOf(assetId)); + assertThat(bookmark1.getId()).isEqualTo(String.valueOf(assetId)); // Match content of asset position assertThat(bookmark1.getPosition()).isEqualTo(this.position); @@ -89,5 +93,117 @@ private void add() { // Verify total count = 1 assertThat(bookmarkListResponse.results.getTotalCount()).isEqualTo(1); + } + + @Description("bookmark/action/add - pause") + @Test + private void stopPlayback() { + // Set action type to "PAUSE" + actionType = BookmarkActionType.get(BookmarkActionType.PAUSE.getValue()); + playerData.setAction(actionType); + position = 30; + bookmark.setPosition(position); + + // Invoke bookmark/action/add request + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned + assertThat(booleanResponse.error).isNull(); + + // Invoke bookmark/action/list to verify insertion of bookmark position + Response> bookmarkListResponse2 = BookmarkServiceImpl.list(client, bookmarkFilter); + Bookmark bookmark2 = bookmarkListResponse2.results.getObjects().get(0); + + // Match content of asset position + assertThat(bookmark2.getPosition()).isEqualTo(this.position); + } + + @Description("bookmark/action/add - 95% watching == finish watching") + @Test + private void watchingNinetyFive() { + actionType = BookmarkActionType.get(BookmarkActionType.PLAY.getValue()); + playerData.setAction(actionType); + position = 999; + bookmark.setPosition(position); + + // Invoke bookmark/action/add request + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned + assertThat(booleanResponse.error).isNull(); + + // Invoke bookmark/action/list to verify insertion of bookmark position + Response> bookmarkListResponse3 = BookmarkServiceImpl.list(client, bookmarkFilter); + Bookmark bookmark3 = bookmarkListResponse3.results.getObjects().get(0); + + // Assertions + // *********************************************** + + // Verify finishedWatching = true + assertThat(bookmark3.getFinishedWatching()).isTrue(); + + } + + @Description("bookmark/action/add - back to start - position:0") + @Test + private void backToStart() { + actionType = BookmarkActionType.get(BookmarkActionType.STOP.getValue()); + playerData.setAction(actionType); + position = 0; + bookmark.setPosition(position); + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + + Response> bookmarkListResponse4 = BookmarkServiceImpl.list(client, bookmarkFilter); + Bookmark bookmark4 = bookmarkListResponse4.results.getObjects().get(0); + // Verify finishedWatching = false + assertThat(bookmark4.getFinishedWatching()).isFalse(); + } + + + @Description("bookmark/action/add - finish watching") + @Test + private void finishWatching() { + // Set action type to "FINISH" + actionType = BookmarkActionType.get(BookmarkActionType.FINISH.getValue()); + playerData.setAction(actionType); + position = 60; + bookmark.setPosition(position); + + // Invoke bookmark/action/add request + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); + // Verify no error returned + assertThat(booleanResponse.error).isNull(); + + // Invoke bookmark/action/list to verify insertion of bookmark position + Response> bookmarkListResponse5 = BookmarkServiceImpl.list(client, bookmarkFilter); + Bookmark bookmark5 = bookmarkListResponse5.results.getObjects().get(0); + + // Assertions + // *********************************************** + + // Verify finishedWatching = true + assertThat(bookmark5.getFinishedWatching()).isTrue(); + + } + + // Error validations + + @Description("bookmark/action/add - empty asset id") + @Test + private void emptyAssetId() { + bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + assertThat(booleanResponse.results).isNull(); + // Verify exception returned - code: 500003 ("Invalid Asset id") + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500003).getCode()); + } + + + // TODO - Add test for EPG bookmark + // TODO - Add test for recording bookmark } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java index 6fecc5771..e4551d380 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; +import com.kaltura.client.Client; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.BookmarkOrderBy; @@ -22,6 +23,7 @@ public class ListTests extends BaseTest { + private Client client; private String assetId; private int fileId; @@ -33,6 +35,8 @@ public class ListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { + client = getClient(sharedMasterUserKs); + assetId = "606283"; List assetFileIds = AssetUtils.getAssetFileIds(assetId); fileId = assetFileIds.get(0); @@ -51,17 +55,17 @@ private void BookmarkOrderBy() { // Bookmark asset1 Bookmark bookmark = BookmarkUtils.addBookmark(0, assetId, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - Response booleanResponse = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark); + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); assertThat(booleanResponse.results.booleanValue()).isTrue(); // Bookmark asset2 Bookmark bookmark2 = BookmarkUtils.addBookmark(10, assetId2, fileId2, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - Response booleanResponse2 = BookmarkServiceImpl.add(sharedMasterUserKs, bookmark2); + Response booleanResponse2 = BookmarkServiceImpl.add(client, bookmark2); assertThat(booleanResponse2.results.booleanValue()).isTrue(); BookmarkFilter bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_DESC,AssetType.MEDIA, assetList); - Response> bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + Response> bookmarkListResponse = BookmarkServiceImpl.list(client,bookmarkFilter); Bookmark bookmarkObject = bookmarkListResponse.results.getObjects().get(0); Bookmark bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); @@ -74,7 +78,7 @@ private void BookmarkOrderBy() { assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId)); bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC,AssetType.MEDIA, assetList); - bookmarkListResponse = BookmarkServiceImpl.list(sharedMasterUserKs,bookmarkFilter); + bookmarkListResponse = BookmarkServiceImpl.list(client,bookmarkFilter); bookmarkObject = bookmarkListResponse.results.getObjects().get(0); bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index d39d6344f..54138af84 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.types.Asset; @@ -9,13 +10,16 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.test.tests.BaseTest.getClient; import static com.kaltura.client.test.tests.BaseTest.sharedMasterUserKs; public class AssetUtils extends BaseUtils { public static List getAssetFileIds(String assetId) { + Client client = getClient(sharedMasterUserKs); + AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); - Response assetResponse = AssetServiceImpl.get(sharedMasterUserKs, assetId, assetReferenceType); + Response assetResponse = AssetServiceImpl.get(client, assetId, assetReferenceType); List mediafiles = assetResponse.results.getMediaFiles(); System.out.println(mediafiles.size()); List fileIdsList = new ArrayList<>(); From 28faa89718de5be5d5a4e5ba0542e092ae13d23e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 12 Apr 2018 17:00:33 +0300 Subject: [PATCH 072/605] Finish HouseholdServiceImpl and TransactionHistoryServiceImpl --- .../servicesImpl/HouseholdServiceImpl.java | 92 +++++++++++++++++++ .../TransactionHistoryServiceImpl.java | 38 ++++++++ .../kaltura/client/test/tests/BaseTest.java | 8 +- .../kaltura/client/test/tests/Sandbox.java | 8 +- .../entitlementTests/GrantTests.java | 41 +++++---- .../client/test/utils/HouseholdUtils.java | 1 + src/test/resources/schemas/AppToken.json | 57 ++++++++++++ src/test/resources/schemas/Price.json | 6 +- 8 files changed, 226 insertions(+), 25 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java create mode 100644 src/test/resources/schemas/AppToken.json diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 1ebf12ecb..416aee0f8 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.Client; +import com.kaltura.client.enums.HouseholdFrequencyType; import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.Household; @@ -10,6 +11,7 @@ import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.services.HouseholdService.AddHouseholdBuilder; import static com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; import static org.awaitility.Awaitility.await; @@ -51,4 +53,94 @@ public static Response delete(Client client, @Nullable int householdId) return booleanResponse; } + + // get + public static Response get(Client client, int id) { + GetHouseholdBuilder getHouseholdBuilder = HouseholdService.get(id) + .setCompletion((ApiCompletion) result -> { + householdResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdResponse; + } + + // purge + public static Response purge(Client client, int id) { + PurgeHouseholdBuilder purgeHouseholdBuilder = HouseholdService.purge(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(purgeHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // resetFrequency + public static Response resetFrequency(Client client, HouseholdFrequencyType frequencyType) { + ResetFrequencyHouseholdBuilder resetFrequencyHouseholdBuilder = HouseholdService.resetFrequency(frequencyType) + .setCompletion((ApiCompletion) result -> { + householdResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(resetFrequencyHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdResponse; + } + + // resume + public static Response resume(Client client) { + ResumeHouseholdBuilder resumeHouseholdBuilder = HouseholdService.resume() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(resumeHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // suspend + public static Response suspend(Client client, @Nullable Integer roleId) { + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(roleId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(suspendHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // update + public static Response update(Client client, Household household) { + UpdateHouseholdBuilder updateHouseholdBuilder = HouseholdService.update(household) + .setCompletion((ApiCompletion) result -> { + householdResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateHouseholdBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java new file mode 100644 index 000000000..2d098a091 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java @@ -0,0 +1,38 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.TransactionHistoryService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.BillingTransaction; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.TransactionHistoryFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; +import static org.awaitility.Awaitility.await; + +public class TransactionHistoryServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> billingTransactionListResponse; + + // list + public static Response> list(Client client, TransactionHistoryFilter filter, FilterPager pager) { + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(filter, pager) + .setCompletion((ApiCompletion>) result -> { + billingTransactionListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listTransactionHistoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return billingTransactionListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index b4b185bc6..a09887ea1 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,13 +3,11 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; -import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; import java.util.List; -import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; @@ -69,9 +67,9 @@ public void base_test_before_suite() { // Set project shared HH and users initSharedHousehold(); - mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - System.out.println("INGESTED VOD: " + mediaAsset.getId()); +// mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), +// Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); +// System.out.println("INGESTED VOD: " + mediaAsset.getId()); Logger.getLogger(BaseTest.class).debug("Finish Setup!"); } diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java index 797263f27..6e82529ac 100644 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ b/src/test/java/com/kaltura/client/test/tests/Sandbox.java @@ -1,12 +1,13 @@ package com.kaltura.client.test.tests; +import com.kaltura.client.test.utils.HouseholdUtils; import io.restassured.RestAssured; import io.restassured.path.xml.XmlPath; import org.testng.annotations.Test; import static io.restassured.RestAssured.given; -public class Sandbox { +public class Sandbox extends BaseTest { @Test(enabled = false) private void test() { @@ -25,4 +26,9 @@ private void test() { int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); System.out.println("!!! " + assetId); } + + @Test(enabled = true) + private void test1() { + HouseholdUtils.createHouseHold(2, 1, false); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index f0a446f0c..30f4cc2d3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -1,34 +1,43 @@ package com.kaltura.client.test.tests.servicesTests.entitlementTests; import com.kaltura.client.Client; +import com.kaltura.client.enums.EntityReferenceBy; +import com.kaltura.client.enums.TransactionHistoryOrderBy; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.OttUserService; -import com.kaltura.client.test.Properties; import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; +import com.kaltura.client.test.servicesImpl.TransactionHistoryServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.OttUserUtils; -import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.BillingTransaction; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.TransactionHistoryFilter; +import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class GrantTests extends BaseTest { - @Test(description = "entitlement/action/grant - grant") - private void grant() { + @Test(description = "entitlement/action/grant - grant with history = true") + private void grant_subscription_with_history() { Client client = getClient(null); + // TODO: 4/12/2018 remove hardcoded subscription Id int subscriptionId = 369426; + int ppv = 30297; -// Household household = HouseholdUtils.createHouseHold(2, 1, false); -// HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); -// Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, OttUserUtils.getUserNameFromId(Integer.parseInt(masterUser.getUserId())), -// GLOBAL_USER_PASSWORD, null, null); - OTTUser user = OttUserUtils.generateOttUser(); - + // grant subscription - history = true client.setKs(administratorKs); - client.setUserId(user.getus); - EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, true, null); + client.setUserId(Integer.valueOf(sharedUser.getUserId())); + Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, true, null); + assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + + // check transaction return in transactionHistory + client.setKs(sharedMasterUserKs); + TransactionHistoryFilter filter = new TransactionHistoryFilter(); + filter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); + filter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); + Response> billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, filter, null); -// Client client = getClient(operatorKs); -// EntitlementServiceImpl.grant(client, ) + // assert list item } } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index ec5fa0c7b..7fa66687f 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -67,6 +67,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO } + HouseholdServiceImpl. return household; } diff --git a/src/test/resources/schemas/AppToken.json b/src/test/resources/schemas/AppToken.json new file mode 100644 index 000000000..b2cd279a5 --- /dev/null +++ b/src/test/resources/schemas/AppToken.json @@ -0,0 +1,57 @@ +{ + "$id": "AppToken", + "definitions": { + "AppToken": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 0 + }, + "partnerId": { + "type": "integer", + "minimum": 0 + }, + "sessionDuration": { + "type": "integer", + "minimum": 0 + }, + "hashType": { + "type": "string", + "minLength": 0 + }, + "token": { + "type": "string", + "minLength": 0 + }, + "sessionUserId": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "id", + "partnerId", + "sessionDuration", + "hashType", + "token", + "sessionUserId", + "objectType" + ] + } + }, + "type": "object", + "properties": { + "result": { + "ref": "#/definitions/AppToken" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/Price.json b/src/test/resources/schemas/Price.json index d611a9197..21a4c1431 100644 --- a/src/test/resources/schemas/Price.json +++ b/src/test/resources/schemas/Price.json @@ -1,7 +1,7 @@ { - "$id": "KalturaPrice", + "$id": "Price", "definitions": { - "KalturaPrice": { + "Price": { "type": "object", "properties": { "amount": { @@ -31,5 +31,5 @@ ] } }, - "$ref": "#/definitions/KalturaPrice" + "$ref": "#/definitions/Price" } \ No newline at end of file From 0ff59c41e812d9a29ff820ee8311337fe54e0d66 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 12 Apr 2018 17:25:53 +0300 Subject: [PATCH 073/605] Added draft for ingest EPG --- .../productPriceTests/ListTests.java | 3 + .../client/test/utils/IngestEPGUtils.java | 257 ++++++++++++++++++ 2 files changed, 260 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 8eae84cf6..ec41d9760 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.IngestEPGUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -27,6 +28,8 @@ public void beforeClass() { entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); entitlementPpvsFilter.setIsExpiredEqual(false); + IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), + Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); } @Description("productPrice/action/list - subscription test by Operator without currency") diff --git a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java new file mode 100644 index 000000000..fe565cf0e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java @@ -0,0 +1,257 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.Logger; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.utils.response.base.Response; +import io.restassured.RestAssured; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.tests.BaseTest.anonymousKs; +import static io.restassured.path.xml.XmlPath.from; +import static org.awaitility.Awaitility.await; + +public class IngestEPGUtils extends BaseUtils { + // TODO: think about ENUMS if we really need it here? should we create new ENUM class for it? where? + public static final String DURATION_PERIOD_DAYS = "days"; + public static final String DURATION_PERIOD_HOURS = "hours"; + public static final String DURATION_PERIOD_MINUTES = "minutes"; + public static final String DURATION_PERIOD_SECONDS = "seconds"; + + // default values + public static final int DEFAULT_COUNT_OF_SEASONES = 1; + public static final int DEFAULT_COUNT_OF_PROGRAMMES = 2; + public static final int DEFAULT_PROGRAM_DURATION = 30; + public static final String DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; + + private static List durationPeriodNames = new ArrayList<>(); + static { + durationPeriodNames.add(DURATION_PERIOD_DAYS); + durationPeriodNames.add(DURATION_PERIOD_HOURS); + durationPeriodNames.add(DURATION_PERIOD_MINUTES); + durationPeriodNames.add(DURATION_PERIOD_SECONDS); + } + + // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project + public static MediaAsset ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, + Optional programDuration, Optional programDurationPeriodName, + Optional isCridUnique4AllPrograms, Optional seasonCount, + Optional coguid, Optional crid, Optional seriesId) { + + int programCountValue = programCount.orElse(DEFAULT_COUNT_OF_PROGRAMMES); + if (programCountValue <= 0) { + Logger.getLogger(IngestEPGUtils.class).error("Invalid programCount value " + programCount.get() + + ". Should be bigger than 0"); + return null; + } + int seasonCountValue = seasonCount.orElse(DEFAULT_COUNT_OF_SEASONES); + + String datePattern = "MM/yy/dd HH:mm:ss"; + SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); + String firstProgramStartDateValue = firstProgramStartDate.orElse(getCurrentDataInFormat(datePattern)); + Calendar startDate = Calendar.getInstance(); + try { + startDate.setTime(dateFormat.parse(firstProgramStartDateValue)); + } catch (ParseException e) { + e.printStackTrace(); + } + + int programDurationValue = programDuration.orElse(DEFAULT_PROGRAM_DURATION); + if (programDurationValue <= 0) { + Logger.getLogger(IngestEPGUtils.class).error("Invalid programDuration value " + programDuration.get() + + ". Should be bigger than 0"); + return null; + } + String programDurationPeriodNameValue = programDurationPeriodName.orElse(DEFAULT_PROGRAM_DURATION_PERIOD_NAME); + if (!durationPeriodNames.contains(programDurationPeriodNameValue)) { + Logger.getLogger(IngestEPGUtils.class).error("Invalid programDurationPeriodName value " + programDurationPeriodName.get() + + ". Should be one from " + durationPeriodNames); + return null; + } + boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); + + String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); + String cridValue = crid.orElse(coguidValue); + String seriesIdValue = seriesId.orElse(coguidValue); + int seasonId = 1; + Date endDate; + String output = ""; + String oneProgrammOutput = ""; + SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss"); + Date now = Calendar.getInstance().getTime(); + while (seasonId <= seasonCountValue) { + int idx = 1; + while(idx <= programCountValue) { + endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); + oneProgrammOutput = getProgrammeXML(idx, df2.format(startDate.getTime()), df2.format(endDate), + epgChannelName, coguidValue, cridValue, "Program", df2.format(now), + seriesIdValue, String.valueOf(seasonId), isCridUnique4AllProgramsValue); + startDate.setTime(endDate); + output = output + oneProgrammOutput; + idx = idx + 1; + } + seasonId = seasonId + 1; + } + String epgChannelIngestXml = getChannelXML(PARTNER_ID, epgChannelName, output); + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headermap = new HashMap<>(); + headermap.put("Content-Type", "text/xml;charset=UTF-8"); + headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); + String reqBody = "\n" + + " \n" + + " \n" + + " " + + " " + + " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + epgChannelIngestXml + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + io.restassured.response.Response resp = RestAssured.given() + .log().all() + .headers(headermap) + .body(reqBody) + .post(url); + System.out.println("RESPONSE: " + resp.asString()); + /*String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); + + MediaAsset mediaAsset = new MediaAsset(); + //mediaAsset.setName(nameValue); + mediaAsset.setId(Long.valueOf(id)); + mediaAsset.setDescription(descriptionValue); + //mediaAsset.setStartDate(startDate); + //mediaAsset.setEndDate(endDate); + + await().pollInterval(3, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); + Response mediaAssetDetails = AssetServiceImpl.get(anonymousKs, id, AssetReferenceType.MEDIA); + mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + return mediaAsset;*/ + return null; + } + + private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { + return " " + + "" + + "" + + programsXml + + "" + + "]]>"; + } + + // generate XML for ingest of 1 program + private static String getProgrammeXML(int idx, String startDate, String endDate, String channel, String coguid, String crid, + String programNamePrefix, String currentDate, String seriesId, String seasonNumber, + boolean isCridUnique4AllPrograms) { + String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; + // TODO: complete to cover util from old project completely + String CRID = "" + crid + "_" + idx + ""; + if (isCridUnique4AllPrograms) { + CRID = "" + crid + "_" + seasonNumber + "_" + idx + ""; + } + String output = + "" + + "" + name + "" + + CRID + + "" + startDate + " until " + endDate + "" + + "" + currentDate + "" + + "eng" + + //"" + + //"" + enableCDVR + "" + + //"" + enableCatchUp + ""+ + //"" + enableStartOver + "" + + //"" + enableTrickPlay + "" + + //"" + + //"" + metaName + "" + + //"" + metaValue + "" + + //"" + + "" + + // TODO: that meta should be added into property file + "season_num" + + "" + seasonNumber + "" + + "" + + "" + + // TODO: that meta should be added into property file + "Series_ID" + + "" + seriesId + "" + + "" + + "" + + // TODO: that meta should be added into property file + "Episode number" + + "" + idx + "" + + "" + + /* "" + + "Season" + + "" + seasonNumber + "" + + "" + + "" + + "Episode" + + "" + id + "" + + "" + + */ + //"" + + //"Country" + + //"Israel" + + //"" + + //"" + + //"YEAR" + + //"2015" + + //"" + + //"" + + //"Genre" + + //"" + genre + "" + + //"" + + //"" + + //"Actors" + + //"Shay" + + //"Ortal" + + //"" + + //"" + + //"" + tagName + "" + + //"" + tagValue + "" + + //"" + + //"" + + //"" + parentalFieldName + "" + + //"" + parentalValue + "" + + //"" + + //"" + + //"" + parentalFieldName + "" + + //"" + parentalValue2 + "" + + //"" + + ""; + return output; + } + + private static Date loadEndDate(Date startDate, int durationValue, String periodName) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + switch (periodName) { + case DURATION_PERIOD_DAYS: + calendar.add(Calendar.DATE, durationValue); + break; + case DURATION_PERIOD_HOURS: + calendar.add(Calendar.HOUR, durationValue); + break; + case DURATION_PERIOD_MINUTES: + calendar.add(Calendar.MINUTE, durationValue); + break; + case DURATION_PERIOD_SECONDS: + calendar.add(Calendar.SECOND, durationValue); + } + return calendar.getTime(); + } + + private static Callable isDataReturned(String mediaId) { + return () -> AssetServiceImpl.get(anonymousKs, mediaId, AssetReferenceType.MEDIA).error == null; + } +} From 5c2d781fce4008318779070c055fcb871073d9ec Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 12 Apr 2018 17:26:43 +0300 Subject: [PATCH 074/605] Updated AppToken classes --- .../servicesImpl/AppTokenServiceImpl.java | 4 +- .../servicesTests/appTokenTests/AddTests.java | 56 ++++++++++++++++-- .../client/test/utils/AppTokenUtils.java | 3 +- src/test/resources/schemas/AppToken.json | 58 +++++++++++++++++++ 4 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 src/test/resources/schemas/AppToken.json diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java index a24deca45..2ff8e6247 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java @@ -17,7 +17,7 @@ public class AppTokenServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response appTokenResponse; - public static AddAppTokenBuilder add(Client client, AppToken appToken) { + public static Response add(Client client, AppToken appToken) { AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) .setCompletion((ApiCompletion) result -> { appTokenResponse = result; @@ -28,6 +28,6 @@ public static AddAppTokenBuilder add(Client client, AppToken appToken) { await().untilTrue(done); done.set(false); - return addAppTokenBuilder; + return appTokenResponse; } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java index e228b08cb..4ada9bebf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -2,35 +2,79 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; +import com.kaltura.client.test.Properties; +import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; -import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.AppToken; +import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class AddTests extends BaseTest { private AppTokenHashType hashType; private String sessionUserId; private AppToken appToken = new AppToken(); public static Client client; + String sessionPrivileges; @BeforeClass private void add_tests_before_class() { + sessionUserId = "1577578"; + client = getClient(operatorKs); hashType = AppTokenHashType.SHA1; - sessionUserId = OttUserUtils.generateOttUser().getId(); - appToken = AppTokenUtils.addAppToken(sessionUserId,hashType ); + appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null); + } + + @Description("appToken/action/add") + @Test + private void addAppToken() { + Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + // Assertions + // **************************** + // Verify no error returned + assertThat(appTokenResponse.error).isNull(); + assertThat(appTokenResponse.results.getExpiry()).isNull(); + assertThat(appTokenResponse.results.getId()).isNotEmpty(); + assertThat(appTokenResponse.results.getSessionDuration()).isGreaterThan(0); + assertThat(appTokenResponse.results.getHashType()).isEqualTo(this.hashType); + assertThat(appTokenResponse.results.getToken()).isNotEmpty(); + assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(this.sessionUserId); + assertThat(appTokenResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(String.valueOf(this.sessionUserId)); } - @Description("appToken/action/add") + @Description("appToken/action/add - without hash type") + @Test + private void addAppTokenWithDefaultHashType() { + appToken = AppTokenUtils.addAppToken(sessionUserId, null, null); + // Invoke AppToken/action/add - with no hash type (will return the default hash type) + Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + // Verify that hashType = SHA256 + assertThat(appTokenResponse.results.getHashType()).isEqualTo(AppTokenHashType.SHA256); + } + + @Description("appToken/action/add - with privileges") @Test + private void addAppTokenWithPrivileges() { + sessionPrivileges = "key1:value1,key2:value2"; + appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges); + Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); - private void addAppToken() { -// Response appTokenResponse = AppTokenServiceImpl.add() + assertThat(appTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); } + + @Description("appToken/action/add - with expiry date") + @Test + private void addAppTokenWith + + + } diff --git a/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java index aa6f91c66..acd6c1bb7 100644 --- a/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java @@ -5,10 +5,11 @@ public class AppTokenUtils extends BaseUtils { - public static AppToken addAppToken(String userId, AppTokenHashType appTokenHashType) { + public static AppToken addAppToken(String userId, AppTokenHashType appTokenHashType, String sessionPrivileges) { AppToken appToken = new AppToken(); appToken.setHashType(appTokenHashType); appToken.sessionUserId(userId); + appToken.setSessionPrivileges(sessionPrivileges); return appToken; } diff --git a/src/test/resources/schemas/AppToken.json b/src/test/resources/schemas/AppToken.json new file mode 100644 index 000000000..55a0a8946 --- /dev/null +++ b/src/test/resources/schemas/AppToken.json @@ -0,0 +1,58 @@ +{ + "$id": "AppToken", + "definitions": { + "AppToken": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 0 + }, + "partnerId": { + "type": "integer", + "minimum": 0 + }, + "sessionDuration": { + "type": "integer", + "minimum": 0 + }, + "hashType": { + "type": "string", + "minLength": 0 + }, + "token": { + "type": "string", + "minLength": 0 + }, + "sessionUserId": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "enum": ["AppToken"], + "minLength": 0 + } + }, + "required": [ + "id", + "partnerId", + "sessionDuration", + "hashType", + "token", + "sessionUserId", + "objectType" + ] + } + }, + "type": "object", + "properties": { + "result": { + "ref": "#/definitions/AppToken" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From 08754dd7ed00ba503f1d6387ce56142e3e1db380 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 15 Apr 2018 10:50:18 +0300 Subject: [PATCH 075/605] add getRegularUsersListFromHouseHold method to HouseholdUtils --- .../com/kaltura/client/types/Household.java | 2 -- .../servicesImpl/HouseholdServiceImpl.java | 21 +++++++++++++------ .../HouseholdUserServiceImpl.java | 17 +++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 19 +++++++---------- .../client/test/utils/HouseholdUtils.java | 19 +++++++++++++++-- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/kaltura/client/types/Household.java b/src/main/java/com/kaltura/client/types/Household.java index f1993a6d0..22bb19410 100644 --- a/src/main/java/com/kaltura/client/types/Household.java +++ b/src/main/java/com/kaltura/client/types/Household.java @@ -31,7 +31,6 @@ import com.kaltura.client.Params; import com.kaltura.client.enums.HouseholdRestriction; import com.kaltura.client.enums.HouseholdState; -import com.kaltura.client.types.ObjectBase; import com.kaltura.client.utils.GsonParser; import com.kaltura.client.utils.request.MultiRequestBuilder; @@ -334,7 +333,6 @@ public Household(JsonObject jsonObject) throws APIException { frequencyNextUserAction = GsonParser.parseLong(jsonObject.get("frequencyNextUserAction")); restriction = HouseholdRestriction.get(GsonParser.parseString(jsonObject.get("restriction"))); roleId = GsonParser.parseInt(jsonObject.get("roleId")); - } public Params toParams() { diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 416aee0f8..6f2ae1f1e 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -55,12 +55,21 @@ public static Response delete(Client client, @Nullable int householdId) } // get - public static Response get(Client client, int id) { - GetHouseholdBuilder getHouseholdBuilder = HouseholdService.get(id) - .setCompletion((ApiCompletion) result -> { - householdResponse = result; - done.set(true); - }); + public static Response get(Client client, @Nullable Integer id) { + GetHouseholdBuilder getHouseholdBuilder; + if (id == null) { + getHouseholdBuilder = HouseholdService.get() + .setCompletion((ApiCompletion) result -> { + householdResponse = result; + done.set(true); + }); + } else { + getHouseholdBuilder = HouseholdService.get(id) + .setCompletion((ApiCompletion) result -> { + householdResponse = result; + done.set(true); + }); + } TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdBuilder.build(client)); await().untilTrue(done); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java index 9787c8bf3..dcf997615 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java @@ -12,6 +12,7 @@ import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.HouseholdUserService.*; import static com.kaltura.client.services.HouseholdUserService.AddHouseholdUserBuilder; import static com.kaltura.client.services.HouseholdUserService.ListHouseholdUserBuilder; import static org.awaitility.Awaitility.await; @@ -22,6 +23,7 @@ public class HouseholdUserServiceImpl { private static Response householdUserResponse; private static Response> householdUserListResponse; + private static Response booleanResponse; // add @@ -53,4 +55,19 @@ public static Response> list(Client client, @Nullabl return householdUserListResponse; } + + // delete + public static Response delete(Client client, String id) { + DeleteHouseholdUserBuilder deleteHouseholdUserBuilder = HouseholdUserService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteHouseholdUserBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index a09887ea1..dd9d7f357 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,18 +3,17 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; +import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; -import java.util.List; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; -import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; import static com.kaltura.client.test.utils.OttUserUtils.getUserNameFromId; import static org.awaitility.Awaitility.setDefaultTimeout; @@ -75,20 +74,18 @@ public void base_test_before_suite() { } private void initSharedHousehold() { + // create hh sharedHousehold = createHouseHold(2, 2, false); - List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); - for (HouseholdUser user : sharedHouseholdUsers) { - if (user.getIsMaster() != null && user.getIsMaster()) { - sharedMasterUser = user; - } - if (user.getIsMaster() == null && user.getIsDefault() == null) { - sharedUser = user; - } - } + // init shared users + sharedMasterUser = HouseholdUtils.getMasterUserFromHousehold(sharedHousehold); + sharedUser = HouseholdUtils.getUsersListFromHouseHold(sharedHousehold).get(0); + + // init shared master user ks loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedMasterUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); + // init shared user ks loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 7fa66687f..1e8c468e7 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -67,8 +67,8 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO } - HouseholdServiceImpl. - return household; + householdResponse = HouseholdServiceImpl.get(client, null); + return householdResponse.results; } // get users list from given household @@ -107,4 +107,19 @@ public static HouseholdUser getDefaultUserFromHousehold(Household household) { Logger.getLogger(BaseUtils.class).error("can't find default user in household"); return null; } + + // get regular users list from given household + public static List getRegularUsersListFromHouseHold(Household household) { + List users = getUsersListFromHouseHold(household); + + for (HouseholdUser user : users) { + if (user.getIsDefault() != null && user.getIsDefault()) { + users.remove(user); + } + if (user.getIsMaster() != null && user.getIsMaster()) { + users.remove(user); + } + } + return users; + } } From 2dd895964ee6258ec53908dc03dc3684aa7cc93e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Sun, 15 Apr 2018 14:15:25 +0300 Subject: [PATCH 076/605] Updated AppToken classes + added 2 new utils to baseutils --- .../servicesImpl/AppTokenServiceImpl.java | 16 +++++ .../servicesTests/appTokenTests/AddTests.java | 32 +++++++--- .../servicesTests/appTokenTests/GetTests.java | 64 +++++++++++++++++++ .../client/test/utils/AppTokenUtils.java | 7 +- .../kaltura/client/test/utils/BaseUtils.java | 28 ++++++-- src/test/resources/schemas/Bookmark.json | 13 +++- 6 files changed, 144 insertions(+), 16 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java index 2ff8e6247..b300aca74 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java @@ -17,6 +17,7 @@ public class AppTokenServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response appTokenResponse; + // AppToken/action/add public static Response add(Client client, AppToken appToken) { AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) .setCompletion((ApiCompletion) result -> { @@ -30,4 +31,19 @@ public static Response add(Client client, AppToken appToken) { return appTokenResponse; } + + //AppToken/acton/get + public static Response get(Client client, String id) { + GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(id) + .setCompletion((ApiCompletion) result -> { + appTokenResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getAppTokenBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return appTokenResponse; + } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java index 4ada9bebf..fba0b97a1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -6,12 +6,14 @@ import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.AppToken; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class AddTests extends BaseTest { @@ -20,7 +22,7 @@ public class AddTests extends BaseTest { private String sessionUserId; private AppToken appToken = new AppToken(); public static Client client; - String sessionPrivileges; + private String sessionPrivileges; @BeforeClass @@ -28,7 +30,7 @@ private void add_tests_before_class() { sessionUserId = "1577578"; client = getClient(operatorKs); hashType = AppTokenHashType.SHA1; - appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null); + appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); } @Description("appToken/action/add") @@ -54,7 +56,7 @@ private void addAppToken() { @Description("appToken/action/add - without hash type") @Test private void addAppTokenWithDefaultHashType() { - appToken = AppTokenUtils.addAppToken(sessionUserId, null, null); + appToken = AppTokenUtils.addAppToken(sessionUserId, null, null, null); // Invoke AppToken/action/add - with no hash type (will return the default hash type) Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); // Verify that hashType = SHA256 @@ -65,7 +67,7 @@ private void addAppTokenWithDefaultHashType() { @Test private void addAppTokenWithPrivileges() { sessionPrivileges = "key1:value1,key2:value2"; - appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges); + appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, null); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); assertThat(appTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); @@ -73,8 +75,22 @@ private void addAppTokenWithPrivileges() { @Description("appToken/action/add - with expiry date") @Test - private void addAppTokenWith - - - + private void addAppTokenWithExpiryDate() { + Long expiryDate = BaseUtils.getTimeInEpoch(1); + appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); + Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); + assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); + + // Wait until token is expired (according to expiry date) + System.out.println("Waiting 1 minute until token expiry date reached"); + + try { + Thread.sleep(72000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + Response getAppTokenResponse = AppTokenServiceImpl.get(client, addAppTokenResponse.results.getId()); + assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java new file mode 100644 index 000000000..7a84af7ee --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java @@ -0,0 +1,64 @@ +package com.kaltura.client.test.tests.servicesTests.appTokenTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AppTokenHashType; +import com.kaltura.client.test.Properties; +import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AppTokenUtils; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.AppToken; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static org.assertj.core.api.Assertions.assertThat; + +public class GetTests extends BaseTest { + + final private String sessionUserId = "1577578"; + private String sessionPrivileges = "key1:value1,key2:value2"; + private AppTokenHashType hashType; + public static Client client; + Long expiryDate; + int offSetInMinutes = 1; + int sessionDuration = 86400; + AppToken appToken; + + @BeforeClass + private void get_tests_before_class() { + client = getClient(operatorKs); + hashType = AppTokenHashType.SHA1; + + expiryDate = BaseUtils.getTimeInEpoch(offSetInMinutes); + } + + @Description("AppToken/action/get") + @Test + + private void getAppToken() { + appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); + Response getAppTokenResponse = AppTokenServiceImpl.get(client, addAppTokenResponse.results.getId()); + + assertThat(getAppTokenResponse.results.getId()).isEqualTo(addAppTokenResponse.results.getId()); + assertThat(getAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); + assertThat(getAppTokenResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(getAppTokenResponse.results.getSessionDuration()).isEqualTo(sessionDuration); + assertThat(getAppTokenResponse.results.getHashType()).isEqualTo(hashType); + assertThat(getAppTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); + assertThat(getAppTokenResponse.results.getToken()).isEqualTo(addAppTokenResponse.results.getToken()); + assertThat(getAppTokenResponse.results.getSessionUserId()).isEqualTo(sessionUserId); + } + + @Description("AppToken/action/get") + @Test + private void getAppTokenWithInvalidId() { + Response getAppTokenResponse = AppTokenServiceImpl.get(client, "1234"); + assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + } + + +} diff --git a/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java index acd6c1bb7..696c898e0 100644 --- a/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java @@ -3,13 +3,16 @@ import com.kaltura.client.enums.AppTokenHashType; import com.kaltura.client.types.AppToken; +import javax.annotation.Nullable; + public class AppTokenUtils extends BaseUtils { - public static AppToken addAppToken(String userId, AppTokenHashType appTokenHashType, String sessionPrivileges) { + public static AppToken addAppToken(String userId, @Nullable AppTokenHashType appTokenHashType, @Nullable String sessionPrivileges, @Nullable Integer expiryDate) { AppToken appToken = new AppToken(); appToken.setHashType(appTokenHashType); - appToken.sessionUserId(userId); + appToken.setSessionUserId(userId); appToken.setSessionPrivileges(sessionPrivileges); + appToken.setExpiry(expiryDate); return appToken; } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index dd7aa743d..abd68818a 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -13,10 +13,7 @@ import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; -import java.util.Random; +import java.util.*; import java.util.concurrent.ThreadLocalRandom; import static com.kaltura.client.test.Properties.API_URL_VERSION; @@ -36,6 +33,29 @@ public static String getOffsetDateInFormat(int offsetDay, String pattern) { return dateFormat.format(cal.getTime()); } + // Get Date time according to off set parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) + public static String getTimeInDate(int offSetInMinutes) { + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + Date dNow = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dNow); + calendar.add(Calendar.MINUTE, offSetInMinutes); + dNow = calendar.getTime(); + + return dateFormat.format(dNow); + } + + // Get epoch time in seconds according to off set parameter provided (in minutes) + public static long getTimeInEpoch (int offSetInMinutes) { + //DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + Date dNow = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dNow); + calendar.add(Calendar.MINUTE, offSetInMinutes); + + return calendar.getTimeInMillis()/1000; + } + // generate current data String in specified format public static String getCurrentDataInFormat(String pattern) { return getOffsetDateInFormat(0, pattern); diff --git a/src/test/resources/schemas/Bookmark.json b/src/test/resources/schemas/Bookmark.json index 71a7c931c..8eb2d63f6 100644 --- a/src/test/resources/schemas/Bookmark.json +++ b/src/test/resources/schemas/Bookmark.json @@ -56,14 +56,23 @@ "type": "string", "minLength": 0 } - } + }, + "required": [ + "id", + "userId", + "position", + "positionOwner", + "finishedWatching", + "type" + ] } }, "type": "object", "properties": { "result": { - "type": "boolean" + "type": "boolean", + "ref": "#/definitions/Bookmark" }, "executionTime": { "type": "number", From cdffadd9492f62f8eadbffbb27e002b0b14c4938 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 15 Apr 2018 16:23:51 +0300 Subject: [PATCH 077/605] Completed simple version of IngestEPG util --- .../test/servicesImpl/AssetServiceImpl.java | 26 +++++++-- .../productPriceTests/ListTests.java | 3 +- .../kaltura/client/test/utils/DBUtils.java | 25 ++++++++- .../client/test/utils/IngestEPGUtils.java | 55 ++++++++++++------- src/test/resources/schemas/Asset.json | 18 ++++++ src/test/resources/schemas/ListResponse.json | 4 ++ 6 files changed, 104 insertions(+), 27 deletions(-) create mode 100644 src/test/resources/schemas/Asset.json diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java index c1b17c275..b7172964e 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java @@ -3,14 +3,16 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.AssetService.*; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.Asset; +import com.kaltura.client.types.AssetFilter; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; - +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.AssetService.GetAssetBuilder; import static org.awaitility.Awaitility.await; public class AssetServiceImpl { @@ -18,8 +20,9 @@ public class AssetServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response assetResponse; + private static Response> assetListResponse; - // list + // get public static Response get(Client client, String id, AssetReferenceType assetReferenceType) { GetAssetBuilder assetBuilder = AssetService.get(id, assetReferenceType) .setCompletion((ApiCompletion) result -> { @@ -33,6 +36,21 @@ public static Response get(Client client, String id, AssetReferenceType a return assetResponse; } + + // list + public static Response> list(Client client, AssetFilter assetFilter, @Nullable FilterPager filterPager) { + ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + assetListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listAssetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetListResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 6c250c7df..7be1ca1dd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -32,8 +32,9 @@ public void beforeClass() { entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); entitlementPpvsFilter.setIsExpiredEqual(false); - IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), + /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); + System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ } @Description("productPrice/action/list - subscription test by Operator without currency") diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index e3ed0b13c..24d31298f 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -20,7 +20,7 @@ public class DBUtils extends BaseUtils { //selects private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; - + private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; public static String getActivationToken(String username) { openConnection(); @@ -45,6 +45,29 @@ public static String getActivationToken(String username) { return activationToken; } + public static int getEpgChannelId(String channelName) { + openConnection(); + try { + rs = stam.executeQuery(String.format(EPG_CHANNEL_ID_SELECT, PARTNER_ID + 1, channelName)); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + } + int epgChannelId =-1; + try { + epgChannelId = rs.getInt("ID"); + } catch (SQLException e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("epgChannelId can't be null"); + } + closeConnection(); + return epgChannelId; + } + private static void openConnection() { dataSource = new SQLServerDataSource(); dataSource.setUser(getProperty(DB_USER)); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java index a29014210..2042c70ef 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java @@ -1,11 +1,9 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; import com.kaltura.client.Logger; -import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; import java.text.ParseException; @@ -16,7 +14,6 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.anonymousKs; import static com.kaltura.client.test.tests.BaseTest.getClient; -import static io.restassured.path.xml.XmlPath.from; import static org.awaitility.Awaitility.await; public class IngestEPGUtils extends BaseUtils { @@ -40,8 +37,10 @@ public class IngestEPGUtils extends BaseUtils { durationPeriodNames.add(DURATION_PERIOD_SECONDS); } + private static String titleOfIngestedItem = ""; + // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project - public static MediaAsset ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, + public static Response> ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, Optional programDuration, Optional programDurationPeriodName, Optional isCridUnique4AllPrograms, Optional seasonCount, Optional coguid, Optional crid, Optional seriesId) { @@ -123,21 +122,32 @@ public static MediaAsset ingestEPG(String epgChannelName, Optional prog .headers(headermap) .body(reqBody) .post(url); - System.out.println("RESPONSE: " + resp.asString()); - /*String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - - MediaAsset mediaAsset = new MediaAsset(); - //mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id)); - mediaAsset.setDescription(descriptionValue); - //mediaAsset.setStartDate(startDate); - //mediaAsset.setEndDate(endDate); - - await().pollInterval(3, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); - Response mediaAssetDetails = AssetServiceImpl.get(anonymousKs, id, AssetReferenceType.MEDIA); - mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); - return mediaAsset;*/ - return null; + //System.out.println("RESPONSE: " + resp.asString()); + int epgChannelId = DBUtils.getEpgChannelId(epgChannelName); + // TODO: create method getting epoch value from String and pattern + long epoch = 0L; + try { + Date firstProgramStartDateAsDate = dateFormat.parse(firstProgramStartDateValue); + epoch = firstProgramStartDateAsDate.getTime()/1000; + } catch (ParseException e) { + e.printStackTrace(); + } + String firstProgramStartDateEpoch = String.valueOf(epoch); + + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); + assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + await().pollInterval(3, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS) + .until(isDataReturned(epgChannelId, assetFilter, programCountValue*seasonCountValue)); + + Response> ingestedProgrammes = AssetServiceImpl.list(getClient(anonymousKs), assetFilter, null); + // TODO: complete Asset.json at least for programs + return ingestedProgrammes; + } + + private static Callable isDataReturned(int epgChannelId, SearchAssetFilter assetFilter, int totalCount) { + return () -> (AssetServiceImpl.list(getClient(anonymousKs), assetFilter, null).error == null && + AssetServiceImpl.list(getClient(anonymousKs), assetFilter, null).results.getTotalCount() == totalCount); } private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { @@ -156,6 +166,9 @@ private static String getProgrammeXML(int idx, String startDate, String endDate, String programNamePrefix, String currentDate, String seriesId, String seasonNumber, boolean isCridUnique4AllPrograms) { String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; + if ("".equals(titleOfIngestedItem)) { + titleOfIngestedItem = name; + } // TODO: complete to cover util from old project completely String CRID = "" + crid + "_" + idx + ""; if (isCridUnique4AllPrograms) { diff --git a/src/test/resources/schemas/Asset.json b/src/test/resources/schemas/Asset.json new file mode 100644 index 000000000..22a7e00b3 --- /dev/null +++ b/src/test/resources/schemas/Asset.json @@ -0,0 +1,18 @@ +{ + "$id": "Asset", + "definitions": { + "Asset": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + } + } + } + }, + "executionTime": { + "type": "number", + "minimum": 0 + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 4dfb1d50a..753b14a3e 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -32,6 +32,9 @@ }, { "$ref": "Bookmark.json#/definitions/Bookmark" + }, + { + "$ref": "Asset.json#/definitions/Asset" } ] } @@ -43,6 +46,7 @@ "objectType": { "type": "string", "enum": [ + "KalturaAssetListResponse", "KalturaEntitlementListResponse", "KalturaBillingTransactionListResponse", "KalturaHouseholdUserListResponse", From 323c281eaef1d6d429c1dab14a6ac2b0ddcc2a38 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 15 Apr 2018 16:42:23 +0300 Subject: [PATCH 078/605] add entitlement/action/grant tests --- .../kaltura/client/test/tests/BaseTest.java | 31 +-- .../entitlementTests/GrantTests.java | 236 ++++++++++++++++-- .../servicesTests/ottUserTests/ListTests.java | 8 +- .../client/test/utils/HouseholdUtils.java | 7 +- .../client/test/utils/IngestVODUtils.java | 7 +- .../client/test/utils/OttUserUtils.java | 18 +- src/test/resources/schemas/Bookmark.json | 1 - src/test/resources/schemas/Household.json | 12 +- .../resources/schemas/HouseholdDevice.json | 2 +- src/test/resources/schemas/ListResponse.json | 8 +- src/test/resources/schemas/LoginResponse.json | 4 +- src/test/resources/schemas/MediaAsset.json | 16 +- .../schemas/MultilingualStringValueArray.json | 3 +- .../resources/schemas/PpvEntitlement.json | 6 +- src/test/resources/schemas/PpvPrice.json | 8 +- .../schemas/SubscriptionEntitlement.json | 4 +- .../resources/schemas/SubscriptionPrice.json | 8 +- src/test/resources/schemas/Transaction.json | 2 +- 18 files changed, 294 insertions(+), 87 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index dd9d7f357..1b7374ae0 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,18 +3,19 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; +import java.util.List; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; -import static com.kaltura.client.test.utils.OttUserUtils.getUserNameFromId; +import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.OttUserUtils.getUserById; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -64,8 +65,8 @@ public void base_test_before_suite() { anonymousKs = loginSession.results.getKs(); // Set project shared HH and users - initSharedHousehold(); - +// initSharedHousehold(); +// // mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), // Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); // System.out.println("INGESTED VOD: " + mediaAsset.getId()); @@ -74,19 +75,21 @@ public void base_test_before_suite() { } private void initSharedHousehold() { - // create hh sharedHousehold = createHouseHold(2, 2, false); - - // init shared users - sharedMasterUser = HouseholdUtils.getMasterUserFromHousehold(sharedHousehold); - sharedUser = HouseholdUtils.getUsersListFromHouseHold(sharedHousehold).get(0); - - // init shared master user ks - loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedMasterUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); + List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); + for (HouseholdUser user : sharedHouseholdUsers) { + if (user.getIsMaster() != null && user.getIsMaster()) { + sharedMasterUser = user; + } + if (user.getIsMaster() == null && user.getIsDefault() == null) { + sharedUser = user; + } + } + + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - // init shared user ks - loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(sharedUser.getUserId())), GLOBAL_USER_PASSWORD, null, null); + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index 30f4cc2d3..3c74287af 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -2,14 +2,16 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.EntityReferenceBy; +import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionHistoryOrderBy; import com.kaltura.client.enums.TransactionType; import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; +import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.servicesImpl.TransactionHistoryServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.BillingTransaction; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.TransactionHistoryFilter; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.Test; @@ -17,27 +19,227 @@ public class GrantTests extends BaseTest { - @Test(description = "entitlement/action/grant - grant with history = true") + // TODO: 4/12/2018 remove hardcoded subscription Id + private final int subscriptionId = 369426; + private final int ppvId = 30297; + private final int contentId = 937202; //937190; + + private Response> billingTransactionListResponse; + + + @Test(description = "entitlement/action/grant - grant subscription with history = true") private void grant_subscription_with_history() { - Client client = getClient(null); + Client client = getClient(administratorKs); + + // set household + Household household = HouseholdUtils.createHouseHold(2, 1, false); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); - // TODO: 4/12/2018 remove hardcoded subscription Id - int subscriptionId = 369426; - int ppv = 30297; // grant subscription - history = true - client.setKs(administratorKs); - client.setUserId(Integer.valueOf(sharedUser.getUserId())); + client.setUserId(Integer.valueOf(user.getUserId())); Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, true, null); + + assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + + + // verify other user from the household entitled to granted subscription + client.setUserId(Integer.valueOf(masterUser.getUserId())); + + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.subscriptionIdIn(String.valueOf(subscriptionId)); + + Response> productPriceListResponse = ProductPriceServiceImpl.list(client, productPriceFilter); + ProductPrice productPrice = productPriceListResponse.results.getObjects().get(0); + + assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPrice.getPrice().getAmount()).isEqualTo(0); + assertThat(productPrice.getPurchaseStatus().getValue()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED.getValue()); + + + // check transaction return in transactionHistory by user + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setUserId(null); + + BillingTransaction billingTransaction; + TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); + transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); + + billingTransaction = billingTransactionListResponse.results.getObjects().get(0); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(subscriptionId)); + + + // check transaction return in transactionHistory by household + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); + + billingTransaction = billingTransactionListResponse.results.getObjects().get(0); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(subscriptionId)); + + + // force cancel subscription + foreCancelSubsription(Integer.parseInt(user.getUserId())); + } + + @Test(description = "entitlement/action/grant - grant subscription with history = false") + private void grant_subscription_without_history() { + Client client = getClient(administratorKs); + + // set household + Household household = HouseholdUtils.createHouseHold(2, 1, false); + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + + + // grant subscription - history = true + client.setUserId(Integer.valueOf(user.getUserId())); + Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + + assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + + + // check transaction not return in transactionHistory by user + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setUserId(null); + + TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); + transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); + + + // check transaction not return in transactionHistory by household + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); + + + // force cancel subscription + foreCancelSubsription(Integer.parseInt(user.getUserId())); + } + + @Test(description = "entitlement/action/grant - grant ppv with history = true") + private void grant_ppv_with_history() { + Client client = getClient(administratorKs); + + // set household + Household household = HouseholdUtils.createHouseHold(2, 1, false); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + + + // grant subscription - history = true + client.setUserId(Integer.valueOf(user.getUserId())); + Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); + assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); - // check transaction return in transactionHistory - client.setKs(sharedMasterUserKs); - TransactionHistoryFilter filter = new TransactionHistoryFilter(); - filter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); - filter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - Response> billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, filter, null); - // assert list item + // verify other user from the household entitled to granted subscription + client.setUserId(Integer.valueOf(masterUser.getUserId())); + + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.fileIdIn(String.valueOf(contentId)); + + Response> productPriceListResponse = ProductPriceServiceImpl.list(client, productPriceFilter); + ProductPrice productPrice = productPriceListResponse.results.getObjects().get(0); + + assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPrice.getPrice().getAmount()).isEqualTo(0); + assertThat(productPrice.getPurchaseStatus().getValue()).isEqualTo(PurchaseStatus.PPV_PURCHASED.getValue()); + + + // check transaction return in transactionHistory by user + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setUserId(null); + + BillingTransaction billingTransaction; + TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); + transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); + + billingTransaction = billingTransactionListResponse.results.getObjects().get(0); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + + + // check transaction return in transactionHistory by household + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); + + billingTransaction = billingTransactionListResponse.results.getObjects().get(0); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + + + // force cancel subscription + foreCancelSubsription(Integer.parseInt(user.getUserId())); + } + + @Test(description = "entitlement/action/grant - grant ppv with history = false") + private void grant_ppv_without_history() { + Client client = getClient(administratorKs); + + // set household + Household household = HouseholdUtils.createHouseHold(2, 1, false); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + + + // grant subscription - history = true + client.setUserId(Integer.valueOf(user.getUserId())); + Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); + + assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + + + // check transaction return in transactionHistory by user + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setUserId(null); + + BillingTransaction billingTransaction; + TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); + transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); + + billingTransaction = billingTransactionListResponse.results.getObjects().get(0); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + + + // check transaction return in transactionHistory by household + transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); + + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); + + billingTransaction = billingTransactionListResponse.results.getObjects().get(0); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + + + // force cancel subscription + foreCancelSubsription(Integer.parseInt(user.getUserId())); + } + + //ppvId, TransactionType.SUBSCRIPTION + + private void foreCancelSubsription(int userId) { + Client client = getClient(administratorKs); + client.setUserId(userId); + EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index eb9a89c11..e883f30ef 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -18,7 +18,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUserFromHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; -import static com.kaltura.client.test.utils.OttUserUtils.getUserNameFromId; +import static com.kaltura.client.test.utils.OttUserUtils.getUserById; import static org.assertj.core.api.Assertions.assertThat; public class ListTests extends BaseTest { @@ -39,7 +39,7 @@ private void ottUser_list_tests_setup() { private void list_from_master_ks() { HouseholdUser masterUser = getMasterUserFromHousehold(household); - Response loginResponse = login(client, PARTNER_ID, getUserNameFromId(Integer.parseInt(masterUser.getUserId())), + Response loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(masterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); client.setKs(loginResponse.results.getLoginSession().getKs()); @@ -73,7 +73,7 @@ private void list_withd_filter_usernameEqual() { List householdUsers = getUsersListFromHouseHold(household); OTTUserFilter filter = new OTTUserFilter(); - String usernameEqual = getUserNameFromId(Integer.valueOf(householdUsers.get(0).getUserId())); + String usernameEqual = getUserById(Integer.valueOf(householdUsers.get(0).getUserId())).getUsername(); filter.setUsernameEqual(usernameEqual); @@ -92,7 +92,7 @@ private void list_with_not_valid_filter() { OTTUserFilter filter = new OTTUserFilter(); filter.setIdIn(householdUsers.get(0).getUserId()); - filter.setUsernameEqual(getUserNameFromId(Integer.valueOf(householdUsers.get(1).getUserId()))); + filter.setUsernameEqual(getUserById(Integer.valueOf(householdUsers.get(1).getUserId())).getUsername()); client.setKs(administratorKs); householdUserListResponse = list(client, filter); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 1e8c468e7..d57e0ade5 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -8,6 +8,7 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -111,15 +112,17 @@ public static HouseholdUser getDefaultUserFromHousehold(Household household) { // get regular users list from given household public static List getRegularUsersListFromHouseHold(Household household) { List users = getUsersListFromHouseHold(household); + List usersToRemove = new ArrayList<>(); for (HouseholdUser user : users) { if (user.getIsDefault() != null && user.getIsDefault()) { - users.remove(user); + usersToRemove.add(user); } if (user.getIsMaster() != null && user.getIsMaster()) { - users.remove(user); + usersToRemove.add(user); } } + users.removeAll(usersToRemove); return users; } } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index e45edb3d3..afb52c54c 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -21,9 +21,8 @@ public class IngestVODUtils extends BaseUtils { // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, - Optional thumbUrl, Optional description, Optional catalogStartDate, - Optional catalogEndDate, Optional startDate, Optional endDate, + public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, + Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); @@ -68,6 +67,8 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op await().pollInterval(3, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); Response mediaAssetDetails = AssetServiceImpl.get(getClient(anonymousKs), id, AssetReferenceType.MEDIA); mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + + // TODO: 4/15/2018 add log for ingest and index failures return mediaAsset; } diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 4f3de82d1..298a09e8c 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -2,13 +2,16 @@ import com.kaltura.client.Client; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; -import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import java.util.Random; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.tests.BaseTest.administratorKs; +import static com.kaltura.client.test.tests.BaseTest.getClient; public class OttUserUtils extends BaseUtils { @@ -33,11 +36,18 @@ public static OTTUser generateOttUser() { return user; } - public static String getUserNameFromId(int userId) { - Client client = BaseTest.getClient(administratorKs); + public static OTTUser getUserById(int userId) { + Client client = getClient(administratorKs); client.setUserId(userId); Response userResponse = OttUserServiceImpl.get(client); - return userResponse.results.getUsername(); + return userResponse.results; + } + + public static String getKs(int userId) { + Client client = getClient(null); + OTTUser ottUser = getUserById(userId); + Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, ottUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + return loginResponse.results.getLoginSession().getKs(); } } diff --git a/src/test/resources/schemas/Bookmark.json b/src/test/resources/schemas/Bookmark.json index 71a7c931c..77fac7a3c 100644 --- a/src/test/resources/schemas/Bookmark.json +++ b/src/test/resources/schemas/Bookmark.json @@ -59,7 +59,6 @@ } } }, - "type": "object", "properties": { "result": { diff --git a/src/test/resources/schemas/Household.json b/src/test/resources/schemas/Household.json index 7d3197459..1bbafa220 100644 --- a/src/test/resources/schemas/Household.json +++ b/src/test/resources/schemas/Household.json @@ -1,5 +1,5 @@ { - "$id": "KalturaHousehold", + "$id": "Household", "type": "object", "properties": { "result": { @@ -38,7 +38,6 @@ }, "users": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { @@ -59,7 +58,6 @@ }, "masterUsers": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { @@ -80,7 +78,6 @@ }, "defaultUsers": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { @@ -100,8 +97,7 @@ } }, "pendingUsers": { - "type": "array", - "additionalItems": false + "type": "array" }, "regionId": { "type": "integer", @@ -126,13 +122,11 @@ }, "deviceFamilies": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { "devices": { - "type": "array", - "additionalItems": false + "type": "array" }, "id": { "type": "integer", diff --git a/src/test/resources/schemas/HouseholdDevice.json b/src/test/resources/schemas/HouseholdDevice.json index a92228ffe..03e368374 100644 --- a/src/test/resources/schemas/HouseholdDevice.json +++ b/src/test/resources/schemas/HouseholdDevice.json @@ -1,5 +1,5 @@ { - "$id": "KalturaHouseholdDevice", + "$id": "HouseholdDevice", "type": "object", "properties": { "result": { diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 4dfb1d50a..6672f6cbe 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -10,10 +10,10 @@ "items": { "anyOf": [ { - "$ref": "PpvEntitlement.json#/definitions/KalturaPpvEntitlement" + "$ref": "PpvEntitlement.json#/definitions/PpvEntitlement" }, { - "$ref": "SubscriptionEntitlement.json#/definitions/KalturaSubscriptionEntitlement" + "$ref": "SubscriptionEntitlement.json#/definitions/SubscriptionEntitlement" }, { "$ref": "BillingTransaction.json#/definitions/BillingTransaction" @@ -25,10 +25,10 @@ "$ref": "OTTUser.json#/definitions/OTTUser" }, { - "$ref": "SubscriptionPrice.json#/definitions/KalturaSubscriptionPrice" + "$ref": "SubscriptionPrice.json#/definitions/SubscriptionPrice" }, { - "$ref": "PpvPrice.json#/definitions/KalturaPpvPrice" + "$ref": "PpvPrice.json#/definitions/PpvPrice" }, { "$ref": "Bookmark.json#/definitions/Bookmark" diff --git a/src/test/resources/schemas/LoginResponse.json b/src/test/resources/schemas/LoginResponse.json index 3bc0b5ebf..aee20741d 100644 --- a/src/test/resources/schemas/LoginResponse.json +++ b/src/test/resources/schemas/LoginResponse.json @@ -6,9 +6,7 @@ "type": "object", "properties": { "user": {"$ref": "OTTUser.json#/definitions/OTTUser"}, - "loginSession": { - "$ref": "LoginSession.json#/definitions/LoginSession" - }, + "loginSession": {"$ref": "LoginSession.json#/definitions/LoginSession"}, "objectType": {"type": "string", "enum": ["KalturaLoginResponse"]} }, "required": ["user", "loginSession", "objectType"] diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index 61f2f58e0..336f5290a 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -1,5 +1,5 @@ { - "$id": "KalturaMediaAsset", + "$id": "MediaAsset", "type": "object", "properties": { "result": { @@ -38,7 +38,6 @@ }, "images": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { @@ -78,7 +77,6 @@ }, "mediaFiles": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { @@ -152,22 +150,22 @@ "type": "object", "properties": { "Free": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Genre": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Parental Rating": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Director": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Country": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" }, "Series name": { - "$ref": "MultilingualStringValueArray.json#/definitions/KalturaMultilingualStringValueArray" + "$ref": "MultilingualStringValueArray.json#/definitions/MultilingualStringValueArray" } } }, diff --git a/src/test/resources/schemas/MultilingualStringValueArray.json b/src/test/resources/schemas/MultilingualStringValueArray.json index b57313f9f..f724423de 100644 --- a/src/test/resources/schemas/MultilingualStringValueArray.json +++ b/src/test/resources/schemas/MultilingualStringValueArray.json @@ -1,12 +1,11 @@ { - "$id": "KalturaMediaAsset", + "$id": "MultilingualStringValueArray", "definitions": { "MultilingualStringValueArray": { "type": "object", "properties": { "objects": { "type": "array", - "additionalItems": false, "items": { "type": "object", "properties": { diff --git a/src/test/resources/schemas/PpvEntitlement.json b/src/test/resources/schemas/PpvEntitlement.json index 52f1d2249..6e045716b 100644 --- a/src/test/resources/schemas/PpvEntitlement.json +++ b/src/test/resources/schemas/PpvEntitlement.json @@ -1,7 +1,7 @@ { - "$id": "KalturaPpvEntitlement", + "$id": "PpvEntitlement", "definitions": { - "KalturaPpvEntitlement": { + "PpvEntitlement": { "type": "object", "properties": { "mediaFileId": { @@ -106,5 +106,5 @@ ] } }, - "$ref": "#/definitions/KalturaPpvEntitlement" + "$ref": "#/definitions/PpvEntitlement" } \ No newline at end of file diff --git a/src/test/resources/schemas/PpvPrice.json b/src/test/resources/schemas/PpvPrice.json index 85173dbce..cd43a401c 100644 --- a/src/test/resources/schemas/PpvPrice.json +++ b/src/test/resources/schemas/PpvPrice.json @@ -1,7 +1,7 @@ { - "$id": "KalturaPpvPrice", + "$id": "PpvPrice", "definitions": { - "KalturaPpvPrice": { + "PpvPrice": { "type": "object", "properties": { "fileId": { @@ -131,7 +131,7 @@ "minLength": 1 }, "price": { - "$ref": "Price.json#/definitions/KalturaPrice" + "$ref": "Price.json#/definitions/Price" }, "purchaseStatus": { "type": "string", @@ -165,5 +165,5 @@ ] } }, - "$ref": "#/definitions/KalturaPpvPrice" + "$ref": "#/definitions/PpvPrice" } \ No newline at end of file diff --git a/src/test/resources/schemas/SubscriptionEntitlement.json b/src/test/resources/schemas/SubscriptionEntitlement.json index 69b2d27df..800dc8869 100644 --- a/src/test/resources/schemas/SubscriptionEntitlement.json +++ b/src/test/resources/schemas/SubscriptionEntitlement.json @@ -1,7 +1,7 @@ { - "$id": "KalturaSubscriptionEntitlement", + "$id": "SubscriptionEntitlement", "definitions": { - "KalturaSubscriptionEntitlement": { + "SubscriptionEntitlement": { "type": "object", "properties": { "nextRenewalDate": { diff --git a/src/test/resources/schemas/SubscriptionPrice.json b/src/test/resources/schemas/SubscriptionPrice.json index d0292a09a..9ce3159f8 100644 --- a/src/test/resources/schemas/SubscriptionPrice.json +++ b/src/test/resources/schemas/SubscriptionPrice.json @@ -1,11 +1,11 @@ { - "$id": "KalturaSubscriptionPrice", + "$id": "SubscriptionPrice", "definitions": { - "KalturaSubscriptionPrice": { + "SubscriptionPrice": { "type": "object", "properties": { "price": { - "$ref": "Price.json#/definitions/KalturaPrice" + "$ref": "Price.json#/definitions/Price" }, "purchaseStatus": { "type": "string", @@ -38,5 +38,5 @@ ] } }, - "$ref": "#/definitions/KalturaSubscriptionPrice" + "$ref": "#/definitions/SubscriptionPrice" } \ No newline at end of file diff --git a/src/test/resources/schemas/Transaction.json b/src/test/resources/schemas/Transaction.json index 63b5f4c9d..01aa7ef1f 100644 --- a/src/test/resources/schemas/Transaction.json +++ b/src/test/resources/schemas/Transaction.json @@ -1,5 +1,5 @@ { - "$id": "KalturaTransaction", + "$id": "Transaction", "type": "object", "properties": { "result": { From 370d27213dfb041f26e128755d71668ec6e1d7bc Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 15 Apr 2018 17:43:32 +0300 Subject: [PATCH 079/605] grantTests --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../entitlementTests/GrantTests.java | 41 ++++++++++++------- .../kaltura/client/test/utils/AssetUtils.java | 33 +++++++++++++++ 3 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/AssetUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 1b7374ae0..eb873a754 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -65,7 +65,7 @@ public void base_test_before_suite() { anonymousKs = loginSession.results.getKs(); // Set project shared HH and users -// initSharedHousehold(); + initSharedHousehold(); // // mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), // Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index 3c74287af..cb62032e7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -9,6 +9,7 @@ import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.servicesImpl.TransactionHistoryServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.*; @@ -22,7 +23,9 @@ public class GrantTests extends BaseTest { // TODO: 4/12/2018 remove hardcoded subscription Id private final int subscriptionId = 369426; private final int ppvId = 30297; - private final int contentId = 937202; //937190; + private final int assetId = 607368; + + private int contentId; private Response> billingTransactionListResponse; @@ -85,7 +88,9 @@ private void grant_subscription_with_history() { // force cancel subscription - foreCancelSubsription(Integer.parseInt(user.getUserId())); + client.setKs(administratorKs); + client.setUserId(Integer.valueOf(user.getUserId())); + EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); } @Test(description = "entitlement/action/grant - grant subscription with history = false") @@ -124,12 +129,15 @@ private void grant_subscription_without_history() { // force cancel subscription - foreCancelSubsription(Integer.parseInt(user.getUserId())); + client.setKs(administratorKs); + client.setUserId(Integer.valueOf(user.getUserId())); + EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); } @Test(description = "entitlement/action/grant - grant ppv with history = true") private void grant_ppv_with_history() { Client client = getClient(administratorKs); + contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); // set household Household household = HouseholdUtils.createHouseHold(2, 1, false); @@ -171,7 +179,7 @@ private void grant_ppv_with_history() { assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); - assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(assetId)); // check transaction return in transactionHistory by household @@ -181,16 +189,19 @@ private void grant_ppv_with_history() { assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); - assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(assetId)); // force cancel subscription - foreCancelSubsription(Integer.parseInt(user.getUserId())); + client.setKs(administratorKs); + client.setUserId(Integer.valueOf(user.getUserId())); + EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); } @Test(description = "entitlement/action/grant - grant ppv with history = false") private void grant_ppv_without_history() { Client client = getClient(administratorKs); + contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); // set household Household household = HouseholdUtils.createHouseHold(2, 1, false); @@ -218,7 +229,7 @@ private void grant_ppv_without_history() { assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); - assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(assetId)); // check transaction return in transactionHistory by household @@ -228,18 +239,18 @@ private void grant_ppv_without_history() { assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); - assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(ppvId)); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(assetId)); // force cancel subscription - foreCancelSubsription(Integer.parseInt(user.getUserId())); + client.setKs(administratorKs); + client.setUserId(Integer.valueOf(user.getUserId())); + EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); } - //ppvId, TransactionType.SUBSCRIPTION +// @Test(description = "entitlement/action/grant - ppv - error 6001") +// @Test(description = "entitlement/action/grant - ppv - error 3021") +// @Test(description = "entitlement/action/grant - subscription - error 3024") +// @Test(description = "entitlement/action/grant - subscription - error 3023") - private void foreCancelSubsription(int userId) { - Client client = getClient(administratorKs); - client.setUserId(userId); - EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); - } } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java new file mode 100644 index 000000000..f8af12c0d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -0,0 +1,33 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.MediaFile; +import com.kaltura.client.utils.response.base.Response; + +import java.util.ArrayList; +import java.util.List; + +import static com.kaltura.client.test.tests.BaseTest.getClient; +import static com.kaltura.client.test.tests.BaseTest.sharedMasterUserKs; + +public class AssetUtils extends BaseUtils { + + public static List getAssetFileIds(String assetId) { + Client client = getClient(sharedMasterUserKs); + + AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); + Response assetResponse = AssetServiceImpl.get(client, assetId, assetReferenceType); + List mediafiles = assetResponse.results.getMediaFiles(); + + List fileIdsList = new ArrayList<>(); + for (MediaFile mediaFile : mediafiles) { + fileIdsList.add(mediaFile.getId()); + } + + return fileIdsList; + } +} + From 014ec6cc430be7b57369c679d1f026e8223b703f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 16 Apr 2018 10:49:37 +0300 Subject: [PATCH 080/605] Updated class - "StartSessionTests" + added new util to AppTokenUtils --- .../servicesImpl/AppTokenServiceImpl.java | 33 +++++++++++ .../servicesTests/appTokenTests/AddTests.java | 17 +++++- .../appTokenTests/DeleteTests.java | 53 ++++++++++++++++++ .../appTokenTests/StartSessionTests.java | 55 +++++++++++++++++++ .../client/test/utils/AppTokenUtils.java | 22 +++++++- 5 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/DeleteTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java index b300aca74..d40d20885 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java @@ -4,6 +4,7 @@ import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.AppToken; +import com.kaltura.client.types.SessionInfo; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; @@ -16,6 +17,8 @@ public class AppTokenServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response appTokenResponse; + private static Response booleanResponse; + private static Response sessionInfoResponse; // AppToken/action/add public static Response add(Client client, AppToken appToken) { @@ -46,4 +49,34 @@ public static Response get(Client client, String id) { return appTokenResponse; } + + // AppToken/action/delete + public static Response delete(Client client, String id) { + DeleteAppTokenBuilder deleteAppTokenBuilder = AppTokenService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteAppTokenBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + //AppToken/action/startSession + public static Response startSession(Client client, String id, String hashToken, String userId, int expiry, String udid) { + StartSessionAppTokenBuilder startSessionAppTokenBuilder = AppTokenService.startSession(id, hashToken, userId, expiry, udid) + .setCompletion((ApiCompletion) result -> { + sessionInfoResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(startSessionAppTokenBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return sessionInfoResponse; + } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java index fba0b97a1..758f77469 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -19,7 +19,7 @@ public class AddTests extends BaseTest { private AppTokenHashType hashType; - private String sessionUserId; + private String sessionUserId = "1577578"; private AppToken appToken = new AppToken(); public static Client client; private String sessionPrivileges; @@ -27,7 +27,6 @@ public class AddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - sessionUserId = "1577578"; client = getClient(operatorKs); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); @@ -93,4 +92,18 @@ private void addAppTokenWithExpiryDate() { Response getAppTokenResponse = AppTokenServiceImpl.get(client, addAppTokenResponse.results.getId()); assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } + + @Description("appToken/action/add - with no specific user id") + @Test + private void addAppTokenWithoutSpecificUserId() { + + appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, null); + Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); + assertThat(addAppTokenResponse.error).isNull(); + assertThat(addAppTokenResponse.results.getExpiry()).isNull(); + assertThat(addAppTokenResponse.results.getId()).isNotEmpty(); + assertThat(addAppTokenResponse.results.getToken()).isNotEmpty(); + assertThat(addAppTokenResponse.results.getSessionUserId()).isNotEqualTo(sessionUserId); + assertThat(addAppTokenResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/DeleteTests.java new file mode 100644 index 000000000..8c6baa4cc --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/DeleteTests.java @@ -0,0 +1,53 @@ +package com.kaltura.client.test.tests.servicesTests.appTokenTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AppTokenHashType; +import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AppTokenUtils; +import com.kaltura.client.types.AppToken; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static org.assertj.core.api.Assertions.assertThat; + +public class DeleteTests extends BaseTest { + + private AppTokenHashType hashType; + private String sessionUserId; + private AppToken appToken = new AppToken(); + public static Client client; + + @BeforeClass + private void add_tests_before_class() { + sessionUserId = "1577578"; + client = getClient(operatorKs); + hashType = AppTokenHashType.SHA1; + appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); + } + + @Description("appToken/action/delete") + @Test + private void addAppToken() { + // Add token + Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + assertThat(appTokenResponse.error).isNull(); + assertThat(appTokenResponse.results.getExpiry()).isNull(); + + // Delete token + Response deleteTokenResponse = AppTokenServiceImpl.delete(client, appTokenResponse.results.getId()); + assertThat(deleteTokenResponse.results).isTrue(); + + // Try to delete token using invalid token id + deleteTokenResponse = AppTokenServiceImpl.delete(client, "1234"); + assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + + // Try to delete token again - exception returned + deleteTokenResponse = AppTokenServiceImpl.delete(client, appTokenResponse.results.getId()); + assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + } + +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java new file mode 100644 index 000000000..dc2cc349c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java @@ -0,0 +1,55 @@ +package com.kaltura.client.test.tests.servicesTests.appTokenTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AppTokenHashType; +import com.kaltura.client.test.Properties; +import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AppTokenUtils; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.AppToken; +import com.kaltura.client.types.LoginSession; +import com.kaltura.client.types.SessionInfo; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class StartSessionTests extends BaseTest { + + private AppTokenHashType hashType; + private String sessionUserId = "1577578"; + private String udid = "1234567890"; + private AppToken appToken = new AppToken(); + public static Client client; + //private String sessionPrivileges = "key1:value1,key2:value2"; + private Long expiryDate; + private Response loginSessionResponse; + private String anonymousKs; + + + @BeforeClass + private void add_tests_before_class() { + client = getClient(null); + // Invoke ottUser/action/anonymousLogin to receive LoginSession object (and anonymous KS) + loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, Properties.PARTNER_ID, udid); + anonymousKs = loginSessionResponse.results.getKs(); + + client.setKs(operatorKs); + hashType = AppTokenHashType.SHA1; + expiryDate = BaseUtils.getTimeInEpoch(1); + appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, Math.toIntExact(expiryDate)); + } + + @Description("appToken/action/startSession") + @Test + + private void startSession() { + Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + client.setKs(anonymousKs); + String tokenHash = AppTokenUtils.getTokenHash(hashType,anonymousKs,appTokenResponse.results.getToken()); + Response sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() + ,tokenHash, null, Math.toIntExact(expiryDate), udid); + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java index 696c898e0..0e3b62653 100644 --- a/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AppTokenUtils.java @@ -7,7 +7,7 @@ public class AppTokenUtils extends BaseUtils { - public static AppToken addAppToken(String userId, @Nullable AppTokenHashType appTokenHashType, @Nullable String sessionPrivileges, @Nullable Integer expiryDate) { + public static AppToken addAppToken(@Nullable String userId, @Nullable AppTokenHashType appTokenHashType, @Nullable String sessionPrivileges, @Nullable Integer expiryDate) { AppToken appToken = new AppToken(); appToken.setHashType(appTokenHashType); appToken.setSessionUserId(userId); @@ -17,5 +17,25 @@ public static AppToken addAppToken(String userId, @Nullable AppTokenHashType app return appToken; } + // Return hashed token according to the hash type provides + public static String getTokenHash(AppTokenHashType hashType, String anonymousKs, String token) { + + String concatenatedString = anonymousKs + token; + String hashedString = ""; + + if (hashType.equals(AppTokenHashType.MD5)) { + hashedString = org.apache.commons.codec.digest.DigestUtils.md5Hex(concatenatedString); + } else if (hashType.equals(AppTokenHashType.SHA1)) { + hashedString = org.apache.commons.codec.digest.DigestUtils.sha1Hex(concatenatedString); + } else if (hashType.equals(AppTokenHashType.SHA256)) { + hashedString = org.apache.commons.codec.digest.DigestUtils.sha256Hex(concatenatedString); + } else if (hashType.equals(AppTokenHashType.SHA512)) { + hashedString = org.apache.commons.codec.digest.DigestUtils.sha512Hex(concatenatedString); + } + + return hashedString; + } + } + From 080a17d070a3c5c05de697543e76dbed838cefe6 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 16 Apr 2018 10:59:41 +0300 Subject: [PATCH 081/605] no message --- .../test/tests/servicesTests/entitlementTests/GrantTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index cb62032e7..cc3a62b9a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -248,6 +248,7 @@ private void grant_ppv_without_history() { EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); } + // TODO: 4/16/2018 finish negative scenarios // @Test(description = "entitlement/action/grant - ppv - error 6001") // @Test(description = "entitlement/action/grant - ppv - error 3021") // @Test(description = "entitlement/action/grant - subscription - error 3024") From cacaf40e76680cb308a574553a573225e84d399d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 16 Apr 2018 11:42:22 +0300 Subject: [PATCH 082/605] Fixed test case public ppvTest() (profuctPrice/list) --- .../HouseholdDeviceServiceImpl.java | 22 ++++++++++++++++--- .../productPriceTests/ListTests.java | 4 ++-- .../client/test/utils/HouseholdUtils.java | 22 ++++++++++++++----- .../resources/schemas/HouseholdDevice.json | 18 ++++++++++----- src/test/resources/schemas/ListResponse.json | 4 ++++ .../resources/schemas/PpvEntitlement.json | 2 +- 6 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index cf08969c8..57ac98fbf 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -2,14 +2,14 @@ import com.kaltura.client.Client; import com.kaltura.client.services.HouseholdDeviceService; +import com.kaltura.client.services.HouseholdDeviceService.*; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.HouseholdDevice; +import com.kaltura.client.types.HouseholdDeviceFilter; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; - import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HouseholdDeviceService.AddHouseholdDeviceBuilder; import static org.awaitility.Awaitility.await; public class HouseholdDeviceServiceImpl { @@ -17,6 +17,7 @@ public class HouseholdDeviceServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response householdDeviceResponse; + private static Response> householdDevicesListResponse; // add @@ -33,4 +34,19 @@ public static Response add(Client client, HouseholdDevice house return householdDeviceResponse; } + + // list + public static Response> list(Client client, HouseholdDeviceFilter filter) { + ListHouseholdDeviceBuilder listHouseholdDeviceBuilder = HouseholdDeviceService.list(filter) + .setCompletion((ApiCompletion>) result -> { + householdDevicesListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdDevicesListResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 7be1ca1dd..70f664fd2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.IngestEPGUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -61,12 +60,13 @@ public void list_without_required_fields() { } @Description("productPrice/action/list - ppv test") - @Test(enabled = false) // as failed + @Test() public void ppvTest() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ + // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType client.setKs(sharedMasterUserKs); Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 8d033703b..be3645c8c 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -2,16 +2,11 @@ import com.kaltura.client.Client; import com.kaltura.client.Logger; -import com.kaltura.client.test.servicesImpl.HouseholdDeviceServiceImpl; -import com.kaltura.client.test.servicesImpl.HouseholdPaymentGatewayServiceImpl; -import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; -import com.kaltura.client.test.servicesImpl.HouseholdUserServiceImpl; +import com.kaltura.client.test.servicesImpl.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; - import java.util.List; import java.util.Random; - import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; @@ -65,6 +60,12 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO HouseholdDeviceServiceImpl.add(client, householdDevice); } + // login as Master with Udid + if (numberOfDevicesInHousehold > 0) { + List householdDevices = getDevicesListFromHouseHold(household); + OttUserServiceImpl.login(client, PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, householdDevices.get(0).getUdid()); + } + if (isPreparePG) { // TODO: there should be added logic with getting and using default PG currently it all hardcoded client = getClient(null); @@ -76,6 +77,15 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO return household; } + // get users list from given household + public static List getDevicesListFromHouseHold(Household household) { + Client client = getClient(administratorKs); + HouseholdDeviceFilter filter = new HouseholdDeviceFilter(); + filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); + Response> devicesResponse = HouseholdDeviceServiceImpl.list(client, filter); + return devicesResponse.results.getObjects(); + } + // get users list from given household public static List getUsersListFromHouseHold(Household household) { Client client = getClient(administratorKs); diff --git a/src/test/resources/schemas/HouseholdDevice.json b/src/test/resources/schemas/HouseholdDevice.json index a92228ffe..a2d370864 100644 --- a/src/test/resources/schemas/HouseholdDevice.json +++ b/src/test/resources/schemas/HouseholdDevice.json @@ -1,8 +1,7 @@ { - "$id": "KalturaHouseholdDevice", - "type": "object", - "properties": { - "result": { + "$id": "HouseholdDevice", + "definitions": { + "HouseholdDevice": { "type": "object", "properties": { "householdId": { @@ -35,7 +34,7 @@ }, "objectType": { "type": "string", - "enum": ["KalturaHouseholdDevice"] + "enum": ["KalturaDevice", "KalturaHouseholdDevice"] } }, "required": [ @@ -48,12 +47,19 @@ "status", "objectType" ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/HouseholdDevice" }, "executionTime": { "type": "number" } }, "required": [ - "result" + "result", + "executionTime" ] } \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 753b14a3e..58e5d6c6b 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -35,6 +35,9 @@ }, { "$ref": "Asset.json#/definitions/Asset" + }, + { + "$ref": "HouseholdDevice.json#/definitions/HouseholdDevice" } ] } @@ -46,6 +49,7 @@ "objectType": { "type": "string", "enum": [ + "KalturaHouseholdDeviceListResponse", "KalturaAssetListResponse", "KalturaEntitlementListResponse", "KalturaBillingTransactionListResponse", diff --git a/src/test/resources/schemas/PpvEntitlement.json b/src/test/resources/schemas/PpvEntitlement.json index 8528cb568..52f1d2249 100644 --- a/src/test/resources/schemas/PpvEntitlement.json +++ b/src/test/resources/schemas/PpvEntitlement.json @@ -97,7 +97,7 @@ "purchaseId", "paymentMethod", "deviceUdid", - //"deviceName", + "deviceName", "isCancelationWindowEnabled", "maxUses", "isRenewable", From 9b31235b257ec9d5ae8fcf3c424ef2a9c59713f6 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 16 Apr 2018 12:15:22 +0300 Subject: [PATCH 083/605] Added new schema - sessionInfo.json --- .../appTokenTests/StartSessionTests.java | 76 ++++++++++++++++--- src/test/resources/schemas/SessionInfo.json | 65 ++++++++++++++++ 2 files changed, 130 insertions(+), 11 deletions(-) create mode 100644 src/test/resources/schemas/SessionInfo.json diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java index dc2cc349c..3b60c7daa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java @@ -16,16 +16,18 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class StartSessionTests extends BaseTest { private AppTokenHashType hashType; private String sessionUserId = "1577578"; - private String udid = "1234567890"; + private String udid1 = "1234567890"; + private String udid2 = "9876543210"; private AppToken appToken = new AppToken(); public static Client client; - //private String sessionPrivileges = "key1:value1,key2:value2"; + private String sessionPrivileges = "key1:value1,key2:value2"; private Long expiryDate; - private Response loginSessionResponse; private String anonymousKs; @@ -33,23 +35,75 @@ public class StartSessionTests extends BaseTest { private void add_tests_before_class() { client = getClient(null); // Invoke ottUser/action/anonymousLogin to receive LoginSession object (and anonymous KS) - loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, Properties.PARTNER_ID, udid); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, Properties.PARTNER_ID, udid1); anonymousKs = loginSessionResponse.results.getKs(); - client.setKs(operatorKs); - hashType = AppTokenHashType.SHA1; expiryDate = BaseUtils.getTimeInEpoch(1); - appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, Math.toIntExact(expiryDate)); } - @Description("appToken/action/startSession") + @Description("appToken/action/startSession - SHA1") @Test + private void startSessionSha1() { + hashType = AppTokenHashType.SHA1; + // Build appToken object + appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + // Invoke AppToken/action/add + Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + client.setKs(anonymousKs); + + // Generate new token hash + String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + // Invoke AppToken/action/startSession - with udid1 + Response sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() + , tokenHash, null, Math.toIntExact(expiryDate), udid1); + + assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); + assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(sessionInfoResponse.results.getUserId()).isEqualTo(sessionUserId); + assertThat(sessionInfoResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); + assertThat(sessionInfoResponse.results.getPrivileges()).contains(sessionPrivileges); + assertThat(sessionInfoResponse.results.getUdid()).isEqualTo(udid1); + assertThat(sessionInfoResponse.results.getCreateDate()).isNotZero(); + + // Invoke AppToken/action/startSession - with udid2 + sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() + , tokenHash, null, Math.toIntExact(expiryDate), udid2); - private void startSession() { + assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); + + // TODO - Add session/action/get request with ks received from startSession API + + } + + @Description("appToken/action/startSession - SHA256") + @Test + private void startSessionSha256() { + hashType = AppTokenHashType.SHA256; + // Build appToken object + appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + // Invoke AppToken/action/add Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); client.setKs(anonymousKs); - String tokenHash = AppTokenUtils.getTokenHash(hashType,anonymousKs,appTokenResponse.results.getToken()); + // Generate new token hash + String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + // // Invoke AppToken/action/startSession - with udid1 Response sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() - ,tokenHash, null, Math.toIntExact(expiryDate), udid); + , tokenHash, null, Math.toIntExact(expiryDate), udid1); + + assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); + assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(sessionInfoResponse.results.getUserId()).isEqualTo(sessionUserId); + assertThat(sessionInfoResponse.results.getExpiry()).isEqualTo(expiryDate); + assertThat(sessionInfoResponse.results.getPrivileges()).isEqualTo(sessionPrivileges); + assertThat(sessionInfoResponse.results.getUdid()).isEqualTo(udid1); + assertThat(sessionInfoResponse.results.getCreateDate()).isNotZero(); + + // Invoke AppToken/action/startSession - with udid2 + sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() + , tokenHash, null, Math.toIntExact(expiryDate), udid2); + + assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); + + // TODO - Add session/action/get request with ks received from startSession API } } diff --git a/src/test/resources/schemas/SessionInfo.json b/src/test/resources/schemas/SessionInfo.json new file mode 100644 index 000000000..c2bc3c7f8 --- /dev/null +++ b/src/test/resources/schemas/SessionInfo.json @@ -0,0 +1,65 @@ +{ + "$id": "SessionInfo", + "definitions": { + "SessionInfo": { + "type": "object", + "properties": { + "ks": { + "type": "string", + "minLength": 0 + }, + "sessionType": { + "type": "string", + "minLength": 0 + }, + "partnerId": { + "type": "integer", + "minimum": 0 + }, + "userId": { + "type": "string", + "minLength": 0 + }, + "expiry": { + "type": "integer", + "minimum": 0 + }, + "privileges": { + "type": "string", + "minLength": 0 + }, + "udid": { + "type": "string", + "minLength": 0 + }, + "createDate": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "ks", + "sessionType", + "partnerId", + "userId", + "udid", + "createDate", + "objectType" + ] + } + }, + "type": "object", + "properties": { + "result": { + "ref": "#/definitions/SessionInfo" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From a6d4275f7670e8126d82afe256b77a500aeaa708 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 16 Apr 2018 14:17:05 +0300 Subject: [PATCH 084/605] Services impl --- .../com/kaltura/client/test/Properties.java | 1 - .../servicesImpl/AnnouncementServiceImpl.java | 116 ++++++++++++++++++ .../servicesImpl/AppTokenServiceImpl.java | 24 +++- .../servicesImpl/AssetCommentServiceImpl.java | 56 +++++++++ .../servicesImpl/AssetFileServiceImpl.java | 51 ++++++++ .../servicesImpl/AssetHistoryServiceImpl.java | 46 +++++++ .../AssetStatisticsServiceImpl.java | 35 ++++++ .../CDVRAdapterProfileServiceImpl.java | 98 +++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 10 +- .../servicesTests/bookmarkTests/AddTests.java | 5 +- .../resources/schemas/PpvEntitlement.json | 2 +- 11 files changed, 433 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 9a66aeaad..f7b66afc4 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -90,5 +90,4 @@ public static String getProperty(String propertyKey) { // TODO: 3/19/2018 update readme file with project structure and list of services // TODO: 3/19/2018 find how to run specific tests according to api version // TODO: 3/22/2018 ask Elram where to open the apiException meesage not equal to description issue - // TODO: 4/2/2018 integrate allure reports and annotate known issues / bugs } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java new file mode 100644 index 000000000..41a84afb4 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java @@ -0,0 +1,116 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.AnnouncementService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Announcement; +import com.kaltura.client.types.AnnouncementFilter; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.AnnouncementService.*; +import static org.awaitility.Awaitility.await; + +public class AnnouncementServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response announcementResponse; + private static Response booleanResponse; + private static Response> announcementListResponse; + + // activate + public static Response add(Client client, Announcement announcement) { + AddAnnouncementBuilder addAnnouncementBuilder = AnnouncementService.add(announcement) + .setCompletion((ApiCompletion) result -> { + announcementResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addAnnouncementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return announcementResponse; + } + + // delete + public static Response delete(Client client, long id) { + DeleteAnnouncementBuilder deleteAnnouncementBuilder = AnnouncementService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteAnnouncementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // enableSystemAnnouncements + public static Response enableSystemAnnouncements(Client client) { + EnableSystemAnnouncementsAnnouncementBuilder enableSystemAnnouncementsAnnouncementBuilder = + AnnouncementService.enableSystemAnnouncements().setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(enableSystemAnnouncementsAnnouncementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, AnnouncementFilter announcementFilter, @Nullable FilterPager filterPager) { + ListAnnouncementBuilder listAnnouncementBuilder = AnnouncementService.list(announcementFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + announcementListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listAnnouncementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return announcementListResponse; + } + + // update + public static Response update(Client client, int announcementId, Announcement announcement) { + UpdateAnnouncementBuilder updateAnnouncementBuilder = AnnouncementService.update(announcementId, announcement) + .setCompletion((ApiCompletion) result -> { + announcementResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateAnnouncementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return announcementResponse; + } + + // updateStatus + public static Response updateStatus(Client client, long id, boolean status) { + UpdateStatusAnnouncementBuilder updateStatusAnnouncementBuilder = AnnouncementService.updateStatus(id, status) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusAnnouncementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java index b300aca74..b466675fb 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java @@ -15,9 +15,11 @@ public class AppTokenServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); + private static Response appTokenResponse; + private static Response booleanResponse; - // AppToken/action/add + // add public static Response add(Client client, AppToken appToken) { AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) .setCompletion((ApiCompletion) result -> { @@ -32,7 +34,7 @@ public static Response add(Client client, AppToken appToken) { return appTokenResponse; } - //AppToken/acton/get + // get public static Response get(Client client, String id) { GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(id) .setCompletion((ApiCompletion) result -> { @@ -46,4 +48,22 @@ public static Response get(Client client, String id) { return appTokenResponse; } + + // delete + public static Response delete(Client client, String id) { + DeleteAppTokenBuilder deleteAppTokenBuilder = AppTokenService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteAppTokenBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // startSession + } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java new file mode 100644 index 000000000..5b45ffe60 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java @@ -0,0 +1,56 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.AssetCommentService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.AssetComment; +import com.kaltura.client.types.AssetCommentFilter; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.AssetCommentService.*; +import static org.awaitility.Awaitility.await; + +public class AssetCommentServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response assetCommentResponse; + private static Response> assetCommentListResponse; + + + // add + public static Response add(Client client, AssetComment assetComment) { + AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment) + .setCompletion((ApiCompletion) result -> { + assetCommentResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addAssetCommentBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetCommentResponse; + } + + // list + public static Response> list(Client client, AssetCommentFilter assetCommentFilter, @Nullable FilterPager filterPager) { + ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + assetCommentListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listAssetCommentBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetCommentListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java new file mode 100644 index 000000000..f0ad0d956 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java @@ -0,0 +1,51 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.ContextType; +import com.kaltura.client.enums.PlaybackContextType; +import com.kaltura.client.services.AssetFileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.AssetFileContext; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.AssetFileService.*; +import static org.awaitility.Awaitility.await; + +public class AssetFileServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response assetFileContextResponse; + + // getContext + public static Response getContext(Client client, String id, ContextType contextType) { + GetContextAssetFileBuilder getContextAssetFileBuilder = AssetFileService.getContext(id, contextType) + .setCompletion((ApiCompletion) result -> { + assetFileContextResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getContextAssetFileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetFileContextResponse; + } + + // playManifest + public static void playManifest(Client client, int partnerId, String assetId, AssetType assetType, long assetFileId, + PlaybackContextType playbackContextType, @Nullable String ks) { + PlayManifestAssetFileBuilder playManifestAssetFileBuilder = AssetFileService.playManifest(partnerId, assetId, assetType, + assetFileId, playbackContextType, ks); + playManifestAssetFileBuilder.setCompletion((ApiCompletion) result -> done.set(true)); + + TestAPIOkRequestsExecutor.getExecutor().queue(playManifestAssetFileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java new file mode 100644 index 000000000..5f27e9e70 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java @@ -0,0 +1,46 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.AssetHistoryService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.AssetHistoryService.*; +import static org.awaitility.Awaitility.await; + +public class AssetHistoryServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> assetHistoryListResponse; + + // clean + public static void clean(Client client, AssetHistoryFilter assetHistoryFilter) { + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setCompletion((ApiCompletion) result -> done.set(true)); + + TestAPIOkRequestsExecutor.getExecutor().queue(cleanAssetHistoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + } + + // list + public static Response> list(Client client, AssetHistoryFilter assetHistoryFilter, @Nullable FilterPager filterPager) { + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + assetHistoryListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listAssetHistoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetHistoryListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java new file mode 100644 index 000000000..1d7c5bebe --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.AssetStatisticsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.AssetStatisticsService.*; +import static org.awaitility.Awaitility.await; + +public class AssetStatisticsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> assetStatisticsListResponse; + + // query + public static Response> query(Client client, AssetStatisticsQuery assetStatisticsQuery) { + QueryAssetStatisticsBuilder queryAssetStatisticsBuilder = AssetStatisticsService.query(assetStatisticsQuery) + .setCompletion((ApiCompletion>) result -> { + assetStatisticsListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(queryAssetStatisticsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetStatisticsListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java new file mode 100644 index 000000000..a1f20d6b1 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java @@ -0,0 +1,98 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CDVRAdapterProfileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.CDVRAdapterProfile; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CDVRAdapterProfileService.*; +import static org.awaitility.Awaitility.await; + +public class CDVRAdapterProfileServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response cdvrAdapterProfileResponse; + private static Response booleanResponse; + private static Response> cdvrAdapterProfileListResponse; + + // add + public static Response add(Client client, CDVRAdapterProfile cdvrAdapterProfile) { + AddCDVRAdapterProfileBuilder addCDVRAdapterProfileBuilder = CDVRAdapterProfileService.add(cdvrAdapterProfile) + .setCompletion((ApiCompletion) result -> { + cdvrAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addCDVRAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdvrAdapterProfileResponse; + } + + // delete + public static Response delete(Client client, int adapterId) { + DeleteCDVRAdapterProfileBuilder deleteCDVRAdapterProfileBuilder = CDVRAdapterProfileService.delete(adapterId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteCDVRAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // generateSharedSecret + public static Response generateSharedSecret(Client client, int adapterId) { + GenerateSharedSecretCDVRAdapterProfileBuilder generateSharedSecretCDVRAdapterProfileBuilder = + CDVRAdapterProfileService.generateSharedSecret(adapterId).setCompletion((ApiCompletion) result -> { + cdvrAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretCDVRAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdvrAdapterProfileResponse; + } + + // list + public static Response> list(Client client) { + ListCDVRAdapterProfileBuilder listCDVRAdapterProfileBuilder = CDVRAdapterProfileService.list() + .setCompletion((ApiCompletion>) result -> { + cdvrAdapterProfileListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listCDVRAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdvrAdapterProfileListResponse; + } + + // update + public static Response update(Client client, int adapterId, CDVRAdapterProfile cdvrAdapterProfile) { + UpdateCDVRAdapterProfileBuilder updateCDVRAdapterProfileBuilder = CDVRAdapterProfileService.update(adapterId, cdvrAdapterProfile) + .setCompletion((ApiCompletion) result -> { + cdvrAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateCDVRAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdvrAdapterProfileResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 5f246c1b6..532ba1647 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,11 +3,13 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; +import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; @@ -66,10 +68,10 @@ public void base_test_before_suite() { // Set project shared HH and users initSharedHousehold(); -// -// mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), -// Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); -// System.out.println("INGESTED VOD: " + mediaAsset.getId()); + + mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + System.out.println("INGESTED VOD: " + mediaAsset.getId()); Logger.getLogger(BaseTest.class).debug("Finish Setup!"); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java index 3e5f6acd2..e58df7af1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java @@ -60,7 +60,6 @@ private void add_tests_before_class() { @Description("bookmark/action/add - first play") @Test private void firstPlayback() { - // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); // Verify response return true @@ -196,8 +195,8 @@ private void finishWatching() { @Description("bookmark/action/add - empty asset id") @Test private void emptyAssetId() { - bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + Bookmark bookmark1 = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark1); assertThat(booleanResponse.results).isNull(); // Verify exception returned - code: 500003 ("Invalid Asset id") assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500003).getCode()); diff --git a/src/test/resources/schemas/PpvEntitlement.json b/src/test/resources/schemas/PpvEntitlement.json index ebd3a6854..6e045716b 100644 --- a/src/test/resources/schemas/PpvEntitlement.json +++ b/src/test/resources/schemas/PpvEntitlement.json @@ -97,7 +97,7 @@ "purchaseId", "paymentMethod", "deviceUdid", - //"deviceName", + "deviceName", "isCancelationWindowEnabled", "maxUses", "isRenewable", From e07af9a5e57173ed2d50557036b177ee46fc6e25 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 16 Apr 2018 17:35:01 +0300 Subject: [PATCH 085/605] Services impl 2 --- .../CdnAdapterProfilesServiceImpl.java | 99 +++++++++++++++++++ .../CdnPartnerSettingsServiceImpl.java | 50 ++++++++++ .../test/servicesImpl/ChannelServiceImpl.java | 81 +++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 12 +-- .../kaltura/client/test/utils/BaseUtils.java | 10 ++ 5 files changed, 245 insertions(+), 7 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java new file mode 100644 index 000000000..49ce36b74 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java @@ -0,0 +1,99 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CdnAdapterProfileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.CDNAdapterProfile; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CdnAdapterProfileService.*; +import static com.kaltura.client.services.CdnAdapterProfileService.AddCdnAdapterProfileBuilder; +import static org.awaitility.Awaitility.await; + +public class CdnAdapterProfilesServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response cdnAdapterProfileResponse; + private static Response booleanResponse; + private static Response> cdnAdapterProfileListResponse; + + // add + public static Response add(Client client, CDNAdapterProfile cdnAdapterProfile) { + AddCdnAdapterProfileBuilder addCdnAdapterProfileBuilder = CdnAdapterProfileService.add(cdnAdapterProfile) + .setCompletion((ApiCompletion) result -> { + cdnAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addCdnAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdnAdapterProfileResponse; + } + + // delete + public static Response delete(Client client, int adapterId) { + DeleteCdnAdapterProfileBuilder deleteCdnAdapterProfileBuilder = CdnAdapterProfileService.delete(adapterId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteCdnAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // generateSharedSecret + public static Response generateSharedSecret(Client client, int adapterId) { + GenerateSharedSecretCdnAdapterProfileBuilder generateSharedSecretCdnAdapterProfileBuilder = + CdnAdapterProfileService.generateSharedSecret(adapterId).setCompletion((ApiCompletion) result -> { + cdnAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretCdnAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdnAdapterProfileResponse; + } + + // list + public static Response> list(Client client) { + ListCdnAdapterProfileBuilder listCdnAdapterProfileBuilder = CdnAdapterProfileService.list() + .setCompletion((ApiCompletion>) result -> { + cdnAdapterProfileListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listCdnAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdnAdapterProfileListResponse; + } + + // update + public static Response update(Client client, int adapterId, CDNAdapterProfile cdnAdapterProfile) { + UpdateCdnAdapterProfileBuilder updateCdnAdapterProfileBuilder = CdnAdapterProfileService.update(adapterId, cdnAdapterProfile) + .setCompletion((ApiCompletion) result -> { + cdnAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateCdnAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdnAdapterProfileResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java new file mode 100644 index 000000000..126e0de19 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java @@ -0,0 +1,50 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CdnPartnerSettingsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.CDNPartnerSettings; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CdnPartnerSettingsService.*; +import static org.awaitility.Awaitility.await; + +public class CdnPartnerSettingsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response cdnPartnerSettingsResponse; + + // get + public static Response get(Client client) { + GetCdnPartnerSettingsBuilder getCdnPartnerSettingsBuilder = CdnPartnerSettingsService.get() + .setCompletion((ApiCompletion) result -> { + cdnPartnerSettingsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getCdnPartnerSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdnPartnerSettingsResponse; + } + + // update + public static Response update(Client client, CDNPartnerSettings cdnPartnerSettings) { + UpdateCdnPartnerSettingsBuilder updateCdnPartnerSettingsBuilder = CdnPartnerSettingsService.update(cdnPartnerSettings) + .setCompletion((ApiCompletion) result -> { + cdnPartnerSettingsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateCdnPartnerSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return cdnPartnerSettingsResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java new file mode 100644 index 000000000..16cd3cbf9 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java @@ -0,0 +1,81 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ChannelService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Channel; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ChannelService.*; +import static org.awaitility.Awaitility.await; + +public class ChannelServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response channelResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, Channel channel) { + AddChannelBuilder addChannelBuilder = ChannelService.add(channel) + .setCompletion((ApiCompletion) result -> { + channelResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addChannelBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return channelResponse; + } + + // delete + public static Response delete(Client client, int channelId) { + DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteChannelBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, int channelId) { + GetChannelBuilder getChannelBuilder = ChannelService.get(channelId) + .setCompletion((ApiCompletion) result -> { + channelResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getChannelBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return channelResponse; + } + + // update + public static Response update(Client client, int channelId, Channel channel) { + UpdateChannelBuilder updateChannelBuilder = ChannelService.update(channelId, channel) + .setCompletion((ApiCompletion) result -> { + channelResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateChannelBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return channelResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 532ba1647..82d581150 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,13 +3,11 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; -import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; import java.util.List; -import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; @@ -67,11 +65,11 @@ public void base_test_before_suite() { anonymousKs = loginSession.results.getKs(); // Set project shared HH and users - initSharedHousehold(); - - mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - System.out.println("INGESTED VOD: " + mediaAsset.getId()); +// initSharedHousehold(); +// +// mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), +// Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); +// System.out.println("INGESTED VOD: " + mediaAsset.getId()); Logger.getLogger(BaseTest.class).debug("Finish Setup!"); } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index abd68818a..d2dd1b899 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -6,6 +6,7 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -123,4 +124,13 @@ private static List getApiExceptionList() { } return exceptions; } + +// public static MediaAsset getSharedMediaAsset() { +// if (mediaAsset == null) { +// mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), +// Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); +// System.out.println("INGESTED VOD: " + mediaAsset.getId()); +// } +// return mediaAsset; +// } } From 880cfa59117e2761a0282c98878a22f8283ba014 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 10:00:50 +0300 Subject: [PATCH 086/605] no message --- .../servicesImpl/CollectionServiceImpl.java | 37 ++++++++++++++ .../kaltura/client/test/tests/BaseTest.java | 27 ++-------- .../kaltura/client/test/utils/BaseUtils.java | 49 ++++++++++++++++--- 3 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java new file mode 100644 index 000000000..4d0c5218a --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CollectionService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Collection; +import com.kaltura.client.types.CollectionFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CollectionService.ListCollectionBuilder; +import static org.awaitility.Awaitility.await; + +public class CollectionServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> collectionListResponse; + + // list + public static Response> list(Client client, CollectionFilter collectionFilter) { + ListCollectionBuilder listCollectionBuilder = CollectionService.list(collectionFilter) + .setCompletion((ApiCompletion>) result -> { + collectionListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listCollectionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return collectionListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 82d581150..126681666 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -7,15 +7,12 @@ import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; -import java.util.List; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; -import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; -import static com.kaltura.client.test.utils.OttUserUtils.getUserById; +import static com.kaltura.client.test.utils.BaseUtils.getSharedMediaAsset; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -66,7 +63,8 @@ public void base_test_before_suite() { // Set project shared HH and users // initSharedHousehold(); -// + getSharedMediaAsset(); + // mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), // Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); // System.out.println("INGESTED VOD: " + mediaAsset.getId()); @@ -74,25 +72,6 @@ public void base_test_before_suite() { Logger.getLogger(BaseTest.class).debug("Finish Setup!"); } - private void initSharedHousehold() { - sharedHousehold = createHouseHold(2, 2, true); - List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); - for (HouseholdUser user : sharedHouseholdUsers) { - if (user.getIsMaster() != null && user.getIsMaster()) { - sharedMasterUser = user; - } - if (user.getIsMaster() == null && user.getIsDefault() == null) { - sharedUser = user; - } - } - - loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); - sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - - loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); - sharedUserKs = loginResponse.results.getLoginSession().getKs(); - } - public static Client getClient(String ks) { client = new Client(config); client.setApiVersion(API_REQUEST_VERSION); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index d2dd1b899..39392ee30 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -1,7 +1,12 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Logger; +import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.APIException; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.utils.response.base.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -18,6 +23,14 @@ import java.util.concurrent.ThreadLocalRandom; import static com.kaltura.client.test.Properties.API_URL_VERSION; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.BaseTest.mediaAsset; +import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; +import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.OttUserUtils.getUserById; public class BaseUtils { @@ -125,12 +138,32 @@ private static List getApiExceptionList() { return exceptions; } -// public static MediaAsset getSharedMediaAsset() { -// if (mediaAsset == null) { -// mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), -// Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); -// System.out.println("INGESTED VOD: " + mediaAsset.getId()); -// } -// return mediaAsset; -// } + // utils for baseTest + public static MediaAsset getSharedMediaAsset() { + if (mediaAsset == null) { + mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + System.out.println("INGESTED VOD: " + mediaAsset.getId()); + } + return mediaAsset; + } + + private void getSharedHousehold() { + sharedHousehold = createHouseHold(2, 2, true); + List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); + for (HouseholdUser user : sharedHouseholdUsers) { + if (user.getIsMaster() != null && user.getIsMaster()) { + sharedMasterUser = user; + } + if (user.getIsMaster() == null && user.getIsDefault() == null) { + sharedUser = user; + } + } + + Response loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); + + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedUserKs = loginResponse.results.getLoginSession().getKs(); + } } From b561172705dd71b242b04418e8988e4c9e0a92f4 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 10:05:02 +0300 Subject: [PATCH 087/605] no message --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 2d7f581c5..de0679b30 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,17 +3,12 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; -import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; -<<<<<<< HEAD -======= -import java.util.List; -import java.util.Optional; ->>>>>>> master import java.util.concurrent.TimeUnit; + import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; From cffa21d58dec40afdc2a683a2fbec9c7f134d62b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 10:47:30 +0300 Subject: [PATCH 088/605] no message From 12b9234fe3fa86073d87bd5b137e0decaeb91c80 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 10:51:32 +0300 Subject: [PATCH 089/605] no message From 8533e402102270fa2c85023de3683a9f9ac65bb5 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 10:52:43 +0300 Subject: [PATCH 090/605] no message From 47c749669a666345618a6ea67c81b8e5b1d901d1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 12:17:19 +0300 Subject: [PATCH 091/605] edit gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e72efd19a..89d303ead 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ src/test/java/resources/test.properties allure-results/ .allure/ log4j.log +src/test/resources/test.properties From 127bac806d05d807fae5bca9d2cf4cbe78442576 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 20:30:08 +0300 Subject: [PATCH 092/605] service impl 3 --- .../servicesImpl/CompensationServiceImpl.java | 60 +++++++++ .../ConfigurationGroupDeviceServiceImpl.java | 83 +++++++++++++ .../ConfigurationGroupServiceImpl.java | 98 +++++++++++++++ .../ConfigurationGroupTagServiceImpl.java | 84 +++++++++++++ .../ConfigurationsServiceImpl.java | 116 ++++++++++++++++++ .../test/servicesImpl/CountryServiceImpl.java | 37 ++++++ 6 files changed, 478 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java new file mode 100644 index 000000000..5c85a651f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java @@ -0,0 +1,60 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CompensationService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Compensation; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CompensationService.*; +import static org.awaitility.Awaitility.await; + +public class CompensationServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response compensationResponse; + + // add + public static Response add(Client client, Compensation compensation) { + AddCompensationBuilder addCompensationBuilder = CompensationService.add(compensation) + .setCompletion((ApiCompletion) result -> { + compensationResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addCompensationBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return compensationResponse; + } + + // delete + public static void delete(Client client, long id) { + DeleteCompensationBuilder deleteCompensationBuilder = CompensationService.delete(id); + deleteCompensationBuilder.setCompletion((ApiCompletion) result -> done.set(true)); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteCompensationBuilder.build(client)); + await().untilTrue(done); + done.set(false); + } + + // get + public static Response get(Client client, long id) { + GetCompensationBuilder getCompensationBuilder = CompensationService.get(id) + .setCompletion((ApiCompletion) result -> { + compensationResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getCompensationBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return compensationResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java new file mode 100644 index 000000000..0844c75e2 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java @@ -0,0 +1,83 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ConfigurationGroupDeviceService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ConfigurationGroupDeviceService.*; +import static org.awaitility.Awaitility.await; + +public class ConfigurationGroupDeviceServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response configurationGroupDeviceResponse; + private static Response booleanResponse; + private static Response> configurationGroupDeviceListResponse; + + // add + public static Response add(Client client, ConfigurationGroupDevice configurationGroupDevice) { + AddConfigurationGroupDeviceBuilder addConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.add(configurationGroupDevice) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationGroupDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // delete + public static Response delete(Client client, String udid) { + DeleteConfigurationGroupDeviceBuilder deleteConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.delete(udid) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationGroupDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, String udid) { + GetConfigurationGroupDeviceBuilder getConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.get(udid) + .setCompletion((ApiCompletion) result -> { + configurationGroupDeviceResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationGroupDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupDeviceResponse; + } + + // list + public static Response> list(Client client, ConfigurationGroupDeviceFilter configurationGroupDeviceFilter, @Nullable FilterPager filterPager) { + ListConfigurationGroupDeviceBuilder listConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.list(configurationGroupDeviceFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + configurationGroupDeviceListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationGroupDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupDeviceListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java new file mode 100644 index 000000000..ac6687d23 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java @@ -0,0 +1,98 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ConfigurationGroupService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ConfigurationGroup; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ConfigurationGroupService.*; +import static org.awaitility.Awaitility.await; + +public class ConfigurationGroupServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response configurationGroupResponse; + private static Response booleanResponse; + private static Response> configurationGroupListResponse; + + // add + public static Response add(Client client, ConfigurationGroup configurationGroup) { + AddConfigurationGroupBuilder addConfigurationGroupBuilder = ConfigurationGroupService.add(configurationGroup) + .setCompletion((ApiCompletion) result -> { + configurationGroupResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationGroupBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupResponse; + } + + // delete + public static Response delete(Client client, String id) { + DeleteConfigurationGroupBuilder deleteConfigurationGroupBuilder = ConfigurationGroupService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationGroupBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, String id) { + GetConfigurationGroupBuilder getConfigurationGroupBuilder = ConfigurationGroupService.get(id) + .setCompletion((ApiCompletion) result -> { + configurationGroupResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationGroupBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupResponse; + } + + // list + public static Response> list(Client client) { + ListConfigurationGroupBuilder listConfigurationGroupBuilder = ConfigurationGroupService.list() + .setCompletion((ApiCompletion>) result -> { + configurationGroupListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationGroupBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupListResponse; + } + + // update + public static Response update(Client client, String id, ConfigurationGroup configurationGroup) { + UpdateConfigurationGroupBuilder updateConfigurationGroupBuilder = ConfigurationGroupService.update(id, configurationGroup) + .setCompletion((ApiCompletion) result -> { + configurationGroupResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateConfigurationGroupBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java new file mode 100644 index 000000000..cdf3236fe --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java @@ -0,0 +1,84 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ConfigurationGroupTagService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ConfigurationGroupTag; +import com.kaltura.client.types.ConfigurationGroupTagFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ConfigurationGroupTagService.*; +import static org.awaitility.Awaitility.await; + +public class ConfigurationGroupTagServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response configurationGroupTagResponse; + private static Response booleanResponse; + private static Response> configurationGroupTagListResponse; + + // add + public static Response add(Client client, ConfigurationGroupTag configurationGroupTag) { + AddConfigurationGroupTagBuilder addConfigurationGroupTagBuilder = ConfigurationGroupTagService.add(configurationGroupTag) + .setCompletion((ApiCompletion) result -> { + configurationGroupTagResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationGroupTagBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupTagResponse; + } + + // delete + public static Response delete(Client client, String tag) { + DeleteConfigurationGroupTagBuilder deleteConfigurationGroupTagBuilder = ConfigurationGroupTagService.delete(tag) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationGroupTagBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, String tag) { + GetConfigurationGroupTagBuilder getConfigurationGroupTagBuilder = ConfigurationGroupTagService.get(tag) + .setCompletion((ApiCompletion) result -> { + configurationGroupTagResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationGroupTagBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupTagResponse; + } + + // list + public static Response> list(Client client, ConfigurationGroupTagFilter configurationGroupTagFilter) { + ListConfigurationGroupTagBuilder listConfigurationGroupTagBuilder = ConfigurationGroupTagService.list(configurationGroupTagFilter) + .setCompletion((ApiCompletion>) result -> { + configurationGroupTagListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationGroupTagBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationGroupTagListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java new file mode 100644 index 000000000..066581d34 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java @@ -0,0 +1,116 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ConfigurationsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Configurations; +import com.kaltura.client.types.ConfigurationsFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ConfigurationsService.*; +import static org.awaitility.Awaitility.await; + +public class ConfigurationsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response configurationsResponse; + private static Response booleanResponse; + private static Response> configurationsListResponse; + private static Response stringResponse; + + // add + public static Response add(Client client, Configurations configurations) { + AddConfigurationsBuilder addConfigurationsBuilder = ConfigurationsService.add(configurations) + .setCompletion((ApiCompletion) result -> { + configurationsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationsResponse; + } + + // delete + public static Response delete(Client client, String id) { + DeleteConfigurationsBuilder deleteConfigurationsBuilder = ConfigurationsService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, String id) { + GetConfigurationsBuilder getConfigurationsBuilder = ConfigurationsService.get(id) + .setCompletion((ApiCompletion) result -> { + configurationsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationsResponse; + } + + // list + public static Response> list(Client client, ConfigurationsFilter configurationsFilter) { + ListConfigurationsBuilder listConfigurationsBuilder = ConfigurationsService.list(configurationsFilter) + .setCompletion((ApiCompletion>) result -> { + configurationsListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationsListResponse; + } + + // update + public static Response update(Client client, String id, Configurations configurations) { + UpdateConfigurationsBuilder updateConfigurationsBuilder = ConfigurationsService.update(id, configurations) + .setCompletion((ApiCompletion) result -> { + configurationsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateConfigurationsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return configurationsResponse; + } + + // serveByDevice + public static Response serveByDevice(Client client, String applicationName, String clientVersion, String platform, String udid, String tag, @Nullable int partnerId) { + ServeByDeviceConfigurationsBuilder serveByDeviceConfigurationsBuilder = ConfigurationsService.serveByDevice(applicationName, clientVersion, platform, udid, tag, partnerId); + serveByDeviceConfigurationsBuilder.setCompletion((ApiCompletion) result -> { + stringResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(serveByDeviceConfigurationsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return stringResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java new file mode 100644 index 000000000..e25ec56f4 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CountryService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Country; +import com.kaltura.client.types.CountryFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CountryService.*; +import static org.awaitility.Awaitility.await; + +public class CountryServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> countryListResponse; + + // list + public static Response> list(Client client, CountryFilter countryFilter) { + ListCountryBuilder listCountryBuilder = CountryService.list(countryFilter) + .setCompletion((ApiCompletion>) result -> { + countryListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listCountryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return countryListResponse; + } +} From 07cd977e97c816e4d44158c6f2a7b5b9dc43cb42 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 21:27:33 +0300 Subject: [PATCH 093/605] services impl --- .../test/servicesImpl/CouponServiceImpl.java | 35 ++++++ .../servicesImpl/CurrencyServiceImpl.java | 37 ++++++ .../servicesImpl/DeviceBrandServiceImpl.java | 36 ++++++ .../servicesImpl/DeviceFamilyServiceImpl.java | 36 ++++++ .../test/servicesImpl/EmailServiceImpl.java | 35 ++++++ .../EngagementAdapterServiceImpl.java | 113 ++++++++++++++++++ .../servicesImpl/EngagementServiceImpl.java | 84 +++++++++++++ .../servicesImpl/EntitlementServiceImpl.java | 9 +- 8 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java new file mode 100644 index 000000000..2b0653969 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CouponService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Coupon; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CouponService.*; +import static org.awaitility.Awaitility.await; + +public class CouponServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response couponResponse; + + // get + public static Response get(Client client, String code) { + GetCouponBuilder getCouponBuilder = CouponService.get(code) + .setCompletion((ApiCompletion) result -> { + couponResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getCouponBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return couponResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java new file mode 100644 index 000000000..e1e48f476 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.CurrencyService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Currency; +import com.kaltura.client.types.CurrencyFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.CurrencyService.*; +import static org.awaitility.Awaitility.await; + +public class CurrencyServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> currencyListResponse; + + // list + public static Response> list(Client client, CurrencyFilter currencyFilter) { + ListCurrencyBuilder listCurrencyBuilder = CurrencyService.list(currencyFilter) + .setCompletion((ApiCompletion>) result -> { + currencyListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listCurrencyBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return currencyListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java new file mode 100644 index 000000000..53b590b14 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.DeviceBrandService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.DeviceBrand; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.DeviceBrandService.*; +import static org.awaitility.Awaitility.await; + +public class DeviceBrandServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> deviceBrandListResponse; + + // list + public static Response> list(Client client) { + ListDeviceBrandBuilder listDeviceBrandBuilder = DeviceBrandService.list() + .setCompletion((ApiCompletion>) result -> { + deviceBrandListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listDeviceBrandBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return deviceBrandListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java new file mode 100644 index 000000000..fc1506bcf --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.DeviceFamilyService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.DeviceFamily; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.DeviceFamilyService.*; +import static org.awaitility.Awaitility.await; + +public class DeviceFamilyServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> deviceFamilyListResponse; + + // list + public static Response> list(Client client) { + ListDeviceFamilyBuilder listDeviceFamilyBuilder = DeviceFamilyService.list() + .setCompletion((ApiCompletion>) result -> { + deviceFamilyListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listDeviceFamilyBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return deviceFamilyListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java new file mode 100644 index 000000000..69552eda6 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.EmailService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.EmailMessage; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.EmailService.*; +import static org.awaitility.Awaitility.await; + +public class EmailServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response booleanResponse; + + // send + public static Response send(Client client, EmailMessage emailMessage) { + SendEmailBuilder sendEmailBuilder = EmailService.send(emailMessage) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(sendEmailBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java new file mode 100644 index 000000000..f9e5195e9 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java @@ -0,0 +1,113 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.EngagementAdapterService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.EngagementAdapter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.EngagementAdapterService.*; +import static org.awaitility.Awaitility.await; + +public class EngagementAdapterServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response engagementAdapterResponse; + private static Response booleanResponse; + private static Response> engagementAdapterListResponse; + + // add + public static Response add(Client client, EngagementAdapter engagementAdapter) { + AddEngagementAdapterBuilder addEngagementAdapterBuilder = EngagementAdapterService.add(engagementAdapter) + .setCompletion((ApiCompletion) result -> { + engagementAdapterResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addEngagementAdapterBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementAdapterResponse; + } + + // delete + public static Response delete(Client client, int id) { + DeleteEngagementAdapterBuilder deleteEngagementAdapterBuilder = EngagementAdapterService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteEngagementAdapterBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, int id) { + GetEngagementAdapterBuilder getEngagementAdapterBuilder = EngagementAdapterService.get(id) + .setCompletion((ApiCompletion) result -> { + engagementAdapterResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getEngagementAdapterBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementAdapterResponse; + } + + // list + public static Response> list(Client client) { + ListEngagementAdapterBuilder listEngagementAdapterBuilder = EngagementAdapterService.list() + .setCompletion((ApiCompletion>) result -> { + engagementAdapterListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listEngagementAdapterBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementAdapterListResponse; + } + + // update + public static Response update(Client client, int id, EngagementAdapter engagementAdapter) { + UpdateEngagementAdapterBuilder updateEngagementAdapterBuilder = EngagementAdapterService.update(id, engagementAdapter) + .setCompletion((ApiCompletion) result -> { + engagementAdapterResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateEngagementAdapterBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementAdapterResponse; + } + + // generateSharedSecret + public static Response generateSharedSecret(Client client, int id) { + GenerateSharedSecretEngagementAdapterBuilder generateSharedSecretEngagementAdapterBuilder = EngagementAdapterService.generateSharedSecret(id) + .setCompletion((ApiCompletion) result -> { + engagementAdapterResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretEngagementAdapterBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementAdapterResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java new file mode 100644 index 000000000..a08fc83c3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java @@ -0,0 +1,84 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.EngagementService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Engagement; +import com.kaltura.client.types.EngagementFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.EngagementService.*; +import static org.awaitility.Awaitility.await; + +public class EngagementServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response engagementResponse; + private static Response booleanResponse; + private static Response> engagementListResponse; + + // add + public static Response add(Client client, Engagement engagement) { + AddEngagementBuilder addEngagementBuilder = EngagementService.add(engagement) + .setCompletion((ApiCompletion) result -> { + engagementResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addEngagementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementResponse; + } + + // delete + public static Response delete(Client client, int id) { + DeleteEngagementBuilder deleteEngagementBuilder = EngagementService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteEngagementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, int id) { + GetEngagementBuilder getEngagementBuilder = EngagementService.get(id) + .setCompletion((ApiCompletion) result -> { + engagementResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getEngagementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementResponse; + } + + // list + public static Response> list(Client client, EngagementFilter engagementFilter) { + ListEngagementBuilder listEngagementBuilder = EngagementService.list(engagementFilter) + .setCompletion((ApiCompletion>) result -> { + engagementListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listEngagementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return engagementListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java index 498f2e519..918333d76 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java @@ -162,7 +162,14 @@ public static Response update(Client client, int id, Entitlement en } // cancelRenewal - // TODO: 4/10/2018 implement cancelRenewal function and check why it returns Response + public static void cancelRenewal(Client client, String subscriptionId) { + CancelRenewalEntitlementBuilder cancelRenewalEntitlementBuilder = EntitlementService.cancelRenewal(subscriptionId); + cancelRenewalEntitlementBuilder.setCompletion((ApiCompletion) result -> done.set(true)); + + TestAPIOkRequestsExecutor.getExecutor().queue(cancelRenewalEntitlementBuilder.build(client)); + await().untilTrue(done); + done.set(false); + } } From 93f452af00c08bf86dd0728d574bf21ce8dcf49a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 22:24:51 +0300 Subject: [PATCH 094/605] Services impl --- .../servicesImpl/ExportTaskServiceImpl.java | 100 +++++++++++++++ .../ExternalChannelProfileServiceImpl.java | 83 +++++++++++++ .../servicesImpl/FavoriteServiceImpl.java | 70 +++++++++++ .../FollowTvSeriesServiceImpl.java | 72 +++++++++++ .../servicesImpl/HomeNetworkServiceImpl.java | 82 +++++++++++++ .../HouseholdDeviceServiceImpl.java | 115 +++++++++++++++++- 6 files changed, 519 insertions(+), 3 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java new file mode 100644 index 000000000..d227ef05b --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java @@ -0,0 +1,100 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ExportTaskService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ExportTask; +import com.kaltura.client.types.ExportTaskFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ExportTaskService.*; +import static org.awaitility.Awaitility.await; + +public class ExportTaskServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response exportTaskResponse; + private static Response> exportTaskListResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, ExportTask exportTask) { + AddExportTaskBuilder addExportTaskBuilder = ExportTaskService.add(exportTask) + .setCompletion((ApiCompletion) result -> { + exportTaskResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addExportTaskBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return exportTaskResponse; + } + + // delete + public static Response delete(Client client, long id) { + DeleteExportTaskBuilder deleteExportTaskBuilder = ExportTaskService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteExportTaskBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, long id) { + GetExportTaskBuilder getExportTaskBuilder = ExportTaskService.get(id) + .setCompletion((ApiCompletion) result -> { + exportTaskResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getExportTaskBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return exportTaskResponse; + } + + // list + public static Response> list(Client client, @Nullable ExportTaskFilter exportTaskFilter) { + ListExportTaskBuilder listExportTaskBuilder = ExportTaskService.list(exportTaskFilter) + .setCompletion((ApiCompletion>) result -> { + exportTaskListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listExportTaskBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return exportTaskListResponse; + } + + // update + public static Response update(Client client, long id, ExportTask exportTask) { + UpdateExportTaskBuilder updateExportTaskBuilder = ExportTaskService.update(id, exportTask) + .setCompletion((ApiCompletion) result -> { + exportTaskResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateExportTaskBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return exportTaskResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java new file mode 100644 index 000000000..d6f69e9f3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java @@ -0,0 +1,83 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ExternalChannelProfileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ExternalChannelProfile; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ExternalChannelProfileService.*; +import static org.awaitility.Awaitility.await; + +public class ExternalChannelProfileServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response externalChannelProfileResponse; + private static Response> externalChannelProfileListResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, ExternalChannelProfile externalChannelProfile) { + AddExternalChannelProfileBuilder addExternalChannelProfileBuilder = ExternalChannelProfileService.add(externalChannelProfile) + .setCompletion((ApiCompletion) result -> { + externalChannelProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addExternalChannelProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return externalChannelProfileResponse; + } + + // delete + public static Response delete(Client client, int externalChannelId) { + DeleteExternalChannelProfileBuilder deleteExternalChannelProfileBuilder = ExternalChannelProfileService.delete(externalChannelId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteExternalChannelProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client) { + ListExternalChannelProfileBuilder listExternalChannelProfileBuilder = ExternalChannelProfileService.list() + .setCompletion((ApiCompletion>) result -> { + externalChannelProfileListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listExternalChannelProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return externalChannelProfileListResponse; + } + + // update + public static Response update(Client client, int externalChannelId, ExternalChannelProfile externalChannelProfile) { + UpdateExternalChannelProfileBuilder updateExternalChannelProfileBuilder = ExternalChannelProfileService.update(externalChannelId, externalChannelProfile) + .setCompletion((ApiCompletion) result -> { + externalChannelProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateExternalChannelProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return externalChannelProfileResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java new file mode 100644 index 000000000..fcfb229eb --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java @@ -0,0 +1,70 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.FavoriteService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Favorite; +import com.kaltura.client.types.FavoriteFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.FavoriteService.*; +import static org.awaitility.Awaitility.await; + +public class FavoriteServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response favoriteResponse; + private static Response> favoriteListResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, Favorite favorite) { + AddFavoriteBuilder addFavoriteBuilder = FavoriteService.add(favorite) + .setCompletion((ApiCompletion) result -> { + favoriteResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addFavoriteBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return favoriteResponse; + } + + // delete + public static Response delete(Client client, int id) { + DeleteFavoriteBuilder deleteFavoriteBuilder = FavoriteService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteFavoriteBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, @Nullable FavoriteFilter favoriteFilter) { + ListFavoriteBuilder listFavoriteBuilder = FavoriteService.list(favoriteFilter) + .setCompletion((ApiCompletion>) result -> { + favoriteListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listFavoriteBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return favoriteListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java new file mode 100644 index 000000000..beb4513cf --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java @@ -0,0 +1,72 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.FollowTvSeriesService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.FollowTvSeries; +import com.kaltura.client.types.FollowTvSeriesFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.FollowTvSeriesService.*; +import static org.awaitility.Awaitility.await; + +public class FollowTvSeriesServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response followTvSeriesResponse; + private static Response> followTvSeriesListResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, FollowTvSeries followTvSeries) { + + AddFollowTvSeriesBuilder addFollowTvSeriesBuilder = FollowTvSeriesService.add(followTvSeries) + .setCompletion((ApiCompletion) result -> { + followTvSeriesResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addFollowTvSeriesBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return followTvSeriesResponse; + } + + // delete + public static Response delete(Client client, int assetId) { + DeleteFollowTvSeriesBuilder deleteFollowTvSeriesBuilder = FollowTvSeriesService.delete(assetId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteFollowTvSeriesBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, FollowTvSeriesFilter followTvSeriesFilter, @Nullable FilterPager filterPager) { + ListFollowTvSeriesBuilder listFollowTvSeriesBuilder = FollowTvSeriesService.list(followTvSeriesFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + followTvSeriesListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listFollowTvSeriesBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return followTvSeriesListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java new file mode 100644 index 000000000..557208082 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java @@ -0,0 +1,82 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.HomeNetworkService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.HomeNetworkService.*; +import static org.awaitility.Awaitility.await; + +public class HomeNetworkServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response homeNetworkResponse; + private static Response> homeNetworkListResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, HomeNetwork homeNetwork) { + AddHomeNetworkBuilder addHomeNetworkBuilder = HomeNetworkService.add(homeNetwork) + .setCompletion((ApiCompletion) result -> { + homeNetworkResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addHomeNetworkBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return homeNetworkResponse; + } + + // delete + public static Response delete(Client client, String externalId) { + DeleteHomeNetworkBuilder deleteHomeNetworkBuilder = HomeNetworkService.delete(externalId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteHomeNetworkBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return homeNetworkResponse; + } + + // list + public static Response> list(Client client) { + ListHomeNetworkBuilder listHomeNetworkBuilder = HomeNetworkService.list() + .setCompletion((ApiCompletion>) result -> { + homeNetworkListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listHomeNetworkBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return homeNetworkListResponse; + } + + // update + public static Response list(Client client, String externalId, HomeNetwork homeNetwork) { + UpdateHomeNetworkBuilder updateHomeNetworkBuilder = HomeNetworkService.update(externalId, homeNetwork) + .setCompletion((ApiCompletion) result -> { + homeNetworkResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateHomeNetworkBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return homeNetworkResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index 57ac98fbf..55143ea2f 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -1,14 +1,15 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.Client; +import com.kaltura.client.enums.DeviceStatus; import com.kaltura.client.services.HouseholdDeviceService; import com.kaltura.client.services.HouseholdDeviceService.*; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.HouseholdDevice; -import com.kaltura.client.types.HouseholdDeviceFilter; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; import static org.awaitility.Awaitility.await; @@ -18,6 +19,9 @@ public class HouseholdDeviceServiceImpl { private static Response householdDeviceResponse; private static Response> householdDevicesListResponse; + private static Response booleanResponse; + private static Response devicePinResponse; + private static Response loginResponse; // add @@ -49,4 +53,109 @@ public static Response> list(Client client, Househ return householdDevicesListResponse; } + + // addByPin + public static Response addByPin(Client client, String deviceName, String pin) { + AddByPinHouseholdDeviceBuilder addByPinHouseholdDeviceBuilder = HouseholdDeviceService.addByPin(deviceName, pin) + .setCompletion((ApiCompletion) result -> { + householdDeviceResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addByPinHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdDeviceResponse; + } + + // delete + public static Response delete(Client client, String udid) { + DeleteHouseholdDeviceBuilder deleteHouseholdDeviceBuilder = HouseholdDeviceService.delete(udid) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // generatePin + public static Response generatePin(Client client, String udid, int brandId) { + GeneratePinHouseholdDeviceBuilder generatePinHouseholdDeviceBuilder = HouseholdDeviceService.generatePin(udid, brandId) + .setCompletion((ApiCompletion) result -> { + devicePinResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(generatePinHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return devicePinResponse; + } + + // get + public static Response get(Client client) { + GetHouseholdDeviceBuilder getHouseholdDeviceBuilder = HouseholdDeviceService.get() + .setCompletion((ApiCompletion) result -> { + householdDeviceResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdDeviceResponse; + } + + // loginWithPin + public static Response loginWithPin(Client client, int partnerId, String pin, @Nullable String udid) { + LoginWithPinHouseholdDeviceBuilder loginWithPinHouseholdDeviceBuilder = HouseholdDeviceService.loginWithPin(partnerId, pin, udid) + .setCompletion((ApiCompletion) result -> { + loginResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(loginWithPinHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return loginResponse; + } + + // update + public static Response update(Client client, String udid, HouseholdDevice householdDevice) { + UpdateHouseholdDeviceBuilder updateHouseholdDeviceBuilder = HouseholdDeviceService.update(udid, householdDevice) + .setCompletion((ApiCompletion) result -> { + householdDeviceResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdDeviceResponse; + } + + // updateStatus + public static Response updateStatus(Client client, String udid, DeviceStatus deviceStatus) { + UpdateStatusHouseholdDeviceBuilder updateStatusHouseholdDeviceBuilder = HouseholdDeviceService.updateStatus(udid, deviceStatus) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusHouseholdDeviceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } } From ff693672b43ea61fa05686bbd0d96342c785cf71 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 17 Apr 2018 22:45:28 +0300 Subject: [PATCH 095/605] reorder in baseTest beforesuite() --- .../kaltura/client/test/tests/BaseTest.java | 46 +++++++-------- .../kaltura/client/test/utils/BaseUtils.java | 59 +++++++++++-------- 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index de0679b30..e2cae56c0 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -12,17 +12,12 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.utils.BaseUtils.getSharedMediaAsset; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { - private static Client client; private static Configuration config; - private Response loginResponse; - private Response loginSession; - public static String administratorKs, operatorKs, managerKs, anonymousKs; // shared household @@ -42,36 +37,39 @@ public void base_test_before_suite() { config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); config.setAcceptGzipEncoding(false); - // set client - client = getClient(null); - // Set default awaitility timeout setDefaultTimeout(20, TimeUnit.SECONDS); - // Login with shared users + // TODO: 4/17/2018 move init functions to the relevant used places instead calling it in beforeSuite + initGlobalUsersKs(); +// getSharedHousehold(); +// getSharedMediaAsset(); + + Logger.getLogger(BaseTest.class).debug("Finish Setup!"); + } + + public static Client getClient(String ks) { + Client client = new Client(config); + client.setApiVersion(API_REQUEST_VERSION); + client.setKs(ks); + return client; + } + + private void initGlobalUsersKs() { + Client client = getClient(null); + Response loginResponse; + Response loginSession; + loginResponse = login(client, PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); administratorKs = loginResponse.results.getLoginSession().getKs(); loginResponse = login(client, PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); operatorKs = loginResponse.results.getLoginSession().getKs(); -// loginResponse = login(PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); -// managerKs = loginResponse.results.getLoginSession().getKs(); + loginResponse = login(client, PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); + managerKs = loginResponse.results.getLoginSession().getKs(); loginSession = anonymousLogin(client, PARTNER_ID, null); anonymousKs = loginSession.results.getKs(); - - // Set project shared HH and users -// initSharedHousehold(); - getSharedMediaAsset(); - - Logger.getLogger(BaseTest.class).debug("Finish Setup!"); - } - - public static Client getClient(String ks) { - client = new Client(config); - client.setApiVersion(API_REQUEST_VERSION); - client.setKs(ks); - return client; } } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 4751c359d..2cc00f354 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -1,8 +1,9 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Client; import com.kaltura.client.Logger; -import com.kaltura.client.types.APIException; -import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -19,7 +20,13 @@ import java.util.concurrent.ThreadLocalRandom; import static com.kaltura.client.test.Properties.API_URL_VERSION; -import static com.kaltura.client.test.tests.BaseTest.mediaAsset; +import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; +import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.OttUserUtils.getUserById; public class BaseUtils { @@ -49,14 +56,14 @@ public static String getTimeInDate(int offSetInMinutes) { } // Get epoch time in seconds according to off set parameter provided (in minutes) - public static long getTimeInEpoch (int offSetInMinutes) { + public static long getTimeInEpoch(int offSetInMinutes) { //DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date dNow = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(dNow); calendar.add(Calendar.MINUTE, offSetInMinutes); - return calendar.getTimeInMillis()/1000; + return calendar.getTimeInMillis() / 1000; } // generate current data String in specified format @@ -137,22 +144,28 @@ public static MediaAsset getSharedMediaAsset() { return mediaAsset; } -// private void getSharedHousehold() { -// sharedHousehold = createHouseHold(2, 2, true); -// List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); -// for (HouseholdUser user : sharedHouseholdUsers) { -// if (user.getIsMaster() != null && user.getIsMaster()) { -// sharedMasterUser = user; -// } -// if (user.getIsMaster() == null && user.getIsDefault() == null) { -// sharedUser = user; -// } -// } -// -// Response loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); -// sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); -// -// loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); -// sharedUserKs = loginResponse.results.getLoginSession().getKs(); -// } + public static Household getSharedHousehold() { + Client client = getClient(null); + + if (sharedHousehold == null) { + sharedHousehold = createHouseHold(2, 2, true); + List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); + for (HouseholdUser user : sharedHouseholdUsers) { + if (user.getIsMaster() != null && user.getIsMaster()) { + sharedMasterUser = user; + } + if (user.getIsMaster() == null && user.getIsDefault() == null) { + sharedUser = user; + } + } + + Response loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); + + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedUserKs = loginResponse.results.getLoginSession().getKs(); + } + + return sharedHousehold; + } } From 7fa8ee88071c5a65ce41ab6b2644e59f9bc62285 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Apr 2018 13:47:20 +0300 Subject: [PATCH 096/605] service impl --- .../HouseholdLimitationsServiceImpl.java | 35 +++++ .../HouseholdPaymentGatewayServiceImpl.java | 120 +++++++++++++++++- .../HouseholdPaymentMethodServiceImpl.java | 100 +++++++++++++++ .../HouseholdPremiumServiceImpl.java | 36 ++++++ .../HouseholdQuotaServiceImpl.java | 34 +++++ .../servicesImpl/InboxMessageServiceImpl.java | 72 +++++++++++ .../servicesImpl/LanguageServiceImpl.java | 32 +++++ .../kaltura/client/test/tests/BaseTest.java | 1 + 8 files changed, 423 insertions(+), 7 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java new file mode 100644 index 000000000..83de2a94c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.HouseholdLimitationsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.HouseholdLimitationsService.*; +import static org.awaitility.Awaitility.await; + +public class HouseholdLimitationsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response householdLimitationsResponse; + + // get + public static Response get(Client client, int id) { + GetHouseholdLimitationsBuilder getHouseholdLimitationsBuilder = HouseholdLimitationsService.get(id) + .setCompletion((ApiCompletion) result -> { + householdLimitationsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdLimitationsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdLimitationsResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java index 19645512f..3f342610c 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java @@ -3,25 +3,36 @@ import com.kaltura.client.Client; import com.kaltura.client.services.HouseholdPaymentGatewayService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.HouseholdPaymentGateway; +import com.kaltura.client.types.KeyValue; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.PaymentGatewayConfiguration; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; + +import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import static com.kaltura.client.services.HouseholdPaymentGatewayService.SetChargeIDHouseholdPaymentGatewayBuilder; + +import static com.kaltura.client.services.HouseholdPaymentGatewayService.*; import static org.awaitility.Awaitility.await; public class HouseholdPaymentGatewayServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); + private static Response booleanResponse; + private static Response stringResponse; + private static Response paymentGatewayConfigurationResponse; + private static Response> householdPaymentGatewayListResponse; - // add + // setChargeId public static Response setChargeId(Client client, String paymentGatewayExternalId, String chargeId) { SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = - new HouseholdPaymentGatewayService.SetChargeIDHouseholdPaymentGatewayBuilder(paymentGatewayExternalId, chargeId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); + setChargeID(paymentGatewayExternalId, chargeId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); TestAPIOkRequestsExecutor.getExecutor().queue(setChargeIDHouseholdPaymentGatewayBuilder.build(client)); await().untilTrue(done); @@ -29,4 +40,99 @@ public static Response setChargeId(Client client, String paymentGateway return booleanResponse; } + + // disable + public static Response disable(Client client, int paymentGateway) { + DisableHouseholdPaymentGatewayBuilder disableHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.disable(paymentGateway) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(disableHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // enable + public static Response enable(Client client, int paymentGateway) { + EnableHouseholdPaymentGatewayBuilder enableHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.enable(paymentGateway) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(enableHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // getChargeID + public static Response getChargeID(Client client, String paymentGatewayExternalId) { + GetChargeIDHouseholdPaymentGatewayBuilder getChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService + .getChargeID(paymentGatewayExternalId).setCompletion((ApiCompletion) result -> { + stringResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getChargeIDHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return stringResponse; + } + + // invoke + public static Response invoke(Client client, int paymentGateway, String intent, List extraParams) { + InvokeHouseholdPaymentGatewayBuilder invokeHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService + .invoke(paymentGateway, intent, extraParams).setCompletion((ApiCompletion) result -> { + paymentGatewayConfigurationResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(invokeHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentGatewayConfigurationResponse; + } + + // list + public static Response> list(Client client) { + ListHouseholdPaymentGatewayBuilder listHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.list() + .setCompletion((ApiCompletion>) result -> { + householdPaymentGatewayListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdPaymentGatewayListResponse; + } + + // resume + public static void resume(Client client, int paymentGateway) { + ResumeHouseholdPaymentGatewayBuilder resumeHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.resume(paymentGateway); + resumeHouseholdPaymentGatewayBuilder.setCompletion((ApiCompletion) result -> done.set(true)); + + TestAPIOkRequestsExecutor.getExecutor().queue(resumeHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + } + + // suspend + public static void suspend(Client client, int paymentGateway) { + SuspendHouseholdPaymentGatewayBuilder suspendHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.suspend(paymentGateway); + suspendHouseholdPaymentGatewayBuilder.setCompletion((ApiCompletion) result -> done.set(true)); + + TestAPIOkRequestsExecutor.getExecutor().queue(suspendHouseholdPaymentGatewayBuilder.build(client)); + await().untilTrue(done); + done.set(false); + } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java new file mode 100644 index 000000000..3f8055d3d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java @@ -0,0 +1,100 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.HouseholdPaymentMethodService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.HouseholdPaymentMethod; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.PaymentGatewayConfiguration; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.HouseholdPaymentMethodService.*; +import static org.awaitility.Awaitility.await; + +public class HouseholdPaymentMethodServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response booleanResponse; + private static Response householdPaymentMethodResponse; + private static Response paymentGatewayConfigurationResponse; + private static Response> householdPaymentMethodListResponse; + + // add + public static Response add(Client client, HouseholdPaymentMethod householdPaymentMethod) { + AddHouseholdPaymentMethodBuilder addHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService.add(householdPaymentMethod) + .setCompletion((ApiCompletion) result -> { + householdPaymentMethodResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdPaymentMethodBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdPaymentMethodResponse; + } + + // forceRemove + public static Response forceRemove(Client client, int paymentGatewayId, int paymentMethodId) { + ForceRemoveHouseholdPaymentMethodBuilder forceRemoveHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService + .forceRemove(paymentGatewayId, paymentMethodId).setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(forceRemoveHouseholdPaymentMethodBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client) { + ListHouseholdPaymentMethodBuilder listHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService.list() + .setCompletion((ApiCompletion>) result -> { + householdPaymentMethodListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdPaymentMethodBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdPaymentMethodListResponse; + } + + // remove + public static Response remove(Client client, int paymentGatewayId, int paymentMethodId) { + RemoveHouseholdPaymentMethodBuilder removeHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService + .remove(paymentGatewayId, paymentMethodId).setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(removeHouseholdPaymentMethodBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // setAsDefault + public static Response setAsDefault(Client client, int paymentGatewayId, int paymentMethodId) { + SetAsDefaultHouseholdPaymentMethodBuilder setAsDefaultHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService + .setAsDefault(paymentGatewayId, paymentMethodId).setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(setAsDefaultHouseholdPaymentMethodBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java new file mode 100644 index 000000000..83751e220 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.HouseholdPremiumServiceService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.HouseholdPremiumService; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.HouseholdPremiumServiceService.*; +import static org.awaitility.Awaitility.await; + +public class HouseholdPremiumServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> householdPremiumServiceListResponse; + + // list + public static Response> list(Client client) { + ListHouseholdPremiumServiceBuilder listHouseholdPremiumServiceBuilder = HouseholdPremiumServiceService.list() + .setCompletion((ApiCompletion>) result -> { + householdPremiumServiceListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdPremiumServiceBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdPremiumServiceListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java new file mode 100644 index 000000000..46378d037 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java @@ -0,0 +1,34 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.HouseholdQuotaService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.HouseholdQuota; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.awaitility.Awaitility.await; + +public class HouseholdQuotaServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response householdQuotaResponse; + + // get + public static Response get(Client client) { + HouseholdQuotaService.GetHouseholdQuotaBuilder getHouseholdQuotaBuilder = HouseholdQuotaService.get() + .setCompletion((ApiCompletion) result -> { + householdQuotaResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdQuotaBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return householdQuotaResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java new file mode 100644 index 000000000..29da4d440 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java @@ -0,0 +1,72 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.InboxMessageStatus; +import com.kaltura.client.services.InboxMessageService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.InboxMessage; +import com.kaltura.client.types.InboxMessageFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.InboxMessageService.*; +import static org.awaitility.Awaitility.await; + +public class InboxMessageServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response inboxMessageResponse; + private static Response> inboxMessageListResponse; + private static Response booleanResponse; + + // get + public static Response get(Client client, String id) { + GetInboxMessageBuilder getInboxMessageBuilder = InboxMessageService.get(id) + .setCompletion((ApiCompletion) result -> { + inboxMessageResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getInboxMessageBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return inboxMessageResponse; + } + + // list + public static Response> list(Client client, @Nullable InboxMessageFilter inboxMessageFilter, @Nullable FilterPager filterPager) { + ListInboxMessageBuilder listInboxMessageBuilder = InboxMessageService.list(inboxMessageFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + inboxMessageListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listInboxMessageBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return inboxMessageListResponse; + } + + // updateStatus + public static Response updateStatus(Client client, String id, InboxMessageStatus inboxMessageStatus) { + UpdateStatusInboxMessageBuilder updateStatusInboxMessageBuilder = InboxMessageService.updateStatus(id, inboxMessageStatus) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusInboxMessageBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java new file mode 100644 index 000000000..b3217acc2 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java @@ -0,0 +1,32 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.types.InboxMessage; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +public class LanguageServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response inboxMessageResponse; + private static Response> inboxMessageListResponse; + private static Response booleanResponse; + +// // list +// public static void list(Client client) { +// +// InboxMessageService.GetInboxMessageBuilder getInboxMessageBuilder = InboxMessageService.get(id) +// .setCompletion((ApiCompletion) result -> { +// inboxMessageResponse = result; +// done.set(true); +// }); +// +// TestAPIOkRequestsExecutor.getExecutor().queue(getInboxMessageBuilder.build(client)); +// await().untilTrue(done); +// done.set(false); +// +// return inboxMessageResponse; +// } +} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index e2cae56c0..0eab92240 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -18,6 +18,7 @@ public class BaseTest { private static Configuration config; + // shared ks's public static String administratorKs, operatorKs, managerKs, anonymousKs; // shared household From 0a6a327471620d005886c07e88d639ddee3d3661 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Apr 2018 15:15:15 +0300 Subject: [PATCH 097/605] service impl --- .../servicesImpl/LanguageServiceImpl.java | 45 +++++++----- .../servicesImpl/LicensedUrlServiceImpl.java | 35 +++++++++ .../MessageTemplateServiceImpl.java | 51 +++++++++++++ .../test/servicesImpl/MetaServiceImpl.java | 52 +++++++++++++ .../servicesImpl/NotificationServiceImpl.java | 73 +++++++++++++++++++ 5 files changed, 236 insertions(+), 20 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java index b3217acc2..9dd5daa2f 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java @@ -1,32 +1,37 @@ package com.kaltura.client.test.servicesImpl; -import com.kaltura.client.types.InboxMessage; +import com.kaltura.client.Client; +import com.kaltura.client.services.LanguageService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Language; +import com.kaltura.client.types.LanguageFilter; import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.LanguageService.*; +import static org.awaitility.Awaitility.await; + public class LanguageServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response inboxMessageResponse; - private static Response> inboxMessageListResponse; - private static Response booleanResponse; - -// // list -// public static void list(Client client) { -// -// InboxMessageService.GetInboxMessageBuilder getInboxMessageBuilder = InboxMessageService.get(id) -// .setCompletion((ApiCompletion) result -> { -// inboxMessageResponse = result; -// done.set(true); -// }); -// -// TestAPIOkRequestsExecutor.getExecutor().queue(getInboxMessageBuilder.build(client)); -// await().untilTrue(done); -// done.set(false); -// -// return inboxMessageResponse; -// } + private static Response> languageListResponse; + + // list + public static Response> list(Client client, LanguageFilter languageFilter) { + ListLanguageBuilder listLanguageBuilder = LanguageService.list(languageFilter) + .setCompletion((ApiCompletion>) result -> { + languageListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listLanguageBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return languageListResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java new file mode 100644 index 000000000..6110319f2 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.LicensedUrlService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.LicensedUrlService.*; +import static org.awaitility.Awaitility.await; + +public class LicensedUrlServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response licensedUrlResponse; + + // get + public static Response get(Client client, LicensedUrlBaseRequest licensedUrlBaseRequest) { + GetLicensedUrlBuilder getLicensedUrlBuilder = LicensedUrlService.get(licensedUrlBaseRequest) + .setCompletion((ApiCompletion) result -> { + licensedUrlResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getLicensedUrlBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return licensedUrlResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java new file mode 100644 index 000000000..0729d9075 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java @@ -0,0 +1,51 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.MessageTemplateType; +import com.kaltura.client.services.MessageTemplateService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.MessageTemplate; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.MessageTemplateService.*; +import static org.awaitility.Awaitility.await; + +public class MessageTemplateServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response messageTemplateResponse; + + // get + public static Response get(Client client, MessageTemplateType messageTemplateType) { + GetMessageTemplateBuilder getMessageTemplateBuilder = MessageTemplateService.get(messageTemplateType) + .setCompletion((ApiCompletion) result -> { + messageTemplateResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getMessageTemplateBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return messageTemplateResponse; + } + + // update + public static Response update(Client client, MessageTemplateType messageTemplateType, MessageTemplate messageTemplate) { + UpdateMessageTemplateBuilder updateMessageTemplateBuilder = MessageTemplateService.update(messageTemplateType, messageTemplate) + .setCompletion((ApiCompletion) result -> { + messageTemplateResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateMessageTemplateBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return messageTemplateResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java new file mode 100644 index 000000000..477c0462f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java @@ -0,0 +1,52 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.MetaService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.Meta; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.MetaService.*; +import static org.awaitility.Awaitility.await; + +public class MetaServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> metaListResponse; + private static Response metaResponse; + + // list + public static Response> list(Client client) { + ListMetaBuilder listMetaBuilder = MetaService.list() + .setCompletion((ApiCompletion>) result -> { + metaListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listMetaBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return metaListResponse; + } + + // update + public static Response update(Client client, String id, Meta meta) { + UpdateMetaBuilder updateMetaBuilder = MetaService.update(id, meta) + .setCompletion((ApiCompletion) result -> { + metaResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateMetaBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return metaResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java new file mode 100644 index 000000000..87037d2dc --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java @@ -0,0 +1,73 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.NotificationType; +import com.kaltura.client.services.NotificationService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.PushMessage; +import com.kaltura.client.types.RegistryResponse; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.NotificationService.*; +import static com.kaltura.client.services.NotificationService.RegisterNotificationBuilder; +import static com.kaltura.client.services.NotificationService.SendPushNotificationBuilder; +import static org.awaitility.Awaitility.await; + +public class NotificationServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response booleanResponse; + private static Response registryResponse; + + // register + public static Response register(Client client, String identifier, NotificationType notificationType) { + RegisterNotificationBuilder registerNotificationBuilder = NotificationService.register(identifier, notificationType) + .setCompletion((ApiCompletion) result -> { + registryResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(registerNotificationBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return registryResponse; + } + + // sendPush + public static Response sendPush(Client client, int userId, PushMessage pushMessage) { + SendPushNotificationBuilder sendPushNotificationBuilder = NotificationService.sendPush(userId, pushMessage) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(sendPushNotificationBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // setDevicePushToken + public static Response setDevicePushToken(Client client, String pushToken) { + SetDevicePushTokenNotificationBuilder setDevicePushTokenNotificationBuilder = NotificationService.setDevicePushToken(pushToken) + .setCompletion(new ApiCompletion() { + @Override + public void onComplete(Response result) { + booleanResponse = result; + done.set(true); + } + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(setDevicePushTokenNotificationBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} From 3b9bcd61e7f923c9ce951782962bcbc9b99dd3df Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Apr 2018 18:28:03 +0300 Subject: [PATCH 098/605] service impl --- .../servicesImpl/NotificationServiceImpl.java | 2 +- ...tificationsPartnerSettingsServiceImpl.java | 51 ++++++++ .../NotificationsSettingsServiceImpl.java | 52 ++++++++ .../OssAdapterProfileServiceImpl.java | 114 ++++++++++++++++++ .../servicesImpl/OttCategoryServiceImpl.java | 35 ++++++ .../servicesImpl/ParentalRuleServiceImpl.java | 42 +++++++ 6 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java index 87037d2dc..61966f0e3 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java @@ -20,8 +20,8 @@ public class NotificationServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response booleanResponse; private static Response registryResponse; + private static Response booleanResponse; // register public static Response register(Client client, String identifier, NotificationType notificationType) { diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java new file mode 100644 index 000000000..2a1191270 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java @@ -0,0 +1,51 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.NotificationsPartnerSettingsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.NotificationsPartnerSettings; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.NotificationsPartnerSettingsService.*; +import static org.awaitility.Awaitility.await; + +public class NotificationsPartnerSettingsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response notificationsPartnerSettingsResponse; + private static Response booleanResponse; + + // get + public static Response get(Client client) { + GetNotificationsPartnerSettingsBuilder getNotificationsPartnerSettingsBuilder = + NotificationsPartnerSettingsService.get().setCompletion((ApiCompletion) result -> { + notificationsPartnerSettingsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getNotificationsPartnerSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return notificationsPartnerSettingsResponse; + } + + // update + public static Response update(Client client, NotificationsPartnerSettings notificationsPartnerSettings) { + UpdateNotificationsPartnerSettingsBuilder updateNotificationsPartnerSettingsBuilder = NotificationsPartnerSettingsService + .update(notificationsPartnerSettings).setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateNotificationsPartnerSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java new file mode 100644 index 000000000..92f59cbae --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java @@ -0,0 +1,52 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.NotificationsSettingsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.NotificationsSettings; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.NotificationsSettingsService.GetNotificationsSettingsBuilder; +import static com.kaltura.client.services.NotificationsSettingsService.UpdateNotificationsSettingsBuilder; +import static org.awaitility.Awaitility.await; + +public class NotificationsSettingsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response notificationsSettingsResponse; + private static Response booleanResponse; + + // get + public static Response get(Client client) { + GetNotificationsSettingsBuilder getNotificationsSettingsBuilder = NotificationsSettingsService.get() + .setCompletion((ApiCompletion) result -> { + notificationsSettingsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getNotificationsSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return notificationsSettingsResponse; + } + + // update + public static Response update(Client client, NotificationsSettings notificationsSettings) { + UpdateNotificationsSettingsBuilder updateNotificationsSettingsBuilder = NotificationsSettingsService.update(notificationsSettings) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateNotificationsSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java new file mode 100644 index 000000000..f72aaec2c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java @@ -0,0 +1,114 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.OssAdapterProfileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.OSSAdapterProfile; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.OssAdapterProfileService.*; +import static org.awaitility.Awaitility.await; + +public class OssAdapterProfileServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response ossAdapterProfileResponse; + private static Response booleanResponse; + private static Response> ossAdapterProfileListResponse; + + // add + public static Response add(Client client, OSSAdapterProfile ossAdapterProfile) { + AddOssAdapterProfileBuilder addOssAdapterProfileBuilder = OssAdapterProfileService.add(ossAdapterProfile) + .setCompletion((ApiCompletion) result -> { + ossAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addOssAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ossAdapterProfileResponse; + } + + // delete + public static Response delete(Client client, int ossAdapterId) { + DeleteOssAdapterProfileBuilder deleteOssAdapterProfileBuilder = OssAdapterProfileService.delete(ossAdapterId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteOssAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // generateSharedSecret + public static Response generateSharedSecret(Client client, int ossAdapterId) { + GenerateSharedSecretOssAdapterProfileBuilder generateSharedSecretOssAdapterProfileBuilder = + OssAdapterProfileService.generateSharedSecret(ossAdapterId) + .setCompletion((ApiCompletion) result -> { + ossAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretOssAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ossAdapterProfileResponse; + } + + // get + public static Response get(Client client, int id) { + GetOssAdapterProfileBuilder getOssAdapterProfileBuilder = OssAdapterProfileService.get(id) + .setCompletion((ApiCompletion) result -> { + ossAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getOssAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ossAdapterProfileResponse; + } + + // list + public static Response> list(Client client) { + ListOssAdapterProfileBuilder listOssAdapterProfileBuilder = OssAdapterProfileService.list() + .setCompletion((ApiCompletion>) result -> { + ossAdapterProfileListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listOssAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ossAdapterProfileListResponse; + } + + // update + public static Response update(Client client, int ossAdapterId, OSSAdapterProfile ossAdapterProfile) { + UpdateOssAdapterProfileBuilder updateOssAdapterProfileBuilder = OssAdapterProfileService.update(ossAdapterId, ossAdapterProfile) + .setCompletion((ApiCompletion) result -> { + ossAdapterProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateOssAdapterProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ossAdapterProfileResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java new file mode 100644 index 000000000..a01b70f8f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.OttCategoryService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.OTTCategory; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.OttCategoryService.*; +import static org.awaitility.Awaitility.await; + +public class OttCategoryServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response ottCategoryResponse; + + // get + public static Response get(Client client, int id) { + GetOttCategoryBuilder getOttCategoryBuilder = OttCategoryService.get(id) + .setCompletion((ApiCompletion) result -> { + ottCategoryResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getOttCategoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ottCategoryResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java new file mode 100644 index 000000000..6157aa7d9 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java @@ -0,0 +1,42 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.OttCategoryService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.OTTCategory; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.awaitility.Awaitility.await; + +public class ParentalRuleServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response ottCategoryResponse; + + // disable + + // disableDefault + + // enable + + // list + + // get + public static Response get(Client client, int id) { + OttCategoryService.GetOttCategoryBuilder getOttCategoryBuilder = OttCategoryService.get(id) + .setCompletion((ApiCompletion) result -> { + ottCategoryResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getOttCategoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ottCategoryResponse; + } +} From 50470eb641c18b3f1392e0da0b110cf88c02f90a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Apr 2018 22:57:29 +0300 Subject: [PATCH 099/605] service impl --- .../servicesImpl/ParentalRuleServiceImpl.java | 64 ++++++++-- .../PartnerConfigurationServiceImpl.java | 35 ++++++ .../PaymentGatewayProfileServiceImpl.java | 119 ++++++++++++++++++ .../PaymentMethodProfileServiceImpl.java | 83 ++++++++++++ .../servicesImpl/PersonalFeedServiceImpl.java | 36 ++++++ .../test/servicesImpl/PinServiceImpl.java | 69 ++++++++++ .../test/servicesImpl/PpvServiceImpl.java | 34 +++++ .../servicesImpl/PriceDetailsServiceImpl.java | 36 ++++++ .../servicesImpl/PricePlanServiceImpl.java | 54 ++++++++ 9 files changed, 519 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java index 6157aa7d9..e3df6d39f 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java @@ -1,42 +1,84 @@ package com.kaltura.client.test.servicesImpl; import com.kaltura.client.Client; -import com.kaltura.client.services.OttCategoryService; +import com.kaltura.client.enums.EntityReferenceBy; +import com.kaltura.client.services.ParentalRuleService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.OTTCategory; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.ParentalRule; +import com.kaltura.client.types.ParentalRuleFilter; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.ParentalRuleService.*; import static org.awaitility.Awaitility.await; public class ParentalRuleServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response ottCategoryResponse; + private static Response> parentalRuleListResponse; + private static Response booleanResponse; // disable + public static Response disable(Client client, long ruleId, EntityReferenceBy entityReferenceBy) { + DisableParentalRuleBuilder disableParentalRuleBuilder = ParentalRuleService.disable(ruleId, entityReferenceBy) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(disableParentalRuleBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } // disableDefault + public static Response disableDefault(Client client, EntityReferenceBy entityReferenceBy) { + DisableDefaultParentalRuleBuilder disableDefaultParentalRuleBuilder = ParentalRuleService + .disableDefault(entityReferenceBy).setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(disableDefaultParentalRuleBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } // enable + public static Response enable(Client client, long ruleId, EntityReferenceBy entityReferenceBy) { + EnableParentalRuleBuilder enableParentalRuleBuilder = ParentalRuleService.enable(ruleId, entityReferenceBy) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); - // list + TestAPIOkRequestsExecutor.getExecutor().queue(enableParentalRuleBuilder.build(client)); + await().untilTrue(done); + done.set(false); - // get - public static Response get(Client client, int id) { - OttCategoryService.GetOttCategoryBuilder getOttCategoryBuilder = OttCategoryService.get(id) - .setCompletion((ApiCompletion) result -> { - ottCategoryResponse = result; + return booleanResponse; + } + + // list + public static Response> list(Client client, ParentalRuleFilter parentalRuleFilter) { + ListParentalRuleBuilder listParentalRuleBuilder = ParentalRuleService.list(parentalRuleFilter) + .setCompletion((ApiCompletion>) result -> { + parentalRuleListResponse = result; done.set(true); }); - TestAPIOkRequestsExecutor.getExecutor().queue(getOttCategoryBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(listParentalRuleBuilder.build(client)); await().untilTrue(done); done.set(false); - return ottCategoryResponse; + return parentalRuleListResponse; } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java new file mode 100644 index 000000000..aa1a55314 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.PartnerConfigurationService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.PartnerConfiguration; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PartnerConfigurationService.UpdatePartnerConfigurationBuilder; +import static org.awaitility.Awaitility.await; + +public class PartnerConfigurationServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response booleanResponse; + + // update + public static Response update(Client client, PartnerConfiguration partnerConfiguration) { + UpdatePartnerConfigurationBuilder updatePartnerConfigurationBuilder = PartnerConfigurationService.update(partnerConfiguration) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updatePartnerConfigurationBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java new file mode 100644 index 000000000..037f8466d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java @@ -0,0 +1,119 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.PaymentGatewayProfileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.KeyValue; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.PaymentGatewayConfiguration; +import com.kaltura.client.types.PaymentGatewayProfile; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PaymentGatewayProfileService.*; +import static org.awaitility.Awaitility.await; + +public class PaymentGatewayProfileServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response paymentGatewayProfileResponse; + private static Response paymentGatewayConfigurationResponse; + private static Response> paymentGatewayProfileListResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, PaymentGatewayProfile paymentGatewayProfile) { + AddPaymentGatewayProfileBuilder addPaymentGatewayProfileBuilder = PaymentGatewayProfileService + .add(paymentGatewayProfile).setCompletion((ApiCompletion) result -> { + paymentGatewayProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addPaymentGatewayProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentGatewayProfileResponse; + } + + // delete + public static Response delete(Client client, int paymentGatewayId) { + DeletePaymentGatewayProfileBuilder deletePaymentGatewayProfileBuilder = PaymentGatewayProfileService.delete(paymentGatewayId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deletePaymentGatewayProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // generateSharedSecret + public static Response generateSharedSecret(Client client, int paymentGatewayId) { + GenerateSharedSecretPaymentGatewayProfileBuilder generateSharedSecretPaymentGatewayProfileBuilder = + PaymentGatewayProfileService.generateSharedSecret(paymentGatewayId) + .setCompletion((ApiCompletion) result -> { + paymentGatewayProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretPaymentGatewayProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentGatewayProfileResponse; + } + + // getConfiguration + public static Response getConfiguration(Client client, String alias, String intent, List extraParams) { + GetConfigurationPaymentGatewayProfileBuilder getConfigurationPaymentGatewayProfileBuilder = + PaymentGatewayProfileService.getConfiguration(alias, intent, extraParams) + .setCompletion((ApiCompletion) result -> { + paymentGatewayConfigurationResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationPaymentGatewayProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentGatewayConfigurationResponse; + } + + // list + public static Response> list(Client client) { + ListPaymentGatewayProfileBuilder listPaymentGatewayProfileBuilder = PaymentGatewayProfileService.list() + .setCompletion((ApiCompletion>) result -> { + paymentGatewayProfileListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listPaymentGatewayProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentGatewayProfileListResponse; + } + + // update + public static Response update(Client client, int paymentGatewayId, PaymentGatewayProfile paymentGatewayProfile) { + UpdatePaymentGatewayProfileBuilder updatePaymentGatewayProfileBuilder = PaymentGatewayProfileService + .update(paymentGatewayId, paymentGatewayProfile).setCompletion((ApiCompletion) result -> { + paymentGatewayProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updatePaymentGatewayProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentGatewayProfileResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java new file mode 100644 index 000000000..0b2afdca0 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java @@ -0,0 +1,83 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.PaymentMethodProfileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PaymentMethodProfileService.*; +import static org.awaitility.Awaitility.await; + +public class PaymentMethodProfileServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response paymentMethodProfileResponse; + private static Response paymentGatewayConfigurationResponse; + private static Response> paymentMethodProfileListResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, PaymentMethodProfile paymentMethodProfile) { + AddPaymentMethodProfileBuilder addPaymentMethodProfileBuilder = PaymentMethodProfileService.add(paymentMethodProfile) + .setCompletion((ApiCompletion) result -> { + paymentMethodProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addPaymentMethodProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentMethodProfileResponse; + } + + // delete + public static Response delete(Client client, int paymentMethodId) { + DeletePaymentMethodProfileBuilder deletePaymentMethodProfileBuilder = PaymentMethodProfileService.delete(paymentMethodId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deletePaymentMethodProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, PaymentMethodProfileFilter paymentMethodProfileFilter) { + ListPaymentMethodProfileBuilder listPaymentMethodProfileBuilder = PaymentMethodProfileService.list(paymentMethodProfileFilter) + .setCompletion((ApiCompletion>) result -> { + paymentMethodProfileListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listPaymentMethodProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentMethodProfileListResponse; + } + + // update + public static Response update(Client client, int paymentMethodId, PaymentMethodProfile paymentMethodProfile) { + UpdatePaymentMethodProfileBuilder updatePaymentMethodProfileBuilder = PaymentMethodProfileService.update(paymentMethodId, paymentMethodProfile) + .setCompletion((ApiCompletion) result -> { + paymentMethodProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updatePaymentMethodProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return paymentMethodProfileResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java new file mode 100644 index 000000000..fa7983ba8 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.PersonalFeedService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PersonalFeedService.*; +import static org.awaitility.Awaitility.await; + +public class PersonalFeedServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> personalFeedListResponse; + + // list + public static Response> list(Client client, PersonalFeedFilter personalFeedFilter, @Nullable FilterPager filterPager) { + ListPersonalFeedBuilder listPersonalFeedBuilder = PersonalFeedService.list(personalFeedFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + personalFeedListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listPersonalFeedBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return personalFeedListResponse; + } +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java new file mode 100644 index 000000000..9a93d93c0 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java @@ -0,0 +1,69 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.EntityReferenceBy; +import com.kaltura.client.enums.PinType; +import com.kaltura.client.services.PinService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Pin; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PinService.*; +import static org.awaitility.Awaitility.await; + +public class PinServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response pinResponse; + private static Response booleanResponse; + + // get + public static Response get(Client client, EntityReferenceBy entityReferenceBy, PinType pinType) { + GetPinBuilder getPinBuilder = PinService.get(entityReferenceBy, pinType) + .setCompletion((ApiCompletion) result -> { + pinResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getPinBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return pinResponse; + } + + // update + public static Response update(Client client, EntityReferenceBy entityReferenceBy, PinType pinType, Pin pin, @Nullable int ruleId) { + UpdatePinBuilder updatePinBuilder = PinService.update(entityReferenceBy, pinType, pin, ruleId) + .setCompletion((ApiCompletion) result -> { + pinResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updatePinBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return pinResponse; + } + + // validate + public static Response validate(Client client, String pin, PinType pinType, int ruleId) { + ValidatePinBuilder validatePinBuilder = PinService.validate(pin, pinType, ruleId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(validatePinBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java new file mode 100644 index 000000000..f46a331b7 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java @@ -0,0 +1,34 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.PpvService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Ppv; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PpvService.*; +import static org.awaitility.Awaitility.await; + +public class PpvServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response ppvResponse; + + // get + public static Response get(Client client, long id) { + GetPpvBuilder getPpvBuilder = PpvService.get(id).setCompletion((ApiCompletion) result -> { + ppvResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getPpvBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return ppvResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java new file mode 100644 index 000000000..51074fee5 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.PriceDetailsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.PriceDetails; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PriceDetailsService.*; +import static org.awaitility.Awaitility.await; + +public class PriceDetailsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> priceDetailsListResponse; + + // list + public static Response> list(Client client) { + ListPriceDetailsBuilder listPriceDetailsBuilder = PriceDetailsService.list() + .setCompletion((ApiCompletion>) result -> { + priceDetailsListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listPriceDetailsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return priceDetailsListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java new file mode 100644 index 000000000..44fe9355f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java @@ -0,0 +1,54 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.PricePlanService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.PricePlan; +import com.kaltura.client.types.PricePlanFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PricePlanService.*; +import static org.awaitility.Awaitility.await; + +public class PricePlanServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> pricePlanListResponse; + private static Response pricePlanResponse; + + // list + public static Response> list(Client client, @Nullable PricePlanFilter pricePlanFilter) { + ListPricePlanBuilder listPricePlanBuilder = PricePlanService.list(pricePlanFilter) + .setCompletion((ApiCompletion>) result -> { + pricePlanListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listPricePlanBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return pricePlanListResponse; + } + + // update + public static Response update(Client client, long id, PricePlan pricePlan) { + UpdatePricePlanBuilder updatePricePlanBuilder = PricePlanService.update(id, pricePlan) + .setCompletion((ApiCompletion) result -> { + pricePlanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updatePricePlanBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return pricePlanResponse; + } +} From 44f71d466bcf1a0f41a414baac116f7f3dad0338 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Apr 2018 23:07:15 +0300 Subject: [PATCH 100/605] no message --- .../test/servicesImpl/HouseholdDeviceServiceImpl.java | 4 ++-- .../kaltura/client/test/servicesImpl/MetaServiceImpl.java | 6 ++++-- .../client/test/servicesImpl/PriceDetailsServiceImpl.java | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java index 55143ea2f..aa38e33b2 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java @@ -40,8 +40,8 @@ public static Response add(Client client, HouseholdDevice house } // list - public static Response> list(Client client, HouseholdDeviceFilter filter) { - ListHouseholdDeviceBuilder listHouseholdDeviceBuilder = HouseholdDeviceService.list(filter) + public static Response> list(Client client, HouseholdDeviceFilter householdDeviceFilter) { + ListHouseholdDeviceBuilder listHouseholdDeviceBuilder = HouseholdDeviceService.list(householdDeviceFilter) .setCompletion((ApiCompletion>) result -> { householdDevicesListResponse = result; done.set(true); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java index 477c0462f..9fc3daacc 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java @@ -5,9 +5,11 @@ import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.Meta; +import com.kaltura.client.types.MetaFilter; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.MetaService.*; @@ -21,8 +23,8 @@ public class MetaServiceImpl { private static Response metaResponse; // list - public static Response> list(Client client) { - ListMetaBuilder listMetaBuilder = MetaService.list() + public static Response> list(Client client, @Nullable MetaFilter metaFilter) { + ListMetaBuilder listMetaBuilder = MetaService.list(metaFilter) .setCompletion((ApiCompletion>) result -> { metaListResponse = result; done.set(true); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java index 51074fee5..2bd04fcb5 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java @@ -5,9 +5,11 @@ import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.PriceDetails; +import com.kaltura.client.types.PriceDetailsFilter; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.services.PriceDetailsService.*; @@ -20,8 +22,8 @@ public class PriceDetailsServiceImpl { private static Response> priceDetailsListResponse; // list - public static Response> list(Client client) { - ListPriceDetailsBuilder listPriceDetailsBuilder = PriceDetailsService.list() + public static Response> list(Client client, @Nullable PriceDetailsFilter priceDetailsFilter) { + ListPriceDetailsBuilder listPriceDetailsBuilder = PriceDetailsService.list(priceDetailsFilter) .setCompletion((ApiCompletion>) result -> { priceDetailsListResponse = result; done.set(true); From e145a3df9ba5ec290261a66d2969f13c3bee5cda Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 19 Apr 2018 20:22:18 +0300 Subject: [PATCH 101/605] service impl --- .../PurchaseSettingsServiceImpl.java | 51 ++++++++ .../RecommendationProfileServiceImpl.java | 99 ++++++++++++++++ .../servicesImpl/RecordingServiceImpl.java | 112 ++++++++++++++++++ .../test/servicesImpl/RegionServiceImpl.java | 37 ++++++ .../RegistrySettingsServiceImpl.java | 36 ++++++ .../servicesImpl/ReminderServiceImpl.java | 72 +++++++++++ 6 files changed, 407 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java new file mode 100644 index 000000000..7fb27cda0 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java @@ -0,0 +1,51 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.EntityReferenceBy; +import com.kaltura.client.services.PurchaseSettingsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.PurchaseSettings; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.PurchaseSettingsService.*; +import static org.awaitility.Awaitility.await; + +public class PurchaseSettingsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response purchaseSettingsResponse; + + // get + public static Response get(Client client, EntityReferenceBy entityReferenceBy) { + GetPurchaseSettingsBuilder getPurchaseSettingsBuilder = PurchaseSettingsService.get(entityReferenceBy) + .setCompletion((ApiCompletion) result -> { + purchaseSettingsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getPurchaseSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return purchaseSettingsResponse; + } + + // update + public static Response update(Client client, EntityReferenceBy entityReferenceBy, PurchaseSettings purchaseSettings) { + UpdatePurchaseSettingsBuilder updatePurchaseSettingsBuilder = PurchaseSettingsService.update(entityReferenceBy, purchaseSettings) + .setCompletion((ApiCompletion) result -> { + purchaseSettingsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updatePurchaseSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return purchaseSettingsResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java new file mode 100644 index 000000000..f9d900c54 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java @@ -0,0 +1,99 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.RecommendationProfileService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.RecommendationProfile; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.RecommendationProfileService.*; +import static org.awaitility.Awaitility.await; + +public class RecommendationProfileServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response recommendationProfileResponse; + private static Response booleanResponse; + private static Response> recommendationProfileListResponse; + + // add + public static Response add(Client client, RecommendationProfile recommendationProfile) { + AddRecommendationProfileBuilder addRecommendationProfileBuilder = RecommendationProfileService.add(recommendationProfile) + .setCompletion((ApiCompletion) result -> { + recommendationProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addRecommendationProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recommendationProfileResponse; + } + + // delete + public static Response delete(Client client, int id) { + DeleteRecommendationProfileBuilder deleteRecommendationProfileBuilder = RecommendationProfileService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteRecommendationProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // generateSharedSecret + public static Response generateSharedSecret(Client client, int recommendationProfieId) { + GenerateSharedSecretRecommendationProfileBuilder generateSharedSecretRecommendationProfileBuilder = + RecommendationProfileService.generateSharedSecret(recommendationProfieId) + .setCompletion((ApiCompletion) result -> { + recommendationProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretRecommendationProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recommendationProfileResponse; + } + + // list + public static Response> list(Client client) { + ListRecommendationProfileBuilder listRecommendationProfileBuilder = RecommendationProfileService.list() + .setCompletion((ApiCompletion>) result -> { + recommendationProfileListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listRecommendationProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recommendationProfileListResponse; + } + + // update + public static Response update(Client client, int recommendationProfieId, RecommendationProfile recommendationProfile) { + UpdateRecommendationProfileBuilder updateRecommendationProfileBuilder = RecommendationProfileService.update(recommendationProfieId, recommendationProfile) + .setCompletion((ApiCompletion) result -> { + recommendationProfileResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateRecommendationProfileBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recommendationProfileResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java new file mode 100644 index 000000000..4e857e3bf --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java @@ -0,0 +1,112 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.RecordingService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.RecordingService.*; +import static org.awaitility.Awaitility.await; + +public class RecordingServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response recordingResponse; + private static Response> recordingListResponse; + + // add + public static Response add(Client client, Recording recording) { + AddRecordingBuilder addRecordingBuilder = RecordingService.add(recording) + .setCompletion((ApiCompletion) result -> { + recordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recordingResponse; + } + + // cancel + public static Response cancel(Client client, long id) { + CancelRecordingBuilder cancelRecordingBuilder = RecordingService.cancel(id) + .setCompletion((ApiCompletion) result -> { + recordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(cancelRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recordingResponse; + } + + // delete + public static Response delete(Client client, long id) { + DeleteRecordingBuilder deleteRecordingBuilder = RecordingService.delete(id) + .setCompletion((ApiCompletion) result -> { + recordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recordingResponse; + } + + // get + public static Response get(Client client, long id) { + GetRecordingBuilder getRecordingBuilder = RecordingService.get(id) + .setCompletion((ApiCompletion) result -> { + recordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recordingResponse; + } + + // list + public static Response> list(Client client, @Nullable RecordingFilter recordingFilter, @Nullable FilterPager filterPager) { + ListRecordingBuilder listRecordingBuilder = RecordingService.list(recordingFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + recordingListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recordingListResponse; + } + + // protect + public static Response protect(Client client, long id) { + ProtectRecordingBuilder protectRecordingBuilder = RecordingService.protect(id) + .setCompletion((ApiCompletion) result -> { + recordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(protectRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return recordingResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java new file mode 100644 index 000000000..659df1f19 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.RegionService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.Region; +import com.kaltura.client.types.RegionFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.RegionService.*; +import static org.awaitility.Awaitility.await; + +public class RegionServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> regionListResponse; + + // list + public static Response> list(Client client, RegionFilter regionFilter) { + ListRegionBuilder listRegionBuilder = RegionService.list(regionFilter) + .setCompletion((ApiCompletion>) result -> { + regionListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listRegionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return regionListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java new file mode 100644 index 000000000..e00df8596 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.RegistrySettingsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.RegistrySettings; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.RegistrySettingsService.*; +import static org.awaitility.Awaitility.await; + +public class RegistrySettingsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> registrySettingsListResponse; + + // list + public static Response> list(Client client) { + ListRegistrySettingsBuilder listRegistrySettingsBuilder = RegistrySettingsService.list() + .setCompletion((ApiCompletion>) result -> { + registrySettingsListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listRegistrySettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return registrySettingsListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java new file mode 100644 index 000000000..d67540cf1 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java @@ -0,0 +1,72 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.ReminderType; +import com.kaltura.client.services.ReminderService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.Reminder; +import com.kaltura.client.types.ReminderFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ReminderService.*; +import static org.awaitility.Awaitility.await; + +public class ReminderServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response reminderResponse; + private static Response booleanResponse; + private static Response> reminderListResponse; + + // add + public static Response add(Client client, Reminder reminder) { + AddReminderBuilder addReminderBuilder = ReminderService.add(reminder) + .setCompletion((ApiCompletion) result -> { + reminderResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addReminderBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return reminderResponse; + } + + // delete + public static Response add(Client client, long id, ReminderType reminderType) { + DeleteReminderBuilder deleteReminderBuilder = ReminderService.delete(id, reminderType) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteReminderBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, ReminderFilter reminderFilter, @Nullable FilterPager filterPager) { + ListReminderBuilder listReminderBuilder = ReminderService.list(reminderFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + reminderListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listReminderBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return reminderListResponse; + } +} From 0e495f3fcafd3d9da50978b683f368dfed676773 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 19 Apr 2018 22:24:40 +0300 Subject: [PATCH 102/605] service impl --- .../test/servicesImpl/ReportServiceImpl.java | 52 +++++++ .../SearchHistoryServiceImpl.java | 67 ++++++++ .../SeriesRecordingServiceImpl.java | 129 ++++++++++++++++ .../test/servicesImpl/SessionServiceImpl.java | 70 +++++++++ .../test/servicesImpl/SocialServiceImpl.java | 146 ++++++++++++++++++ 5 files changed, 464 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java new file mode 100644 index 000000000..8bfc98322 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java @@ -0,0 +1,52 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.ReportService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.ReportService.*; +import static org.awaitility.Awaitility.await; + +public class ReportServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response reportResponse; + private static Response> reportListResponse; + + // get + public static Response get(Client client, String udid) { + GetReportBuilder getReportBuilder = ReportService.get(udid) + .setCompletion((ApiCompletion) result -> { + reportResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getReportBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return reportResponse; + } + + // list + public static Response> list(Client client, ReportFilter reportFilter, @Nullable FilterPager filterPager) { + ListReportBuilder listReportBuilder = ReportService.list(reportFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + reportListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listReportBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return reportListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java new file mode 100644 index 000000000..5f97566a2 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java @@ -0,0 +1,67 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SearchHistoryService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SearchHistoryService.*; +import static org.awaitility.Awaitility.await; + +public class SearchHistoryServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response booleanResponse; + private static Response> searchHistoryListResponse; + + // clean + public static Response clean(Client client, @Nullable SearchHistoryFilter searchHistoryFilter) { + CleanSearchHistoryBuilder cleanSearchHistoryBuilder = SearchHistoryService.clean(searchHistoryFilter) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(cleanSearchHistoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // delete + public static Response delete(Client client, String id) { + DeleteSearchHistoryBuilder deleteSearchHistoryBuilder = SearchHistoryService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteSearchHistoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, @Nullable SearchHistoryFilter searchHistoryFilter, @Nullable FilterPager filterPager) { + ListSearchHistoryBuilder listSearchHistoryBuilder = SearchHistoryService.list(searchHistoryFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + searchHistoryListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listSearchHistoryBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return searchHistoryListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java new file mode 100644 index 000000000..d9bc3d8fe --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java @@ -0,0 +1,129 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SeriesRecordingService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.SeriesRecording; +import com.kaltura.client.types.SeriesRecordingFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SeriesRecordingService.*; +import static org.awaitility.Awaitility.await; + +public class SeriesRecordingServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response seriesRecordingResponse; + private static Response> seriesRecordingListResponse; + + // add + public static Response add(Client client, SeriesRecording seriesRecording) { + AddSeriesRecordingBuilder addSeriesRecordingBuilder = SeriesRecordingService.add(seriesRecording) + .setCompletion((ApiCompletion) result -> { + seriesRecordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addSeriesRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return seriesRecordingResponse; + } + + // cancel + public static Response cancel(Client client, long id) { + CancelSeriesRecordingBuilder cancelSeriesRecordingBuilder = SeriesRecordingService.cancel(id) + .setCompletion((ApiCompletion) result -> { + seriesRecordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(cancelSeriesRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return seriesRecordingResponse; + } + + // cancelByEpgId + public static Response cancelByEpgId(Client client, long id, long epgId) { + CancelByEpgIdSeriesRecordingBuilder cancelByEpgIdSeriesRecordingBuilder = SeriesRecordingService.cancelByEpgId(id, epgId) + .setCompletion((ApiCompletion) result -> { + seriesRecordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(cancelByEpgIdSeriesRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return seriesRecordingResponse; + } + + // cancelBySeasonNumber + public static Response cancelBySeasonNumber(Client client, long id, long seasonNumber) { + CancelBySeasonNumberSeriesRecordingBuilder cancelBySeasonNumberSeriesRecordingBuilder = SeriesRecordingService + .cancelBySeasonNumber(id, seasonNumber).setCompletion((ApiCompletion) result -> { + seriesRecordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(cancelBySeasonNumberSeriesRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return seriesRecordingResponse; + } + + // delete + public static Response delete(Client client, long id) { + DeleteSeriesRecordingBuilder deleteSeriesRecordingBuilder = SeriesRecordingService.delete(id) + .setCompletion((ApiCompletion) result -> { + seriesRecordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteSeriesRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return seriesRecordingResponse; + } + + // deleteBySeasonNumber + public static Response deleteBySeasonNumber(Client client, long id, int seasonNumber) { + DeleteBySeasonNumberSeriesRecordingBuilder deleteBySeasonNumberSeriesRecordingBuilder = + SeriesRecordingService.deleteBySeasonNumber(id, seasonNumber).setCompletion((ApiCompletion) result -> { + seriesRecordingResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteBySeasonNumberSeriesRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return seriesRecordingResponse; + } + + // list + public static Response> list(Client client, @Nullable SeriesRecordingFilter seriesRecordingFilter) { + ListSeriesRecordingBuilder listSeriesRecordingBuilder = SeriesRecordingService.list(seriesRecordingFilter) + .setCompletion((ApiCompletion>) result -> { + seriesRecordingListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listSeriesRecordingBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return seriesRecordingListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java new file mode 100644 index 000000000..1255622ba --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java @@ -0,0 +1,70 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SessionService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.LoginSession; +import com.kaltura.client.types.Session; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SessionService.*; +import static com.kaltura.client.services.SessionService.GetSessionBuilder; +import static com.kaltura.client.services.SessionService.RevokeSessionBuilder; +import static org.awaitility.Awaitility.await; + +public class SessionServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response sessionResponse; + private static Response booleanResponse; + private static Response loginSessionResponse; + + // get + public static Response get(Client client, @Nullable String session) { + GetSessionBuilder getSessionBuilder = SessionService.get(session) + .setCompletion((ApiCompletion) result -> { + sessionResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getSessionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return sessionResponse; + } + + // revoke + public static Response revoke(Client client) { + RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke().setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(revokeSessionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // switchUser + public static Response switchUser(Client client, String userIdToSwitch) { + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(userIdToSwitch) + .setCompletion((ApiCompletion) result -> { + loginSessionResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(switchUserSessionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return loginSessionResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java new file mode 100644 index 000000000..b5c52a603 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java @@ -0,0 +1,146 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.SocialNetwork; +import com.kaltura.client.services.SocialService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.Social; +import com.kaltura.client.types.SocialConfig; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SocialService.*; +import static org.awaitility.Awaitility.await; + +public class SocialServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response socialResponse; + private static Response loginResponse; + private static Response socialConfigResponse; + + // get + public static Response get(Client client, SocialNetwork socialNetwork) { + GetSocialBuilder getSocialBuilder = SocialService.get(socialNetwork) + .setCompletion((ApiCompletion) result -> { + socialResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialResponse; + } + + // getByToken + public static Response getByToken(Client client, int partnerId, String token, SocialNetwork socialNetwork) { + GetByTokenSocialBuilder getByTokenSocialBuilder = SocialService.getByToken(partnerId, token, socialNetwork) + .setCompletion((ApiCompletion) result -> { + socialResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getByTokenSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialResponse; + } + + // getConfiguration + public static Response getConfiguration(Client client, SocialNetwork socialNetwork, @Nullable int partnerId) { + GetConfigurationSocialBuilder getConfigurationSocialBuilder = SocialService.getConfiguration(socialNetwork, partnerId) + .setCompletion((ApiCompletion) result -> { + socialConfigResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialConfigResponse; + } + + // login + public static Response login(Client client, int partnerId, String token, SocialNetwork socialNetwork, @Nullable String udid) { + LoginSocialBuilder loginSocialBuilder = SocialService.login(partnerId, token, socialNetwork, udid) + .setCompletion((ApiCompletion) result -> { + loginResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(loginSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return loginResponse; + } + + // merge + public static Response merge(Client client, String token, SocialNetwork socialNetwork) { + MergeSocialBuilder mergeSocialBuilder = SocialService.merge(token, socialNetwork) + .setCompletion((ApiCompletion) result -> { + socialResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(mergeSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialResponse; + } + + // register + public static Response register(Client client, int partnerId, String token, SocialNetwork socialNetwork, @Nullable String email) { + RegisterSocialBuilder registerSocialBuilder = SocialService.register(partnerId, token, socialNetwork, email) + .setCompletion((ApiCompletion) result -> { + socialResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(registerSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialResponse; + } + + // unmerge + public static Response unmerge(Client client, SocialNetwork socialNetwork) { + UnmergeSocialBuilder unmergeSocialBuilder = SocialService.unmerge(socialNetwork) + .setCompletion((ApiCompletion) result -> { + socialResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(unmergeSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialResponse; + } + + // updateConfiguration + public static Response updateConfiguration(Client client, SocialConfig socialConfig) { + UpdateConfigurationSocialBuilder updateConfigurationSocialBuilder = SocialService.UpdateConfiguration(socialConfig) + .setCompletion((ApiCompletion) result -> { + socialConfigResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateConfigurationSocialBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialConfigResponse; + } +} From 098a79c2686b435a6b626f117ca51025ec108ffc Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Sun, 22 Apr 2018 10:49:27 +0300 Subject: [PATCH 103/605] Added classes that were not pushed to master due to recent issue in git --- .../test/servicesImpl/SessionServiceImpl.java | 35 +++++++++ .../entitlementTests/GrantTests.java | 8 +-- .../test/tests/sessionTests/GetTests.java | 72 +++++++++++++++++++ .../client/test/utils/OttUserUtils.java | 5 +- .../client/test/utils/SessionUtils.java | 20 ++++++ src/test/resources/schemas/Session.json | 61 ++++++++++++++++ 6 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/SessionUtils.java create mode 100644 src/test/resources/schemas/Session.json diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java new file mode 100644 index 000000000..ad252d265 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SessionService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Session; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.awaitility.Awaitility.await; + +public class SessionServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + private static Response getSessionResponse; + + + // session/action/get + + public static Response get(Client client, String session) { + SessionService.GetSessionBuilder sessionBuilder = SessionService.get(session) + .setCompletion((ApiCompletion) result -> { + getSessionResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(sessionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return getSessionResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index cc3a62b9a..8b5bf9036 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -62,7 +62,7 @@ private void grant_subscription_with_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); client.setUserId(null); BillingTransaction billingTransaction; @@ -110,7 +110,7 @@ private void grant_subscription_without_history() { // check transaction not return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); client.setUserId(null); TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); @@ -167,7 +167,7 @@ private void grant_ppv_with_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); client.setUserId(null); BillingTransaction billingTransaction; @@ -217,7 +217,7 @@ private void grant_ppv_without_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); client.setUserId(null); BillingTransaction billingTransaction; diff --git a/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java new file mode 100644 index 000000000..6b23c4910 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java @@ -0,0 +1,72 @@ +package com.kaltura.client.test.tests.sessionTests; + +import com.kaltura.client.Client; +import com.kaltura.client.test.Properties; +import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.test.utils.SessionUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.types.Session; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GetTests extends BaseTest { + + private Client client; + + long timeStampSeconds; + + @BeforeClass + private void get_tests_before_class() { + + } + + @Description("session/action/get - master user") + @Test + private void getMasterUserSession() { + client = getClient(administratorKs); + Household household = HouseholdUtils.createHouseHold(2, 1, false); + HouseholdUser user = HouseholdUtils.getMasterUserFromHousehold(household); + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String session = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), udid); + Response getSessionResponse = SessionServiceImpl.get(client, session); + + assertThat(getSessionResponse.results.getKs()).isEqualTo(session); + assertThat(getSessionResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(getSessionResponse.results.getUserId()).isEqualTo(user.getUserId()); + assertThat(getSessionResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(System.currentTimeMillis()/ 1000)); + assertThat(getSessionResponse.results.getUdid()).isEqualTo(udid); + assertThat(getSessionResponse.results.getCreateDate()).isGreaterThan(1523954068); + } + + @Description("session/action/get - Anonymous user") + @Test + private void getAnonymousUserSession() { + client = getClient(administratorKs); + String session = anonymousKs; + Response getSessionResponse = SessionServiceImpl.get(client, session); + + assertThat(getSessionResponse.results.getKs()).isEqualTo(session); + assertThat(getSessionResponse.results.getUserId()).isEqualTo("0"); + assertThat(getSessionResponse.results.getUdid()).isEqualTo(""); + } + + @Description("session/action/get - operator user") + @Test + private void getOperatorUserSession() { + client = getClient(administratorKs); + String session = operatorKs; + Response getSessionResponse = SessionServiceImpl.get(client, session); + + assertThat(getSessionResponse.results.getKs()).isEqualTo(session); + assertThat(getSessionResponse.results.getUserId()).isEqualTo(SessionUtils.getUserIdByKs(operatorKs)); + assertThat(getSessionResponse.results.getUdid()).isEqualTo(""); + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 298a09e8c..4fe3fcd3b 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -6,6 +6,7 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.Random; import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; @@ -44,10 +45,10 @@ public static OTTUser getUserById(int userId) { return userResponse.results; } - public static String getKs(int userId) { + public static String getKs(int userId, @Nullable String udid) { Client client = getClient(null); OTTUser ottUser = getUserById(userId); - Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, ottUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, ottUser.getUsername(), GLOBAL_USER_PASSWORD, null, udid); return loginResponse.results.getLoginSession().getKs(); } } diff --git a/src/test/java/com/kaltura/client/test/utils/SessionUtils.java b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java new file mode 100644 index 000000000..360e2bac3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java @@ -0,0 +1,20 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.Client; +import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.types.Session; +import com.kaltura.client.utils.response.base.Response; + +import static com.kaltura.client.test.tests.BaseTest.administratorKs; +import static com.kaltura.client.test.tests.BaseTest.getClient; + +public class SessionUtils extends BaseUtils { + + + // Return user id according to the ks provided + public static String getUserIdByKs(String ks) { + Client client = getClient(administratorKs); + Response getSessionResponse = SessionServiceImpl.get(client,ks); + return getSessionResponse.results.getUserId(); + } +} diff --git a/src/test/resources/schemas/Session.json b/src/test/resources/schemas/Session.json new file mode 100644 index 000000000..d4c56f8be --- /dev/null +++ b/src/test/resources/schemas/Session.json @@ -0,0 +1,61 @@ +{ + "$id": "session", + "definitions": { + "session": { + "type": "object", + "properties": { + "ks": { + "type": "string", + "minLength": 0 + }, + "partnerId": { + "type": "integer", + "minimum": 0 + }, + "userId": { + "type": "string", + "minLength": 0 + }, + "expiry": { + "type": "integer", + "minimum": 0 + }, + "privileges": { + "type": "string", + "minLength": 0 + }, + "udid": { + "type": "string", + "minLength": 0 + }, + "createDate": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": ["KalturaSession"], + "minLength": 0 + } + }, + "required": [ + "ks", + "partnerId", + "userId", + "expiry", + "udid", + "createDate" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/session" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From 5ea069a5c160c7e718ba297324a3cca913c62add Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 22 Apr 2018 11:54:16 +0300 Subject: [PATCH 104/605] service impl --- .../servicesImpl/SocialActionServiceImpl.java | 69 +++++++++++++ .../SocialCommentServiceImpl.java | 36 +++++++ .../SocialFriendActivityServiceImpl.java | 37 +++++++ .../servicesImpl/SubscriptionServiceImpl.java | 18 +++- .../SubscriptionSetServiceImpl.java | 98 +++++++++++++++++++ .../test/servicesImpl/SystemServiceImpl.java | 67 +++++++++++++ ...meShiftedTvPartnerSettingsServiceImpl.java | 51 ++++++++++ .../test/servicesImpl/TopicServiceImpl.java | 85 ++++++++++++++++ .../UnifiedPaymentServiceImpl.java | 35 +++++++ .../UserAssetRuleServiceImpl.java | 37 +++++++ .../UserAssetsListItemServiceImpl.java | 69 +++++++++++++ .../servicesImpl/UserInterestServiceImpl.java | 68 +++++++++++++ .../servicesImpl/UserRoleServiceImpl.java | 54 +++++++++- 13 files changed, 720 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java new file mode 100644 index 000000000..7aca2b606 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java @@ -0,0 +1,69 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SocialActionService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SocialActionService.*; +import static org.awaitility.Awaitility.await; + +public class SocialActionServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response userSocialActionResponseResponse; + private static Response> networkActionStatusList; + private static Response> socialActionListResponse; + + // add + public static Response add(Client client, SocialAction socialAction) { + AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialAction) + .setCompletion((ApiCompletion) result -> { + userSocialActionResponseResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addSocialActionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userSocialActionResponseResponse; + } + + // delete + public static Response> delete(Client client, String id) { + DeleteSocialActionBuilder deleteSocialActionBuilder = SocialActionService.delete(id) + .setCompletion((ApiCompletion>) result -> { + networkActionStatusList = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteSocialActionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return networkActionStatusList; + } + + // list + public static Response> list(Client client, SocialActionFilter socialActionFilter, @Nullable FilterPager filterPager) { + ListSocialActionBuilder listSocialActionBuilder = SocialActionService.list(socialActionFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + socialActionListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listSocialActionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialActionListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java new file mode 100644 index 000000000..ba66c3dfc --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SocialCommentService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SocialCommentService.*; +import static org.awaitility.Awaitility.await; + +public class SocialCommentServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> socialCommentListResponse; + + // list + public static Response> list(Client client, SocialCommentFilter socialCommentFilter, @Nullable FilterPager filterPager) { + ListSocialCommentBuilder listSocialCommentBuilder = SocialCommentService.list(socialCommentFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + socialCommentListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listSocialCommentBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialCommentListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java new file mode 100644 index 000000000..33c2c597a --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SocialFriendActivityService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SocialFriendActivityService.*; +import static org.awaitility.Awaitility.await; + +public class SocialFriendActivityServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> socialFriendActivityListResponse; + + // list + public static Response> list(Client client, @Nullable SocialFriendActivityFilter socialFriendActivityFilter, + @Nullable FilterPager filterPager) { + ListSocialFriendActivityBuilder listSocialFriendActivityBuilder = SocialFriendActivityService.list(socialFriendActivityFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + socialFriendActivityListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listSocialFriendActivityBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return socialFriendActivityListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java index 3083726c8..1275672d3 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java @@ -3,6 +3,7 @@ import com.kaltura.client.Client; import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.Coupon; import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.Subscription; import com.kaltura.client.types.SubscriptionFilter; @@ -11,6 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.SubscriptionService.*; import static com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; import static org.awaitility.Awaitility.await; @@ -19,6 +21,7 @@ public class SubscriptionServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response> subscriptionListResponse; + private static Response couponResponse; // list public static Response> list(Client client, SubscriptionFilter subscriptionFilter) { @@ -35,5 +38,18 @@ public static Response> list(Client client, Subscript return subscriptionListResponse; } -// validateCoupon + // validateCoupon + public static Response validateCoupon(Client client, int id, String code) { + ValidateCouponSubscriptionBuilder validateCouponSubscriptionBuilder = SubscriptionService.validateCoupon(id, code) + .setCompletion((ApiCompletion) result -> { + couponResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(validateCouponSubscriptionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return couponResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java new file mode 100644 index 000000000..b4e73b0a2 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java @@ -0,0 +1,98 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SubscriptionSetService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SubscriptionSetService.*; +import static org.awaitility.Awaitility.await; + +public class SubscriptionSetServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> subscriptionSetListResponse; + private static Response subscriptionSetResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, SubscriptionSet subscriptionSet) { + AddSubscriptionSetBuilder addSubscriptionSetBuilder = SubscriptionSetService.add(subscriptionSet) + .setCompletion((ApiCompletion) result -> { + subscriptionSetResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addSubscriptionSetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return subscriptionSetResponse; + } + + // delete + public static Response delete(Client client, long id) { + DeleteSubscriptionSetBuilder deleteSubscriptionSetBuilder = SubscriptionSetService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteSubscriptionSetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, long id) { + GetSubscriptionSetBuilder getSubscriptionSetBuilder = SubscriptionSetService.get(id) + .setCompletion((ApiCompletion) result -> { + subscriptionSetResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getSubscriptionSetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return subscriptionSetResponse; + } + + // list + public static Response> delete(Client client, @Nullable SubscriptionSetFilter subscriptionSetFilter) { + ListSubscriptionSetBuilder listSubscriptionSetBuilder = SubscriptionSetService.list(subscriptionSetFilter) + .setCompletion((ApiCompletion>) result -> { + subscriptionSetListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listSubscriptionSetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return subscriptionSetListResponse; + } + + // update + public static Response delete(Client client, long id, SubscriptionSet subscriptionSet) { + UpdateSubscriptionSetBuilder updateSubscriptionSetBuilder = SubscriptionSetService.update(id, subscriptionSet) + .setCompletion((ApiCompletion) result -> { + subscriptionSetResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateSubscriptionSetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return subscriptionSetResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java new file mode 100644 index 000000000..f417d62ea --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java @@ -0,0 +1,67 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.SystemService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.SubscriptionSet; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.SystemService.*; +import static org.awaitility.Awaitility.await; + +public class SystemServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response longResponse; + private static Response stringResponse; + private static Response booleanResponse; + + // getTime + public static Response getTime(Client client, SubscriptionSet subscriptionSet) { + GetTimeSystemBuilder getTimeSystemBuilder = SystemService.getTime() + .setCompletion((ApiCompletion) result -> { + longResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getTimeSystemBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return longResponse; + } + + // getVersion + public static Response getTime(Client client) { + GetVersionSystemBuilder getVersionSystemBuilder = SystemService.getVersion() + .setCompletion((ApiCompletion) result -> { + stringResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getVersionSystemBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return stringResponse; + } + + // ping + public static Response ping(Client client) { + PingSystemBuilder pingSystemBuilder = SystemService.ping() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(pingSystemBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java new file mode 100644 index 000000000..9b0da4a62 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java @@ -0,0 +1,51 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.TimeShiftedTvPartnerSettingsService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.TimeShiftedTvPartnerSettings; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.TimeShiftedTvPartnerSettingsService.*; +import static org.awaitility.Awaitility.await; + +public class TimeShiftedTvPartnerSettingsServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response timeShiftedTvPartnerSettingsResponse; + private static Response booleanResponse; + + // get + public static Response get(Client client) { + GetTimeShiftedTvPartnerSettingsBuilder getTimeShiftedTvPartnerSettingsBuilder = + TimeShiftedTvPartnerSettingsService.get().setCompletion((ApiCompletion) result -> { + timeShiftedTvPartnerSettingsResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getTimeShiftedTvPartnerSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return timeShiftedTvPartnerSettingsResponse; + } + + // update + public static Response update(Client client, TimeShiftedTvPartnerSettings timeShiftedTvPartnerSettings) { + UpdateTimeShiftedTvPartnerSettingsBuilder updateTimeShiftedTvPartnerSettingsBuilder = TimeShiftedTvPartnerSettingsService + .update(timeShiftedTvPartnerSettings).setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateTimeShiftedTvPartnerSettingsBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java new file mode 100644 index 000000000..ab7d8e16b --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java @@ -0,0 +1,85 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.TopicAutomaticIssueNotification; +import com.kaltura.client.services.TopicService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.TopicService.*; +import static org.awaitility.Awaitility.await; + +public class TopicServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response topicResponse; + private static Response booleanResponse; + private static Response> topicListResponse; + + // get + public static Response get(Client client, int id) { + GetTopicBuilder getTopicBuilder = TopicService.get(id) + .setCompletion((ApiCompletion) result -> { + topicResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getTopicBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return topicResponse; + } + + // delete + public static Response delete(Client client, int id) { + DeleteTopicBuilder deleteTopicBuilder = TopicService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteTopicBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, @Nullable TopicFilter topicFilter, @Nullable FilterPager filterPager) { + ListTopicBuilder listTopicBuilder = TopicService.list(topicFilter, filterPager) + .setCompletion((ApiCompletion>) result -> { + topicListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listTopicBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return topicListResponse; + } + + // updateStatus + public static Response updateStatus(Client client, int id, TopicAutomaticIssueNotification topicAutomaticIssueNotification) { + UpdateStatusTopicBuilder updateStatusTopicBuilder = TopicService.updateStatus(id, topicAutomaticIssueNotification) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusTopicBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java new file mode 100644 index 000000000..5e3e3437c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java @@ -0,0 +1,35 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.UnifiedPaymentService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.UnifiedPaymentRenewal; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.UnifiedPaymentService.GetNextRenewalUnifiedPaymentBuilder; +import static org.awaitility.Awaitility.await; + +public class UnifiedPaymentServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response unifiedPaymentRenewalResponse; + + // getNextRenewal + public static Response getNextRenewal(Client client, int id) { + GetNextRenewalUnifiedPaymentBuilder getNextRenewalUnifiedPaymentBuilder = UnifiedPaymentService.getNextRenewal(id) + .setCompletion((ApiCompletion) result -> { + unifiedPaymentRenewalResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getNextRenewalUnifiedPaymentBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return unifiedPaymentRenewalResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java new file mode 100644 index 000000000..9f2bd74a2 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.UserAssetRuleService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.UserAssetRule; +import com.kaltura.client.types.UserAssetRuleFilter; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.UserAssetRuleService.*; +import static org.awaitility.Awaitility.await; + +public class UserAssetRuleServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response> userAssetRuleListResponse; + + // list + public static Response> list(Client client, UserAssetRuleFilter userAssetRuleFilter) { + ListUserAssetRuleBuilder listUserAssetRuleBuilder = UserAssetRuleService.list(userAssetRuleFilter) + .setCompletion((ApiCompletion>) result -> { + userAssetRuleListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listUserAssetRuleBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userAssetRuleListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java new file mode 100644 index 000000000..1aba08844 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java @@ -0,0 +1,69 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.UserAssetsListItemType; +import com.kaltura.client.enums.UserAssetsListType; +import com.kaltura.client.services.UserAssetsListItemService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.UserAssetsListItem; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.UserAssetsListItemService.*; +import static org.awaitility.Awaitility.await; + +public class UserAssetsListItemServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response userAssetsListItemResponse; + private static Response booleanResponse; + + // add + public static Response add(Client client, UserAssetsListItem userAssetsListItem) { + AddUserAssetsListItemBuilder addUserAssetsListItemBuilder = UserAssetsListItemService.add(userAssetsListItem) + .setCompletion((ApiCompletion) result -> { + userAssetsListItemResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addUserAssetsListItemBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userAssetsListItemResponse; + } + + // delete + public static Response delete(Client client, String assetId, UserAssetsListType userAssetsListType) { + DeleteUserAssetsListItemBuilder deleteUserAssetsListItemBuilder = UserAssetsListItemService.delete(assetId, userAssetsListType) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserAssetsListItemBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // get + public static Response get(Client client, String assetId, UserAssetsListType userAssetsListType, + UserAssetsListItemType userAssetsListItemType) { + GetUserAssetsListItemBuilder getUserAssetsListItemBuilder = UserAssetsListItemService.get(assetId, userAssetsListType, userAssetsListItemType) + .setCompletion((ApiCompletion) result -> { + userAssetsListItemResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getUserAssetsListItemBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userAssetsListItemResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java new file mode 100644 index 000000000..8ea00d879 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java @@ -0,0 +1,68 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.services.UserInterestService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.UserInterest; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.kaltura.client.services.UserInterestService.*; +import static org.awaitility.Awaitility.await; + +public class UserInterestServiceImpl { + + private static final AtomicBoolean done = new AtomicBoolean(false); + + private static Response userInterestResponse; + private static Response booleanResponse; + private static Response> userInterestListResponse; + + // add + public static Response add(Client client, UserInterest userInterest) { + AddUserInterestBuilder addUserInterestBuilder = UserInterestService.add(userInterest) + .setCompletion((ApiCompletion) result -> { + userInterestResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addUserInterestBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userInterestResponse; + } + + // delete + public static Response add(Client client, String id) { + DeleteUserInterestBuilder deleteUserInterestBuilder = UserInterestService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserInterestBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // list + public static Response> list(Client client, String id) { + ListUserInterestBuilder listUserInterestBuilder = UserInterestService.list() + .setCompletion((ApiCompletion>) result -> { + userInterestListResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(listUserInterestBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userInterestListResponse; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java index 86ee6932e..0611fde67 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java @@ -12,6 +12,7 @@ import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.UserRoleService.*; import static com.kaltura.client.services.UserRoleService.ListUserRoleBuilder; import static org.awaitility.Awaitility.await; @@ -20,10 +21,12 @@ public class UserRoleServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); private static Response> userRoleListResponse; + private static Response userRoleResponse; + private static Response booleanResponse; - //list - public static Response> list(Client client, @Nullable UserRoleFilter filter) { - ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(filter) + // list + public static Response> list(Client client, @Nullable UserRoleFilter userRoleFilter) { + ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(userRoleFilter) .setCompletion((ApiCompletion>) result -> { userRoleListResponse = result; done.set(true); @@ -35,4 +38,49 @@ public static Response> list(Client client, @Nullable Use return userRoleListResponse; } + + // add + public static Response add(Client client, UserRole userRole) { + AddUserRoleBuilder addUserRoleBuilder = UserRoleService.add(userRole) + .setCompletion((ApiCompletion) result -> { + userRoleResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(addUserRoleBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userRoleResponse; + } + + // delete + public static Response delete(Client client, long id) { + DeleteUserRoleBuilder deleteUserRoleBuilder = UserRoleService.delete(id) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserRoleBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // update + public static Response update(Client client, long id, UserRole userRole) { + UpdateUserRoleBuilder updateUserRoleBuilder = UserRoleService.update(id, userRole) + .setCompletion((ApiCompletion) result -> { + userRoleResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(updateUserRoleBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return userRoleResponse; + } } From 9fb4543d2cbae5d04245bc120e6f78f98d0c557a Mon Sep 17 00:00:00 2001 From: alonbasin-kaltura <35916900+alonbasin-kaltura@users.noreply.github.com> Date: Sun, 22 Apr 2018 11:59:37 +0300 Subject: [PATCH 105/605] Update SessionServiceImpl.java --- .../test/servicesImpl/SessionServiceImpl.java | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java index ad252d265..027419370 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java @@ -3,33 +3,69 @@ import com.kaltura.client.Client; import com.kaltura.client.services.SessionService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.types.LoginSession; import com.kaltura.client.types.Session; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.services.SessionService.*; +import static com.kaltura.client.services.SessionService.GetSessionBuilder; +import static com.kaltura.client.services.SessionService.RevokeSessionBuilder; import static org.awaitility.Awaitility.await; public class SessionServiceImpl { private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response getSessionResponse; + private static Response sessionResponse; + private static Response booleanResponse; + private static Response loginSessionResponse; - // session/action/get - - public static Response get(Client client, String session) { - SessionService.GetSessionBuilder sessionBuilder = SessionService.get(session) + // get + public static Response get(Client client, @Nullable String session) { + GetSessionBuilder getSessionBuilder = SessionService.get(session) .setCompletion((ApiCompletion) result -> { - getSessionResponse = result; + sessionResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getSessionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return sessionResponse; + } + + // revoke + public static Response revoke(Client client) { + RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(revokeSessionBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return booleanResponse; + } + + // switchUser + public static Response switchUser(Client client, String userIdToSwitch) { + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(userIdToSwitch) + .setCompletion((ApiCompletion) result -> { + loginSessionResponse = result; done.set(true); }); - TestAPIOkRequestsExecutor.getExecutor().queue(sessionBuilder.build(client)); + TestAPIOkRequestsExecutor.getExecutor().queue(switchUserSessionBuilder.build(client)); await().untilTrue(done); done.set(false); - return getSessionResponse; + return loginSessionResponse; } } From 32cd6175bffd89fbd814b15c9f6c0ddd73bba682 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 22 Apr 2018 12:17:50 +0300 Subject: [PATCH 106/605] no message --- .../test/servicesImpl/BaseServiceImpl.java | 23 +++++++++++++++++++ .../test/servicesImpl/SessionServiceImpl.java | 9 ++++---- 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java new file mode 100644 index 000000000..b9b394cbc --- /dev/null +++ b/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java @@ -0,0 +1,23 @@ +package com.kaltura.client.test.servicesImpl; + +import com.kaltura.client.Client; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.utils.request.RequestBuilder; +import com.kaltura.client.utils.response.base.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.awaitility.Awaitility.await; + +public class BaseServiceImpl { + + protected static final AtomicBoolean done = new AtomicBoolean(false); + + public static Response executeRequest(Client client, RequestBuilder requestBuilder, Response response) { + TestAPIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return response; + } +} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java index 1255622ba..027419370 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java @@ -41,10 +41,11 @@ public static Response get(Client client, @Nullable String session) { // revoke public static Response revoke(Client client) { - RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke().setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); + RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); TestAPIOkRequestsExecutor.getExecutor().queue(revokeSessionBuilder.build(client)); await().untilTrue(done); From 3ebce45ba82ecec2e7468a51845ceddc44ca1cf7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Sun, 22 Apr 2018 12:18:14 +0300 Subject: [PATCH 107/605] Updated AddTests class (AppToken) --- .../tests/servicesTests/appTokenTests/AddTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java index 758f77469..c6ffeb307 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -93,6 +93,18 @@ private void addAppTokenWithExpiryDate() { assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } + @Description("appToken/action/add - with no expiry date (return default expiry date -" + + "According to app_token_max_expiry_seconds key value in group_203 CB document") + @Test + private void addAppTokenWithNoExpiryDate() { + client = getClient(sharedMasterUserKs); + int expiryDate = 0; + int cbExpiryDateValue = 2592000; + appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, expiryDate); + Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); + assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(cbExpiryDateValue)); + } + @Description("appToken/action/add - with no specific user id") @Test private void addAppTokenWithoutSpecificUserId() { From 4f6e6997a26bbaf3771208db9d027bd9dfa2d1cb Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Sun, 22 Apr 2018 13:46:09 +0300 Subject: [PATCH 108/605] Updated several classes in AppToken service --- .../servicesTests/appTokenTests/AddTests.java | 11 ++++++++--- .../servicesTests/appTokenTests/GetTests.java | 8 ++++---- .../appTokenTests/StartSessionTests.java | 18 ++++++++++++++++++ .../test/tests/sessionTests/GetTests.java | 14 +++++++++++++- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java index c6ffeb307..446dad42b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java @@ -27,7 +27,6 @@ public class AddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - client = getClient(operatorKs); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); } @@ -35,6 +34,7 @@ private void add_tests_before_class() { @Description("appToken/action/add") @Test private void addAppToken() { + client = getClient(operatorKs); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); // Assertions @@ -55,6 +55,7 @@ private void addAppToken() { @Description("appToken/action/add - without hash type") @Test private void addAppTokenWithDefaultHashType() { + client = getClient(operatorKs); appToken = AppTokenUtils.addAppToken(sessionUserId, null, null, null); // Invoke AppToken/action/add - with no hash type (will return the default hash type) Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); @@ -65,6 +66,7 @@ private void addAppTokenWithDefaultHashType() { @Description("appToken/action/add - with privileges") @Test private void addAppTokenWithPrivileges() { + client = getClient(operatorKs); sessionPrivileges = "key1:value1,key2:value2"; appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, null); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); @@ -75,12 +77,13 @@ private void addAppTokenWithPrivileges() { @Description("appToken/action/add - with expiry date") @Test private void addAppTokenWithExpiryDate() { + client = getClient(operatorKs); Long expiryDate = BaseUtils.getTimeInEpoch(1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); - // Wait until token is expired (according to expiry date) + // Wait until token is expired (according to expiry date) System.out.println("Waiting 1 minute until token expiry date reached"); try { @@ -97,18 +100,20 @@ private void addAppTokenWithExpiryDate() { "According to app_token_max_expiry_seconds key value in group_203 CB document") @Test private void addAppTokenWithNoExpiryDate() { + BaseUtils.getSharedHousehold(); client = getClient(sharedMasterUserKs); int expiryDate = 0; int cbExpiryDateValue = 2592000; appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, expiryDate); Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(cbExpiryDateValue)); + } @Description("appToken/action/add - with no specific user id") @Test private void addAppTokenWithoutSpecificUserId() { - + client = getClient(operatorKs); appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, null); Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); assertThat(addAppTokenResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java index 7a84af7ee..539900826 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java @@ -22,10 +22,10 @@ public class GetTests extends BaseTest { private String sessionPrivileges = "key1:value1,key2:value2"; private AppTokenHashType hashType; public static Client client; - Long expiryDate; - int offSetInMinutes = 1; - int sessionDuration = 86400; - AppToken appToken; + private Long expiryDate; + private int offSetInMinutes = 1; + private int sessionDuration = 86400; + private AppToken appToken; @BeforeClass private void get_tests_before_class() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java index 3b60c7daa..59d7506fe 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java @@ -106,4 +106,22 @@ private void startSessionSha256() { // TODO - Add session/action/get request with ks received from startSession API } + + @Description("appToken/action/startSession - token id with default expiry date (according to the value in group_203 CB document" + + "OPEN BEO-4980") + @Test + private void startSessionDefaultExpiryDate() { + int expiryDate = 0; + BaseUtils.getSharedHousehold(); + client = getClient(sharedMasterUserKs); + hashType = AppTokenHashType.SHA1; + appToken = AppTokenUtils.addAppToken(null, hashType, null, expiryDate); + Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + client = getClient(anonymousKs); + String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + Response sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() + , tokenHash, null, expiryDate, udid1); + + assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java index 6b23c4910..91e676fb3 100644 --- a/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java @@ -15,6 +15,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class GetTests extends BaseTest { @@ -41,7 +42,7 @@ private void getMasterUserSession() { assertThat(getSessionResponse.results.getKs()).isEqualTo(session); assertThat(getSessionResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); assertThat(getSessionResponse.results.getUserId()).isEqualTo(user.getUserId()); - assertThat(getSessionResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(System.currentTimeMillis()/ 1000)); + assertThat(getSessionResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(System.currentTimeMillis() / 1000)); assertThat(getSessionResponse.results.getUdid()).isEqualTo(udid); assertThat(getSessionResponse.results.getCreateDate()).isGreaterThan(1523954068); } @@ -69,4 +70,15 @@ private void getOperatorUserSession() { assertThat(getSessionResponse.results.getUserId()).isEqualTo(SessionUtils.getUserIdByKs(operatorKs)); assertThat(getSessionResponse.results.getUdid()).isEqualTo(""); } + + @Description("session/action/get - invalid ks") + @Test + private void getSessionWithInvalidSessionKs() { + client = getClient(administratorKs); + String session = operatorKs + 1; + Response getSessionResponse = SessionServiceImpl.get(client, session); + + assertThat(getSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500015).getCode()); + } } + From a18c98efcca451b0a0a833e39920eefe4a1207e5 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 22 Apr 2018 15:12:25 +0300 Subject: [PATCH 109/605] no message --- .../test/servicesImpl/AssetServiceImpl.java | 54 +++++++++++++++++-- .../{AddTests.java => AppTokenAddTests.java} | 0 2 files changed, 50 insertions(+), 4 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/{AddTests.java => AppTokenAddTests.java} (100%) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java index b7172964e..44d36bde9 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java @@ -2,13 +2,11 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.enums.AssetType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.AssetService.*; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.AssetFilter; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; import javax.annotation.Nullable; @@ -21,6 +19,9 @@ public class AssetServiceImpl { private static Response assetResponse; private static Response> assetListResponse; + private static Response assetCountResponse; + private static Response adsContextResponse; + private static Response playbackContextResponse; // get public static Response get(Client client, String id, AssetReferenceType assetReferenceType) { @@ -51,6 +52,51 @@ public static Response> list(Client client, AssetFilter asse return assetListResponse; } + + // count + public static Response get(Client client, @Nullable SearchAssetFilter searchAssetFilter) { + CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) + .setCompletion((ApiCompletion) result -> { + assetCountResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(countAssetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return assetCountResponse; + } + + // getAdsContext + public static Response getAdsContext(Client client, String assetId, AssetType assetType, PlaybackContextOptions playbackContextOptions) { + GetAdsContextAssetBuilder getAdsContextAssetBuilder = AssetService.getAdsContext(assetId, assetType, playbackContextOptions) + .setCompletion((ApiCompletion) result -> { + adsContextResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getAdsContextAssetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return adsContextResponse; + } + + // getPlaybackContext + public static Response getPlaybackContext(Client client, String assetId, AssetType assetType, PlaybackContextOptions playbackContextOptions) { + GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = AssetService.getPlaybackContext(assetId, assetType, playbackContextOptions) + .setCompletion((ApiCompletion) result -> { + playbackContextResponse = result; + done.set(true); + }); + + TestAPIOkRequestsExecutor.getExecutor().queue(getPlaybackContextAssetBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return playbackContextResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java From 1287b28fbed6225c75ae5cf5f61576c8c1795765 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Sun, 22 Apr 2018 15:15:07 +0300 Subject: [PATCH 110/605] Change name of several classes to new format (name of the class before) + update classes of service "session" --- .../{AddTests.java => AppTokenAddTests.java} | 2 +- ...eteTests.java => AppTokenDeleteTests.java} | 2 +- .../{GetTests.java => AppTokenGetTests.java} | 2 +- ...ts.java => AppTokenStartSessionTests.java} | 2 +- .../{AddTests.java => BookmarkAddTests.java} | 2 +- ...{ListTests.java => BookmarkListTests.java} | 2 +- .../sessionTests/SessionGetTests.java} | 4 +- .../sessionTests/SessionRevokeTests.java | 65 +++++++++++++++++++ .../sessionTests/SessionSwitchUserTests.java | 20 ++++++ .../client/test/utils/HouseholdUtils.java | 17 ++++- 10 files changed, 109 insertions(+), 9 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/{AddTests.java => AppTokenAddTests.java} (99%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/{DeleteTests.java => AppTokenDeleteTests.java} (97%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/{GetTests.java => AppTokenGetTests.java} (98%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/{StartSessionTests.java => AppTokenStartSessionTests.java} (99%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/{AddTests.java => BookmarkAddTests.java} (99%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/{ListTests.java => BookmarkListTests.java} (98%) rename src/test/java/com/kaltura/client/test/tests/{sessionTests/GetTests.java => servicesTests/sessionTests/SessionGetTests.java} (96%) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java similarity index 99% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 446dad42b..021701da8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -16,7 +16,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -public class AddTests extends BaseTest { +public class AppTokenAddTests extends BaseTest { private AppTokenHashType hashType; private String sessionUserId = "1577578"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java similarity index 97% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/DeleteTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java index 8c6baa4cc..793ca5e75 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java @@ -14,7 +14,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -public class DeleteTests extends BaseTest { +public class AppTokenDeleteTests extends BaseTest { private AppTokenHashType hashType; private String sessionUserId; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index 539900826..5b69a6c18 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -16,7 +16,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -public class GetTests extends BaseTest { +public class AppTokenGetTests extends BaseTest { final private String sessionUserId = "1577578"; private String sessionPrivileges = "key1:value1,key2:value2"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java similarity index 99% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index 59d7506fe..8370a852f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/StartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class StartSessionTests extends BaseTest { +public class AppTokenStartSessionTests extends BaseTest { private AppTokenHashType hashType; private String sessionUserId = "1577578"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java similarity index 99% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index e58df7af1..a546f31fb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/AddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class AddTests extends BaseTest { +public class BookmarkAddTests extends BaseTest { private Client client; private long assetId; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index e4551d380..703f05cbc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -21,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class ListTests extends BaseTest { +public class BookmarkListTests extends BaseTest { private Client client; private String assetId; diff --git a/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java similarity index 96% rename from src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index 91e676fb3..e6c98e4c0 100644 --- a/src/test/java/com/kaltura/client/test/tests/sessionTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -1,4 +1,4 @@ -package com.kaltura.client.test.tests.sessionTests; +package com.kaltura.client.test.tests.servicesTests.sessionTests; import com.kaltura.client.Client; import com.kaltura.client.test.Properties; @@ -18,7 +18,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -public class GetTests extends BaseTest { +public class SessionGetTests extends BaseTest { private Client client; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java new file mode 100644 index 000000000..5ab202317 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java @@ -0,0 +1,65 @@ +package com.kaltura.client.test.tests.servicesTests.sessionTests; + +import com.kaltura.client.Client; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; + +import com.kaltura.client.types.Household; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static org.assertj.core.api.Assertions.assertThat; + +public class SessionRevokeTests extends BaseTest { + + public static Client client; + private String udid; + + @BeforeClass + private void revoke_tests_before_class() { + udid = "123456789"; + } + + + @Description("/session/action/revoke - 2 different kss") + @Test + private void RevokeKs() { + Household household = HouseholdUtils.createHouseHold(2, 2, false); + String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + String masterUserKs2 = HouseholdUtils.getHouseholdMasterUserKs(household, udid); + client = getClient(masterUserKs); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + // Revoke all sessions for specific user + Response booleanResponse = SessionServiceImpl.revoke(client); + assertThat(booleanResponse.results).isTrue(); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + // Verify ks is expired + Response ottUserResponse2 = OttUserServiceImpl.get(client); + assertThat(ottUserResponse2.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); + + client = getClient(masterUserKs2); + + // Verify ks2 is expired + Response ottUserResponse3 = OttUserServiceImpl.get(client); + assertThat(ottUserResponse3.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); + } + +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java new file mode 100644 index 000000000..9e5cdc252 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -0,0 +1,20 @@ +package com.kaltura.client.test.tests.servicesTests.sessionTests; + +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SessionSwitchUserTests { + + @BeforeClass + private void switchUser_tests_before_class() { + + } + + @Description("/session/action/switchUser") + @Test + private void SwitchUser() { + + + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index a212f764b..6595355a7 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -5,9 +5,12 @@ import com.kaltura.client.test.servicesImpl.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; + +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Random; + import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; @@ -72,7 +75,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO client = getClient(null); client.setKs(operatorKs); client.setUserId(Integer.valueOf(masterUser.getId())); - HouseholdPaymentGatewayServiceImpl.setChargeId(client,"0110151474255957105", "1234"); + HouseholdPaymentGatewayServiceImpl.setChargeId(client, "0110151474255957105", "1234"); } return household; @@ -140,4 +143,16 @@ public static List getRegularUsersListFromHouseHold(Household hou users.removeAll(usersToRemove); return users; } + + // Get master KS by providing household object + public static String getHouseholdMasterUserKs(Household household, @Nullable String udid) { + HouseholdUser masterUser = getMasterUserFromHousehold(household); + return OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + } + + // Get regular user KS by providing household object + public static String getHouseholdUserKs(Household household, @Nullable String udid) { + HouseholdUser user = getRegularUsersListFromHouseHold(household).get(0); + return OttUserUtils.getKs(Integer.parseInt(user.getUserId()), udid); + } } From 18f09a3f365d126589cb302929387fa649923f21 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 22 Apr 2018 16:35:12 +0300 Subject: [PATCH 111/605] no message --- .../kaltura/client/test/servicesImpl/BaseServiceImpl.java | 5 +---- .../appTokenTests/{AppTokenAddTests.java => AddTests.java} | 0 2 files changed, 1 insertion(+), 4 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/{AppTokenAddTests.java => AddTests.java} (100%) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java index b9b394cbc..0f38a458f 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java @@ -3,7 +3,6 @@ import com.kaltura.client.Client; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.utils.request.RequestBuilder; -import com.kaltura.client.utils.response.base.Response; import java.util.concurrent.atomic.AtomicBoolean; @@ -13,11 +12,9 @@ public class BaseServiceImpl { protected static final AtomicBoolean done = new AtomicBoolean(false); - public static Response executeRequest(Client client, RequestBuilder requestBuilder, Response response) { + static void executeRequest(Client client, RequestBuilder requestBuilder) { TestAPIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); await().untilTrue(done); done.set(false); - - return response; } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AddTests.java From 5c97099e8359810d96f6d7e4230bc42db133929b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 22 Apr 2018 16:37:51 +0300 Subject: [PATCH 112/605] no message --- .../com/kaltura/client/test/servicesImpl/BaseServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java index 0f38a458f..25c48f9a1 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java @@ -12,6 +12,7 @@ public class BaseServiceImpl { protected static final AtomicBoolean done = new AtomicBoolean(false); + // TODO: 4/22/2018 use executeRequest() method in all services and check behavior in parallel execution static void executeRequest(Client client, RequestBuilder requestBuilder) { TestAPIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); await().untilTrue(done); From b44427665666798b575ef3871d1c51a1ca5e958e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 23 Apr 2018 11:00:05 +0300 Subject: [PATCH 113/605] Updated class SessionRevokeTests --- .../sessionTests/SessionRevokeTests.java | 2 +- .../sessionTests/SessionSwitchUserTests.java | 73 ++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java index 5ab202317..ae3bdaeef 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java @@ -23,7 +23,6 @@ public class SessionRevokeTests extends BaseTest { @BeforeClass private void revoke_tests_before_class() { - udid = "123456789"; } @@ -31,6 +30,7 @@ private void revoke_tests_before_class() { @Test private void RevokeKs() { Household household = HouseholdUtils.createHouseHold(2, 2, false); + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); String masterUserKs2 = HouseholdUtils.getHouseholdMasterUserKs(household, udid); client = getClient(masterUserKs); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index 9e5cdc252..0f7fce5b2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -1,10 +1,27 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; +import com.kaltura.client.Client; +import com.kaltura.client.enums.UserState; +import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.DBUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.LoginSession; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.Session; +import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class SessionSwitchUserTests { +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static org.assertj.core.api.Assertions.assertThat; + +public class SessionSwitchUserTests extends BaseTest { + + public static Client client; @BeforeClass private void switchUser_tests_before_class() { @@ -15,6 +32,60 @@ private void switchUser_tests_before_class() { @Test private void SwitchUser() { + Household household = HouseholdUtils.createHouseHold(2, 1, false); + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); + String secondUserId = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0).getUserId(); + client = getClient(masterUserKs); + + // Invoke session/action/switchUser - second user replace master user in the session + Response loginSessionResponse = SessionServiceImpl.switchUser(client, secondUserId); + // Verify new session ks returned + assertThat(loginSessionResponse.results.getKs()).isNotEmpty(); + String secondUserKs = loginSessionResponse.results.getKs(); + + ///----- After User was switched ------ + // Invoke OttUser/action/get - with master user (expired) ks + Response ottUserResponse = OttUserServiceImpl.get(client); + // Verify master user ks is now expired (after the switch) + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); + + client = getClient(secondUserKs); + // Invoke OttUser/action/get with second user new ks + Response ottUserResponse2 = OttUserServiceImpl.get(client); + // Verify second user id return in the response + assertThat(ottUserResponse2.results.getId()).isEqualTo(secondUserId); + assertThat(ottUserResponse2.results.getUserState()).isEqualTo(UserState.OK); + + client = getClient(administratorKs); + // Invoke session/action/get + Response getSessionResponse = SessionServiceImpl.get(client, secondUserKs); + // Verify second user id returned in the response + assertThat(getSessionResponse.results.getUserId()).isEqualTo(secondUserId); + assertThat(getSessionResponse.results.getUdid()).isEqualTo(udid); } + + @Description("/session/action/switchUser - user switch to himself") + @Test + private void SwitchUserToHimself() { + Household household = HouseholdUtils.createHouseHold(2, 1, false); + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); + String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); + client = getClient(masterUserKs); + + // Invoke session/action/switchUser - Should return an error (user can't switched to himself + Response loginSessionResponse = SessionServiceImpl.switchUser(client, masterUserId); + + // Verify exception returned + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1).getCode()); + } + + @Description("/session/action/switchUser - switch to inactive user") + @Test + private void SwitchInactiveUser() { + + } + } From b11382683cb324a4015f82c9d9543f164405e1e5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 23 Apr 2018 12:44:25 +0300 Subject: [PATCH 114/605] commented date/time information --- .../client/test/TestAPIOkRequestsExecutor.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 5f6d46291..7185bbb01 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -8,12 +8,7 @@ import com.kaltura.client.utils.request.RequestElement; import com.kaltura.client.utils.response.base.ResponseElement; import okhttp3.Response; - import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; - import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.hamcrest.MatcherAssert.assertThat; @@ -72,12 +67,12 @@ protected ResponseElement onGotResponse(Response response, RequestElement action String schema = s1 + s2 + s3; Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); - SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); + /*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); Date date = new Date(); - System.out.println("BEFORE VALIDATION: " + formatter.format(date)); + System.out.println("BEFORE VALIDATION: " + formatter.format(date));*/ assertThat(responseString, matchesJsonSchemaInClasspath(schema)); - date = new Date(); - System.out.println("AFTER VALIDATION: " + formatter.format(date)); + /*date = new Date(); + System.out.println("AFTER VALIDATION: " + formatter.format(date));*/ } return responseElement; } From c4f100977ac4aedba39d0b53ec9001cb22387e01 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 23 Apr 2018 12:44:54 +0300 Subject: [PATCH 115/605] Added IngestMPP util --- .../com/kaltura/client/test/Properties.java | 9 +- .../productPriceTests/ListTests.java | 8 +- .../client/test/utils/IngestMPPUtils.java | 175 ++++++++++++++++++ .../client/test/utils/IngestPPVUtils.java | 5 +- 4 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index f7b66afc4..9ff0c842c 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -46,23 +46,30 @@ public class Properties { // ingest public static final String INGEST_USER_NAME = "ingest_user_username"; public static final String INGEST_USER_PASSWORD = "ingest_user_password"; + public static final String INGEST_BUSINESS_MODULE_USER_NAME = "ingest_business_module_user_username"; + public static final String INGEST_BUSINESS_MODULE_USER_PASSWORD = "ingest_business_module_user_password"; public static final String INGEST_ACTION_INSERT = "insert"; public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + // channels + public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" + // price codes public static final String AMOUNT_4_99_EUR = "amount_4_99_eur"; // 4.99 public static final String CURRENCY_EUR = "EUR"; // usage modules - public static final String ONE_DAY_USAGE_MODULE = "one_day_usage_module"; // module has 1 Day life cycles, 0 maximum views and 5 minute waiver + public static final String DEFAULT_USAGE_MODULE_4_INGEST_PPV = "default_usage_module_4_ingest_ppv"; // module has 10 Minutes life cycles, 0 maximum views + public static final String DEFAULT_USAGE_MODULE_4_INGEST_MPP = "default_usage_module_4_ingest_mpp"; // module has 1 Day life cycles, 0 maximum views // product codes public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; // discount modules public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; + public static final String HUNDRED_PERCENTS_UKP_DISCOUNT_NAME = "hundred_percents_ukp_discount_name"; // PG adapter data public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 70f664fd2..d8edde58a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -34,6 +34,12 @@ public void beforeClass() { /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ + + /*Subscription subscription = IngestMPPUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.of("Camilo 5 min renews 4.99"), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.of(""), Optional.empty()); + Logger.getLogger(ListTests.class).debug("ID: " + subscription.getId());*/ } @Description("productPrice/action/list - subscription test by Operator without currency") @@ -63,7 +69,7 @@ public void list_without_required_fields() { @Test() public void ppvTest() { /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), - Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(ONE_DAY_USAGE_MODULE), false, false, + Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType diff --git a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java new file mode 100644 index 000000000..e8abe68db --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java @@ -0,0 +1,175 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.Logger; +import com.kaltura.client.types.*; +import io.restassured.RestAssured; +import io.restassured.response.Response; +import java.util.HashMap; +import java.util.Optional; +import static com.kaltura.client.test.Properties.*; +import static io.restassured.path.xml.XmlPath.from; + +public class IngestMPPUtils extends BaseUtils { + + private static String DEFAULT_ACTION_VALUE = "insert"; + private static boolean DEFAULT_IS_ACTIVE_VALUE = true; + private static String DEFAULT_TITLE_VALUE = "Ingest MPP title"; + private static String DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; + private static String DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; + private static String DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; + private static boolean DEFAULT_IS_RENEWABLE_VALUE = false; + private static int DEFAULT_GRACE_PERIOD_VALUE = 0; + + // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon + private static String DEFAULT_COUPON_GROUP_VALUE = + "\n" + + "01/05/2017 00:00:00\n" + + "31/12/2099 23:59:59\n" + + "100% unlimited\n" + + "\n" + + "\n" + + "01/05/2017 00:00:00\n" + + "31/05/2017 23:59:59\n" + + "Expired coupon group 1\n" + + ""; + private static String DEFAULT_PRODUCT_CODES_VALUE = + "\n" + + "ProductCode1\n" + + "Google\n" + + "\n" + + "\n" + + "ProductCode2\n" + + "Apple\n" + + ""; + + // ingest new MPP + public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, + Optional title, Optional description, Optional startDate, + Optional endDate, Optional internalDiscount, + Optional productCode, Optional isRenewable, + Optional gracePeriodMinute, Optional pricePlanCode1, + Optional pricePlanCode2, Optional channel1, + Optional channel2, Optional fileType1, + Optional fileType2, Optional couponGroup, Optional productCodes) { + String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); + String actionValue = action.orElse(DEFAULT_ACTION_VALUE); + boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); + String titleValue = title.orElse(DEFAULT_TITLE_VALUE); + String descriptionValue = description.orElse(DEFAULT_DESCRIPTION_VALUE); + String startDateValue = startDate.orElse(DEFAULT_START_DATE_VALUE); + String endDateValue = endDate.orElse(DEFAULT_END_DATE_VALUE); + String internalDiscountValue = internalDiscount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); + String productCodeValue = productCode.orElse(""); + boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); + int gracePeriodMinuteValue = gracePeriodMinute.orElse(DEFAULT_GRACE_PERIOD_VALUE); + + String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); + String pricePlanCode2Value = pricePlanCode2.orElse(""); + String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); + String channel2Value = channel2.orElse(""); + String fileType1Value = fileType1.orElse(""); + String fileType2Value = fileType2.orElse(""); + String couponGroupValue = couponGroup.orElse(DEFAULT_COUPON_GROUP_VALUE); + String productCodesValue = productCodes.orElse(DEFAULT_PRODUCT_CODES_VALUE); + + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headermap = new HashMap<>(); + headermap.put("Content-Type", "text/xml;charset=UTF-8"); + headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + + Response resp = RestAssured.given() + .log().all() + .headers(headermap) + .body(reqBody) + .post(url); + + //Logger.getLogger(IngestMPPUtils.class).debug(reqBody); + Logger.getLogger(IngestMPPUtils.class).debug(resp.asString()); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); + + url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + Logger.getLogger(IngestMPPUtils.class).debug(resp.asString()); + //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); + + Subscription subscription = new Subscription(); + subscription.setId(id); + subscription.setName(titleValue); + subscription.setDescription(descriptionValue); + // TODO: complete COMMENTED IF NEEDED + //subscription.setStartDate(); + //subscription.setEndDate(); + //subscription.setDiscountModule(); + //subscription.setProductCodes(); + subscription.isRenewable(String.valueOf(isRenewableValue)); + subscription.setGracePeriodMinutes(gracePeriodMinuteValue); + //subscription.setPricePlanIds(); + //subscription.setChannels(); + //subscription.setFileTypes(); + //subscription.setCouponsGroups(); + return subscription; + } + + private static String buildIngestMppXML(String action, String mppCode, boolean isActive, String title, String description, + String startDate, String endDate, String internalDiscount, String productCode, + boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, + String pricePlanCode2, String channel1, String channel2, String fileType1, + String fileType2, String couponGroup, String productCodes) { + return "\n" + + "\n" + + "\n" + + "\n" + + "" + title + "\n" + + "\n" + + "\n" + + "" + description + "" + + "\n" + + "" + startDate + "\n" + + "" + endDate + "\n" + + "" + internalDiscount + "\n" + + "\n" + + "" + productCode + "\n" + + "" + isRenewable + "\n" + + "\n" + + "" + gracePeriodMinute + "\n" + + "\n" + + "" + pricePlanCode1 + "\n" + + "" + pricePlanCode2 + "\n" + + "\n" + + "\n" + + "" + channel1 + "\n" + + "" + channel2 + "\n" + + "\n" + + "\n" + + "" + fileType1 + "\n" + + "" + fileType2 + "\n" + + "\n" + + "\n" + + "" + couponGroup + "\n" + + "" + productCodes + "\n" + + "\n" + + "\n" + + "\n"; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index f90223f4a..5c33e8d42 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -25,7 +25,7 @@ public static Ppv ingestPPVWithDefaultValues(Optional action, Optional getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(AMOUNT_4_99_EUR))); String currencyValue = currency.orElseGet(() -> getProperty(CURRENCY_EUR)); - String usageModuleValue = usageModule.orElseGet(() -> getProperty(ONE_DAY_USAGE_MODULE)); + String usageModuleValue = usageModule.orElseGet(() -> getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; String productCodeValue = productCode.orElseGet(() -> getProperty(DEFAULT_PRODUCT_CODE)); @@ -52,7 +52,8 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + " \n" + From b1a9b0ed38583740445dd011a6781b853fb318f4 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 23 Apr 2018 15:57:50 +0300 Subject: [PATCH 116/605] Added util to DButils to allow returning Json array from DB --- .../kaltura/client/test/utils/DBUtils.java | 69 +++++++++++++++++-- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 24d31298f..d1006dddb 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -1,13 +1,13 @@ package com.kaltura.client.test.utils; +import com.google.gson.JsonArray; import com.kaltura.client.Logger; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; +import org.json.JSONArray; +import org.json.JSONObject; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; +import java.sql.*; import static com.kaltura.client.test.Properties.*; @@ -22,6 +22,65 @@ public class DBUtils extends BaseUtils { private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + + // Return json array from DB + public static JSONArray convertToJSON(String query) throws Exception { + openConnection(); + JSONArray jsonArray = new JSONArray(); + rs = stam.executeQuery(query); + ResultSetMetaData rsmd = rs.getMetaData(); + + if (rs != null && rs.isBeforeFirst()) { + while (rs.next()) { + int numColumns = rsmd.getColumnCount(); + JSONObject obj = new JSONObject(); + + for (int i = 1; i < numColumns + 1; i++) { + String column_name = rsmd.getColumnName(i).toLowerCase(); + + if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { + obj.put(column_name, rs.getArray(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { + obj.put(column_name, rs.getBoolean(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { + obj.put(column_name, rs.getBlob(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { + obj.put(column_name, rs.getDouble(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { + obj.put(column_name, rs.getFloat(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { + obj.put(column_name, rs.getNString(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { + obj.put(column_name, rs.getString(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { + obj.put(column_name, rs.getDate(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { + obj.put(column_name, rs.getTimestamp(column_name)); + } else { + obj.put(column_name, rs.getObject(column_name)); + } + } + jsonArray.put(obj); + } + closeConnection(); + return jsonArray; + + } else { + Logger.getLogger(DBUtils.class).error("No result found"); + closeConnection(); + return null; + } + + } + public static String getActivationToken(String username) { openConnection(); try { @@ -57,7 +116,7 @@ public static int getEpgChannelId(String channelName) { } catch (SQLException e) { e.printStackTrace(); } - int epgChannelId =-1; + int epgChannelId = -1; try { epgChannelId = rs.getInt("ID"); } catch (SQLException e) { From 52953e54f68140431b8b06d02cacb0bf30dfb321 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 23 Apr 2018 16:09:14 +0300 Subject: [PATCH 117/605] Added IngestPP util --- .../productPriceTests/ListTests.java | 5 + .../client/test/utils/IngestPPUtils.java | 114 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index d8edde58a..1798671fb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -40,6 +40,11 @@ public void beforeClass() { Optional.of(true), Optional.empty(), Optional.of("Camilo 5 min renews 4.99"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(""), Optional.empty()); Logger.getLogger(ListTests.class).debug("ID: " + subscription.getId());*/ + + /* PricePlan pricePlan = IngestPPUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + Logger.getLogger(ListTests.class).debug("ID: " + pricePlan.getId());*/ } @Description("productPrice/action/list - subscription test by Operator without currency") diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java new file mode 100644 index 000000000..6ffe8141c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java @@ -0,0 +1,114 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.Logger; +import com.kaltura.client.types.PricePlan; +import io.restassured.RestAssured; +import io.restassured.response.Response; +import java.util.HashMap; +import java.util.Optional; +import static com.kaltura.client.test.Properties.*; +import static io.restassured.path.xml.XmlPath.from; + +public class IngestPPUtils extends BaseUtils { + + private static String DEFAULT_ACTION_VALUE = "insert"; + private static boolean DEFAULT_IS_ACTIVE_VALUE = true; + private static String DEFAULT_FULL_LIFE_CYCLE_VALUE = "5 Minutes"; + private static String DEFAULT_VIEW_LIFE_CYCLE_VALUE = "5 Minutes"; + private static int DEFAULT_MAX_VIEWS_VALUE = 0; + private static boolean DEFAULT_IS_RENEWABLE_VALUE = false; + private static int DEFAULT_RECURRING_PERIODS_VALUE = 1; + + // ingest new PP + public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, + Optional fullLifeCycle, Optional viewLifeCycle, Optional maxViews, + Optional price, Optional currency, + Optional discount, Optional isRenewable, + Optional recurringPeriods) { + String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", 9999999999L)); + String actionValue = action.orElse(DEFAULT_ACTION_VALUE); + boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); + String fullLifeCycleValue = fullLifeCycle.orElse(DEFAULT_FULL_LIFE_CYCLE_VALUE); + String viewLifeCycleValue = viewLifeCycle.orElse(DEFAULT_VIEW_LIFE_CYCLE_VALUE); + int maxViewsValue = maxViews.orElse(DEFAULT_MAX_VIEWS_VALUE); + String priceValue = price.orElse(getProperty(AMOUNT_4_99_EUR)); + String currencyValue = currency.orElse(CURRENCY_EUR); + String discountValue = discount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); + boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); + int recurringPeriodsValue = recurringPeriods.orElse(DEFAULT_RECURRING_PERIODS_VALUE); + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headermap = new HashMap<>(); + headermap.put("Content-Type", "text/xml;charset=UTF-8"); + headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + + Response resp = RestAssured.given() + .log().all() + .headers(headermap) + .body(reqBody) + .post(url); + + Logger.getLogger(IngestPPUtils.class).debug(reqBody); + Logger.getLogger(IngestPPUtils.class).debug(resp.asString()); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); + + url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + Logger.getLogger(IngestPPUtils.class).debug(resp.asString()); + //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); + //Logger.getLogger(IngestPPUtils.class).debug("ID: " + id); + + PricePlan pricePlan = new PricePlan(); + pricePlan.setId(Long.valueOf(id)); + pricePlan.setMaxViewsNumber(maxViewsValue); + pricePlan.setIsRenewable(isRenewableValue); + pricePlan.setRenewalsNumber(recurringPeriodsValue); + // TODO: complete COMMENTED IF NEEDED + //pricePlan.setFullLifeCycle(); + //pricePlan.setViewLifeCycle(); + //pricePlan.setPriceDetailsId(); + //pricePlan.setDiscountId(); + return pricePlan; + } + + private static String buildIngestPpXML(String action, String ppCode, boolean isActive, String fullLifeCycle, + String viewLifeCycle, int maxViews, String price, String currency, + String discount, boolean isRenewable, int recurringPeriods) { + String id = "reportIngestPricePlan" + action.substring(0, 1).toUpperCase() + action.substring(1); + return "\n" + + "\n" + + "\n" + + "" + fullLifeCycle + "\n" + + "" + viewLifeCycle + "\n" + + "" + maxViews + "\n" + + "\n" + + "" + price + "\n" + + "" + currency + "\n" + + "\n" + + "" + discount + "\n" + + "" + isRenewable + "\n" + + "" + recurringPeriods + "\n" + + "\n" + + "\n" + + "\n"; + } +} From eb2cc8c1852ceee98ed6760c3f26c89f6b75afab Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 23 Apr 2018 17:19:41 +0300 Subject: [PATCH 118/605] Added additional methods to SessionSwitchUserTests class --- .../sessionTests/SessionSwitchUserTests.java | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index 0f7fce5b2..1715c1a41 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -2,15 +2,11 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.UserState; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; -import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.test.servicesImpl.*; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.DBUtils; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.LoginSession; -import com.kaltura.client.types.OTTUser; -import com.kaltura.client.types.Session; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; @@ -21,11 +17,13 @@ public class SessionSwitchUserTests extends BaseTest { + private String UserId = "1543798"; + private String userKs; public static Client client; @BeforeClass private void switchUser_tests_before_class() { - + userKs = OttUserUtils.getKs(Integer.valueOf(UserId), null); } @Description("/session/action/switchUser") @@ -85,7 +83,33 @@ private void SwitchUserToHimself() { @Description("/session/action/switchUser - switch to inactive user") @Test private void SwitchInactiveUser() { - + + String inactiveUserId = "1543797"; + String UserKs = OttUserUtils.getKs(Integer.valueOf(UserId), null); + client = getClient(UserKs); + + Response loginSessionResponse = SessionServiceImpl.switchUser(client, inactiveUserId); + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2016).getCode()); } + @Description("/session/action/switchUser - switch to user from another HH") + @Test + private void switchToUserFromAnotherHousehold() { + String userIdFromHousehold1 = "1543798"; + String Use1rKs = OttUserUtils.getKs(Integer.valueOf(userIdFromHousehold1), null); + client = getClient(Use1rKs); + String userIdFromHousehold2 = "638731"; + + Response loginSessionResponse = SessionServiceImpl.switchUser(client, userIdFromHousehold2); + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + } + + + @Description("/session/action/switchUser - No user id to switch provided") + @Test + private void switchToUserWithoutUserId() { + client = getClient(userKs); + Response loginSessionResponse = SessionServiceImpl.switchUser(client, null); + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500053).getCode()); + } } From 73a832fb0da3ca119d528a965473a35fd014f745 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 24 Apr 2018 14:01:34 +0300 Subject: [PATCH 119/605] Added AssetCommentTests class + change version to 4.8.1 + fixed failed tests in BookmarksAddTests class --- .../com/kaltura/client/test/Properties.java | 2 +- .../appTokenTests/AppTokenAddTests.java | 6 +- .../AppTokenStartSessionTests.java | 6 +- .../AssetCommentAddTests.java | 62 +++++++++++++++++++ .../bookmarkTests/BookmarkAddTests.java | 62 +++++++------------ .../client/test/utils/AssetCommentUtils.java | 24 +++++++ .../kaltura/client/test/utils/DBUtils.java | 1 + src/test/resources/schemas/AssetComment.json | 61 ++++++++++++++++++ 8 files changed, 179 insertions(+), 45 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java create mode 100644 src/test/resources/schemas/AssetComment.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 9ff0c842c..5f422c490 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -10,7 +10,7 @@ public class Properties { public static final String API_BASE_URL = "http://api-preprod.ott.kaltura.com"; // "http://34.249.122.223:8080" public static final String SOAP_BASE_URL = "http://api-preprod.ott.kaltura.com:8030"; // "http://34.249.122.223:8030"; public static final String INGEST_REPORT_URL = "http://api-preprod.ott.kaltura.com:5823"; // "http://34.249.122.223:5823"; - public static final String API_URL_VERSION = "v4_8"; + public static final String API_URL_VERSION = "v4_8_1"; // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 021701da8..81c2d6c16 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -99,15 +99,15 @@ private void addAppTokenWithExpiryDate() { @Description("appToken/action/add - with no expiry date (return default expiry date -" + "According to app_token_max_expiry_seconds key value in group_203 CB document") @Test + //todo - Add specific mark indicating the version of the feature private void addAppTokenWithNoExpiryDate() { BaseUtils.getSharedHousehold(); client = getClient(sharedMasterUserKs); int expiryDate = 0; - int cbExpiryDateValue = 2592000; + //int cbExpiryDateValue = 2592000; appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, expiryDate); Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); - assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(cbExpiryDateValue)); - + assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(BaseUtils.getTimeInEpoch(0))); } @Description("appToken/action/add - with no specific user id") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index 8370a852f..f9eaeface 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -48,6 +48,7 @@ private void startSessionSha1() { // Build appToken object appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); // Invoke AppToken/action/add + client.setKs(operatorKs); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); client.setKs(anonymousKs); @@ -82,6 +83,7 @@ private void startSessionSha256() { // Build appToken object appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); // Invoke AppToken/action/add + client.setKs(operatorKs); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); client.setKs(anonymousKs); // Generate new token hash @@ -93,8 +95,8 @@ private void startSessionSha256() { assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); assertThat(sessionInfoResponse.results.getUserId()).isEqualTo(sessionUserId); - assertThat(sessionInfoResponse.results.getExpiry()).isEqualTo(expiryDate); - assertThat(sessionInfoResponse.results.getPrivileges()).isEqualTo(sessionPrivileges); + assertThat(sessionInfoResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); + assertThat(sessionInfoResponse.results.getPrivileges()).contains(sessionPrivileges); assertThat(sessionInfoResponse.results.getUdid()).isEqualTo(udid1); assertThat(sessionInfoResponse.results.getCreateDate()).isNotZero(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java new file mode 100644 index 000000000..2b48c4d55 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -0,0 +1,62 @@ +package com.kaltura.client.test.tests.servicesTests.assetCommentTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetCommentUtils; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.IngestEPGUtils; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.AssetComment; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Optional; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +public class AssetCommentAddTests extends BaseTest { + private Client client; + String writer = "Shmulik"; + Long createDate = 0L; + String header = "header"; + String subHeader = "subHeader"; + String text = "A lot of text"; + + @BeforeClass + private void add_tests_before_class() { + BaseUtils.getSharedHousehold(); + client = getClient(sharedMasterUserKs); + } + + @Description + @Test + private void addCommentForVod() { + + Long assetId = 608772L; + AssetComment assetComment = AssetCommentUtils.addAssetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); + Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + assertThat(assetCommentResponse.results.getId()).isGreaterThan(0); + assertThat(assetCommentResponse.results.getAssetId()).isEqualTo(Math.toIntExact(assetId)); + assertThat(assetCommentResponse.results.getAssetType()).isEqualTo(AssetType.MEDIA); + assertThat(assetCommentResponse.results.getWriter()).isEqualTo(writer); + assertThat(assetCommentResponse.results.getText()).isEqualTo(text); + assertThat(assetCommentResponse.results.getSubHeader()).isEqualTo(subHeader); + assertThat(assetCommentResponse.results.getHeader()).isEqualTo(header); + assertThat(assetCommentResponse.results.getCreateDate()).isGreaterThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); + } + + @Description + @Test + private void addCommentForEPGProgram() { + Response> epgProgram = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + //Long epgProgramId = epgProgram.results.getObjects().get(0).getId(); +// AssetComment assetComment = AssetCommentUtils.addAssetComment(Math.toIntExact(epgProgramId), AssetType.EPG, writer, text, createDate, subHeader, header); +// Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index a546f31fb..5754a6899 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -23,27 +24,20 @@ public class BookmarkAddTests extends BaseTest { private Client client; private long assetId; - private AssetType type; private int fileId; private BookmarkActionType actionType; private int position = 0; private List assetList = new ArrayList<>(); // instantiate Bookmark object private Bookmark bookmark = new Bookmark(); - // instantiate BookmarkPlayerData object - private BookmarkPlayerData playerData = new BookmarkPlayerData(); // instantiate BookmarkFilter object private BookmarkFilter bookmarkFilter = new BookmarkFilter(); @BeforeClass private void add_tests_before_class() { + BaseUtils.getSharedHousehold(); client = getClient(sharedMasterUserKs); - - // Get VOD asset id from ingest - - assetId = mediaAsset.getId(); - - type = AssetType.get(AssetType.MEDIA.getValue()); + assetId = 608775; AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); Response assetResponse = AssetServiceImpl.get(client, String.valueOf(assetId), assetReferenceType); fileId = assetResponse.results.getMediaFiles().get(0).getId(); @@ -51,7 +45,6 @@ private void add_tests_before_class() { assetList.add(String.valueOf(assetId)); // Initialize bookmark object parameters - bookmark = BookmarkUtils.addBookmark(0, assetList.get(0), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); // Initialize bookmarkFilter object parameters bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC, AssetType.MEDIA, assetList); @@ -60,6 +53,10 @@ private void add_tests_before_class() { @Description("bookmark/action/add - first play") @Test private void firstPlayback() { + actionType = BookmarkActionType.FIRST_PLAY; + position = 0; + bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); + // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); // Verify response return true @@ -72,9 +69,6 @@ private void firstPlayback() { Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); - // Assertions - // *********************************************** - // Match content of asset id assertThat(bookmark1.getId()).isEqualTo(String.valueOf(assetId)); @@ -97,12 +91,11 @@ private void firstPlayback() { @Description("bookmark/action/add - pause") @Test - private void stopPlayback() { + private void pausePlayback() { // Set action type to "PAUSE" - actionType = BookmarkActionType.get(BookmarkActionType.PAUSE.getValue()); - playerData.setAction(actionType); + actionType = BookmarkActionType.PAUSE; position = 30; - bookmark.setPosition(position); + bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); @@ -122,10 +115,9 @@ private void stopPlayback() { @Description("bookmark/action/add - 95% watching == finish watching") @Test private void watchingNinetyFive() { - actionType = BookmarkActionType.get(BookmarkActionType.PLAY.getValue()); - playerData.setAction(actionType); + actionType = BookmarkActionType.PLAY; position = 999; - bookmark.setPosition(position); + bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); @@ -138,9 +130,6 @@ private void watchingNinetyFive() { Response> bookmarkListResponse3 = BookmarkServiceImpl.list(client, bookmarkFilter); Bookmark bookmark3 = bookmarkListResponse3.results.getObjects().get(0); - // Assertions - // *********************************************** - // Verify finishedWatching = true assertThat(bookmark3.getFinishedWatching()).isTrue(); @@ -149,27 +138,25 @@ private void watchingNinetyFive() { @Description("bookmark/action/add - back to start - position:0") @Test private void backToStart() { - actionType = BookmarkActionType.get(BookmarkActionType.STOP.getValue()); - playerData.setAction(actionType); + actionType = BookmarkActionType.STOP; position = 0; - bookmark.setPosition(position); - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + assertThat(booleanResponse.results.booleanValue()).isTrue(); Response> bookmarkListResponse4 = BookmarkServiceImpl.list(client, bookmarkFilter); Bookmark bookmark4 = bookmarkListResponse4.results.getObjects().get(0); // Verify finishedWatching = false assertThat(bookmark4.getFinishedWatching()).isFalse(); } - @Description("bookmark/action/add - finish watching") @Test private void finishWatching() { // Set action type to "FINISH" - actionType = BookmarkActionType.get(BookmarkActionType.FINISH.getValue()); - playerData.setAction(actionType); + actionType = BookmarkActionType.FINISH; position = 60; - bookmark.setPosition(position); + bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); @@ -179,14 +166,11 @@ private void finishWatching() { assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse5 = BookmarkServiceImpl.list(client, bookmarkFilter); - Bookmark bookmark5 = bookmarkListResponse5.results.getObjects().get(0); - - // Assertions - // *********************************************** + Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); + Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = true - assertThat(bookmark5.getFinishedWatching()).isTrue(); + assertThat(bookmark.getFinishedWatching()).isTrue(); } @@ -195,8 +179,8 @@ private void finishWatching() { @Description("bookmark/action/add - empty asset id") @Test private void emptyAssetId() { - Bookmark bookmark1 = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark1); + bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); assertThat(booleanResponse.results).isNull(); // Verify exception returned - code: 500003 ("Invalid Asset id") assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500003).getCode()); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java new file mode 100644 index 000000000..012488bd8 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java @@ -0,0 +1,24 @@ +package com.kaltura.client.test.utils; + + +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.types.AssetComment; + +import javax.annotation.Nullable; + +public class AssetCommentUtils extends BaseUtils { + + public static AssetComment addAssetComment(int assetId, AssetType assetType, @Nullable String writer, @Nullable String text, + @Nullable Long createDate, @Nullable String subHeader, @Nullable String header) { + AssetComment assetComment = new AssetComment(); + assetComment.setAssetId(assetId); + assetComment.setAssetType(assetType); + assetComment.setWriter(writer); + assetComment.setText(text); + assetComment.setCreateDate(createDate); + assetComment.setSubHeader(subHeader); + assetComment.setHeader(header); + + return assetComment; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index d1006dddb..3b4aa4615 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -22,6 +22,7 @@ public class DBUtils extends BaseUtils { private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + //TODO - change existing methods to work with the new convertToJSON method // Return json array from DB public static JSONArray convertToJSON(String query) throws Exception { diff --git a/src/test/resources/schemas/AssetComment.json b/src/test/resources/schemas/AssetComment.json new file mode 100644 index 000000000..7d814a284 --- /dev/null +++ b/src/test/resources/schemas/AssetComment.json @@ -0,0 +1,61 @@ +{ + "$id": "AssetComment", + "definitions": { + "AssetComment": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "minimum": 0 + }, + "assetId": { + "type": "integer", + "minimum": 0 + }, + "assetType": { + "type": "string", + "minLength": 0 + }, + "subHeader": { + "type": "string", + "minLength": 0 + }, + "header": { + "type": "string", + "minLength": 0 + }, + "text": { + "type": "string", + "minLength": 0 + }, + "createDate": { + "type": "integer", + "minimum": 0 + }, + "writer": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "assetId", + "assetType", + "createDate" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/AssetComment" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From 58f7abd3c46c730d4e4f54659526f6e7f21bc932 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 24 Apr 2018 15:32:32 +0300 Subject: [PATCH 120/605] Updated class AssetCommentAddTests class + added assetCommentFilter method to class assetCommentUtils + added enum to listResponse.json schema --- .../AssetCommentAddTests.java | 48 +++++++++++++++---- .../client/test/utils/AssetCommentUtils.java | 15 +++++- src/test/resources/schemas/ListResponse.json | 3 +- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 2b48c4d55..183b1fb5a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -1,6 +1,8 @@ package com.kaltura.client.test.tests.servicesTests.assetCommentTests; import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetCommentOrderBy; +import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -9,6 +11,7 @@ import com.kaltura.client.test.utils.IngestEPGUtils; import com.kaltura.client.types.Asset; import com.kaltura.client.types.AssetComment; +import com.kaltura.client.types.AssetCommentFilter; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -33,13 +36,19 @@ private void add_tests_before_class() { client = getClient(sharedMasterUserKs); } - @Description + @Description ("AssetComment/action/add - vod asset") @Test private void addCommentForVod() { - Long assetId = 608772L; - AssetComment assetComment = AssetCommentUtils.addAssetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); + Long assetId = BaseUtils.getSharedMediaAsset().getId(); + + // Initialize assetComment object + AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); + + // AssetComment/action/add Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + + //Assertions assertThat(assetCommentResponse.results.getId()).isGreaterThan(0); assertThat(assetCommentResponse.results.getAssetId()).isEqualTo(Math.toIntExact(assetId)); assertThat(assetCommentResponse.results.getAssetType()).isEqualTo(AssetType.MEDIA); @@ -47,16 +56,39 @@ private void addCommentForVod() { assertThat(assetCommentResponse.results.getText()).isEqualTo(text); assertThat(assetCommentResponse.results.getSubHeader()).isEqualTo(subHeader); assertThat(assetCommentResponse.results.getHeader()).isEqualTo(header); - assertThat(assetCommentResponse.results.getCreateDate()).isGreaterThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); + assertThat(assetCommentResponse.results.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); + + + //Initialize assetCommentFilter object + AssetCommentFilter assetCommentFilter = AssetCommentUtils.assetCommentFilter(Math.toIntExact(assetId),AssetType.MEDIA, + AssetCommentOrderBy.CREATE_DATE_DESC); + + //AssetComment/action/list + Response> assetCommentListResponse = AssetCommentServiceImpl.list(client,assetCommentFilter,null); + AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); + assertThat(assetCommentObjectResponse.getId()).isEqualTo(assetCommentResponse.results.getId()); + assertThat(assetCommentObjectResponse.getAssetId()).isEqualTo(assetCommentListResponse.results.getObjects().get(0).getAssetId()); + assertThat(assetCommentObjectResponse.getAssetType()).isEqualTo(AssetType.MEDIA); + assertThat(assetCommentObjectResponse.getSubHeader()).isEqualTo(subHeader); + assertThat(assetCommentObjectResponse.getHeader()).isEqualTo(header); + assertThat(assetCommentObjectResponse.getText()).isNotEqualTo(text); + assertThat(assetCommentObjectResponse.getWriter()).isEqualTo(writer); + assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); } - @Description + @Description("AssetComment/action/add - EPG program") @Test private void addCommentForEPGProgram() { Response> epgProgram = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - //Long epgProgramId = epgProgram.results.getObjects().get(0).getId(); -// AssetComment assetComment = AssetCommentUtils.addAssetComment(Math.toIntExact(epgProgramId), AssetType.EPG, writer, text, createDate, subHeader, header); -// Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + Long epgProgramId = epgProgram.results.getObjects().get(0).getId(); + AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(epgProgramId), AssetType.EPG, writer, text, createDate, subHeader, header); + Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + assertThat(assetCommentResponse.results.getId()).isGreaterThan(0); + assertThat(assetCommentResponse.results.getAssetId()).isEqualTo(Math.toIntExact(epgProgramId)); + assertThat(assetCommentResponse.results.getAssetType()).isEqualTo(AssetType.EPG); + } + + } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java index 012488bd8..20a00b308 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetCommentUtils.java @@ -1,15 +1,17 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.enums.AssetCommentOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.types.AssetComment; +import com.kaltura.client.types.AssetCommentFilter; import javax.annotation.Nullable; public class AssetCommentUtils extends BaseUtils { - public static AssetComment addAssetComment(int assetId, AssetType assetType, @Nullable String writer, @Nullable String text, - @Nullable Long createDate, @Nullable String subHeader, @Nullable String header) { + public static AssetComment assetComment(int assetId, AssetType assetType, @Nullable String writer, @Nullable String text, + @Nullable Long createDate, @Nullable String subHeader, @Nullable String header) { AssetComment assetComment = new AssetComment(); assetComment.setAssetId(assetId); assetComment.setAssetType(assetType); @@ -21,4 +23,13 @@ public static AssetComment addAssetComment(int assetId, AssetType assetType, @Nu return assetComment; } + + public static AssetCommentFilter assetCommentFilter(int assetId, AssetType assetType, AssetCommentOrderBy orderBy) { + AssetCommentFilter assetCommentFilter = new AssetCommentFilter(); + assetCommentFilter.setAssetIdEqual(assetId); + assetCommentFilter.setAssetTypeEqual(assetType); + assetCommentFilter.setOrderBy(orderBy.toString()); + + return assetCommentFilter; + } } diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 16dafd535..2d0411b97 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -56,7 +56,8 @@ "KalturaHouseholdUserListResponse", "KalturaOTTUserListResponse", "KalturaProductPriceListResponse", - "KalturaBookmarkListResponse" + "KalturaBookmarkListResponse", + "KalturaAssetCommentListResponse" ] } }, From f5b5d21f35995805f578803ab4e600459fdc1306 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 24 Apr 2018 15:33:22 +0300 Subject: [PATCH 121/605] refactor baseTest and add parallel execution in testng.xml --- .../com/kaltura/client/test/Properties.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 115 +++++++++++++----- .../appTokenTests/AppTokenAddTests.java | 16 +-- .../appTokenTests/AppTokenDeleteTests.java | 2 +- .../appTokenTests/AppTokenGetTests.java | 2 +- .../AppTokenStartSessionTests.java | 6 +- .../bookmarkTests/BookmarkAddTests.java | 7 +- .../bookmarkTests/BookmarkListTests.java | 2 +- .../entitlementTests/GrantTests.java | 16 +-- .../ottUserTests/AddRoleTests.java | 2 +- .../ottUserTests/DeleteTests.java | 2 +- .../ottUserTests/GetEncryptedUserIdTests.java | 2 +- .../servicesTests/ottUserTests/ListTests.java | 6 +- .../ottUserTests/LoginWithPinTests.java | 4 +- .../ottUserTests/ResetPasswordTests.java | 2 +- .../ottUserTests/UpdateDynamicDataTests.java | 2 +- .../ottUserTests/UpdateLoginDataTests.java | 2 +- .../ottUserTests/UpdateTests.java | 2 +- .../productPriceTests/ListTests.java | 10 +- .../sessionTests/SessionGetTests.java | 16 +-- .../sessionTests/SessionSwitchUserTests.java | 2 +- .../kaltura/client/test/utils/AssetUtils.java | 4 +- .../kaltura/client/test/utils/BaseUtils.java | 46 +------ .../client/test/utils/HouseholdUtils.java | 10 +- .../client/test/utils/IngestEPGUtils.java | 14 ++- .../client/test/utils/IngestVODUtils.java | 8 +- .../client/test/utils/OttUserUtils.java | 4 +- .../client/test/utils/SessionUtils.java | 4 +- src/test/resources/testng.xml | 9 +- 29 files changed, 170 insertions(+), 149 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 9ff0c842c..5f422c490 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -10,7 +10,7 @@ public class Properties { public static final String API_BASE_URL = "http://api-preprod.ott.kaltura.com"; // "http://34.249.122.223:8080" public static final String SOAP_BASE_URL = "http://api-preprod.ott.kaltura.com:8030"; // "http://34.249.122.223:8030"; public static final String INGEST_REPORT_URL = "http://api-preprod.ott.kaltura.com:5823"; // "http://34.249.122.223:5823"; - public static final String API_URL_VERSION = "v4_8"; + public static final String API_URL_VERSION = "v4_8_1"; // DB properties // TODO: 3/19/2018 encrypt db username and password in test.properties file diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 0eab92240..3160c7610 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,53 +2,54 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; -import com.kaltura.client.Logger; +import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; +import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; +import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.OttUserUtils.getUserById; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { + private static Client client; + private static Response loginResponse; private static Configuration config; // shared ks's - public static String administratorKs, operatorKs, managerKs, anonymousKs; + private static String administratorKs, operatorKs, managerKs, anonymousKs; // shared household - public static Household sharedHousehold; - public static HouseholdUser sharedMasterUser, sharedUser; - public static String sharedMasterUserKs, sharedUserKs; + private static Household sharedHousehold; + private static HouseholdUser sharedMasterUser, sharedUser; + private static String sharedMasterUserKs, sharedUserKs; // shared VOD - public static MediaAsset mediaAsset; + private static MediaAsset mediaAsset; + @BeforeSuite public void base_test_before_suite() { - Logger.getLogger(BaseTest.class).debug("Start Setup!"); - // set configuration config = new Configuration(); config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); config.setAcceptGzipEncoding(false); + client = getClient(null); // Set default awaitility timeout - setDefaultTimeout(20, TimeUnit.SECONDS); - - // TODO: 4/17/2018 move init functions to the relevant used places instead calling it in beforeSuite - initGlobalUsersKs(); -// getSharedHousehold(); -// getSharedMediaAsset(); - - Logger.getLogger(BaseTest.class).debug("Finish Setup!"); + setDefaultTimeout(30, TimeUnit.SECONDS); } + public static Client getClient(String ks) { Client client = new Client(config); client.setApiVersion(API_REQUEST_VERSION); @@ -56,21 +57,79 @@ public static Client getClient(String ks) { return client; } - private void initGlobalUsersKs() { - Client client = getClient(null); - Response loginResponse; - Response loginSession; + // getters for shared params + public static String getAdministratorKs() { + if (administratorKs == null) { + loginResponse = login(client, PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); + administratorKs = loginResponse.results.getLoginSession().getKs(); + } + return administratorKs; + } + + public static String getOperatorKs() { + if (operatorKs == null) { + loginResponse = login(client, PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); + operatorKs = loginResponse.results.getLoginSession().getKs(); + } + return operatorKs; + } - loginResponse = login(client, PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); - administratorKs = loginResponse.results.getLoginSession().getKs(); + public static String getManagerKs() { + if (managerKs == null) { + loginResponse = login(client, PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); + managerKs = loginResponse.results.getLoginSession().getKs(); + } + return operatorKs; + } - loginResponse = login(client, PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); - operatorKs = loginResponse.results.getLoginSession().getKs(); + public static String getAnonymousKs() { + if (anonymousKs == null) { + Response loginSession = anonymousLogin(client, PARTNER_ID, null); + anonymousKs = loginSession.results.getKs(); + } + return operatorKs; + } - loginResponse = login(client, PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); - managerKs = loginResponse.results.getLoginSession().getKs(); + public static MediaAsset getSharedMediaAsset() { + if (mediaAsset == null) { + mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + System.out.println("INGESTED VOD: " + mediaAsset.getId()); + } + return mediaAsset; + } + + public static Household getSharedHousehold() { + Client client = getClient(null); + + if (sharedHousehold == null) { + sharedHousehold = createHouseHold(2, 2, true); + List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); + for (HouseholdUser user : sharedHouseholdUsers) { + if (user.getIsMaster() != null && user.getIsMaster()) { + sharedMasterUser = user; + } + if (user.getIsMaster() == null && user.getIsDefault() == null) { + sharedUser = user; + } + } + + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); + + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedUserKs = loginResponse.results.getLoginSession().getKs(); + } + return sharedHousehold; + } + + public static String getsharedMasterUserKs() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedMasterUserKs; + } - loginSession = anonymousLogin(client, PARTNER_ID, null); - anonymousKs = loginSession.results.getKs(); + public static String getsharedUserKs() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedUserKs; } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 021701da8..a506334f6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -34,7 +34,7 @@ private void add_tests_before_class() { @Description("appToken/action/add") @Test private void addAppToken() { - client = getClient(operatorKs); + client = getClient(getOperatorKs()); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); // Assertions @@ -55,7 +55,7 @@ private void addAppToken() { @Description("appToken/action/add - without hash type") @Test private void addAppTokenWithDefaultHashType() { - client = getClient(operatorKs); + client = getClient(getOperatorKs()); appToken = AppTokenUtils.addAppToken(sessionUserId, null, null, null); // Invoke AppToken/action/add - with no hash type (will return the default hash type) Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); @@ -66,7 +66,7 @@ private void addAppTokenWithDefaultHashType() { @Description("appToken/action/add - with privileges") @Test private void addAppTokenWithPrivileges() { - client = getClient(operatorKs); + client = getClient(getOperatorKs()); sessionPrivileges = "key1:value1,key2:value2"; appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, null); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); @@ -75,9 +75,9 @@ private void addAppTokenWithPrivileges() { } @Description("appToken/action/add - with expiry date") - @Test + @Test(groups = "slow") private void addAppTokenWithExpiryDate() { - client = getClient(operatorKs); + client = getClient(getOperatorKs()); Long expiryDate = BaseUtils.getTimeInEpoch(1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); @@ -100,8 +100,8 @@ private void addAppTokenWithExpiryDate() { "According to app_token_max_expiry_seconds key value in group_203 CB document") @Test private void addAppTokenWithNoExpiryDate() { - BaseUtils.getSharedHousehold(); - client = getClient(sharedMasterUserKs); + getSharedHousehold(); + client = getClient(getsharedMasterUserKs()); int expiryDate = 0; int cbExpiryDateValue = 2592000; appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, expiryDate); @@ -113,7 +113,7 @@ private void addAppTokenWithNoExpiryDate() { @Description("appToken/action/add - with no specific user id") @Test private void addAppTokenWithoutSpecificUserId() { - client = getClient(operatorKs); + client = getClient(getOperatorKs()); appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, null); Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); assertThat(addAppTokenResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java index 793ca5e75..e4eb54be1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java @@ -24,7 +24,7 @@ public class AppTokenDeleteTests extends BaseTest { @BeforeClass private void add_tests_before_class() { sessionUserId = "1577578"; - client = getClient(operatorKs); + client = getClient(getOperatorKs()); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index 5b69a6c18..271b82f30 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -29,7 +29,7 @@ public class AppTokenGetTests extends BaseTest { @BeforeClass private void get_tests_before_class() { - client = getClient(operatorKs); + client = getClient(getOperatorKs()); hashType = AppTokenHashType.SHA1; expiryDate = BaseUtils.getTimeInEpoch(offSetInMinutes); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index 8370a852f..12cfcd150 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -37,7 +37,7 @@ private void add_tests_before_class() { // Invoke ottUser/action/anonymousLogin to receive LoginSession object (and anonymous KS) Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, Properties.PARTNER_ID, udid1); anonymousKs = loginSessionResponse.results.getKs(); - client.setKs(operatorKs); + client.setKs(getOperatorKs()); expiryDate = BaseUtils.getTimeInEpoch(1); } @@ -112,8 +112,8 @@ private void startSessionSha256() { @Test private void startSessionDefaultExpiryDate() { int expiryDate = 0; - BaseUtils.getSharedHousehold(); - client = getClient(sharedMasterUserKs); + getSharedHousehold(); + client = getClient(getsharedMasterUserKs()); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(null, hashType, null, expiryDate); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index a546f31fb..2791fc4e5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -37,11 +37,11 @@ public class BookmarkAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - client = getClient(sharedMasterUserKs); + client = getClient(getsharedMasterUserKs()); // Get VOD asset id from ingest - assetId = mediaAsset.getId(); + assetId = getSharedMediaAsset().getId(); type = AssetType.get(AssetType.MEDIA.getValue()); AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); @@ -187,11 +187,8 @@ private void finishWatching() { // Verify finishedWatching = true assertThat(bookmark5.getFinishedWatching()).isTrue(); - } - // Error validations - @Description("bookmark/action/add - empty asset id") @Test private void emptyAssetId() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index 703f05cbc..0595b8cd1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -35,7 +35,7 @@ public class BookmarkListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { - client = getClient(sharedMasterUserKs); + client = getClient(getsharedMasterUserKs()); assetId = "606283"; List assetFileIds = AssetUtils.getAssetFileIds(assetId); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index 8b5bf9036..d59377912 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -32,7 +32,7 @@ public class GrantTests extends BaseTest { @Test(description = "entitlement/action/grant - grant subscription with history = true") private void grant_subscription_with_history() { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); // set household Household household = HouseholdUtils.createHouseHold(2, 1, false); @@ -88,14 +88,14 @@ private void grant_subscription_with_history() { // force cancel subscription - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); client.setUserId(Integer.valueOf(user.getUserId())); EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); } @Test(description = "entitlement/action/grant - grant subscription with history = false") private void grant_subscription_without_history() { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); // set household Household household = HouseholdUtils.createHouseHold(2, 1, false); @@ -129,14 +129,14 @@ private void grant_subscription_without_history() { // force cancel subscription - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); client.setUserId(Integer.valueOf(user.getUserId())); EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); } @Test(description = "entitlement/action/grant - grant ppv with history = true") private void grant_ppv_with_history() { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); // set household @@ -193,14 +193,14 @@ private void grant_ppv_with_history() { // force cancel subscription - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); client.setUserId(Integer.valueOf(user.getUserId())); EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); } @Test(description = "entitlement/action/grant - grant ppv with history = false") private void grant_ppv_without_history() { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); // set household @@ -243,7 +243,7 @@ private void grant_ppv_without_history() { // force cancel subscription - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); client.setUserId(Integer.valueOf(user.getUserId())); EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index 968fe1d95..62d65a667 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -38,7 +38,7 @@ private void ottUser_addRole_tests_setup() { // TODO: 3/27/2018 finish and fix test private void addRole() { // set client - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); client.setUserId(Integer.valueOf(user.getId())); OttUserServiceImpl.addRole(client, 3); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 19f7f24b3..c4bb1a308 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -32,7 +32,7 @@ public class DeleteTests extends BaseTest { @BeforeClass private void ottUser_delete_tests_setup() { - client = getClient(administratorKs); + client = getClient(getAdministratorKs()); household = HouseholdUtils.createHouseHold(2, 0, false); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java index 7ce59af48..ce4f002c8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java @@ -34,7 +34,7 @@ private void ottUser_getEncryptedUserId_tests_setup() { @Description("ottUser/action/getEncryptedUserId - getEncryptedUserId") @Test private void getEncryptedUserId() { - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); client.setUserId(Integer.parseInt(user.getId())); stringValueResponse = OttUserServiceImpl.getEncryptedUserId(client); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index e883f30ef..a0a4e3904 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -59,7 +59,7 @@ private void list_with_filter_idIn() { String idIn = householdUsers.get(0).getUserId() + "," + householdUsers.get(1).getUserId(); filter.setIdIn(idIn); - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); householdUserListResponse = list(client, filter); List users = householdUserListResponse.results.getObjects(); @@ -77,7 +77,7 @@ private void list_withd_filter_usernameEqual() { filter.setUsernameEqual(usernameEqual); - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); householdUserListResponse = list(client, filter); List users = householdUserListResponse.results.getObjects(); @@ -94,7 +94,7 @@ private void list_with_not_valid_filter() { filter.setIdIn(householdUsers.get(0).getUserId()); filter.setUsernameEqual(getUserById(Integer.valueOf(householdUsers.get(1).getUserId())).getUsername()); - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); householdUserListResponse = list(client, filter); assertThat(householdUserListResponse.results).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java index c1a5656ed..60740a234 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -35,7 +35,7 @@ private void ottUser_login_tests_setup() { Response ottUserResponse = register(emptyClient, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); user = ottUserResponse.results; - adminClient = getClient(administratorKs); + adminClient = getClient(getAdministratorKs()); adminClient.setUserId(Integer.parseInt(user.getId())); } @@ -65,7 +65,7 @@ private void loginWithPin_with_wrong_secret() { } @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") - @Test(enabled = true) + @Test(groups = "slow") private void loginWithPin_with_expired_pinCode() { userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java index 779d6e08e..bcafcb6cd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java @@ -34,7 +34,7 @@ private void ottUser_resetPassword_tests_setup() { @Description("ottUser/action/resetPassword - resetPassword") @Test(enabled = false) private void resetPassword() { - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); booleanResponse = OttUserServiceImpl.resetPassword(client, PARTNER_ID, user.getUsername()); assertThat(booleanResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java index 363d3467e..d3fb5b0d1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java @@ -33,7 +33,7 @@ private void ottUser_updateDynamicData_tests_setup() { @Test private void updateDynamicData() { // set client - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); client.setUserId(Integer.valueOf(user.getId())); String keyString = "key1"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index 6f25a587e..9699acee4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -55,7 +55,7 @@ private void updateLoginData() { @Description("ottUser/action/updateLoginData - updateLoginData with administratorKs") @Test private void updateLoginData_with_administratorKs() { - client = getClient(administratorKs); + client = getClient(getAdministratorKs()); ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); OTTUser user = ottUserResponse.results; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index 9cb7eb881..529503b18 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -75,7 +75,7 @@ private void update_with_administratorKs() { user.setLastName(newUserInfo); // user.setAffiliateCode(null); - client.setKs(administratorKs); + client.setKs(getAdministratorKs()); ottUserResponse = OttUserServiceImpl.update(client, user, user.getId()); assertThat(ottUserResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 1798671fb..5fab1c729 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -23,7 +23,7 @@ public class ListTests extends BaseTest { @BeforeClass public void beforeClass() { - client = getClient(operatorKs); + client = getClient(getOperatorKs()); entitlementPpvsFilter = new EntitlementFilter(); entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); @@ -78,14 +78,14 @@ public void ppvTest() { getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType - client.setKs(sharedMasterUserKs); + client.setKs(getsharedMasterUserKs()); Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); - int webMediaFileId = mediaAsset.getMediaFiles().get(0).getId(); - int mobileMediaFileId = mediaAsset.getMediaFiles().get(1).getId(); + int webMediaFileId = getSharedMediaAsset().getMediaFiles().get(0).getId(); + int mobileMediaFileId = getSharedMediaAsset().getMediaFiles().get(1).getId(); ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); ppFilter.setIsLowest(false); Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); @@ -101,7 +101,7 @@ public void ppvTest() { System.out.println(entitlementListAfterPurchase.results.getTotalCount()); assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(mediaAsset.getId().intValue()); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index e6c98e4c0..4dc39ce3d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -32,7 +32,7 @@ private void get_tests_before_class() { @Description("session/action/get - master user") @Test private void getMasterUserSession() { - client = getClient(administratorKs); + client = getClient(getAdministratorKs()); Household household = HouseholdUtils.createHouseHold(2, 1, false); HouseholdUser user = HouseholdUtils.getMasterUserFromHousehold(household); String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); @@ -50,8 +50,8 @@ private void getMasterUserSession() { @Description("session/action/get - Anonymous user") @Test private void getAnonymousUserSession() { - client = getClient(administratorKs); - String session = anonymousKs; + client = getClient(getAdministratorKs()); + String session = getAnonymousKs(); Response getSessionResponse = SessionServiceImpl.get(client, session); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); @@ -62,20 +62,20 @@ private void getAnonymousUserSession() { @Description("session/action/get - operator user") @Test private void getOperatorUserSession() { - client = getClient(administratorKs); - String session = operatorKs; + client = getClient(getAdministratorKs()); + String session = getOperatorKs(); Response getSessionResponse = SessionServiceImpl.get(client, session); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); - assertThat(getSessionResponse.results.getUserId()).isEqualTo(SessionUtils.getUserIdByKs(operatorKs)); + assertThat(getSessionResponse.results.getUserId()).isEqualTo(SessionUtils.getUserIdByKs(getOperatorKs())); assertThat(getSessionResponse.results.getUdid()).isEqualTo(""); } @Description("session/action/get - invalid ks") @Test private void getSessionWithInvalidSessionKs() { - client = getClient(administratorKs); - String session = operatorKs + 1; + client = getClient(getAdministratorKs()); + String session = getOperatorKs() + 1; Response getSessionResponse = SessionServiceImpl.get(client, session); assertThat(getSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500015).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index 1715c1a41..edcae5ca2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -56,7 +56,7 @@ private void SwitchUser() { assertThat(ottUserResponse2.results.getId()).isEqualTo(secondUserId); assertThat(ottUserResponse2.results.getUserState()).isEqualTo(UserState.OK); - client = getClient(administratorKs); + client = getClient(getAdministratorKs()); // Invoke session/action/get Response getSessionResponse = SessionServiceImpl.get(client, secondUserKs); // Verify second user id returned in the response diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index f8af12c0d..77fd68a39 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -11,12 +11,12 @@ import java.util.List; import static com.kaltura.client.test.tests.BaseTest.getClient; -import static com.kaltura.client.test.tests.BaseTest.sharedMasterUserKs; +import static com.kaltura.client.test.tests.BaseTest.getsharedMasterUserKs; public class AssetUtils extends BaseUtils { public static List getAssetFileIds(String assetId) { - Client client = getClient(sharedMasterUserKs); + Client client = getClient(getsharedMasterUserKs()); AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); Response assetResponse = AssetServiceImpl.get(client, assetId, assetReferenceType); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 2cc00f354..2175e1d55 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -1,9 +1,7 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; import com.kaltura.client.Logger; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.Response; +import com.kaltura.client.types.APIException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -20,13 +18,6 @@ import java.util.concurrent.ThreadLocalRandom; import static com.kaltura.client.test.Properties.API_URL_VERSION; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; -import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; -import static com.kaltura.client.test.utils.OttUserUtils.getUserById; public class BaseUtils { @@ -133,39 +124,4 @@ private static List getApiExceptionList() { } return exceptions; } - - // utils for baseTest - public static MediaAsset getSharedMediaAsset() { - if (mediaAsset == null) { - mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - System.out.println("INGESTED VOD: " + mediaAsset.getId()); - } - return mediaAsset; - } - - public static Household getSharedHousehold() { - Client client = getClient(null); - - if (sharedHousehold == null) { - sharedHousehold = createHouseHold(2, 2, true); - List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); - for (HouseholdUser user : sharedHouseholdUsers) { - if (user.getIsMaster() != null && user.getIsMaster()) { - sharedMasterUser = user; - } - if (user.getIsMaster() == null && user.getIsDefault() == null) { - sharedUser = user; - } - } - - Response loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); - sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - - loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); - sharedUserKs = loginResponse.results.getLoginSession().getKs(); - } - - return sharedHousehold; - } } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 6595355a7..21a701cc5 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -15,9 +15,7 @@ import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; -import static com.kaltura.client.test.tests.BaseTest.administratorKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; -import static com.kaltura.client.test.tests.BaseTest.operatorKs; +import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class HouseholdUtils extends BaseUtils { @@ -73,7 +71,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO if (isPreparePG) { // TODO: there should be added logic with getting and using default PG currently it all hardcoded client = getClient(null); - client.setKs(operatorKs); + client.setKs(getOperatorKs()); client.setUserId(Integer.valueOf(masterUser.getId())); HouseholdPaymentGatewayServiceImpl.setChargeId(client, "0110151474255957105", "1234"); } @@ -83,7 +81,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO // get users list from given household public static List getDevicesListFromHouseHold(Household household) { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); HouseholdDeviceFilter filter = new HouseholdDeviceFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); Response> devicesResponse = HouseholdDeviceServiceImpl.list(client, filter); @@ -92,7 +90,7 @@ public static List getDevicesListFromHouseHold(Household househ // get users list from given household public static List getUsersListFromHouseHold(Household household) { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); HouseholdUserFilter filter = new HouseholdUserFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); Response> usersResponse = HouseholdUserServiceImpl.list(client, filter); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java index 2042c70ef..0d5c000a6 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java @@ -3,16 +3,20 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.SearchAssetFilter; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; + import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.anonymousKs; +import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; import static com.kaltura.client.test.tests.BaseTest.getClient; import static org.awaitility.Awaitility.await; @@ -140,14 +144,14 @@ public static Response> ingestEPG(String epgChannelName, Op await().pollInterval(3, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS) .until(isDataReturned(epgChannelId, assetFilter, programCountValue*seasonCountValue)); - Response> ingestedProgrammes = AssetServiceImpl.list(getClient(anonymousKs), assetFilter, null); + Response> ingestedProgrammes = AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null); // TODO: complete Asset.json at least for programs return ingestedProgrammes; } private static Callable isDataReturned(int epgChannelId, SearchAssetFilter assetFilter, int totalCount) { - return () -> (AssetServiceImpl.list(getClient(anonymousKs), assetFilter, null).error == null && - AssetServiceImpl.list(getClient(anonymousKs), assetFilter, null).results.getTotalCount() == totalCount); + return () -> (AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).error == null && + AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).results.getTotalCount() == totalCount); } private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index afb52c54c..a85b84e20 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -13,7 +13,7 @@ import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.anonymousKs; +import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; import static com.kaltura.client.test.tests.BaseTest.getClient; import static io.restassured.path.xml.XmlPath.from; import static org.awaitility.Awaitility.await; @@ -64,8 +64,8 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); - await().pollInterval(3, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(isDataReturned(id)); - Response mediaAssetDetails = AssetServiceImpl.get(getClient(anonymousKs), id, AssetReferenceType.MEDIA); + await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(id)); + Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); // TODO: 4/15/2018 add log for ingest and index failures @@ -73,7 +73,7 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op } private static Callable isDataReturned(String mediaId) { - return () -> AssetServiceImpl.get(getClient(anonymousKs), mediaId, AssetReferenceType.MEDIA).error == null; + return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; } private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 4fe3fcd3b..131900df0 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -11,7 +11,7 @@ import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; import static com.kaltura.client.test.Properties.PARTNER_ID; -import static com.kaltura.client.test.tests.BaseTest.administratorKs; +import static com.kaltura.client.test.tests.BaseTest.getAdministratorKs; import static com.kaltura.client.test.tests.BaseTest.getClient; public class OttUserUtils extends BaseUtils { @@ -38,7 +38,7 @@ public static OTTUser generateOttUser() { } public static OTTUser getUserById(int userId) { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); client.setUserId(userId); Response userResponse = OttUserServiceImpl.get(client); diff --git a/src/test/java/com/kaltura/client/test/utils/SessionUtils.java b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java index 360e2bac3..90f74d1fe 100644 --- a/src/test/java/com/kaltura/client/test/utils/SessionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java @@ -5,7 +5,7 @@ import com.kaltura.client.types.Session; import com.kaltura.client.utils.response.base.Response; -import static com.kaltura.client.test.tests.BaseTest.administratorKs; +import static com.kaltura.client.test.tests.BaseTest.getAdministratorKs; import static com.kaltura.client.test.tests.BaseTest.getClient; public class SessionUtils extends BaseUtils { @@ -13,7 +13,7 @@ public class SessionUtils extends BaseUtils { // Return user id according to the ks provided public static String getUserIdByKs(String ks) { - Client client = getClient(administratorKs); + Client client = getClient(getAdministratorKs()); Response getSessionResponse = SessionServiceImpl.get(client,ks); return getSessionResponse.results.getUserId(); } diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 4969d7a26..f7baf6cbe 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,10 +1,17 @@ - + + + + + + + + From 9b77825306f26d83b068e2743214d35ab6e2bd49 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 24 Apr 2018 16:23:07 +0300 Subject: [PATCH 122/605] Updated class AssetCommentAddTests --- .../AssetCommentAddTests.java | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 183b1fb5a..8ec6aa4ed 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -36,7 +36,7 @@ private void add_tests_before_class() { client = getClient(sharedMasterUserKs); } - @Description ("AssetComment/action/add - vod asset") + @Description("AssetComment/action/add - vod asset") @Test private void addCommentForVod() { @@ -48,7 +48,7 @@ private void addCommentForVod() { // AssetComment/action/add Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); - //Assertions + //Assertions for AssetComment/action/add assertThat(assetCommentResponse.results.getId()).isGreaterThan(0); assertThat(assetCommentResponse.results.getAssetId()).isEqualTo(Math.toIntExact(assetId)); assertThat(assetCommentResponse.results.getAssetType()).isEqualTo(AssetType.MEDIA); @@ -60,34 +60,55 @@ private void addCommentForVod() { //Initialize assetCommentFilter object - AssetCommentFilter assetCommentFilter = AssetCommentUtils.assetCommentFilter(Math.toIntExact(assetId),AssetType.MEDIA, + AssetCommentFilter assetCommentFilter = AssetCommentUtils.assetCommentFilter(Math.toIntExact(assetId), AssetType.MEDIA, AssetCommentOrderBy.CREATE_DATE_DESC); //AssetComment/action/list - Response> assetCommentListResponse = AssetCommentServiceImpl.list(client,assetCommentFilter,null); + Response> assetCommentListResponse = AssetCommentServiceImpl.list(client, assetCommentFilter, null); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); + assertThat(assetCommentObjectResponse.getId()).isEqualTo(assetCommentResponse.results.getId()); - assertThat(assetCommentObjectResponse.getAssetId()).isEqualTo(assetCommentListResponse.results.getObjects().get(0).getAssetId()); - assertThat(assetCommentObjectResponse.getAssetType()).isEqualTo(AssetType.MEDIA); - assertThat(assetCommentObjectResponse.getSubHeader()).isEqualTo(subHeader); - assertThat(assetCommentObjectResponse.getHeader()).isEqualTo(header); - assertThat(assetCommentObjectResponse.getText()).isNotEqualTo(text); - assertThat(assetCommentObjectResponse.getWriter()).isEqualTo(writer); + assertThat(assetCommentObjectResponse.getAssetId()).isEqualTo(assetCommentResponse.results.getAssetId()); + assertThat(assetCommentObjectResponse.getAssetType()).isEqualTo(assetCommentResponse.results.getAssetType()); + assertThat(assetCommentObjectResponse.getSubHeader()).isEqualTo(assetCommentResponse.results.getSubHeader()); + assertThat(assetCommentObjectResponse.getHeader()).isEqualTo(assetCommentResponse.results.getHeader()); + assertThat(assetCommentObjectResponse.getText()).isEqualTo(assetCommentResponse.results.getText()); + assertThat(assetCommentObjectResponse.getWriter()).isEqualTo(assetCommentResponse.results.getWriter()); assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); } @Description("AssetComment/action/add - EPG program") @Test private void addCommentForEPGProgram() { + + // Ingest EPG program Response> epgProgram = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); Long epgProgramId = epgProgram.results.getObjects().get(0).getId(); + + // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(epgProgramId), AssetType.EPG, writer, text, createDate, subHeader, header); - Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + + // AssetComment/action/add + Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + + //Assertions for AssetComment/action/add assertThat(assetCommentResponse.results.getId()).isGreaterThan(0); assertThat(assetCommentResponse.results.getAssetId()).isEqualTo(Math.toIntExact(epgProgramId)); assertThat(assetCommentResponse.results.getAssetType()).isEqualTo(AssetType.EPG); + //Initialize assetCommentFilter object + AssetCommentFilter assetCommentFilter = AssetCommentUtils.assetCommentFilter(Math.toIntExact(epgProgramId), AssetType.EPG, + AssetCommentOrderBy.CREATE_DATE_DESC); + + //AssetComment/action/list + Response> assetCommentListResponse = AssetCommentServiceImpl.list(client, assetCommentFilter, null); + AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); + + //Assertions for AssetComment/action/list + assertThat(assetCommentObjectResponse.getId()).isEqualTo(assetCommentResponse.results.getId()); + assertThat(assetCommentObjectResponse.getAssetId()).isEqualTo(assetCommentResponse.results.getAssetId()); + assertThat(assetCommentObjectResponse.getAssetType()).isEqualTo(assetCommentResponse.results.getAssetType()); } From 001e049d8599dcde97e73308338d2a8378ad518d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 24 Apr 2018 16:45:59 +0300 Subject: [PATCH 123/605] Fixed several classes to work with the new changes in baseTest methods. --- .../appTokenTests/AppTokenStartSessionTests.java | 4 ++-- .../assetCommentTests/AssetCommentAddTests.java | 6 +++--- .../tests/servicesTests/bookmarkTests/BookmarkAddTests.java | 5 ++--- .../tests/servicesTests/sessionTests/SessionGetTests.java | 4 +--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index 869cf8470..09b1b489a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -48,7 +48,7 @@ private void startSessionSha1() { // Build appToken object appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); // Invoke AppToken/action/add - client.setKs(operatorKs); + client.setKs(getOperatorKs()); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); client.setKs(anonymousKs); @@ -83,7 +83,7 @@ private void startSessionSha256() { // Build appToken object appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); // Invoke AppToken/action/add - client.setKs(operatorKs); + client.setKs(getOperatorKs()); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); client.setKs(anonymousKs); // Generate new token hash diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 8ec6aa4ed..8413da3a8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -32,15 +32,15 @@ public class AssetCommentAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - BaseUtils.getSharedHousehold(); - client = getClient(sharedMasterUserKs); + BaseTest.getSharedHousehold(); + client = getClient(getsharedUserKs()); } @Description("AssetComment/action/add - vod asset") @Test private void addCommentForVod() { - Long assetId = BaseUtils.getSharedMediaAsset().getId(); + Long assetId = BaseTest.getSharedMediaAsset().getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 5754a6899..494c383e8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -35,8 +34,8 @@ public class BookmarkAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - BaseUtils.getSharedHousehold(); - client = getClient(sharedMasterUserKs); + BaseTest.getSharedHousehold(); + client = getClient(getsharedMasterUserKs()); assetId = 608775; AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); Response assetResponse = AssetServiceImpl.get(client, String.valueOf(assetId), assetReferenceType); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index 4dc39ce3d..9a6c1b5ed 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -22,8 +22,6 @@ public class SessionGetTests extends BaseTest { private Client client; - long timeStampSeconds; - @BeforeClass private void get_tests_before_class() { @@ -51,7 +49,7 @@ private void getMasterUserSession() { @Test private void getAnonymousUserSession() { client = getClient(getAdministratorKs()); - String session = getAnonymousKs(); + String session = BaseTest.getAnonymousKs(); Response getSessionResponse = SessionServiceImpl.get(client, session); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); From 12fc6ac6b1d32e4ba34acb3e2aea59f15eeb3ffb Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 24 Apr 2018 17:02:55 +0300 Subject: [PATCH 124/605] no message --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 4 ++-- .../tests/servicesTests/appTokenTests/AppTokenAddTests.java | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 3160c7610..36a0ed481 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -79,7 +79,7 @@ public static String getManagerKs() { loginResponse = login(client, PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); managerKs = loginResponse.results.getLoginSession().getKs(); } - return operatorKs; + return managerKs; } public static String getAnonymousKs() { @@ -87,7 +87,7 @@ public static String getAnonymousKs() { Response loginSession = anonymousLogin(client, PARTNER_ID, null); anonymousKs = loginSession.results.getKs(); } - return operatorKs; + return anonymousKs; } public static MediaAsset getSharedMediaAsset() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index a506334f6..85f618e0b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -24,7 +24,6 @@ public class AppTokenAddTests extends BaseTest { public static Client client; private String sessionPrivileges; - @BeforeClass private void add_tests_before_class() { hashType = AppTokenHashType.SHA1; @@ -37,9 +36,6 @@ private void addAppToken() { client = getClient(getOperatorKs()); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); - // Assertions - // **************************** - // Verify no error returned assertThat(appTokenResponse.error).isNull(); assertThat(appTokenResponse.results.getExpiry()).isNull(); From af057ced98c0dacc6e6efc5f13ef315a3215e466 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 24 Apr 2018 17:09:47 +0300 Subject: [PATCH 125/605] add getsharedMasterUser() and getsharedUser() --- .../java/com/kaltura/client/test/tests/BaseTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 36a0ed481..a7915cdca 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -132,4 +132,14 @@ public static String getsharedUserKs() { if (sharedHousehold == null) getSharedHousehold(); return sharedUserKs; } + + public static HouseholdUser getsharedMasterUser() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedMasterUser; + } + + public static HouseholdUser getsharedUser() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedUser; + } } From ca45a9ee17dcda92c7b4fe05ec6db58e85054c5f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 24 Apr 2018 17:25:27 +0300 Subject: [PATCH 126/605] Updated AssetCommentListTests class --- .../appTokenTests/AppTokenAddTests.java | 1 + .../AssetCommentAddTests.java | 15 +++-- .../AssetCommentListTests.java | 67 +++++++++++++++++++ 3 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index cfd67d505..809ffd776 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -19,6 +19,7 @@ public class AppTokenAddTests extends BaseTest { private AppTokenHashType hashType; + // todo - replace hardcoded value with method private String sessionUserId = "1577578"; private AppToken appToken = new AppToken(); public static Client client; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 8413da3a8..4af28b33a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetCommentOrderBy; -import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -24,11 +23,11 @@ public class AssetCommentAddTests extends BaseTest { private Client client; - String writer = "Shmulik"; - Long createDate = 0L; - String header = "header"; - String subHeader = "subHeader"; - String text = "A lot of text"; + private String writer = "Shmulik"; + private Long createDate = 0L; + private String header = "header"; + private String subHeader = "subHeader"; + private String text = "A lot of text"; @BeforeClass private void add_tests_before_class() { @@ -77,6 +76,7 @@ private void addCommentForVod() { assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); } + @Description("AssetComment/action/add - EPG program") @Test private void addCommentForEPGProgram() { @@ -111,5 +111,6 @@ private void addCommentForEPGProgram() { assertThat(assetCommentObjectResponse.getAssetType()).isEqualTo(assetCommentResponse.results.getAssetType()); } - + // todo - Add error validations tests + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java new file mode 100644 index 000000000..dbabda797 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -0,0 +1,67 @@ +package com.kaltura.client.test.tests.servicesTests.assetCommentTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetCommentOrderBy; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetCommentUtils; +import com.kaltura.client.types.AssetComment; +import com.kaltura.client.types.AssetCommentFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AssetCommentListTests extends BaseTest { + + private Client client; + private String writer = "Shmulik"; + private Long createDate = 0L; + private String header = "header"; + private String subHeader = "subHeader"; + private String text = "A lot of text"; + + @BeforeClass + private void add_tests_before_class() { + BaseTest.getSharedHousehold(); + client = getClient(getsharedUserKs()); + } + + @Description("AssetComment/action/list - check order by functionality") + @Test + + private void checkCommentsOrder() { + + Long assetId = BaseTest.getSharedMediaAsset().getId(); + + // Initialize assetComment object + AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); + + // AssetComment/action/add - first comment + Response assetComment1Response = AssetCommentServiceImpl.add(client, assetComment); + + // AssetComment/action/add - second comment comment + Response assetComment2Response = AssetCommentServiceImpl.add(client, assetComment); + + //Initialize assetCommentFilter object + AssetCommentFilter assetCommentFilter = AssetCommentUtils.assetCommentFilter(Math.toIntExact(assetId), AssetType.MEDIA, + AssetCommentOrderBy.CREATE_DATE_DESC); + + //AssetComment/action/list - return both comments + Response> assetCommentListResponse = AssetCommentServiceImpl.list(client, assetCommentFilter, null); + + AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); + AssetComment assetComment2ObjectResponse = assetCommentListResponse.results.getObjects().get(1); + + // Assert that total count = 2 (two comments added) + assertThat(assetCommentListResponse.results.getTotalCount()).isEqualTo(2); + + // Assert that second comment return first because order by = CREATE_DATE_DESC (newest comment return first) + assertThat(assetCommentObjectResponse.getAssetId()).isEqualTo(assetComment2Response.results.getAssetId()); + assertThat(assetComment2ObjectResponse.getAssetId()).isEqualTo(assetComment1Response.results.getAssetId()); + } +} From a3840cba6360a89e04e9437936dbbd0287fbf80c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 25 Apr 2018 09:19:44 +0300 Subject: [PATCH 127/605] Updated bookmarkTests and AppTokenTests classes --- .../appTokenTests/AppTokenAddTests.java | 3 +-- .../appTokenTests/AppTokenDeleteTests.java | 2 +- .../appTokenTests/AppTokenGetTests.java | 3 ++- .../bookmarkTests/BookmarkAddTests.java | 2 +- .../bookmarkTests/BookmarkListTests.java | 20 +++++++++---------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 9bec29697..6000808b4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -19,8 +19,7 @@ public class AppTokenAddTests extends BaseTest { private AppTokenHashType hashType; - // todo - replace hardcoded value with method - private String sessionUserId = "1577578"; + private String sessionUserId = BaseTest.getsharedUser().getUserId(); private AppToken appToken = new AppToken(); public static Client client; private String sessionPrivileges; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java index e4eb54be1..b46abc0ae 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java @@ -23,7 +23,7 @@ public class AppTokenDeleteTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - sessionUserId = "1577578"; + sessionUserId = BaseTest.getsharedUser().getUserId(); client = getClient(getOperatorKs()); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index 271b82f30..507bd072c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -18,7 +18,7 @@ public class AppTokenGetTests extends BaseTest { - final private String sessionUserId = "1577578"; + private String sessionUserId; private String sessionPrivileges = "key1:value1,key2:value2"; private AppTokenHashType hashType; public static Client client; @@ -31,6 +31,7 @@ public class AppTokenGetTests extends BaseTest { private void get_tests_before_class() { client = getClient(getOperatorKs()); hashType = AppTokenHashType.SHA1; + sessionUserId = BaseTest.getsharedUser().getUserId(); expiryDate = BaseUtils.getTimeInEpoch(offSetInMinutes); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 494c383e8..2f37b5085 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -36,7 +36,7 @@ public class BookmarkAddTests extends BaseTest { private void add_tests_before_class() { BaseTest.getSharedHousehold(); client = getClient(getsharedMasterUserKs()); - assetId = 608775; + assetId = BaseTest.getSharedMediaAsset().getId(); AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); Response assetResponse = AssetServiceImpl.get(client, String.valueOf(assetId), assetReferenceType); fileId = assetResponse.results.getMediaFiles().get(0).getId(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index 0595b8cd1..7e5922a63 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -24,11 +24,11 @@ public class BookmarkListTests extends BaseTest { private Client client; - private String assetId; + private Long assetId; private int fileId; - private String assetId2; + private Long assetId2; private int fileId2; private List assetList = new ArrayList<>(); @@ -37,15 +37,15 @@ public class BookmarkListTests extends BaseTest { private void list_tests_before_class() { client = getClient(getsharedMasterUserKs()); - assetId = "606283"; - List assetFileIds = AssetUtils.getAssetFileIds(assetId); + assetId = BaseTest.getSharedMediaAsset().getId(); + List assetFileIds = AssetUtils.getAssetFileIds(String.valueOf(assetId)); fileId = assetFileIds.get(0); - assetList.add(assetId); + assetList.add(String.valueOf(assetId)); - assetId2 = "606282"; - List asset2FileIds = AssetUtils.getAssetFileIds(assetId2); + assetId2 = BaseTest.getSharedMediaAsset().getId(); + List asset2FileIds = AssetUtils.getAssetFileIds(String.valueOf(assetId2)); fileId2 = asset2FileIds.get(0); - assetList.add(assetId2); + assetList.add(String.valueOf(assetId2)); } @Description("bookmark/action/list - order by") @@ -54,12 +54,12 @@ private void list_tests_before_class() { private void BookmarkOrderBy() { // Bookmark asset1 - Bookmark bookmark = BookmarkUtils.addBookmark(0, assetId, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); assertThat(booleanResponse.results.booleanValue()).isTrue(); // Bookmark asset2 - Bookmark bookmark2 = BookmarkUtils.addBookmark(10, assetId2, fileId2, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark2 = BookmarkUtils.addBookmark(10, String.valueOf(assetId2), fileId2, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); Response booleanResponse2 = BookmarkServiceImpl.add(client, bookmark2); assertThat(booleanResponse2.results.booleanValue()).isTrue(); From c1084d66b954c495abaa1f5c612950d4730073ce Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 25 Apr 2018 10:34:05 +0300 Subject: [PATCH 128/605] Fixed test case list_subscription() --- .../com/kaltura/client/test/Properties.java | 3 +++ .../kaltura/client/test/tests/BaseTest.java | 18 ++++++++++++++++++ .../productPriceTests/ListTests.java | 4 ++-- .../client/test/utils/IngestPPUtils.java | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 5f422c490..e72425cda 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -81,6 +81,9 @@ public class Properties { public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; public static final String PG_DEFAULT_PG_SETTINGS = "{}"; + // life cycles periods + public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; + public static String getProperty(String propertyKey) { if (resourceBundle == null) resourceBundle = ResourceBundle.getBundle("test"); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index a7915cdca..182cae410 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,6 +2,8 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; +import com.kaltura.client.test.utils.IngestMPPUtils; +import com.kaltura.client.test.utils.IngestPPUtils; import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -36,6 +38,8 @@ public class BaseTest { // shared VOD private static MediaAsset mediaAsset; + // shared MPP + private static Subscription fiveMinRenewableSubscription; @BeforeSuite public void base_test_before_suite() { @@ -142,4 +146,18 @@ public static HouseholdUser getsharedUser() { if (sharedHousehold == null) getSharedHousehold(); return sharedUser; } + + public static Subscription get5MinRenewableSubscription() { + if (fiveMinRenewableSubscription == null) { + PricePlan pricePlan = IngestPPUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), + Optional.of(getProperty(AMOUNT_4_99_EUR)), Optional.of(CURRENCY_EUR), Optional.of(""), + Optional.of(true), Optional.of(3)); + fiveMinRenewableSubscription = IngestMPPUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + } + return fiveMinRenewableSubscription; + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 5fab1c729..17bcd7611 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -51,9 +51,9 @@ public void beforeClass() { @Test(enabled = false) // as used in feature tests public void list_subscription() { ProductPriceFilter filter = new ProductPriceFilter(); - // TODO: fix! filter.setSubscriptionIdIn(five_min_renewable_subscription_id); + filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); Response> productPriceList = list(client, filter); - // TODO: fix! assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(five_min_renewable_subscription_id); + assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java index 6ffe8141c..a28306f47 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java @@ -82,6 +82,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod pricePlan.setMaxViewsNumber(maxViewsValue); pricePlan.setIsRenewable(isRenewableValue); pricePlan.setRenewalsNumber(recurringPeriodsValue); + pricePlan.setName(ppCodeValue); // TODO: complete COMMENTED IF NEEDED //pricePlan.setFullLifeCycle(); //pricePlan.setViewLifeCycle(); From 696cb990cdffe76e142d7666616cadabd2d3466b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 25 Apr 2018 10:42:27 +0300 Subject: [PATCH 129/605] Added test listSubscriptionWithCurrencyTest() --- .../productPriceTests/ListTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 17bcd7611..6110d5aa8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -12,6 +12,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.Optional; +import static com.kaltura.client.test.Properties.CURRENCY_EUR; import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -58,6 +59,21 @@ public void list_subscription() { assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); } + @Description("productPrice/action/list - subscription test with currency by Operator") + @Test() + public void listSubscriptionWithCurrencyTest() { + ProductPriceFilter filter = new ProductPriceFilter(); + filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); + client.setKs(getOperatorKs()); + client.setCurrency(CURRENCY_EUR); + Response> productPriceList = list(client, filter); + // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them + assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); + assertThat(productPriceList.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CURRENCY_EUR); + } + @Description("productPrice/action/list - without required fields (subscriptionIdIn, collectionIdIn and fileIdIn are empty)") @Test() public void list_without_required_fields() { From fd03ac4e35feb07374884caac26a12c2af2f920c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 25 Apr 2018 13:27:33 +0300 Subject: [PATCH 130/605] Move sharedHoueshold params to inner class in BaseTest --- .../kaltura/client/test/tests/BaseTest.java | 88 +++++++++++-------- .../appTokenTests/AppTokenAddTests.java | 1 + .../AppTokenStartSessionTests.java | 1 + .../AssetCommentAddTests.java | 16 ++-- .../bookmarkTests/BookmarkAddTests.java | 3 +- .../bookmarkTests/BookmarkListTests.java | 1 + .../productPriceTests/ListTests.java | 1 + .../kaltura/client/test/utils/AssetUtils.java | 2 +- 8 files changed, 65 insertions(+), 48 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index a7915cdca..623004d6a 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -28,14 +28,15 @@ public class BaseTest { // shared ks's private static String administratorKs, operatorKs, managerKs, anonymousKs; - // shared household - private static Household sharedHousehold; - private static HouseholdUser sharedMasterUser, sharedUser; - private static String sharedMasterUserKs, sharedUserKs; - // shared VOD private static MediaAsset mediaAsset; + /* + // shared household params + Household sharedHousehold; + HouseholdUser sharedMasterUser, sharedUser; + String sharedMasterUserKs, sharedUserKs; + */ @BeforeSuite public void base_test_before_suite() { @@ -99,47 +100,56 @@ public static MediaAsset getSharedMediaAsset() { return mediaAsset; } - public static Household getSharedHousehold() { - Client client = getClient(null); - - if (sharedHousehold == null) { - sharedHousehold = createHouseHold(2, 2, true); - List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); - for (HouseholdUser user : sharedHouseholdUsers) { - if (user.getIsMaster() != null && user.getIsMaster()) { - sharedMasterUser = user; - } - if (user.getIsMaster() == null && user.getIsDefault() == null) { - sharedUser = user; + // shared household + public static class SharedHousehold { + + private static Household sharedHousehold; + private static HouseholdUser sharedMasterUser, sharedUser; + private static String sharedMasterUserKs, sharedUserKs; + + + public static Household getSharedHousehold() { + Client client = getClient(null); + + if (sharedHousehold == null) { + sharedHousehold = createHouseHold(2, 2, true); + List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); + for (HouseholdUser user : sharedHouseholdUsers) { + if (user.getIsMaster() != null && user.getIsMaster()) { + sharedMasterUser = user; + } + if (user.getIsMaster() == null && user.getIsDefault() == null) { + sharedUser = user; + } } - } - loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); - sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); - sharedUserKs = loginResponse.results.getLoginSession().getKs(); + loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + sharedUserKs = loginResponse.results.getLoginSession().getKs(); + } + return sharedHousehold; } - return sharedHousehold; - } - public static String getsharedMasterUserKs() { - if (sharedHousehold == null) getSharedHousehold(); - return sharedMasterUserKs; - } + public static String getsharedMasterUserKs() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedMasterUserKs; + } - public static String getsharedUserKs() { - if (sharedHousehold == null) getSharedHousehold(); - return sharedUserKs; - } + public static String getsharedUserKs() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedUserKs; + } - public static HouseholdUser getsharedMasterUser() { - if (sharedHousehold == null) getSharedHousehold(); - return sharedMasterUser; - } + public static HouseholdUser getsharedMasterUser() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedMasterUser; + } - public static HouseholdUser getsharedUser() { - if (sharedHousehold == null) getSharedHousehold(); - return sharedUser; + public static HouseholdUser getsharedUser() { + if (sharedHousehold == null) getSharedHousehold(); + return sharedUser; + } } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 5cda8ce9f..d7022d390 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -13,6 +13,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index 09b1b489a..b0ceef169 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -16,6 +16,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static org.assertj.core.api.Assertions.assertThat; public class AppTokenStartSessionTests extends BaseTest { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 8413da3a8..92a92f698 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetCommentOrderBy; -import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -20,19 +19,22 @@ import java.util.Optional; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getsharedUserKs; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class AssetCommentAddTests extends BaseTest { + private Client client; - String writer = "Shmulik"; - Long createDate = 0L; - String header = "header"; - String subHeader = "subHeader"; - String text = "A lot of text"; + private String writer = "Shmulik"; + private Long createDate = 0L; + private String header = "header"; + private String subHeader = "subHeader"; + private String text = "A lot of text"; @BeforeClass private void add_tests_before_class() { - BaseTest.getSharedHousehold(); + getSharedHousehold(); client = getClient(getsharedUserKs()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 494c383e8..d7b6537b6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -34,7 +35,7 @@ public class BookmarkAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - BaseTest.getSharedHousehold(); + getSharedHousehold(); client = getClient(getsharedMasterUserKs()); assetId = 608775; AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index 0595b8cd1..425166719 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static org.assertj.core.api.Assertions.assertThat; public class BookmarkListTests extends BaseTest { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 5fab1c729..b2a00d109 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -13,6 +13,7 @@ import org.testng.annotations.Test; import java.util.Optional; import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 77fd68a39..21240008d 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -10,8 +10,8 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getsharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.getClient; -import static com.kaltura.client.test.tests.BaseTest.getsharedMasterUserKs; public class AssetUtils extends BaseUtils { From bec8c72f55451c6fc984f10847710bb3017f4a13 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 25 Apr 2018 15:55:18 +0300 Subject: [PATCH 131/605] Added test productPriceSubscriptionAndPpvBeforePurchaseTest() --- .../kaltura/client/test/tests/BaseTest.java | 27 ++++++++++++++++++- .../productPriceTests/ListTests.java | 25 +++++++++++++++-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 182cae410..2872747c6 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -38,6 +38,10 @@ public class BaseTest { // shared VOD private static MediaAsset mediaAsset; + // shared files + private static MediaFile webMediaFile; + private static MediaFile mobileMediaFile; + // shared MPP private static Subscription fiveMinRenewableSubscription; @@ -98,11 +102,32 @@ public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - System.out.println("INGESTED VOD: " + mediaAsset.getId()); } return mediaAsset; } + public static MediaFile getSharedWebMediaFile() { + if (webMediaFile == null) { + if (getProperty(WEB_FILE_TYPE).equals(getSharedMediaAsset().getMediaFiles().get(0).getType())) { + webMediaFile = mediaAsset.getMediaFiles().get(0); + } else { + webMediaFile = mediaAsset.getMediaFiles().get(1); + } + } + return webMediaFile; + } + + public static MediaFile getSharedMobileMediaFile() { + if (mobileMediaFile == null) { + if (getProperty(MOBILE_FILE_TYPE).equals(getSharedMediaAsset().getMediaFiles().get(0).getType())) { + mobileMediaFile = mediaAsset.getMediaFiles().get(0); + } else { + mobileMediaFile = mediaAsset.getMediaFiles().get(1); + } + } + return mobileMediaFile; + } + public static Household getSharedHousehold() { Client client = getClient(null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 6110d5aa8..61fa7f431 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -5,6 +5,8 @@ import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -64,7 +66,6 @@ public void list_subscription() { public void listSubscriptionWithCurrencyTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - client.setKs(getOperatorKs()); client.setCurrency(CURRENCY_EUR); Response> productPriceList = list(client, filter); // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them @@ -114,7 +115,6 @@ public void ppvTest() { PurchaseUtils.purchasePpv(client, Optional.empty(), Optional.of(webMediaFileId)); Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); - System.out.println(entitlementListAfterPurchase.results.getTotalCount()); assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); @@ -134,4 +134,25 @@ public void ppvTest() { assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); } + + @Description("productPrice/action/list - common test for PPV and subscription to check before purchase") + @Test() + public void productPriceSubscriptionAndPpvBeforePurchaseTest() { + Household household = HouseholdUtils.createHouseHold(1, 1, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + client.setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null)); + + ProductPriceFilter filter = new ProductPriceFilter(); + filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); + filter.setFileIdIn(String.valueOf(getSharedWebMediaFile().getId())); + filter.setIsLowest(false); + Response> productPriceListBeforePurchase = list(client, filter); + assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(2); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceListBeforePurchase.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice) productPriceListBeforePurchase.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + } } From d4266a8375ae49a812f37ec07b64ad447beae00e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 25 Apr 2018 16:01:48 +0300 Subject: [PATCH 132/605] Added variables to properties class + updated several classes + update ingestVOD util (enable"parent allowed" value) + updated listResponse.json schema --- .../com/kaltura/client/test/Properties.java | 8 +- .../AssetHistoryListTests.java | 133 ++++++++++++++++++ .../AssetCommentAddTests.java | 3 +- .../AssetCommentListTests.java | 11 +- .../bookmarkTests/BookmarkAddTests.java | 20 ++- .../client/test/utils/AssetHistoryUtils.java | 20 +++ .../client/test/utils/BookmarkUtils.java | 4 +- .../client/test/utils/IngestVODUtils.java | 3 +- src/test/resources/schemas/ListResponse.json | 3 +- 9 files changed, 181 insertions(+), 24 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 5f422c490..fe0f8648c 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -34,11 +34,17 @@ public class Properties { public static final String GLOBAL_USER_PASSWORD = "password"; - // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts + // media types - default for all accounts public static final String MOVIE_MEDIA_TYPE = "Movie"; public static final String EPISODE_MEDIA_TYPE = "Episode"; public static final String LINEAR_MEDIA_TYPE = "Linear"; + // media types ids + public static final Long MOVIE_MEDIA_TYPE_ID = 425L; + public static final Long EPISODE_MEDIA_TYPE_ID = 426L; + + + // file types public static final String WEB_FILE_TYPE = "web_file_type"; public static final String MOBILE_FILE_TYPE = "mobile_file_type"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java new file mode 100644 index 000000000..ae58f3509 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -0,0 +1,133 @@ +package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; +import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.*; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.test.Properties.EPISODE_MEDIA_TYPE; +import static org.assertj.core.api.Assertions.assertThat; + +public class AssetHistoryListTests extends BaseTest { + private Client client; + private long movieAssetId; + private int movieFileId; + private long episodeAssetId; + private int episodeFileId; + private AssetType assetType; + private BookmarkActionType actionType; + + // instantiate Bookmark object + private Bookmark bookmark = new Bookmark(); + + @BeforeClass + private void add_tests_before_class() { + client = getClient(getsharedMasterUserKs()); + } + + @Description("/AssetHistory/action/list - with no filter") + @Test + private void vodAssetHistory() { + + // Ingest movie vod asset + movieAssetId = BaseTest.getSharedMediaAsset().getId(); + movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movieAssetId)).get(0); + + // Ingest episode vod asset + MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(EPISODE_MEDIA_TYPE)), Optional.empty(), Optional.empty()); + episodeAssetId = mediaAsset.getId(); + episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episodeAssetId)).get(0); + + // Movie asset bookmark + int position1 = 10; + actionType = BookmarkActionType.FIRST_PLAY; + assetType = AssetType.MEDIA; + bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movieAssetId), movieFileId, assetType, actionType); + //bookmark/action/add - Movie asset + BookmarkServiceImpl.add(client, bookmark); + + // Episode asset bookmark + int position2 = 20; + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episodeAssetId), episodeFileId, assetType, actionType); + //bookmark/action/add - Episode asset + BookmarkServiceImpl.add(client, bookmark); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + + //assetHistory/action/list - both assets (episode and movie) should returned + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + // First object + AssetHistory assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); + // Second object + AssetHistory assetHistoryObject2 = assetHistoryListResponse.results.getObjects().get(1); + + // Assertions for first object returned (movie asset) + assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movieAssetId); + assertThat(assetHistoryObject1.getAssetType()).isEqualTo(assetType); + assertThat(assetHistoryObject1.getPosition()).isEqualTo(position1); + assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); + // Verify that flag is set to false (user hasn't finish watching the asset) + assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); + assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); + + // Assertions for second object returned (episode asset) + assertThat(assetHistoryObject2.getAssetId()).isEqualTo(episodeAssetId); + assertThat(assetHistoryObject2.getAssetType()).isEqualTo(assetType); + assertThat(assetHistoryObject2.getPosition()).isEqualTo(position2); + + // Assert total count = 2 (two bookmarks) + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); + + + } + + @Description("/AssetHistory/action/list -filtered by movie type id") + @Test + private void vodAssetHistoryFiltered() { + + // Ingest movie vod asset + movieAssetId = BaseTest.getSharedMediaAsset().getId(); + movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movieAssetId)).get(0); + + // Ingest episode vod asset + MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(EPISODE_MEDIA_TYPE)), Optional.empty(), Optional.empty()); + episodeAssetId = mediaAsset.getId(); + episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episodeAssetId)).get(0); + + // Movie asset bookmark + int position1 = 10; + actionType = BookmarkActionType.FIRST_PLAY; + assetType = AssetType.MEDIA; + bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movieAssetId), movieFileId, assetType, actionType); + //bookmark/action/add - Movie asset + BookmarkServiceImpl.add(client, bookmark); + + // Episode asset bookmark + int position2 = 20; + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episodeAssetId), episodeFileId, assetType, actionType); + //bookmark/action/add - Episode asset + BookmarkServiceImpl.add(client, bookmark); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movieAssetId), null, WatchStatus.ALL, null); + + //assetHistory/action/list - 1111 + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + } + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 4af28b33a..276afca49 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -66,6 +66,7 @@ private void addCommentForVod() { Response> assetCommentListResponse = AssetCommentServiceImpl.list(client, assetCommentFilter, null); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); + //Assertions for AssetComment/action/list assertThat(assetCommentObjectResponse.getId()).isEqualTo(assetCommentResponse.results.getId()); assertThat(assetCommentObjectResponse.getAssetId()).isEqualTo(assetCommentResponse.results.getAssetId()); assertThat(assetCommentObjectResponse.getAssetType()).isEqualTo(assetCommentResponse.results.getAssetType()); @@ -112,5 +113,5 @@ private void addCommentForEPGProgram() { } // todo - Add error validations tests - + // todo - Add tests for recording } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index dbabda797..d9875cee5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -19,11 +19,6 @@ public class AssetCommentListTests extends BaseTest { private Client client; - private String writer = "Shmulik"; - private Long createDate = 0L; - private String header = "header"; - private String subHeader = "subHeader"; - private String text = "A lot of text"; @BeforeClass private void add_tests_before_class() { @@ -36,6 +31,12 @@ private void add_tests_before_class() { private void checkCommentsOrder() { + String writer = "Shmulik"; + Long createDate = 0L; + String header = "header"; + String subHeader = "subHeader"; + String text = "A lot of text"; + Long assetId = BaseTest.getSharedMediaAsset().getId(); // Initialize assetComment object diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 2f37b5085..a37ff88fb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -25,7 +26,7 @@ public class BookmarkAddTests extends BaseTest { private long assetId; private int fileId; private BookmarkActionType actionType; - private int position = 0; + private int position; private List assetList = new ArrayList<>(); // instantiate Bookmark object private Bookmark bookmark = new Bookmark(); @@ -37,13 +38,8 @@ private void add_tests_before_class() { BaseTest.getSharedHousehold(); client = getClient(getsharedMasterUserKs()); assetId = BaseTest.getSharedMediaAsset().getId(); - AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); - Response assetResponse = AssetServiceImpl.get(client, String.valueOf(assetId), assetReferenceType); - fileId = assetResponse.results.getMediaFiles().get(0).getId(); - actionType = BookmarkActionType.get(BookmarkActionType.FIRST_PLAY.getValue()); - + fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); assetList.add(String.valueOf(assetId)); - // Initialize bookmark object parameters // Initialize bookmarkFilter object parameters bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC, AssetType.MEDIA, assetList); @@ -54,7 +50,7 @@ private void add_tests_before_class() { private void firstPlayback() { actionType = BookmarkActionType.FIRST_PLAY; position = 0; - bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); @@ -94,7 +90,7 @@ private void pausePlayback() { // Set action type to "PAUSE" actionType = BookmarkActionType.PAUSE; position = 30; - bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); @@ -116,7 +112,7 @@ private void pausePlayback() { private void watchingNinetyFive() { actionType = BookmarkActionType.PLAY; position = 999; - bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); @@ -139,7 +135,7 @@ private void watchingNinetyFive() { private void backToStart() { actionType = BookmarkActionType.STOP; position = 0; - bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); assertThat(booleanResponse.results.booleanValue()).isTrue(); @@ -155,7 +151,7 @@ private void finishWatching() { // Set action type to "FINISH" actionType = BookmarkActionType.FINISH; position = 60; - bookmark = BookmarkUtils.addBookmark(position,String.valueOf(assetId),fileId,AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java new file mode 100644 index 000000000..c3448a0e1 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java @@ -0,0 +1,20 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.types.AssetHistoryFilter; + +import javax.annotation.Nullable; + +public class AssetHistoryUtils extends BaseUtils { + + public static AssetHistoryFilter getAssetHistoryFilter(@Nullable String assetIdIn, @Nullable Integer days, WatchStatus statusEqual, @Nullable String typeIn) { + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setAssetIdIn(assetIdIn); + assetHistoryFilter.setDaysLessThanOrEqual(days); + assetHistoryFilter.setStatusEqual(statusEqual); + assetHistoryFilter.setTypeIn(typeIn); + + return assetHistoryFilter; + + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java b/src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java index 0e932a51d..f50943253 100644 --- a/src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BookmarkUtils.java @@ -17,14 +17,12 @@ public static Bookmark addBookmark(int position, String assetId, int fileId, Ass Bookmark bookmark = new Bookmark(); bookmark.setPosition(position); bookmark.setId(String.valueOf(assetId)); - AssetType type = AssetType.get(assetType.getValue()); - bookmark.setType(type); + bookmark.setType(assetType); // instantiate BookmarkPlayerData object BookmarkPlayerData playerData = new BookmarkPlayerData(); BookmarkActionType bookmarkactionType = BookmarkActionType.get(actionType.getValue()); playerData.setAction(bookmarkactionType); - playerData.setAction(actionType); playerData.setAverageBitrate(0); playerData.setTotalBitrate(0); playerData.setCurrentBitrate(0); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index a85b84e20..273085a61 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -72,6 +72,7 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op return mediaAsset; } + private static Callable isDataReturned(String mediaId) { return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; } @@ -104,7 +105,7 @@ private static String buildIngestVodXml(String coguid, boolean isActive, String " " + mediaType + "\n" + " \n" + //" ${#TestCase#i_geo_block_rule}\n" + - //" Parent Allowed\n" + + " Parent Allowed\n" + //" ${#TestCase#i_device_block_rule}\n" + " \n" + " \n" + diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 2d0411b97..bfec96dc2 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -57,7 +57,8 @@ "KalturaOTTUserListResponse", "KalturaProductPriceListResponse", "KalturaBookmarkListResponse", - "KalturaAssetCommentListResponse" + "KalturaAssetCommentListResponse", + "KalturaAssetHistoryListResponse" ] } }, From 636adc5eb493b17548a703334074ee6f41e22ce5 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 25 Apr 2018 16:28:39 +0300 Subject: [PATCH 133/605] get shared users typo fix --- .../com/kaltura/client/test/Properties.java | 6 ++--- .../test/TestAPIOkRequestsExecutor.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 8 +++--- .../appTokenTests/AppTokenAddTests.java | 2 +- .../AppTokenStartSessionTests.java | 2 +- .../AssetCommentAddTests.java | 4 +-- .../bookmarkTests/BookmarkAddTests.java | 2 +- .../bookmarkTests/BookmarkListTests.java | 2 +- .../entitlementTests/GrantTests.java | 26 ++++++++++++++----- .../productPriceTests/ListTests.java | 2 +- .../kaltura/client/test/utils/AssetUtils.java | 4 +-- 11 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 5f422c490..c0ad565ad 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -7,9 +7,9 @@ public class Properties { private static ResourceBundle resourceBundle; // Url properties - public static final String API_BASE_URL = "http://api-preprod.ott.kaltura.com"; // "http://34.249.122.223:8080" - public static final String SOAP_BASE_URL = "http://api-preprod.ott.kaltura.com:8030"; // "http://34.249.122.223:8030"; - public static final String INGEST_REPORT_URL = "http://api-preprod.ott.kaltura.com:5823"; // "http://34.249.122.223:5823"; + public static final String API_BASE_URL = "http://api-preprod.ott.kaltura.com"; + public static final String SOAP_BASE_URL = "http://api-preprod.ott.kaltura.com:8030"; + public static final String INGEST_REPORT_URL = "http://api-preprod.ott.kaltura.com:5823"; public static final String API_URL_VERSION = "v4_8_1"; // DB properties diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 7185bbb01..f8f3a4ea1 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -33,7 +33,7 @@ public static TestAPIOkRequestsExecutor getExecutor() { @SuppressWarnings("rawtypes") @Override protected ResponseElement onGotResponse(Response response, RequestElement action) { - + // print request headers // logger.debug("request headers\n" + action.getHeaders().toString()); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 623004d6a..3e4b77476 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -132,22 +132,22 @@ public static Household getSharedHousehold() { return sharedHousehold; } - public static String getsharedMasterUserKs() { + public static String getSharedMasterUserKs() { if (sharedHousehold == null) getSharedHousehold(); return sharedMasterUserKs; } - public static String getsharedUserKs() { + public static String getSharedUserKs() { if (sharedHousehold == null) getSharedHousehold(); return sharedUserKs; } - public static HouseholdUser getsharedMasterUser() { + public static HouseholdUser getSharedMasterUser() { if (sharedHousehold == null) getSharedHousehold(); return sharedMasterUser; } - public static HouseholdUser getsharedUser() { + public static HouseholdUser getSharedUser() { if (sharedHousehold == null) getSharedHousehold(); return sharedUser; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index d7022d390..55516e88d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -99,7 +99,7 @@ private void addAppTokenWithExpiryDate() { //todo - Add specific mark indicating the version of the feature private void addAppTokenWithNoExpiryDate() { getSharedHousehold(); - client = getClient(getsharedMasterUserKs()); + client = getClient(getSharedMasterUserKs()); int expiryDate = 0; //int cbExpiryDateValue = 2592000; appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, expiryDate); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index b0ceef169..a9ef34cfc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -116,7 +116,7 @@ private void startSessionSha256() { private void startSessionDefaultExpiryDate() { int expiryDate = 0; getSharedHousehold(); - client = getClient(getsharedMasterUserKs()); + client = getClient(getSharedMasterUserKs()); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(null, hashType, null, expiryDate); Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 92a92f698..fb80a71ae 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -20,7 +20,7 @@ import java.util.Optional; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getsharedUserKs; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedUserKs; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class AssetCommentAddTests extends BaseTest { @@ -35,7 +35,7 @@ public class AssetCommentAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { getSharedHousehold(); - client = getClient(getsharedUserKs()); + client = getClient(getSharedUserKs()); } @Description("AssetComment/action/add - vod asset") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index d7b6537b6..05e34ad2e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -36,7 +36,7 @@ public class BookmarkAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { getSharedHousehold(); - client = getClient(getsharedMasterUserKs()); + client = getClient(getSharedMasterUserKs()); assetId = 608775; AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); Response assetResponse = AssetServiceImpl.get(client, String.valueOf(assetId), assetReferenceType); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index 425166719..1c0680b08 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -36,7 +36,7 @@ public class BookmarkListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { - client = getClient(getsharedMasterUserKs()); + client = getClient(getSharedMasterUserKs()); assetId = "606283"; List assetFileIds = AssetUtils.getAssetFileIds(assetId); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index d59377912..fa8e848fe 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -16,6 +16,7 @@ import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.Test; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class GrantTests extends BaseTest { @@ -25,8 +26,8 @@ public class GrantTests extends BaseTest { private final int ppvId = 30297; private final int assetId = 607368; - private int contentId; - + private int contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + private Response> billingTransactionListResponse; @@ -137,7 +138,6 @@ private void grant_subscription_without_history() { @Test(description = "entitlement/action/grant - grant ppv with history = true") private void grant_ppv_with_history() { Client client = getClient(getAdministratorKs()); - contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); // set household Household household = HouseholdUtils.createHouseHold(2, 1, false); @@ -201,7 +201,6 @@ private void grant_ppv_with_history() { @Test(description = "entitlement/action/grant - grant ppv with history = false") private void grant_ppv_without_history() { Client client = getClient(getAdministratorKs()); - contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); // set household Household household = HouseholdUtils.createHouseHold(2, 1, false); @@ -248,8 +247,23 @@ private void grant_ppv_without_history() { EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); } - // TODO: 4/16/2018 finish negative scenarios -// @Test(description = "entitlement/action/grant - ppv - error 6001") + @Test(description = "entitlement/action/grant - wrong ppv id - error 6001") + private void grant_ppv_with_wrong_id() { + Client client = getClient(getAdministratorKs()); + + // set household + Household household = HouseholdUtils.createHouseHold(2, 1, false); + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + + // grant subscription - history = true + client.setUserId(Integer.valueOf(user.getUserId())); + Response booleanResponse = EntitlementServiceImpl.grant(client, 1, TransactionType.PPV, true, contentId); + + assertThat(booleanResponse.results.booleanValue()).isEqualTo(null); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); + } + + // TODO: 4/16/2018 finish negative scenarios // @Test(description = "entitlement/action/grant - ppv - error 3021") // @Test(description = "entitlement/action/grant - subscription - error 3024") // @Test(description = "entitlement/action/grant - subscription - error 3023") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index b2a00d109..8f8c75b7b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -79,7 +79,7 @@ public void ppvTest() { getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType - client.setKs(getsharedMasterUserKs()); + client.setKs(getSharedMasterUserKs()); Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 21240008d..1d5a0255b 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -10,13 +10,13 @@ import java.util.ArrayList; import java.util.List; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getsharedMasterUserKs; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.getClient; public class AssetUtils extends BaseUtils { public static List getAssetFileIds(String assetId) { - Client client = getClient(getsharedMasterUserKs()); + Client client = getClient(getSharedMasterUserKs()); AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); Response assetResponse = AssetServiceImpl.get(client, assetId, assetReferenceType); From 9453ccc5103dc8ca0ce37d5e1f12cb7bec6f1e98 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 26 Apr 2018 02:55:00 +0300 Subject: [PATCH 134/605] Updated TestAPIOkRequestsExecutor.java corresponding to code-review comments --- .../test/TestAPIOkRequestsExecutor.java | 81 +++++++------------ 1 file changed, 30 insertions(+), 51 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 7185bbb01..203b2501d 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -3,78 +3,57 @@ import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; -import com.kaltura.client.utils.ErrorElement; -import com.kaltura.client.utils.request.ExecutedRequest; import com.kaltura.client.utils.request.RequestElement; import com.kaltura.client.utils.response.base.ResponseElement; import okhttp3.Response; -import java.io.IOException; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.hamcrest.MatcherAssert.assertThat; /** * @hide + * That class allows to validate json schemas of responses */ -// that class was implemented to get access to full response body as it's superclass APIOkRequestsExecutor doesn't allow to do it +// public class TestAPIOkRequestsExecutor extends APIOkRequestsExecutor { - public static final String TAG = "TestAPIOkRequestsExecutor"; private static ILogger logger = Logger.getLogger(TAG); - protected static TestAPIOkRequestsExecutor self; + + private static TestAPIOkRequestsExecutor executor; + + private TestAPIOkRequestsExecutor() {} public static TestAPIOkRequestsExecutor getExecutor() { - if (self == null) { - self = new TestAPIOkRequestsExecutor(); + if (executor == null) { + executor = new TestAPIOkRequestsExecutor(); } - return self; + return executor; } @SuppressWarnings("rawtypes") @Override protected ResponseElement onGotResponse(Response response, RequestElement action) { - - // print request headers -// logger.debug("request headers\n" + action.getHeaders().toString()); - - String requestId = getRequestId(response); - - if (!response.isSuccessful()) { // in case response has failure status - return new ExecutedRequest().requestId(requestId).error(ErrorElement.fromCode(response.code(), response.message())).success(false); - - } else { - String responseString = null; - try { - responseString = response.body().string(); - } catch (IOException e) { - e.printStackTrace(); - logger.error("failed to retrieve the response body!"); - } - - // print response body - logger.debug("response body:\n" + responseString); - - // print response headers -// logger.debug("response headers:\n" + response.headers()); - - ResponseElement responseElement = new ExecutedRequest().requestId(requestId).response(responseString).code(response.code()).success(responseString != null); - com.kaltura.client.utils.response.base.Response response1 = action.parseResponse(responseElement); - - if (response1.isSuccess()) { - String s1 = "schemas/"; - String s3 = ".json"; - String s2 = response1.results.getClass().getSimpleName(); - - String schema = s1 + s2 + s3; - Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); - /*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); - Date date = new Date(); - System.out.println("BEFORE VALIDATION: " + formatter.format(date));*/ - assertThat(responseString, matchesJsonSchemaInClasspath(schema)); - /*date = new Date(); - System.out.println("AFTER VALIDATION: " + formatter.format(date));*/ - } - return responseElement; + ResponseElement responseElement = super.onGotResponse(response, action); + //logger.debug("response body:\n" + responseElement.getResponse()); // was found in base class + logger.debug("response headers:\n" + response.headers()); + if (responseElement.isSuccess()) { + com.kaltura.client.utils.response.base.Response response1 = action.parseResponse(responseElement); + + if (response1.isSuccess()) { + String s1 = "schemas/"; + String s2 = response1.results.getClass().getSimpleName(); + String s3 = ".json"; + + String schema = s1 + s2 + s3; + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); + /*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); + Date date = new Date(); + System.out.println("BEFORE VALIDATION: " + formatter.format(date));*/ + assertThat(responseElement.getResponse(), matchesJsonSchemaInClasspath(schema)); + /*date = new Date(); + System.out.println("AFTER VALIDATION: " + formatter.format(date));*/ + } } + return responseElement; } } From cba3ed09788445d721c06cf30e8b38d7968123fb Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 26 Apr 2018 09:09:53 +0300 Subject: [PATCH 135/605] Reorder in Properties --- .../com/kaltura/client/test/Properties.java | 69 +++++------ .../kaltura/client/test/tests/BaseTest.java | 26 ++-- .../kaltura/client/test/tests/Sandbox.java | 34 ----- .../appTokenTests/AppTokenAddTests.java | 5 +- .../appTokenTests/AppTokenGetTests.java | 3 +- .../AppTokenStartSessionTests.java | 7 +- .../ottUserTests/ActivateTests.java | 9 +- .../ottUserTests/AddRoleTests.java | 4 +- .../ottUserTests/AnonymousLoginTests.java | 5 +- .../ottUserTests/DeleteTests.java | 4 +- .../ottUserTests/GetEncryptedUserIdTests.java | 5 +- .../servicesTests/ottUserTests/GetTests.java | 7 +- .../servicesTests/ottUserTests/ListTests.java | 8 +- .../ottUserTests/LoginTests.java | 13 +- .../ottUserTests/LoginWithPinTests.java | 10 +- .../ottUserTests/LogoutTests.java | 7 +- .../ottUserTests/RegisterTests.java | 5 +- .../ResendActivationTokenTests.java | 9 +- .../ottUserTests/ResetPasswordTests.java | 9 +- .../ottUserTests/UpdateDynamicDataTests.java | 4 +- .../ottUserTests/UpdateLoginDataTests.java | 21 ++-- .../ottUserTests/UpdateTests.java | 7 +- .../sessionTests/SessionGetTests.java | 3 +- .../kaltura/client/test/utils/BaseUtils.java | 5 +- .../kaltura/client/test/utils/DBUtils.java | 4 +- .../client/test/utils/HouseholdUtils.java | 10 +- .../client/test/utils/IngestEPGUtils.java | 10 +- .../client/test/utils/IngestMPPUtils.java | 117 +++++++++--------- .../client/test/utils/IngestPPUtils.java | 8 +- .../client/test/utils/IngestPPVUtils.java | 8 +- .../client/test/utils/IngestVODUtils.java | 4 +- .../client/test/utils/OttUserUtils.java | 7 +- src/test/resources/test.template.properties | 11 ++ 33 files changed, 199 insertions(+), 259 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/tests/Sandbox.java create mode 100644 src/test/resources/test.template.properties diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index c0ad565ad..5f5b3fda2 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -7,49 +7,43 @@ public class Properties { private static ResourceBundle resourceBundle; // Url properties - public static final String API_BASE_URL = "http://api-preprod.ott.kaltura.com"; - public static final String SOAP_BASE_URL = "http://api-preprod.ott.kaltura.com:8030"; - public static final String INGEST_REPORT_URL = "http://api-preprod.ott.kaltura.com:5823"; - public static final String API_URL_VERSION = "v4_8_1"; + public static final String API_BASE_URL = "api_base_url"; + public static final String INGEST_BASE_URL = "ingest_base_url"; + public static final String INGEST_REPORT_URL = "ingest_report_url"; + public static final String API_VERSION = "api_version"; // DB properties - // TODO: 3/19/2018 encrypt db username and password in test.properties file public static final String DB_URL = "db_url"; public static final String DB_USER = "db_user"; public static final String DB_PASSWORD = "db_password"; // Request properties - public static final int PARTNER_ID = 203; - public static final String API_REQUEST_VERSION = "4.8.1"; + public static final String PARTNER_ID = "partner_id"; - // Global user properties - public static final String ADMINISTRATOR_USERNAME = "administrator_user_username"; - public static final String ADMINISTRATOR_PASSWORD = "administrator_user_password"; + // Global users + public static final String ADMINISTRATOR_USER_USERNAME = "administrator_user_username"; + public static final String ADMINISTRATOR_USER_PASSWORD = "administrator_user_password"; - public static final String OPERATOR_USERNAME = "operator_user_username"; - public static final String OPERATOR_PASSWORD = "operator_user_password"; + public static final String OPERATOR_USER_USERNAME = "operator_user_username"; + public static final String OPERATOR_USER_PASSWORD = "operator_user_password"; - public static final String MANAGER_USERNAME = "manager_user_username"; - public static final String MANAGER_PASSWORD = "manager_user_password"; + public static final String MANAGER_USER_USERNAME = "manager_user_username"; + public static final String MANAGER_USER_PASSWORD = "manager_user_password"; - public static final String GLOBAL_USER_PASSWORD = "password"; - - // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts - public static final String MOVIE_MEDIA_TYPE = "Movie"; - public static final String EPISODE_MEDIA_TYPE = "Episode"; - public static final String LINEAR_MEDIA_TYPE = "Linear"; + public static final String DEFAULT_USER_PASSWORD = "default_user_password"; // file types public static final String WEB_FILE_TYPE = "web_file_type"; public static final String MOBILE_FILE_TYPE = "mobile_file_type"; // ingest - public static final String INGEST_USER_NAME = "ingest_user_username"; + public static final String INGEST_USER_USERNAME = "ingest_user_username"; public static final String INGEST_USER_PASSWORD = "ingest_user_password"; - public static final String INGEST_BUSINESS_MODULE_USER_NAME = "ingest_business_module_user_username"; + + public static final String INGEST_BUSINESS_MODULE_USER_USERNAME = "ingest_business_module_user_username"; public static final String INGEST_BUSINESS_MODULE_USER_PASSWORD = "ingest_business_module_user_password"; - public static final String INGEST_ACTION_INSERT = "insert"; + public static final String INGEST_ACTION_INSERT = "INGEST"; public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; @@ -71,6 +65,12 @@ public class Properties { public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; public static final String HUNDRED_PERCENTS_UKP_DISCOUNT_NAME = "hundred_percents_ukp_discount_name"; + // TODO: 4/25/2018 ask Max if needed to add to properties file + // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts + public static final String MOVIE_MEDIA_TYPE = "Movie"; + public static final String EPISODE_MEDIA_TYPE = "Episode"; + public static final String LINEAR_MEDIA_TYPE = "Linear"; + // PG adapter data public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; @@ -78,23 +78,20 @@ public class Properties { public static final int PG_DEFAULT_PENDING_INTERVAL = 0; public static final int PG_DEFAULT_PENDING_RETRIES = 0; public static final int PG_DEFAULT_RENEW_INTERVAL_MINUTES = 15; - public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; + public static final int PG_DEFAULT_RENEW_START_MINUTES = -5; public static final String PG_DEFAULT_PG_SETTINGS = "{}"; + public static String getProperty(String propertyKey) { - if (resourceBundle == null) + if (resourceBundle == null) { resourceBundle = ResourceBundle.getBundle("test"); - + } return resourceBundle.getString(propertyKey); } - - //todo global list - // TODO: 3/8/2018 talk with Elram about DB cleanup - // TODO: 3/8/2018 add relevant data assertions (include optional params) to impl services - // TODO: 3/12/2018 open conference page with all the documentation problems - // TODO: 12/MAR/2018 decide if we need that autoskip logic for tests with known opened bugs: - // https://dzone.com/articles/how-to-automatically-skip-tests-based-on-defects-s - // TODO: 3/19/2018 update readme file with project structure and list of services - // TODO: 3/19/2018 find how to run specific tests according to api version - // TODO: 3/22/2018 ask Elram where to open the apiException meesage not equal to description issue } + +// todo global list +// TODO: 3/12/2018 open conference page with all the documentation problems +// TODO: 12/MAR/2018 decide if we need that autoskip logic for tests with known opened bugs: +// https://dzone.com/articles/how-to-automatically-skip-tests-based-on-defects-s +// TODO: 3/19/2018 update readme file with project structure and list of services diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 3e4b77476..553761b2e 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -25,6 +25,10 @@ public class BaseTest { private static Response loginResponse; private static Configuration config; + // shared common params + public static int partnerId; + public static String defaultUserPassword; + // shared ks's private static String administratorKs, operatorKs, managerKs, anonymousKs; @@ -40,9 +44,12 @@ public class BaseTest { @BeforeSuite public void base_test_before_suite() { + partnerId = Integer.parseInt(getProperty(PARTNER_ID)); + defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); + // set configuration config = new Configuration(); - config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION); + config.setEndpoint(getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION)); config.setAcceptGzipEncoding(false); client = getClient(null); @@ -53,7 +60,6 @@ public void base_test_before_suite() { public static Client getClient(String ks) { Client client = new Client(config); - client.setApiVersion(API_REQUEST_VERSION); client.setKs(ks); return client; } @@ -61,7 +67,7 @@ public static Client getClient(String ks) { // getters for shared params public static String getAdministratorKs() { if (administratorKs == null) { - loginResponse = login(client, PARTNER_ID, getProperty(ADMINISTRATOR_USERNAME), getProperty(ADMINISTRATOR_PASSWORD), null, null); + loginResponse = login(client, partnerId, getProperty(ADMINISTRATOR_USER_USERNAME), getProperty(ADMINISTRATOR_USER_PASSWORD), null, null); administratorKs = loginResponse.results.getLoginSession().getKs(); } return administratorKs; @@ -69,7 +75,7 @@ public static String getAdministratorKs() { public static String getOperatorKs() { if (operatorKs == null) { - loginResponse = login(client, PARTNER_ID, getProperty(OPERATOR_USERNAME), getProperty(OPERATOR_PASSWORD), null, null); + loginResponse = login(client, partnerId, getProperty(OPERATOR_USER_USERNAME), getProperty(OPERATOR_USER_PASSWORD), null, null); operatorKs = loginResponse.results.getLoginSession().getKs(); } return operatorKs; @@ -77,7 +83,7 @@ public static String getOperatorKs() { public static String getManagerKs() { if (managerKs == null) { - loginResponse = login(client, PARTNER_ID, getProperty(MANAGER_USERNAME), getProperty(MANAGER_PASSWORD), null, null); + loginResponse = login(client, partnerId, getProperty(MANAGER_USER_USERNAME), getProperty(MANAGER_USER_PASSWORD), null, null); managerKs = loginResponse.results.getLoginSession().getKs(); } return managerKs; @@ -85,7 +91,7 @@ public static String getManagerKs() { public static String getAnonymousKs() { if (anonymousKs == null) { - Response loginSession = anonymousLogin(client, PARTNER_ID, null); + Response loginSession = anonymousLogin(client, partnerId, null); anonymousKs = loginSession.results.getKs(); } return anonymousKs; @@ -110,9 +116,11 @@ public static class SharedHousehold { public static Household getSharedHousehold() { Client client = getClient(null); + int numOfUsers = 2; + int numOfDevices = 2; if (sharedHousehold == null) { - sharedHousehold = createHouseHold(2, 2, true); + sharedHousehold = createHouseHold(numOfUsers, numOfDevices, true); List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); for (HouseholdUser user : sharedHouseholdUsers) { if (user.getIsMaster() != null && user.getIsMaster()) { @@ -123,10 +131,10 @@ public static Household getSharedHousehold() { } } - loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + loginResponse = login(client, partnerId, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), defaultUserPassword, null, null); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), GLOBAL_USER_PASSWORD, null, null); + loginResponse = login(client, partnerId, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), defaultUserPassword, null, null); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } return sharedHousehold; diff --git a/src/test/java/com/kaltura/client/test/tests/Sandbox.java b/src/test/java/com/kaltura/client/test/tests/Sandbox.java deleted file mode 100644 index 6e82529ac..000000000 --- a/src/test/java/com/kaltura/client/test/tests/Sandbox.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.kaltura.client.test.tests; - -import com.kaltura.client.test.utils.HouseholdUtils; -import io.restassured.RestAssured; -import io.restassured.path.xml.XmlPath; -import org.testng.annotations.Test; - -import static io.restassured.RestAssured.given; - -public class Sandbox extends BaseTest { - - @Test(enabled = false) - private void test() { - RestAssured.baseURI = "http://34.249.122.223:8030/Ingest_v4_8/Service.svc?wsdl"; - - String myEnvelope = "QABE - Regular-mainQABE - Regular-mainMovie_180328093854266description of 18032809385426627/03/2018 09:38:5427/03/2018 09:38:5414/10/2099 17:00:0014/10/2099 17:00:00MoviePhilippines OnlyParent Allowedsyno pino sistermeta_value190023/03/2017 12:34:56Costa Rica;IsraelGIHABCDEFShay_SeriesKSQL channel_573349]]>"; - String xml = given() - .header("SOAPAction","http://tempuri.org/IService/IngestTvinciData") - .contentType("text/xml;charset=UTF-8") - .body(myEnvelope) - .when() - .post() - .andReturn() - .asString(); - - int assetId = new XmlPath(xml).getInt("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID"); - System.out.println("!!! " + assetId); - } - - @Test(enabled = true) - private void test1() { - HouseholdUtils.createHouseHold(2, 1, false); - } -} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 55516e88d..7fb4fee30 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.Properties; import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; @@ -45,7 +44,7 @@ private void addAppToken() { assertThat(appTokenResponse.results.getHashType()).isEqualTo(this.hashType); assertThat(appTokenResponse.results.getToken()).isNotEmpty(); assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(this.sessionUserId); - assertThat(appTokenResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(appTokenResponse.results.getPartnerId()).isEqualTo(partnerId); assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(String.valueOf(this.sessionUserId)); } @@ -118,6 +117,6 @@ private void addAppTokenWithoutSpecificUserId() { assertThat(addAppTokenResponse.results.getId()).isNotEmpty(); assertThat(addAppTokenResponse.results.getToken()).isNotEmpty(); assertThat(addAppTokenResponse.results.getSessionUserId()).isNotEqualTo(sessionUserId); - assertThat(addAppTokenResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(addAppTokenResponse.results.getPartnerId()).isEqualTo(partnerId); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index 271b82f30..424e639fd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.Properties; import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; @@ -45,7 +44,7 @@ private void getAppToken() { assertThat(getAppTokenResponse.results.getId()).isEqualTo(addAppTokenResponse.results.getId()); assertThat(getAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); - assertThat(getAppTokenResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(getAppTokenResponse.results.getPartnerId()).isEqualTo(partnerId); assertThat(getAppTokenResponse.results.getSessionDuration()).isEqualTo(sessionDuration); assertThat(getAppTokenResponse.results.getHashType()).isEqualTo(hashType); assertThat(getAppTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index a9ef34cfc..729adae79 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.Properties; import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -36,7 +35,7 @@ public class AppTokenStartSessionTests extends BaseTest { private void add_tests_before_class() { client = getClient(null); // Invoke ottUser/action/anonymousLogin to receive LoginSession object (and anonymous KS) - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, Properties.PARTNER_ID, udid1); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, partnerId, udid1); anonymousKs = loginSessionResponse.results.getKs(); client.setKs(getOperatorKs()); expiryDate = BaseUtils.getTimeInEpoch(1); @@ -60,7 +59,7 @@ private void startSessionSha1() { , tokenHash, null, Math.toIntExact(expiryDate), udid1); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); - assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(partnerId); assertThat(sessionInfoResponse.results.getUserId()).isEqualTo(sessionUserId); assertThat(sessionInfoResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); assertThat(sessionInfoResponse.results.getPrivileges()).contains(sessionPrivileges); @@ -94,7 +93,7 @@ private void startSessionSha256() { , tokenHash, null, Math.toIntExact(expiryDate), udid1); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); - assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(partnerId); assertThat(sessionInfoResponse.results.getUserId()).isEqualTo(sessionUserId); assertThat(sessionInfoResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); assertThat(sessionInfoResponse.results.getPrivileges()).contains(sessionPrivileges); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index 16f123073..b75131d13 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -11,8 +11,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -22,15 +20,14 @@ public class ActivateTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; @BeforeClass private void ottUser_activate_tests_setup() { client = getClient(null); user = generateOttUser(); - register(client, PARTNER_ID, user, password); - login(client, PARTNER_ID, user.getUsername(), password, null, null); + register(client, partnerId, user, defaultUserPassword); + login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); } @Description("ottUser/action/activate - activate") @@ -38,7 +35,7 @@ private void ottUser_activate_tests_setup() { private void activate() { String activationToken = DBUtils.getActivationToken(user.getUsername()); - Response ottUserResponse = OttUserServiceImpl.activate(client, PARTNER_ID, user.getUsername(),activationToken); + Response ottUserResponse = OttUserServiceImpl.activate(client, partnerId, user.getUsername(),activationToken); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index 62d65a667..1c8352e54 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -15,8 +15,6 @@ import java.util.List; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -29,7 +27,7 @@ public class AddRoleTests extends BaseTest { private void ottUser_addRole_tests_setup() { client = getClient(null); user = generateOttUser(); - Response ottUserResponse = register(client, PARTNER_ID, user, GLOBAL_USER_PASSWORD); + Response ottUserResponse = register(client, partnerId, user, defaultUserPassword); user = ottUserResponse.results; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 90ae97387..51e7d50ef 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -9,7 +9,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -25,7 +24,7 @@ private void ottUser_anonymousLogin_tests_setup() { @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() private void anonymousLogin() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, PARTNER_ID, null); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, partnerId, null); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); @@ -34,7 +33,7 @@ private void anonymousLogin() { @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") @Test() private void anonymousLogin_with_wrong_partnerId() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, PARTNER_ID + 1, null); + Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, partnerId + 1, null); assertThat(loginSessionResponse.results).isNull(); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index c4bb1a308..f5886de7d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -14,8 +14,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.get; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; @@ -39,7 +37,7 @@ private void ottUser_delete_tests_setup() { @Description("ottUser/action/delete - delete") @Test private void delete() { - Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); OTTUser user = ottUserResponse.results; client.setUserId(Integer.valueOf(user.getId())); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java index ce4f002c8..2189efbee 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java @@ -10,8 +10,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -20,14 +18,13 @@ public class GetEncryptedUserIdTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; private Response stringValueResponse; @BeforeClass private void ottUser_getEncryptedUserId_tests_setup() { client = getClient(null); - Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 7d7aa1ed7..c82fbcc32 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -10,8 +10,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -21,7 +19,6 @@ public class GetTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; private Response loginResponse; private Response ottUserResponse; @@ -29,10 +26,10 @@ public class GetTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { client = getClient(null); - ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; - loginResponse = login(client, PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); user = loginResponse.results.getUser(); client.setKs(loginResponse.results.getLoginSession().getKs()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index a0a4e3904..5e22783aa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -11,8 +11,6 @@ import java.util.List; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.list; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; @@ -25,8 +23,8 @@ public class ListTests extends BaseTest { private Client client; private Household household; - private int numberOfUsersInHousehold = 4; private Response> householdUserListResponse; + private int numberOfUsersInHousehold = 4; @BeforeClass private void ottUser_list_tests_setup() { @@ -39,8 +37,8 @@ private void ottUser_list_tests_setup() { private void list_from_master_ks() { HouseholdUser masterUser = getMasterUserFromHousehold(household); - Response loginResponse = login(client, PARTNER_ID, getUserById(Integer.parseInt(masterUser.getUserId())).getUsername(), - GLOBAL_USER_PASSWORD, null, null); + Response loginResponse = login(client, partnerId, getUserById(Integer.parseInt(masterUser.getUserId())).getUsername(), + defaultUserPassword, null, null); client.setKs(loginResponse.results.getLoginSession().getKs()); householdUserListResponse = list(client, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 083884a59..ecdceaae6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -10,8 +10,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -21,21 +19,20 @@ public class LoginTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; private Response loginResponse; @BeforeClass private void ottUser_login_tests_setup() { client = getClient(null); - Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; } // @Issue("BEO-4933") @Test(description = "ottUser/action/login - login") private void login() { - loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); @@ -45,7 +42,7 @@ private void login() { @Description("ottUser/action/login - login with wrong password - error 1011") @Test private void login_with_wrong_password() { - loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password + "1", null, null); + loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword + "1", null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); @@ -54,7 +51,7 @@ private void login_with_wrong_password() { @Description("ottUser/action/login - login with wrong username - error 2000") @Test private void login_with_wrong_username() { - loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername() + "1", password, null, null); + loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername() + "1", defaultUserPassword, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); @@ -63,7 +60,7 @@ private void login_with_wrong_username() { @Description("ottUser/action/login - login with wrong partnerId - error 500006") @Test() private void login_with_wrong_partnerId() { - loginResponse = OttUserServiceImpl.login(client, PARTNER_ID + 1, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(client, partnerId + 1, user.getUsername(), defaultUserPassword, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java index 60740a234..bf8716ca7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -12,8 +12,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -32,7 +30,7 @@ public class LoginWithPinTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { emptyClient = getClient(null); - Response ottUserResponse = register(emptyClient, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response ottUserResponse = register(emptyClient, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; adminClient = getClient(getAdministratorKs()); @@ -45,7 +43,7 @@ private void loginWithPin_with_secret() throws InterruptedException { userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); String pin = userLoginPinResponse.results.getPinCode(); - loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, PARTNER_ID, pin, null, SECRET); + loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, partnerId, pin, null, SECRET); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); @@ -58,7 +56,7 @@ private void loginWithPin_with_wrong_secret() { userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); String pin = userLoginPinResponse.results.getPinCode(); - loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, PARTNER_ID, pin, null, SECRET + 1); + loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, partnerId, pin, null, SECRET + 1); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2008).getCode()); @@ -72,7 +70,7 @@ private void loginWithPin_with_expired_pinCode() { String pin = userLoginPinResponse.results.getPinCode(); // sleep for 1.5 minutes try { Thread.sleep(120000); } catch (InterruptedException e) { e.printStackTrace(); } - loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, PARTNER_ID, pin, null, SECRET); + loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, partnerId, pin, null, SECRET); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2004).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java index 7da2326e2..de33506bd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java @@ -11,8 +11,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -22,7 +20,6 @@ public class LogoutTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; private Response loginResponse; private Response booleanResponse; @@ -32,14 +29,14 @@ public class LogoutTests extends BaseTest { private void ottUser_logout_tests_setup() { client = getClient(null); - Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; } @Description("ottUser/action/logout - logout") @Test private void logout() { - loginResponse = login(client, PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); client.setKs(loginResponse.results.getLoginSession().getKs()); booleanResponse = OttUserServiceImpl.logout(client); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java index d0c0d7098..e87d26375 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java @@ -9,8 +9,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -18,7 +16,6 @@ public class RegisterTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; private Response ottUserResponse; @@ -32,7 +29,7 @@ private void ottUser_login_tests_setup() { @Description("ottUser/action/register - register") @Test private void register() { - ottUserResponse = OttUserServiceImpl.register(client, PARTNER_ID, user, password); + ottUserResponse = OttUserServiceImpl.register(client, partnerId, user, defaultUserPassword); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUsername()).isEqualTo(user.getUsername()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java index b8881123f..847de62f1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -9,8 +9,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -20,21 +18,20 @@ public class ResendActivationTokenTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; @BeforeClass private void ottUser_resendActivationToken_tests_setup() { client = getClient(null); user = generateOttUser(); - register(client, PARTNER_ID, user, password); - login(client, PARTNER_ID, user.getUsername(), password, null, null); + register(client, partnerId, user, defaultUserPassword); + login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); } @Description("ottUser/action/resendActivationToken - resendActivationToken") @Test(enabled = false) private void resendActivationToken() { - Response booleanResponse = OttUserServiceImpl.resendActivationToken(client, PARTNER_ID, user.getUsername()); + Response booleanResponse = OttUserServiceImpl.resendActivationToken(client, partnerId, user.getUsername()); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java index bcafcb6cd..e29f0b6c4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java @@ -10,8 +10,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -20,14 +18,13 @@ public class ResetPasswordTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; private Response booleanResponse; @BeforeClass private void ottUser_resetPassword_tests_setup() { client = getClient(null); - Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; } @@ -35,13 +32,13 @@ private void ottUser_resetPassword_tests_setup() { @Test(enabled = false) private void resetPassword() { client.setKs(getAdministratorKs()); - booleanResponse = OttUserServiceImpl.resetPassword(client, PARTNER_ID, user.getUsername()); + booleanResponse = OttUserServiceImpl.resetPassword(client, partnerId, user.getUsername()); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); client = getClient(null); - Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); // TODO: 4/1/2018 finsih the test after bug BEO-4884 will be fixed } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java index d3fb5b0d1..c42d4785b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java @@ -11,8 +11,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -25,7 +23,7 @@ public class UpdateDynamicDataTests extends BaseTest { @BeforeClass private void ottUser_updateDynamicData_tests_setup() { client = getClient(null); - Response ottUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index 9699acee4..dd9ad0d34 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -9,8 +9,6 @@ import io.qameta.allure.Description; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -19,7 +17,6 @@ public class UpdateLoginDataTests extends BaseTest { private Client client; - private String password = GLOBAL_USER_PASSWORD; private Response booleanResponse; private Response ottUserResponse; @@ -30,24 +27,24 @@ public class UpdateLoginDataTests extends BaseTest { private void updateLoginData() { client = getClient(null); - ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); OTTUser user = ottUserResponse.results; - Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); client.setKs(loginResponse.results.getLoginSession().getKs()); - booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), password, password + 1); + booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), defaultUserPassword, defaultUserPassword + 1); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password - loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password - loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password + 1, null, null); + loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword + 1, null, null); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } @@ -57,22 +54,22 @@ private void updateLoginData() { private void updateLoginData_with_administratorKs() { client = getClient(getAdministratorKs()); - ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); OTTUser user = ottUserResponse.results; - booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), password, password + 1); + booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), defaultUserPassword, defaultUserPassword + 1); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password client = getClient(null); - Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password - loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password + 1, null, null); + loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword + 1, null, null); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index 529503b18..7d1ef3e5c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -12,8 +12,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -23,7 +21,6 @@ public class UpdateTests extends BaseTest { private Client client; private OTTUser user; - private String password = GLOBAL_USER_PASSWORD; private String originalUserEmail; private Response ottUserResponse; @@ -31,7 +28,7 @@ public class UpdateTests extends BaseTest { @BeforeClass private void ottUser_update_tests_setup() { client = getClient(null); - ottUserResponse = register(client, PARTNER_ID, generateOttUser(), password); + ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; originalUserEmail = user.getEmail(); } @@ -40,7 +37,7 @@ private void ottUser_update_tests_setup() { @Test private void update() { // get self ks - Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, user.getUsername(), password, null, null); + Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); client.setKs(loginResponse.results.getLoginSession().getKs()); // update diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index 9a6c1b5ed..9f10e1b67 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; import com.kaltura.client.Client; -import com.kaltura.client.test.Properties; import com.kaltura.client.test.servicesImpl.SessionServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; @@ -38,7 +37,7 @@ private void getMasterUserSession() { Response getSessionResponse = SessionServiceImpl.get(client, session); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); - assertThat(getSessionResponse.results.getPartnerId()).isEqualTo(Properties.PARTNER_ID); + assertThat(getSessionResponse.results.getPartnerId()).isEqualTo(partnerId); assertThat(getSessionResponse.results.getUserId()).isEqualTo(user.getUserId()); assertThat(getSessionResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(System.currentTimeMillis() / 1000)); assertThat(getSessionResponse.results.getUdid()).isEqualTo(udid); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 2175e1d55..ba7f96e1a 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -17,11 +17,12 @@ import java.util.*; import java.util.concurrent.ThreadLocalRandom; -import static com.kaltura.client.test.Properties.API_URL_VERSION; +import static com.kaltura.client.test.Properties.API_VERSION; +import static com.kaltura.client.test.Properties.getProperty; public class BaseUtils { - private static final String API_SCHEMA_URL = "https://api-preprod.ott.kaltura.com/" + API_URL_VERSION + "/clientlibs/KalturaClient.xml"; + private static final String API_SCHEMA_URL = "https://api-preprod.ott.kaltura.com/" + getProperty(API_VERSION) + "/clientlibs/KalturaClient.xml"; private static List exceptions; // to get e.g. yesterday date in specific date format need call the method so: getOffsetDateInFormat(-1, pattern); diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 3b4aa4615..c759e6f5b 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.utils; -import com.google.gson.JsonArray; import com.kaltura.client.Logger; +import com.kaltura.client.test.tests.BaseTest; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; @@ -108,7 +108,7 @@ public static String getActivationToken(String username) { public static int getEpgChannelId(String channelName) { openConnection(); try { - rs = stam.executeQuery(String.format(EPG_CHANNEL_ID_SELECT, PARTNER_ID + 1, channelName)); + rs = stam.executeQuery(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName)); } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 21a701cc5..637249689 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -11,8 +11,6 @@ import java.util.List; import java.util.Random; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.tests.BaseTest.*; @@ -25,11 +23,11 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO Client client = getClient(null); // create and register - Response masterUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response masterUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); OTTUser masterUser = masterUserResponse.results; // login master user - Response loginResponse = login(client, PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, null); + Response loginResponse = login(client, partnerId, masterUser.getUsername(), defaultUserPassword, null, null); masterUser = loginResponse.results.getUser(); client.setKs(loginResponse.results.getLoginSession().getKs()); @@ -43,7 +41,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO // create, register and add non-master user to household for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { - Response additionalUserResponse = register(client, PARTNER_ID, generateOttUser(), GLOBAL_USER_PASSWORD); + Response additionalUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); OTTUser additionalUser = additionalUserResponse.results; HouseholdUser householdUser = new HouseholdUser(); householdUser.setUserId(additionalUser.getId()); @@ -65,7 +63,7 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO // login as Master with Udid if (numberOfDevicesInHousehold > 0) { List householdDevices = getDevicesListFromHouseHold(household); - OttUserServiceImpl.login(client, PARTNER_ID, masterUser.getUsername(), GLOBAL_USER_PASSWORD, null, householdDevices.get(0).getUdid()); + OttUserServiceImpl.login(client, partnerId, masterUser.getUsername(), defaultUserPassword, null, householdDevices.get(0).getUdid()); } if (isPreparePG) { diff --git a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java index 0d5c000a6..27b4c7313 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java @@ -16,8 +16,7 @@ import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; +import static com.kaltura.client.test.tests.BaseTest.*; import static org.awaitility.Awaitility.await; public class IngestEPGUtils extends BaseUtils { @@ -34,6 +33,7 @@ public class IngestEPGUtils extends BaseUtils { public static final String DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; private static List durationPeriodNames = new ArrayList<>(); + static { durationPeriodNames.add(DURATION_PERIOD_DAYS); durationPeriodNames.add(DURATION_PERIOD_HOURS); @@ -103,9 +103,9 @@ public static Response> ingestEPG(String epgChannelName, Op } seasonId = seasonId + 1; } - String epgChannelIngestXml = getChannelXML(PARTNER_ID, epgChannelName, output); + String epgChannelIngestXml = getChannelXML(partnerId, epgChannelName, output); - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headermap = new HashMap<>(); headermap.put("Content-Type", "text/xml;charset=UTF-8"); headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); @@ -114,7 +114,7 @@ public static Response> ingestEPG(String epgChannelName, Op " \n" + " " + " " + - " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + epgChannelIngestXml + "\n" + " \n" + " \n" + diff --git a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java index e8abe68db..301892c2c 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java @@ -1,12 +1,15 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Logger; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Subscription; import io.restassured.RestAssured; import io.restassured.response.Response; + import java.util.HashMap; import java.util.Optional; + import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.tests.BaseTest.partnerId; import static io.restassured.path.xml.XmlPath.from; public class IngestMPPUtils extends BaseUtils { @@ -23,24 +26,25 @@ public class IngestMPPUtils extends BaseUtils { // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon private static String DEFAULT_COUPON_GROUP_VALUE = "\n" + - "01/05/2017 00:00:00\n" + - "31/12/2099 23:59:59\n" + - "100% unlimited\n" + - "\n" + - "\n" + - "01/05/2017 00:00:00\n" + - "31/05/2017 23:59:59\n" + - "Expired coupon group 1\n" + - ""; + "01/05/2017 00:00:00\n" + + "31/12/2099 23:59:59\n" + + "100% unlimited\n" + + "\n" + + "\n" + + "01/05/2017 00:00:00\n" + + "31/05/2017 23:59:59\n" + + "Expired coupon group 1\n" + + ""; + private static String DEFAULT_PRODUCT_CODES_VALUE = "\n" + - "ProductCode1\n" + - "Google\n" + - "\n" + - "\n" + - "ProductCode2\n" + - "Apple\n" + - ""; + "ProductCode1\n" + + "Google\n" + + "\n" + + "\n" + + "ProductCode2\n" + + "Apple\n" + + ""; // ingest new MPP public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, @@ -62,7 +66,6 @@ public static Subscription ingestMPP(Optional action, Optional m String productCodeValue = productCode.orElse(""); boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); int gracePeriodMinuteValue = gracePeriodMinute.orElse(DEFAULT_GRACE_PERIOD_VALUE); - String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); String pricePlanCode2Value = pricePlanCode2.orElse(""); String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); @@ -73,7 +76,7 @@ public static Subscription ingestMPP(Optional action, Optional m String productCodesValue = productCodes.orElse(DEFAULT_PRODUCT_CODES_VALUE); - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headermap = new HashMap<>(); headermap.put("Content-Type", "text/xml;charset=UTF-8"); headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); @@ -81,12 +84,12 @@ public static Subscription ingestMPP(Optional action, Optional m String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + " \n" + " \n" + ""; @@ -103,7 +106,7 @@ public static Subscription ingestMPP(Optional action, Optional m String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); - url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + url = getProperty(INGEST_REPORT_URL) + "/" + partnerId + "/" + reportId; resp = RestAssured.given() .log().all() .get(url); @@ -137,39 +140,39 @@ private static String buildIngestMppXML(String action, String mppCode, boolean i String pricePlanCode2, String channel1, String channel2, String fileType1, String fileType2, String couponGroup, String productCodes) { return "\n" + - "\n" + - "\n" + - "\n" + - "" + title + "\n" + - "\n" + - "\n" + - "" + description + "" + - "\n" + - "" + startDate + "\n" + - "" + endDate + "\n" + - "" + internalDiscount + "\n" + - "\n" + - "" + productCode + "\n" + - "" + isRenewable + "\n" + - "\n" + - "" + gracePeriodMinute + "\n" + - "\n" + - "" + pricePlanCode1 + "\n" + - "" + pricePlanCode2 + "\n" + - "\n" + - "\n" + - "" + channel1 + "\n" + - "" + channel2 + "\n" + - "\n" + - "\n" + - "" + fileType1 + "\n" + - "" + fileType2 + "\n" + - "\n" + - "\n" + - "" + couponGroup + "\n" + - "" + productCodes + "\n" + - "\n" + - "\n" + + "\n" + + "\n" + + "\n" + + "" + title + "\n" + + "\n" + + "\n" + + "" + description + "" + + "\n" + + "" + startDate + "\n" + + "" + endDate + "\n" + + "" + internalDiscount + "\n" + + "\n" + + "" + productCode + "\n" + + "" + isRenewable + "\n" + + "\n" + + "" + gracePeriodMinute + "\n" + + "\n" + + "" + pricePlanCode1 + "\n" + + "" + pricePlanCode2 + "\n" + + "\n" + + "\n" + + "" + channel1 + "\n" + + "" + channel2 + "\n" + + "\n" + + "\n" + + "" + fileType1 + "\n" + + "" + fileType2 + "\n" + + "\n" + + "\n" + + "" + couponGroup + "\n" + + "" + productCodes + "\n" + + "\n" + + "\n" + "\n"; } } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java index 6ffe8141c..63ee22c09 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java @@ -4,8 +4,10 @@ import com.kaltura.client.types.PricePlan; import io.restassured.RestAssured; import io.restassured.response.Response; + import java.util.HashMap; import java.util.Optional; + import static com.kaltura.client.test.Properties.*; import static io.restassured.path.xml.XmlPath.from; @@ -37,7 +39,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); int recurringPeriodsValue = recurringPeriods.orElse(DEFAULT_RECURRING_PERIODS_VALUE); - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headermap = new HashMap<>(); headermap.put("Content-Type", "text/xml;charset=UTF-8"); headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); @@ -45,7 +47,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + " action, Optional ppCod String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); - url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; resp = RestAssured.given() .log().all() .get(url); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 5c33e8d42..de5dfe933 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -3,10 +3,12 @@ import com.kaltura.client.types.*; import io.restassured.RestAssured; import io.restassured.response.Response; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Optional; + import static com.kaltura.client.test.Properties.*; import static io.restassured.path.xml.XmlPath.from; @@ -44,7 +46,7 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, String secondFileType) { String ppvCode = getRandomValue("PPV_", 9999999999L); - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headermap = new HashMap<>(); headermap.put("Content-Type", "text/xml;charset=UTF-8"); headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); @@ -52,7 +54,7 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + " coguid, boolean isActive, Op String ppvWebNameValue = ppvWebName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value String ppvMobileNameValue = ppvMobileName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value // TODO: check if ingest url is the same for all ingest actions - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headermap = new HashMap<>(); headermap.put("Content-Type", "text/xml;charset=UTF-8"); headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + " \n" + diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 131900df0..8ca0cec20 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -9,10 +9,7 @@ import javax.annotation.Nullable; import java.util.Random; -import static com.kaltura.client.test.Properties.GLOBAL_USER_PASSWORD; -import static com.kaltura.client.test.Properties.PARTNER_ID; -import static com.kaltura.client.test.tests.BaseTest.getAdministratorKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; +import static com.kaltura.client.test.tests.BaseTest.*; public class OttUserUtils extends BaseUtils { @@ -48,7 +45,7 @@ public static OTTUser getUserById(int userId) { public static String getKs(int userId, @Nullable String udid) { Client client = getClient(null); OTTUser ottUser = getUserById(userId); - Response loginResponse = OttUserServiceImpl.login(client, PARTNER_ID, ottUser.getUsername(), GLOBAL_USER_PASSWORD, null, udid); + Response loginResponse = OttUserServiceImpl.login(client, partnerId, ottUser.getUsername(), defaultUserPassword, null, udid); return loginResponse.results.getLoginSession().getKs(); } } diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties new file mode 100644 index 000000000..52c9b63ed --- /dev/null +++ b/src/test/resources/test.template.properties @@ -0,0 +1,11 @@ +# Env Properties +api_base_url=@API_BASE_URL@ +api_version=@API_VERSION@ +ingest_base_url=@INGEST_BASE_URL@ +ingest_report_url=@INGEST_REPORT_URL@ +partner_id=@PARTNER_ID@ + +# DB Properties +db_url=@DB_URL@ +db_user=@DB_USER@ +db_password=@DB_PASSWORD@ \ No newline at end of file From d54a86a2ff9897032662033e62adbdb635d82fc2 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 26 Apr 2018 11:16:43 +0300 Subject: [PATCH 136/605] Added package for featuresTests. --- .../productPriceTests/ListTests.java | 84 +++++++++++++++++++ .../productPriceTests/ListTests.java | 72 +--------------- .../client/test/utils/IngestVODUtils.java | 3 +- src/test/resources/testng.xml | 1 + 4 files changed, 90 insertions(+), 70 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java new file mode 100644 index 000000000..969ff92dd --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java @@ -0,0 +1,84 @@ +package com.kaltura.client.test.tests.featuresTests.productPriceTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.*; +import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; +import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; + +public class ListTests extends BaseTest { + + private Client client; + private EntitlementFilter entitlementPpvsFilter; + + @BeforeClass + public void beforeClass() { + client = getClient(getOperatorKs()); + + entitlementPpvsFilter = new EntitlementFilter(); + entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); + entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); + entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + entitlementPpvsFilter.setIsExpiredEqual(false); + + /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), + Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, + getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ + + /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), + Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); + System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ + } + + @Description("productPrice/action/list - ppv test") + @Test() + public void ppvTest() { + // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType + client.setKs(getsharedMasterUserKs()); + + Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); + assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + int webMediaFileId = getSharedMediaAsset().getMediaFiles().get(0).getId(); + int mobileMediaFileId = getSharedMediaAsset().getMediaFiles().get(1).getId(); + ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); + ppFilter.setIsLowest(false); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); + // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) + assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); + + PurchaseUtils.purchasePpv(client, Optional.empty(), Optional.of(webMediaFileId)); + + Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); + assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) + .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); + + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + + Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); + + ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); + Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 61fa7f431..eb29cda3e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -2,18 +2,14 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.*; -import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; -import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; -import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; import static com.kaltura.client.test.Properties.CURRENCY_EUR; import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; @@ -22,32 +18,18 @@ public class ListTests extends BaseTest { private Client client; - private EntitlementFilter entitlementPpvsFilter; @BeforeClass public void beforeClass() { client = getClient(getOperatorKs()); - entitlementPpvsFilter = new EntitlementFilter(); - entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); - entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); - entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - entitlementPpvsFilter.setIsExpiredEqual(false); + /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), + Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, + getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ - - /*Subscription subscription = IngestMPPUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of("Camilo 5 min renews 4.99"), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.of(""), Optional.empty()); - Logger.getLogger(ListTests.class).debug("ID: " + subscription.getId());*/ - - /* PricePlan pricePlan = IngestPPUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty()); - Logger.getLogger(ListTests.class).debug("ID: " + pricePlan.getId());*/ } @Description("productPrice/action/list - subscription test by Operator without currency") @@ -87,54 +69,6 @@ public void list_without_required_fields() { "One of the arguments [KalturaProductPriceFilter.subscriptionIdIn, KalturaProductPriceFilter.fileIdIn, KalturaProductPriceFilter.collectionIdIn] must have a value"); } - @Description("productPrice/action/list - ppv test") - @Test() - public void ppvTest() { - /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), - Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, - getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ - - // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType - client.setKs(getsharedMasterUserKs()); - - Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); - assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); - - ProductPriceFilter ppFilter = new ProductPriceFilter(); - int webMediaFileId = getSharedMediaAsset().getMediaFiles().get(0).getId(); - int mobileMediaFileId = getSharedMediaAsset().getMediaFiles().get(1).getId(); - ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); - ppFilter.setIsLowest(false); - Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); - // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) - assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - - PurchaseUtils.purchasePpv(client, Optional.empty(), Optional.of(webMediaFileId)); - - Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); - assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) - .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); - - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); - - Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - - ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); - Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); - } - @Description("productPrice/action/list - common test for PPV and subscription to check before purchase") @Test() public void productPriceSubscriptionAndPpvBeforePurchaseTest() { diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index a85b84e20..cfb2f9bb1 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -104,7 +104,8 @@ private static String buildIngestVodXml(String coguid, boolean isActive, String " " + mediaType + "\n" + " \n" + //" ${#TestCase#i_geo_block_rule}\n" + - //" Parent Allowed\n" + + // TODO: check where to put that value (is it env-dependent?) + " Parent Allowed\n" + //" ${#TestCase#i_device_block_rule}\n" + " \n" + " \n" + diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index f7baf6cbe..c49991c68 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -10,6 +10,7 @@ + From 953bda4ebcb15ad0f18f8d731377d65e1c2aec91 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 26 Apr 2018 12:55:51 +0300 Subject: [PATCH 137/605] Refactored assetHistoryActionListTests class --- .../AssetHistoryListTests.java | 141 ++++++++++-------- 1 file changed, 75 insertions(+), 66 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index ae58f3509..b55c92869 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -14,24 +14,14 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; import java.util.Optional; -import static com.kaltura.client.test.Properties.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.Properties.*; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { private Client client; - private long movieAssetId; - private int movieFileId; - private long episodeAssetId; - private int episodeFileId; - private AssetType assetType; - private BookmarkActionType actionType; - - // instantiate Bookmark object - private Bookmark bookmark = new Bookmark(); + private AssetType assetType = AssetType.MEDIA; @BeforeClass private void add_tests_before_class() { @@ -42,92 +32,111 @@ private void add_tests_before_class() { @Test private void vodAssetHistory() { - // Ingest movie vod asset - movieAssetId = BaseTest.getSharedMediaAsset().getId(); - movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movieAssetId)).get(0); - - // Ingest episode vod asset - MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(EPISODE_MEDIA_TYPE)), Optional.empty(), Optional.empty()); - episodeAssetId = mediaAsset.getId(); - episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episodeAssetId)).get(0); + int asset1Position = 10; + int asset2Position = 20; - // Movie asset bookmark - int position1 = 10; - actionType = BookmarkActionType.FIRST_PLAY; - assetType = AssetType.MEDIA; - bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movieAssetId), movieFileId, assetType, actionType); - //bookmark/action/add - Movie asset - BookmarkServiceImpl.add(client, bookmark); - - // Episode asset bookmark - int position2 = 20; - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episodeAssetId), episodeFileId, assetType, actionType); - //bookmark/action/add - Episode asset - BookmarkServiceImpl.add(client, bookmark); + // Ingest and bookmark first asset + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,asset1Position,BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset + Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,asset2Position,BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); - - //assetHistory/action/list - both assets (episode and movie) should returned + //assetHistory/action/list - both assets should returned Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + // First object AssetHistory assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); // Second object AssetHistory assetHistoryObject2 = assetHistoryListResponse.results.getObjects().get(1); - // Assertions for first object returned (movie asset) - assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movieAssetId); + // Assertions for first object returned + assertThat(assetHistoryObject1.getAssetId()).isEqualTo(assetId2); assertThat(assetHistoryObject1.getAssetType()).isEqualTo(assetType); - assertThat(assetHistoryObject1.getPosition()).isEqualTo(position1); + assertThat(assetHistoryObject1.getPosition()).isEqualTo(asset2Position); assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); // Verify that flag is set to false (user hasn't finish watching the asset) assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); - // Assertions for second object returned (episode asset) - assertThat(assetHistoryObject2.getAssetId()).isEqualTo(episodeAssetId); + // Assertions for second object returned + assertThat(assetHistoryObject2.getAssetId()).isEqualTo(assetId1); assertThat(assetHistoryObject2.getAssetType()).isEqualTo(assetType); - assertThat(assetHistoryObject2.getPosition()).isEqualTo(position2); + assertThat(assetHistoryObject2.getPosition()).isEqualTo(asset1Position); // Assert total count = 2 (two bookmarks) assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); + } + + @Description("/AssetHistory/action/list -filtered by movie asset id") + @Test + private void vodAssetHistoryFilteredByAssetId() { + // Ingest and bookmark first asset + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset + Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId2), null, WatchStatus.ALL, null); + //assetHistory/action/list - filter by asset 2 id + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); } @Description("/AssetHistory/action/list -filtered by movie type id") @Test - private void vodAssetHistoryFiltered() { + private void vodAssetHistoryFilteredByAssetType() { - // Ingest movie vod asset - movieAssetId = BaseTest.getSharedMediaAsset().getId(); - movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movieAssetId)).get(0); + // Ingest and bookmark first asset (movie in first play) + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset (movie in finish action) + Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); - // Ingest episode vod asset - MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(EPISODE_MEDIA_TYPE)), Optional.empty(), Optional.empty()); - episodeAssetId = mediaAsset.getId(); - episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episodeAssetId)).get(0); + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, MOVIE_MEDIA_TYPE_ID); + //assetHistory/action/list - filter by in progress assets only + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + } - // Movie asset bookmark - int position1 = 10; - actionType = BookmarkActionType.FIRST_PLAY; - assetType = AssetType.MEDIA; - bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movieAssetId), movieFileId, assetType, actionType); - //bookmark/action/add - Movie asset - BookmarkServiceImpl.add(client, bookmark); - // Episode asset bookmark - int position2 = 20; - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episodeAssetId), episodeFileId, assetType, actionType); - //bookmark/action/add - Episode asset - BookmarkServiceImpl.add(client, bookmark); + @Description("/AssetHistory/action/list -filtered by assets in progress") + @Test + private void vodAssetHistoryFilteredByAssetProgress() { + // Ingest and bookmark first asset (movie in first play) + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset (movie in finish action) + Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE,100,BookmarkActionType.FINISH); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movieAssetId), null, WatchStatus.ALL, null); + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); - //assetHistory/action/list - 1111 + //assetHistory/action/list - filter by in progress assets only Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); - + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + + assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); + //assetHistory/action/list - filter by finished assets only + assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); } + + + // Ingest asset, bookmark it and return the asset id + private Long ingestAssetAndPerformBookmark(String mediaType, int position, BookmarkActionType bookmarkActionType) { + // Ingest asset + MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); + Long assetId = mediaAsset.getId(); + int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + // Movie asset bookmark + assetType = AssetType.MEDIA; + Bookmark bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, assetType, bookmarkActionType); + //bookmark/action/add - Movie asset + BookmarkServiceImpl.add(client, bookmark); + + return assetId; + } } From 687cc69f12c0022477c3c2444c1eb55087b72b9c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 26 Apr 2018 12:56:32 +0300 Subject: [PATCH 138/605] added Sandbox class to gitignore --- .gitignore | 2 +- .../servicesTests/entitlementTests/GrantTests.java | 11 ++++++++--- .../tests/servicesTests/ottUserTests/LoginTests.java | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 89d303ead..bb5e892b7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ build *.iml .gradle target/ -src/test/java/resources/test.properties allure-results/ .allure/ log4j.log src/test/resources/test.properties +src/test/java/com/kaltura/client/test/tests/Sandbox.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index fa8e848fe..69e5ebebc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -14,6 +14,7 @@ import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; @@ -26,11 +27,15 @@ public class GrantTests extends BaseTest { private final int ppvId = 30297; private final int assetId = 607368; - private int contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); - private Response> billingTransactionListResponse; + private int contentId; + @BeforeClass + private void grant_test_before_class() { + contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + } + @Test(description = "entitlement/action/grant - grant subscription with history = true") private void grant_subscription_with_history() { Client client = getClient(getAdministratorKs()); @@ -259,7 +264,7 @@ private void grant_ppv_with_wrong_id() { client.setUserId(Integer.valueOf(user.getUserId())); Response booleanResponse = EntitlementServiceImpl.grant(client, 1, TransactionType.PPV, true, contentId); - assertThat(booleanResponse.results.booleanValue()).isEqualTo(null); + assertThat(booleanResponse.results).isEqualTo(null); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index ecdceaae6..821f89a01 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -48,13 +48,13 @@ private void login_with_wrong_password() { assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); } - @Description("ottUser/action/login - login with wrong username - error 2000") + @Description("ottUser/action/login - login with wrong username - error 1011") @Test private void login_with_wrong_username() { loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername() + "1", defaultUserPassword, null, null); assertThat(loginResponse.results).isNull(); - assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); } @Description("ottUser/action/login - login with wrong partnerId - error 500006") From d60fc6c8ea46925d5333533ae1f16fec2950f717 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 26 Apr 2018 13:49:03 +0300 Subject: [PATCH 139/605] created IngestProperties.java extended from Properties.java --- .../kaltura/client/test/IngestProperties.java | 38 ++++++++++ .../com/kaltura/client/test/Properties.java | 34 +-------- .../kaltura/client/test/tests/BaseTest.java | 5 +- .../productPriceTests/ListTests.java | 63 +---------------- .../productPriceTests/ListTests.java | 69 +++++++++++++++++-- .../client/test/utils/IngestEPGUtils.java | 22 +++--- .../client/test/utils/IngestMPPUtils.java | 13 ++-- .../client/test/utils/IngestPPUtils.java | 23 +++---- .../client/test/utils/IngestPPVUtils.java | 60 +++++++--------- .../client/test/utils/IngestVODUtils.java | 36 ++++++---- 10 files changed, 179 insertions(+), 184 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/IngestProperties.java diff --git a/src/test/java/com/kaltura/client/test/IngestProperties.java b/src/test/java/com/kaltura/client/test/IngestProperties.java new file mode 100644 index 000000000..1321d8d91 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/IngestProperties.java @@ -0,0 +1,38 @@ +package com.kaltura.client.test; + +public class IngestProperties extends Properties { + + public static final String INGEST_ACTION_INSERT = "insert"; + public static Long MAX_RANDOM_GENERATED_VALUE_4_INGEST = 9999999999L; + public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + + // file types + public static final String WEB_FILE_TYPE = "web_file_type"; + public static final String MOBILE_FILE_TYPE = "mobile_file_type"; + + // ingest + public static final String INGEST_USER_NAME = "ingest_user_username"; + public static final String INGEST_USER_PASSWORD = "ingest_user_password"; + public static final String INGEST_BUSINESS_MODULE_USER_NAME = "ingest_business_module_user_username"; + public static final String INGEST_BUSINESS_MODULE_USER_PASSWORD = "ingest_business_module_user_password"; + + // channels + public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" + + // price codes + public static final String PRICE_CODE_AMOUNT_4_99 = "price_code_amount_4_99"; // 4.99 + + // usage modules + public static final String DEFAULT_USAGE_MODULE_4_INGEST_PPV = "default_usage_module_4_ingest_ppv"; // module has 10 Minutes life cycles, 0 maximum views + public static final String DEFAULT_USAGE_MODULE_4_INGEST_MPP = "default_usage_module_4_ingest_mpp"; // module has 1 Day life cycles, 0 maximum views + + // product codes + public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; + + // discount modules + public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; + public static final String HUNDRED_PERCENTS_UKP_DISCOUNT_NAME = "hundred_percents_ukp_discount_name"; + + // life cycles periods + public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; +} diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index e72425cda..2c7852d40 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -39,38 +39,9 @@ public class Properties { public static final String EPISODE_MEDIA_TYPE = "Episode"; public static final String LINEAR_MEDIA_TYPE = "Linear"; - // file types - public static final String WEB_FILE_TYPE = "web_file_type"; - public static final String MOBILE_FILE_TYPE = "mobile_file_type"; - - // ingest - public static final String INGEST_USER_NAME = "ingest_user_username"; - public static final String INGEST_USER_PASSWORD = "ingest_user_password"; - public static final String INGEST_BUSINESS_MODULE_USER_NAME = "ingest_business_module_user_username"; - public static final String INGEST_BUSINESS_MODULE_USER_PASSWORD = "ingest_business_module_user_password"; - - public static final String INGEST_ACTION_INSERT = "insert"; - - public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - - // channels - public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" - - // price codes - public static final String AMOUNT_4_99_EUR = "amount_4_99_eur"; // 4.99 + // currencies public static final String CURRENCY_EUR = "EUR"; - // usage modules - public static final String DEFAULT_USAGE_MODULE_4_INGEST_PPV = "default_usage_module_4_ingest_ppv"; // module has 10 Minutes life cycles, 0 maximum views - public static final String DEFAULT_USAGE_MODULE_4_INGEST_MPP = "default_usage_module_4_ingest_mpp"; // module has 1 Day life cycles, 0 maximum views - - // product codes - public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; - - // discount modules - public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; - public static final String HUNDRED_PERCENTS_UKP_DISCOUNT_NAME = "hundred_percents_ukp_discount_name"; - // PG adapter data public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; @@ -81,9 +52,6 @@ public class Properties { public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; public static final String PG_DEFAULT_PG_SETTINGS = "{}"; - // life cycles periods - public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; - public static String getProperty(String propertyKey) { if (resourceBundle == null) resourceBundle = ResourceBundle.getBundle("test"); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 2872747c6..13c9b0d32 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -8,12 +8,11 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; - import java.util.List; import java.util.Optional; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.IngestProperties.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; @@ -176,7 +175,7 @@ public static Subscription get5MinRenewableSubscription() { if (fiveMinRenewableSubscription == null) { PricePlan pricePlan = IngestPPUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), - Optional.of(getProperty(AMOUNT_4_99_EUR)), Optional.of(CURRENCY_EUR), Optional.of(""), + Optional.of(getProperty(PRICE_CODE_AMOUNT_4_99)), Optional.of(CURRENCY_EUR), Optional.of(""), Optional.of(true), Optional.of(3)); fiveMinRenewableSubscription = IngestMPPUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java index 969ff92dd..b61404115 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java @@ -1,84 +1,23 @@ package com.kaltura.client.test.tests.featuresTests.productPriceTests; import com.kaltura.client.Client; -import com.kaltura.client.enums.*; -import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; -import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.PurchaseUtils; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.Response; -import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import java.util.Optional; -import static org.assertj.core.api.Assertions.assertThat; public class ListTests extends BaseTest { private Client client; - private EntitlementFilter entitlementPpvsFilter; @BeforeClass public void beforeClass() { client = getClient(getOperatorKs()); - entitlementPpvsFilter = new EntitlementFilter(); - entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); - entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); - entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - entitlementPpvsFilter.setIsExpiredEqual(false); - /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), - Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, + Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ } - - @Description("productPrice/action/list - ppv test") - @Test() - public void ppvTest() { - // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType - client.setKs(getsharedMasterUserKs()); - - Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); - assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); - - ProductPriceFilter ppFilter = new ProductPriceFilter(); - int webMediaFileId = getSharedMediaAsset().getMediaFiles().get(0).getId(); - int mobileMediaFileId = getSharedMediaAsset().getMediaFiles().get(1).getId(); - ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); - ppFilter.setIsLowest(false); - Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); - // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) - assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - - PurchaseUtils.purchasePpv(client, Optional.empty(), Optional.of(webMediaFileId)); - - Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); - assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) - .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); - - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); - - Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - - ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); - Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); - } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index eb29cda3e..9b90798d7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -2,14 +2,19 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.*; +import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; +import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.IngestEPGUtils; import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Optional; import static com.kaltura.client.test.Properties.CURRENCY_EUR; import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; @@ -18,13 +23,20 @@ public class ListTests extends BaseTest { private Client client; + private EntitlementFilter entitlementPpvsFilter; @BeforeClass public void beforeClass() { client = getClient(getOperatorKs()); + entitlementPpvsFilter = new EntitlementFilter(); + entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); + entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); + entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + entitlementPpvsFilter.setIsExpiredEqual(false); + /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), - Double.valueOf(getProperty(AMOUNT_4_99_EUR)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, + Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), @@ -34,7 +46,7 @@ public void beforeClass() { @Description("productPrice/action/list - subscription test by Operator without currency") @Test(enabled = false) // as used in feature tests - public void list_subscription() { + public void listSubscription() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); Response> productPriceList = list(client, filter); @@ -59,20 +71,67 @@ public void listSubscriptionWithCurrencyTest() { @Description("productPrice/action/list - without required fields (subscriptionIdIn, collectionIdIn and fileIdIn are empty)") @Test() - public void list_without_required_fields() { + public void listWithoutRequiredFields() { ProductPriceFilter filter = new ProductPriceFilter(); Response> productPriceResponse = list(client, filter); + int errorCode = 500056; assertThat(productPriceResponse.results).isNull(); - assertThat(productPriceResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500056).getCode()); + assertThat(productPriceResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(errorCode).getCode()); assertThat(productPriceResponse.error.getMessage()).isEqualToIgnoringCase( "One of the arguments [KalturaProductPriceFilter.subscriptionIdIn, KalturaProductPriceFilter.fileIdIn, KalturaProductPriceFilter.collectionIdIn] must have a value"); } + @Description("productPrice/action/list - ppv test") + @Test() + public void ppvTest() { + // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType + client.setKs(getsharedMasterUserKs()); + + Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); + assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + int webMediaFileId = getSharedMediaAsset().getMediaFiles().get(0).getId(); + int mobileMediaFileId = getSharedMediaAsset().getMediaFiles().get(1).getId(); + ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); + ppFilter.setIsLowest(false); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); + // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) + assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); + + PurchaseUtils.purchasePpv(client, Optional.empty(), Optional.of(webMediaFileId)); + + Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); + assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); + assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) + .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); + + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + + Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); + + ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); + Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); + } + @Description("productPrice/action/list - common test for PPV and subscription to check before purchase") @Test() public void productPriceSubscriptionAndPpvBeforePurchaseTest() { - Household household = HouseholdUtils.createHouseHold(1, 1, true); + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHouseHold(numberOfUsers, numberOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); client.setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null)); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java index 0d5c000a6..9af2b6f96 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java @@ -8,14 +8,12 @@ import com.kaltura.client.types.SearchAssetFilter; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; - -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.IngestProperties.*; import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; import static com.kaltura.client.test.tests.BaseTest.getClient; import static org.awaitility.Awaitility.await; @@ -106,9 +104,9 @@ public static Response> ingestEPG(String epgChannelName, Op String epgChannelIngestXml = getChannelXML(PARTNER_ID, epgChannelName, output); String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); String reqBody = "\n" + " \n" + " \n" + @@ -123,7 +121,7 @@ public static Response> ingestEPG(String epgChannelName, Op ""; io.restassured.response.Response resp = RestAssured.given() .log().all() - .headers(headermap) + .headers(headerMap) .body(reqBody) .post(url); //System.out.println("RESPONSE: " + resp.asString()); @@ -132,7 +130,7 @@ public static Response> ingestEPG(String epgChannelName, Op long epoch = 0L; try { Date firstProgramStartDateAsDate = dateFormat.parse(firstProgramStartDateValue); - epoch = firstProgramStartDateAsDate.getTime()/1000; + epoch = firstProgramStartDateAsDate.getTime()/1000; // 1000 milliseconds in 1 second } catch (ParseException e) { e.printStackTrace(); } @@ -141,15 +139,17 @@ public static Response> ingestEPG(String epgChannelName, Op SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); - await().pollInterval(3, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS) - .until(isDataReturned(epgChannelId, assetFilter, programCountValue*seasonCountValue)); + int delayBetweenRetriesInSeconds = 3; + int maxTimeExpectingValidResponseInSeconds = 60; + await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(isDataReturned(assetFilter, programCountValue*seasonCountValue)); Response> ingestedProgrammes = AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null); // TODO: complete Asset.json at least for programs return ingestedProgrammes; } - private static Callable isDataReturned(int epgChannelId, SearchAssetFilter assetFilter, int totalCount) { + private static Callable isDataReturned(SearchAssetFilter assetFilter, int totalCount) { return () -> (AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).error == null && AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).results.getTotalCount() == totalCount); } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java index e8abe68db..6e183358f 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java @@ -6,12 +6,11 @@ import io.restassured.response.Response; import java.util.HashMap; import java.util.Optional; -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.IngestProperties.*; import static io.restassured.path.xml.XmlPath.from; public class IngestMPPUtils extends BaseUtils { - private static String DEFAULT_ACTION_VALUE = "insert"; private static boolean DEFAULT_IS_ACTIVE_VALUE = true; private static String DEFAULT_TITLE_VALUE = "Ingest MPP title"; private static String DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; @@ -52,7 +51,7 @@ public static Subscription ingestMPP(Optional action, Optional m Optional channel2, Optional fileType1, Optional fileType2, Optional couponGroup, Optional productCodes) { String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); - String actionValue = action.orElse(DEFAULT_ACTION_VALUE); + String actionValue = action.orElse(INGEST_ACTION_INSERT); boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); String titleValue = title.orElse(DEFAULT_TITLE_VALUE); String descriptionValue = description.orElse(DEFAULT_DESCRIPTION_VALUE); @@ -74,9 +73,9 @@ public static Subscription ingestMPP(Optional action, Optional m String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); String reqBody = "\n" + " \n" + @@ -93,7 +92,7 @@ public static Subscription ingestMPP(Optional action, Optional m Response resp = RestAssured.given() .log().all() - .headers(headermap) + .headers(headerMap) .body(reqBody) .post(url); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java index a28306f47..f894a007a 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java @@ -6,15 +6,12 @@ import io.restassured.response.Response; import java.util.HashMap; import java.util.Optional; -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.IngestProperties.*; import static io.restassured.path.xml.XmlPath.from; public class IngestPPUtils extends BaseUtils { - private static String DEFAULT_ACTION_VALUE = "insert"; private static boolean DEFAULT_IS_ACTIVE_VALUE = true; - private static String DEFAULT_FULL_LIFE_CYCLE_VALUE = "5 Minutes"; - private static String DEFAULT_VIEW_LIFE_CYCLE_VALUE = "5 Minutes"; private static int DEFAULT_MAX_VIEWS_VALUE = 0; private static boolean DEFAULT_IS_RENEWABLE_VALUE = false; private static int DEFAULT_RECURRING_PERIODS_VALUE = 1; @@ -25,22 +22,22 @@ public static PricePlan ingestPP(Optional action, Optional ppCod Optional price, Optional currency, Optional discount, Optional isRenewable, Optional recurringPeriods) { - String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", 9999999999L)); - String actionValue = action.orElse(DEFAULT_ACTION_VALUE); + String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); + String actionValue = action.orElse(INGEST_ACTION_INSERT); boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); - String fullLifeCycleValue = fullLifeCycle.orElse(DEFAULT_FULL_LIFE_CYCLE_VALUE); - String viewLifeCycleValue = viewLifeCycle.orElse(DEFAULT_VIEW_LIFE_CYCLE_VALUE); + String fullLifeCycleValue = fullLifeCycle.orElse(FIVE_MINUTES_PERIOD); + String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); int maxViewsValue = maxViews.orElse(DEFAULT_MAX_VIEWS_VALUE); - String priceValue = price.orElse(getProperty(AMOUNT_4_99_EUR)); + String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT_4_99)); String currencyValue = currency.orElse(CURRENCY_EUR); String discountValue = discount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); int recurringPeriodsValue = recurringPeriods.orElse(DEFAULT_RECURRING_PERIODS_VALUE); String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); String reqBody = "\n" + " \n" + @@ -56,7 +53,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod Response resp = RestAssured.given() .log().all() - .headers(headermap) + .headers(headerMap) .body(reqBody) .post(url); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 5c33e8d42..9070fcf0a 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -7,23 +7,24 @@ import java.util.HashMap; import java.util.List; import java.util.Optional; -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.IngestProperties.*; import static io.restassured.path.xml.XmlPath.from; public class IngestPPVUtils extends BaseUtils { - - // way to ingest PPV using predefined default values for any of input parameters - public static Ppv ingestPPVWithDefaultValues(Optional action, Optional isActive, Optional description, - Optional discount, Optional price, Optional currency, - Optional usageModule, Optional isSubscriptionOnly, - Optional isFirstDeviceLimitation, Optional productCode, - Optional firstFileType, Optional secondFileType) { - String actionValue = action.orElse("insert"); + // ingest new PPV + public static Ppv ingestPPV(Optional action, Optional isActive, Optional description, + Optional discount, Optional price, Optional currency, + Optional usageModule, Optional isSubscriptionOnly, + Optional isFirstDeviceLimitation, Optional productCode, + Optional firstFileType, Optional secondFileType) { + String ppvCode = getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST); + + String actionValue = action.orElse(INGEST_ACTION_INSERT); boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; String descriptionValue = description.orElse("My ingest PPV"); String discountValue = discount.orElseGet(() -> getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); - double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(AMOUNT_4_99_EUR))); + double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99))); String currencyValue = currency.orElseGet(() -> getProperty(CURRENCY_EUR)); String usageModuleValue = usageModule.orElseGet(() -> getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; @@ -32,37 +33,26 @@ public static Ppv ingestPPVWithDefaultValues(Optional action, Optional getProperty(WEB_FILE_TYPE)); String secondFileTypeValue = secondFileType.orElseGet(() -> getProperty(MOBILE_FILE_TYPE)); - return ingestPPV(actionValue, isActiveValue, descriptionValue, discountValue, priceValue, currencyValue, - usageModuleValue, isSubscriptionOnlyValue, isFirstDeviceLimitationValue, productCodeValue, - firstFileTypeValue, secondFileTypeValue); - } - - // ingest new PPV - public static Ppv ingestPPV(String action, boolean isActive, String description, String discount, - double price, String currency, String usageModule, boolean isSubscriptionOnly, - boolean isFirstDeviceLimitation, String productCode, String firstFileType, - String secondFileType) { - String ppvCode = getRandomValue("PPV_", 9999999999L); - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); String reqBody = "\n" + " \n" + " \n" + " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + " \n" + ""; Response resp = RestAssured.given() .log().all() - .headers(headermap) + .headers(headerMap) .body(reqBody) .post(url); @@ -83,21 +73,21 @@ public static Ppv ingestPPV(String action, boolean isActive, String description, ppv.setId(id); List descriptions = new ArrayList<>(); TranslationToken translationToken = new TranslationToken(); - translationToken.setValue(description); + translationToken.setValue(descriptionValue); descriptions.add(translationToken); ppv.setDescriptions(descriptions); PriceDetails priceDetails = new PriceDetails(); Price priceObj = new Price(); - priceObj.setAmount(price); - priceObj.setCurrency(currency); + priceObj.setAmount(priceValue); + priceObj.setCurrency(currencyValue); priceDetails.setPrice(priceObj); ppv.setPrice(priceDetails); UsageModule usageModuleObj = new UsageModule(); - usageModuleObj.setName(usageModule); + usageModuleObj.setName(usageModuleValue); ppv.setUsageModule(usageModuleObj); - ppv.setIsSubscriptionOnly(isSubscriptionOnly); - ppv.setFirstDeviceLimitation(isFirstDeviceLimitation); - ppv.setProductCode(productCode); + ppv.setIsSubscriptionOnly(isSubscriptionOnlyValue); + ppv.setFirstDeviceLimitation(isFirstDeviceLimitationValue); + ppv.setProductCode(productCodeValue); return ppv; } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index cfb2f9bb1..b209517b9 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -6,13 +6,11 @@ import com.kaltura.client.types.MediaAsset; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; - import java.util.HashMap; import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; - -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.IngestProperties.*; import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; import static com.kaltura.client.test.tests.BaseTest.getClient; import static io.restassured.path.xml.XmlPath.from; @@ -24,22 +22,28 @@ public class IngestVODUtils extends BaseUtils { public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); + String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; + String coguidDatePattern = "yyMMddHHmmssSS"; + String maxEndDateValue = "14/10/2099 17:00:00"; + String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value + int defaultDayOffset =-1; + + String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat(coguidDatePattern)); String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); String descriptionValue = description.orElseGet(() -> "description of " + coguidValue); - String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); - String catalogEndDateValue = catalogEndDate.orElse("14/10/2099 17:00:00"); - String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); - String endDateValue = endDate.orElse("14/10/2099 17:00:00"); + String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); + String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String endDateValue = endDate.orElse(maxEndDateValue); String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); - String ppvWebNameValue = ppvWebName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value - String ppvMobileNameValue = ppvMobileName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value + String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); + String ppvMobileNameValue = ppvMobileName.orElse(ppvModuleName); // TODO: check if ingest url is the same for all ingest actions String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); String reqBody = "\n" + " \n" + " \n" + @@ -51,7 +55,7 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op ""; io.restassured.response.Response resp = RestAssured.given() .log().all() - .headers(headermap) + .headers(headerMap) .body(reqBody) .post(url); //System.out.println("RESPONSE: " + resp.asString()); @@ -64,7 +68,9 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); - await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(id)); + int delayBetweenRetriesInSeconds = 3; + int maxTimeExpectingValidResponseInSeconds = 45; + await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(id)); Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); From 0fe7669b7b21b76ebca2dc9e4536846585cec30c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 26 Apr 2018 14:13:14 +0300 Subject: [PATCH 140/605] Added new util to base util + added new class to assethistoryTests package + updated bookmarkTests classes --- .../com/kaltura/client/test/Properties.java | 4 +-- .../AssetHistoryActionCleanLists.java | 4 +++ .../AssetHistoryListTests.java | 30 ++++++++++++------- .../bookmarkTests/BookmarkAddTests.java | 10 +++---- .../bookmarkTests/BookmarkListTests.java | 6 ---- .../kaltura/client/test/utils/BaseUtils.java | 10 +++++++ 6 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index fe0f8648c..2b58ea003 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -40,8 +40,8 @@ public class Properties { public static final String LINEAR_MEDIA_TYPE = "Linear"; // media types ids - public static final Long MOVIE_MEDIA_TYPE_ID = 425L; - public static final Long EPISODE_MEDIA_TYPE_ID = 426L; + public static final String MOVIE_MEDIA_TYPE_ID = "425"; + public static final String EPISODE_MEDIA_TYPE_ID = "426"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java new file mode 100644 index 000000000..afa27c524 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -0,0 +1,4 @@ +package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; + +public class AssetHistoryActionCleanLists { +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index b55c92869..7939d87f3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; import com.kaltura.client.Client; +import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; @@ -36,9 +37,9 @@ private void vodAssetHistory() { int asset2Position = 20; // Ingest and bookmark first asset - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,asset1Position,BookmarkActionType.FIRST_PLAY); + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, asset1Position, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,asset2Position,BookmarkActionType.FIRST_PLAY); + Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, asset2Position, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); //assetHistory/action/list - both assets should returned @@ -72,15 +73,25 @@ private void vodAssetHistory() { private void vodAssetHistoryFilteredByAssetId() { // Ingest and bookmark first asset - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId3 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId2), null, WatchStatus.ALL, null); //assetHistory/action/list - filter by asset 2 id Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + + String concatenatedString = BaseUtils.getConcatenatedString(String.valueOf(assetId2),String.valueOf(assetId3)); + + //assetHistory/action/list - filter by asset 2 and asset 3 ids + assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, + null, WatchStatus.ALL, null); + assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId3); + assertThat(assetHistoryListResponse.results.getObjects().get(1).getAssetId()).isEqualTo(assetId2); } @Description("/AssetHistory/action/list -filtered by movie type id") @@ -88,9 +99,9 @@ private void vodAssetHistoryFilteredByAssetId() { private void vodAssetHistoryFilteredByAssetType() { // Ingest and bookmark first asset (movie in first play) - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, MOVIE_MEDIA_TYPE_ID); //assetHistory/action/list - filter by in progress assets only @@ -100,13 +111,13 @@ private void vodAssetHistoryFilteredByAssetType() { } - @Description("/AssetHistory/action/list -filtered by assets in progress") + @Description("/AssetHistory/action/list -filtered by assets progress") @Test private void vodAssetHistoryFilteredByAssetProgress() { // Ingest and bookmark first asset (movie in first play) - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE,10,BookmarkActionType.FIRST_PLAY); + Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE,100,BookmarkActionType.FINISH); + Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); @@ -123,7 +134,6 @@ private void vodAssetHistoryFilteredByAssetProgress() { } - // Ingest asset, bookmark it and return the asset id private Long ingestAssetAndPerformBookmark(String mediaType, int position, BookmarkActionType bookmarkActionType) { // Ingest asset diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index a37ff88fb..f18988dc4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -122,8 +122,8 @@ private void watchingNinetyFive() { assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse3 = BookmarkServiceImpl.list(client, bookmarkFilter); - Bookmark bookmark3 = bookmarkListResponse3.results.getObjects().get(0); + Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); + Bookmark bookmark3 = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = true assertThat(bookmark3.getFinishedWatching()).isTrue(); @@ -139,10 +139,10 @@ private void backToStart() { Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); assertThat(booleanResponse.results.booleanValue()).isTrue(); - Response> bookmarkListResponse4 = BookmarkServiceImpl.list(client, bookmarkFilter); - Bookmark bookmark4 = bookmarkListResponse4.results.getObjects().get(0); + Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); + Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = false - assertThat(bookmark4.getFinishedWatching()).isFalse(); + assertThat(bookmark.getFinishedWatching()).isFalse(); } @Description("bookmark/action/add - finish watching") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index 7e5922a63..c883bc823 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -70,9 +70,6 @@ private void BookmarkOrderBy() { Bookmark bookmarkObject = bookmarkListResponse.results.getObjects().get(0); Bookmark bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); - // Assertions - // ************************************* - // Verify that asset2 returned first (bookmark/action/list is response is ordered by POSITION DESC) assertThat( bookmarkObject.getId()).isEqualTo(String.valueOf(assetId2)); assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId)); @@ -83,9 +80,6 @@ private void BookmarkOrderBy() { bookmarkObject = bookmarkListResponse.results.getObjects().get(0); bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); - // Assertions - // ************************************* - // Verify that asset1 returned first (bookmark/action/list is response is ordered by POSITION DESC) assertThat( bookmarkObject.getId()).isEqualTo(String.valueOf(assetId)); assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId2)); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 2175e1d55..ff3311fd0 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.types.APIException; +import com.kaltura.client.types.Collection; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -124,4 +125,13 @@ private static List getApiExceptionList() { } return exceptions; } + + // Get concatenated string + public static String getConcatenatedString(String... args) { + List assetIds = new ArrayList<>(); + for (String arg : args) { + assetIds.add(arg); + } + return String.join(",", assetIds); + } } From 4a9b1acb63e98b54d341e1b3f6a5ce1d1e615869 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 26 Apr 2018 15:19:11 +0300 Subject: [PATCH 141/605] updated ingest properties. Created common IngetUtils.java class --- .../kaltura/client/test/IngestConstants.java | 27 + .../kaltura/client/test/IngestProperties.java | 38 - .../com/kaltura/client/test/Properties.java | 40 +- .../kaltura/client/test/tests/BaseTest.java | 12 +- .../productPriceTests/ListTests.java | 4 +- .../AssetCommentAddTests.java | 4 +- .../productPriceTests/ListTests.java | 5 +- .../client/test/utils/IngestEPGUtils.java | 272 ------ .../client/test/utils/IngestMPPUtils.java | 174 ---- .../client/test/utils/IngestPPUtils.java | 112 --- .../client/test/utils/IngestPPVUtils.java | 123 --- .../client/test/utils/IngestUtils.java | 807 ++++++++++++++++++ .../client/test/utils/IngestVODUtils.java | 181 ---- 13 files changed, 871 insertions(+), 928 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/IngestConstants.java delete mode 100644 src/test/java/com/kaltura/client/test/IngestProperties.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/IngestUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java diff --git a/src/test/java/com/kaltura/client/test/IngestConstants.java b/src/test/java/com/kaltura/client/test/IngestConstants.java new file mode 100644 index 000000000..e98e7515e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/IngestConstants.java @@ -0,0 +1,27 @@ +package com.kaltura.client.test; + +public class IngestConstants { + + public static final String INGEST_ACTION_INSERT = "insert"; + public static Long MAX_RANDOM_GENERATED_VALUE_4_INGEST = 9999999999L; + public static final String INGEST_VOD_DEFAULT_THUMB = + "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + + // life cycles periods + public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; + + // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts + public static final String MOVIE_MEDIA_TYPE = "Movie"; + public static final String EPISODE_MEDIA_TYPE = "Episode"; + public static final String LINEAR_MEDIA_TYPE = "Linear"; + + // PG adapter data + /*public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; + public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; + public static final String PG_DEFAULT_SHARED_SECRET = "123456"; + public static final int PG_DEFAULT_PENDING_INTERVAL = 0; + public static final int PG_DEFAULT_PENDING_RETRIES = 0; + public static final int PG_DEFAULT_RENEW_INTERVAL_MINUTES = 15; + public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; + public static final String PG_DEFAULT_PG_SETTINGS = "{}";*/ +} diff --git a/src/test/java/com/kaltura/client/test/IngestProperties.java b/src/test/java/com/kaltura/client/test/IngestProperties.java deleted file mode 100644 index 1321d8d91..000000000 --- a/src/test/java/com/kaltura/client/test/IngestProperties.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.kaltura.client.test; - -public class IngestProperties extends Properties { - - public static final String INGEST_ACTION_INSERT = "insert"; - public static Long MAX_RANDOM_GENERATED_VALUE_4_INGEST = 9999999999L; - public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - - // file types - public static final String WEB_FILE_TYPE = "web_file_type"; - public static final String MOBILE_FILE_TYPE = "mobile_file_type"; - - // ingest - public static final String INGEST_USER_NAME = "ingest_user_username"; - public static final String INGEST_USER_PASSWORD = "ingest_user_password"; - public static final String INGEST_BUSINESS_MODULE_USER_NAME = "ingest_business_module_user_username"; - public static final String INGEST_BUSINESS_MODULE_USER_PASSWORD = "ingest_business_module_user_password"; - - // channels - public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" - - // price codes - public static final String PRICE_CODE_AMOUNT_4_99 = "price_code_amount_4_99"; // 4.99 - - // usage modules - public static final String DEFAULT_USAGE_MODULE_4_INGEST_PPV = "default_usage_module_4_ingest_ppv"; // module has 10 Minutes life cycles, 0 maximum views - public static final String DEFAULT_USAGE_MODULE_4_INGEST_MPP = "default_usage_module_4_ingest_mpp"; // module has 1 Day life cycles, 0 maximum views - - // product codes - public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; - - // discount modules - public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; - public static final String HUNDRED_PERCENTS_UKP_DISCOUNT_NAME = "hundred_percents_ukp_discount_name"; - - // life cycles periods - public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; -} diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 2c7852d40..719b792ab 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -34,23 +34,35 @@ public class Properties { public static final String GLOBAL_USER_PASSWORD = "password"; - // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts - public static final String MOVIE_MEDIA_TYPE = "Movie"; - public static final String EPISODE_MEDIA_TYPE = "Episode"; - public static final String LINEAR_MEDIA_TYPE = "Linear"; - // currencies public static final String CURRENCY_EUR = "EUR"; - // PG adapter data - public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; - public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; - public static final String PG_DEFAULT_SHARED_SECRET = "123456"; - public static final int PG_DEFAULT_PENDING_INTERVAL = 0; - public static final int PG_DEFAULT_PENDING_RETRIES = 0; - public static final int PG_DEFAULT_RENEW_INTERVAL_MINUTES = 15; - public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; - public static final String PG_DEFAULT_PG_SETTINGS = "{}"; + // file types + public static final String WEB_FILE_TYPE = "web_file_type"; + public static final String MOBILE_FILE_TYPE = "mobile_file_type"; + + // ingest + public static final String INGEST_USER_NAME = "ingest_user_username"; + public static final String INGEST_USER_PASSWORD = "ingest_user_password"; + public static final String INGEST_BUSINESS_MODULE_USER_NAME = "ingest_business_module_user_username"; + public static final String INGEST_BUSINESS_MODULE_USER_PASSWORD = "ingest_business_module_user_password"; + + // channels + public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" + + // price codes + public static final String PRICE_CODE_AMOUNT_4_99 = "price_code_amount_4_99"; // 4.99 + + // usage modules + public static final String DEFAULT_USAGE_MODULE_4_INGEST_PPV = "default_usage_module_4_ingest_ppv"; // module has 10 Minutes life cycles, 0 maximum views + public static final String DEFAULT_USAGE_MODULE_4_INGEST_MPP = "default_usage_module_4_ingest_mpp"; // module has 1 Day life cycles, 0 maximum views + + // product codes + public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; + + // discount modules + public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; + public static final String HUNDRED_PERCENTS_UKP_DISCOUNT_NAME = "hundred_percents_ukp_discount_name"; public static String getProperty(String propertyKey) { if (resourceBundle == null) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 13c9b0d32..b709b8e75 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,9 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; -import com.kaltura.client.test.utils.IngestMPPUtils; -import com.kaltura.client.test.utils.IngestPPUtils; -import com.kaltura.client.test.utils.IngestVODUtils; +import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; @@ -12,7 +10,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.IngestProperties.*; +import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; @@ -99,7 +97,7 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { - mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + mediaAsset = IngestUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } return mediaAsset; @@ -173,11 +171,11 @@ public static HouseholdUser getsharedUser() { public static Subscription get5MinRenewableSubscription() { if (fiveMinRenewableSubscription == null) { - PricePlan pricePlan = IngestPPUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), + PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), Optional.of(getProperty(PRICE_CODE_AMOUNT_4_99)), Optional.of(CURRENCY_EUR), Optional.of(""), Optional.of(true), Optional.of(3)); - fiveMinRenewableSubscription = IngestMPPUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), + fiveMinRenewableSubscription = IngestUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java index b61404115..3b273c08d 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java @@ -12,11 +12,11 @@ public class ListTests extends BaseTest { public void beforeClass() { client = getClient(getOperatorKs()); - /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), + /*Ppv ppv = IngestUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ - /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), + /*Response> ingestedProgrammes = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 8413da3a8..0346c1468 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -8,7 +8,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.IngestEPGUtils; +import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.Asset; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; @@ -82,7 +82,7 @@ private void addCommentForVod() { private void addCommentForEPGProgram() { // Ingest EPG program - Response> epgProgram = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Response> epgProgram = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); Long epgProgramId = epgProgram.results.getObjects().get(0).getId(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 9b90798d7..e073e1c4e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.IngestEPGUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; @@ -35,11 +34,11 @@ public void beforeClass() { entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); entitlementPpvsFilter.setIsExpiredEqual(false); - /*Ppv ppv = IngestPPVUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), + /*Ppv ppv = IngestUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ - /*Response> ingestedProgrammes = IngestEPGUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), + /*Response> ingestedProgrammes = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java deleted file mode 100644 index 9af2b6f96..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java +++ /dev/null @@ -1,272 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.Logger; -import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.SearchAssetFilter; -import com.kaltura.client.utils.response.base.Response; -import io.restassured.RestAssured; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.IngestProperties.*; -import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; -import static org.awaitility.Awaitility.await; - -public class IngestEPGUtils extends BaseUtils { - // TODO: think about ENUMS if we really need it here? should we create new ENUM class for it? where? - public static final String DURATION_PERIOD_DAYS = "days"; - public static final String DURATION_PERIOD_HOURS = "hours"; - public static final String DURATION_PERIOD_MINUTES = "minutes"; - public static final String DURATION_PERIOD_SECONDS = "seconds"; - - // default values - public static final int DEFAULT_COUNT_OF_SEASONES = 1; - public static final int DEFAULT_COUNT_OF_PROGRAMMES = 2; - public static final int DEFAULT_PROGRAM_DURATION = 30; - public static final String DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; - - private static List durationPeriodNames = new ArrayList<>(); - static { - durationPeriodNames.add(DURATION_PERIOD_DAYS); - durationPeriodNames.add(DURATION_PERIOD_HOURS); - durationPeriodNames.add(DURATION_PERIOD_MINUTES); - durationPeriodNames.add(DURATION_PERIOD_SECONDS); - } - - private static String titleOfIngestedItem = ""; - - // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project - public static Response> ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, - Optional programDuration, Optional programDurationPeriodName, - Optional isCridUnique4AllPrograms, Optional seasonCount, - Optional coguid, Optional crid, Optional seriesId) { - - int programCountValue = programCount.orElse(DEFAULT_COUNT_OF_PROGRAMMES); - if (programCountValue <= 0) { - Logger.getLogger(IngestEPGUtils.class).error("Invalid programCount value " + programCount.get() + - ". Should be bigger than 0"); - return null; - } - int seasonCountValue = seasonCount.orElse(DEFAULT_COUNT_OF_SEASONES); - - String datePattern = "MM/yy/dd HH:mm:ss"; - SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); - String firstProgramStartDateValue = firstProgramStartDate.orElse(getCurrentDataInFormat(datePattern)); - Calendar startDate = Calendar.getInstance(); - try { - startDate.setTime(dateFormat.parse(firstProgramStartDateValue)); - } catch (ParseException e) { - e.printStackTrace(); - } - - int programDurationValue = programDuration.orElse(DEFAULT_PROGRAM_DURATION); - if (programDurationValue <= 0) { - Logger.getLogger(IngestEPGUtils.class).error("Invalid programDuration value " + programDuration.get() + - ". Should be bigger than 0"); - return null; - } - String programDurationPeriodNameValue = programDurationPeriodName.orElse(DEFAULT_PROGRAM_DURATION_PERIOD_NAME); - if (!durationPeriodNames.contains(programDurationPeriodNameValue)) { - Logger.getLogger(IngestEPGUtils.class).error("Invalid programDurationPeriodName value " + programDurationPeriodName.get() + - ". Should be one from " + durationPeriodNames); - return null; - } - boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); - - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); - String cridValue = crid.orElse(coguidValue); - String seriesIdValue = seriesId.orElse(coguidValue); - int seasonId = 1; - Date endDate; - String output = ""; - String oneProgrammOutput = ""; - SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss"); - Date now = Calendar.getInstance().getTime(); - while (seasonId <= seasonCountValue) { - int idx = 1; - while(idx <= programCountValue) { - endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); - oneProgrammOutput = getProgrammeXML(idx, df2.format(startDate.getTime()), df2.format(endDate), - epgChannelName, coguidValue, cridValue, "Program", df2.format(now), - seriesIdValue, String.valueOf(seasonId), isCridUnique4AllProgramsValue); - startDate.setTime(endDate); - output = output + oneProgrammOutput; - idx = idx + 1; - } - seasonId = seasonId + 1; - } - String epgChannelIngestXml = getChannelXML(PARTNER_ID, epgChannelName, output); - - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); - String reqBody = "\n" + - " \n" + - " \n" + - " " + - " " + - " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + - epgChannelIngestXml + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); - //System.out.println("RESPONSE: " + resp.asString()); - int epgChannelId = DBUtils.getEpgChannelId(epgChannelName); - // TODO: create method getting epoch value from String and pattern - long epoch = 0L; - try { - Date firstProgramStartDateAsDate = dateFormat.parse(firstProgramStartDateValue); - epoch = firstProgramStartDateAsDate.getTime()/1000; // 1000 milliseconds in 1 second - } catch (ParseException e) { - e.printStackTrace(); - } - String firstProgramStartDateEpoch = String.valueOf(epoch); - - SearchAssetFilter assetFilter = new SearchAssetFilter(); - assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); - assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); - int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 60; - await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(assetFilter, programCountValue*seasonCountValue)); - - Response> ingestedProgrammes = AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null); - // TODO: complete Asset.json at least for programs - return ingestedProgrammes; - } - - private static Callable isDataReturned(SearchAssetFilter assetFilter, int totalCount) { - return () -> (AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).error == null && - AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).results.getTotalCount() == totalCount); - } - - private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { - return " " + - "" + - "" + - programsXml + - "" + - "]]>"; - } - - // generate XML for ingest of 1 program - private static String getProgrammeXML(int idx, String startDate, String endDate, String channel, String coguid, String crid, - String programNamePrefix, String currentDate, String seriesId, String seasonNumber, - boolean isCridUnique4AllPrograms) { - String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; - if ("".equals(titleOfIngestedItem)) { - titleOfIngestedItem = name; - } - // TODO: complete to cover util from old project completely - String CRID = "" + crid + "_" + idx + ""; - if (isCridUnique4AllPrograms) { - CRID = "" + crid + "_" + seasonNumber + "_" + idx + ""; - } - String output = - "" + - "" + name + "" + - CRID + - "" + startDate + " until " + endDate + "" + - "" + currentDate + "" + - "eng" + - //"" + - //"" + enableCDVR + "" + - //"" + enableCatchUp + ""+ - //"" + enableStartOver + "" + - //"" + enableTrickPlay + "" + - //"" + - //"" + metaName + "" + - //"" + metaValue + "" + - //"" + - "" + - // TODO: that meta should be added into property file - "season_num" + - "" + seasonNumber + "" + - "" + - "" + - // TODO: that meta should be added into property file - "Series_ID" + - "" + seriesId + "" + - "" + - "" + - // TODO: that meta should be added into property file - "Episode number" + - "" + idx + "" + - "" + - /* "" + - "Season" + - "" + seasonNumber + "" + - "" + - "" + - "Episode" + - "" + id + "" + - "" + - */ - //"" + - //"Country" + - //"Israel" + - //"" + - //"" + - //"YEAR" + - //"2015" + - //"" + - //"" + - //"Genre" + - //"" + genre + "" + - //"" + - //"" + - //"Actors" + - //"Shay" + - //"Ortal" + - //"" + - //"" + - //"" + tagName + "" + - //"" + tagValue + "" + - //"" + - //"" + - //"" + parentalFieldName + "" + - //"" + parentalValue + "" + - //"" + - //"" + - //"" + parentalFieldName + "" + - //"" + parentalValue2 + "" + - //"" + - ""; - return output; - } - - private static Date loadEndDate(Date startDate, int durationValue, String periodName) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(startDate); - switch (periodName) { - case DURATION_PERIOD_DAYS: - calendar.add(Calendar.DATE, durationValue); - break; - case DURATION_PERIOD_HOURS: - calendar.add(Calendar.HOUR, durationValue); - break; - case DURATION_PERIOD_MINUTES: - calendar.add(Calendar.MINUTE, durationValue); - break; - case DURATION_PERIOD_SECONDS: - calendar.add(Calendar.SECOND, durationValue); - } - return calendar.getTime(); - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java deleted file mode 100644 index 6e183358f..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.Logger; -import com.kaltura.client.types.*; -import io.restassured.RestAssured; -import io.restassured.response.Response; -import java.util.HashMap; -import java.util.Optional; -import static com.kaltura.client.test.IngestProperties.*; -import static io.restassured.path.xml.XmlPath.from; - -public class IngestMPPUtils extends BaseUtils { - - private static boolean DEFAULT_IS_ACTIVE_VALUE = true; - private static String DEFAULT_TITLE_VALUE = "Ingest MPP title"; - private static String DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; - private static String DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; - private static String DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; - private static boolean DEFAULT_IS_RENEWABLE_VALUE = false; - private static int DEFAULT_GRACE_PERIOD_VALUE = 0; - - // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon - private static String DEFAULT_COUPON_GROUP_VALUE = - "\n" + - "01/05/2017 00:00:00\n" + - "31/12/2099 23:59:59\n" + - "100% unlimited\n" + - "\n" + - "\n" + - "01/05/2017 00:00:00\n" + - "31/05/2017 23:59:59\n" + - "Expired coupon group 1\n" + - ""; - private static String DEFAULT_PRODUCT_CODES_VALUE = - "\n" + - "ProductCode1\n" + - "Google\n" + - "\n" + - "\n" + - "ProductCode2\n" + - "Apple\n" + - ""; - - // ingest new MPP - public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, - Optional title, Optional description, Optional startDate, - Optional endDate, Optional internalDiscount, - Optional productCode, Optional isRenewable, - Optional gracePeriodMinute, Optional pricePlanCode1, - Optional pricePlanCode2, Optional channel1, - Optional channel2, Optional fileType1, - Optional fileType2, Optional couponGroup, Optional productCodes) { - String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); - String actionValue = action.orElse(INGEST_ACTION_INSERT); - boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); - String titleValue = title.orElse(DEFAULT_TITLE_VALUE); - String descriptionValue = description.orElse(DEFAULT_DESCRIPTION_VALUE); - String startDateValue = startDate.orElse(DEFAULT_START_DATE_VALUE); - String endDateValue = endDate.orElse(DEFAULT_END_DATE_VALUE); - String internalDiscountValue = internalDiscount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); - String productCodeValue = productCode.orElse(""); - boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); - int gracePeriodMinuteValue = gracePeriodMinute.orElse(DEFAULT_GRACE_PERIOD_VALUE); - - String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); - String pricePlanCode2Value = pricePlanCode2.orElse(""); - String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); - String channel2Value = channel2.orElse(""); - String fileType1Value = fileType1.orElse(""); - String fileType2Value = fileType2.orElse(""); - String couponGroupValue = couponGroup.orElse(DEFAULT_COUPON_GROUP_VALUE); - String productCodesValue = productCodes.orElse(DEFAULT_PRODUCT_CODES_VALUE); - - - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - - Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); - - //Logger.getLogger(IngestMPPUtils.class).debug(reqBody); - Logger.getLogger(IngestMPPUtils.class).debug(resp.asString()); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); - - url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - Logger.getLogger(IngestMPPUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); - - Subscription subscription = new Subscription(); - subscription.setId(id); - subscription.setName(titleValue); - subscription.setDescription(descriptionValue); - // TODO: complete COMMENTED IF NEEDED - //subscription.setStartDate(); - //subscription.setEndDate(); - //subscription.setDiscountModule(); - //subscription.setProductCodes(); - subscription.isRenewable(String.valueOf(isRenewableValue)); - subscription.setGracePeriodMinutes(gracePeriodMinuteValue); - //subscription.setPricePlanIds(); - //subscription.setChannels(); - //subscription.setFileTypes(); - //subscription.setCouponsGroups(); - return subscription; - } - - private static String buildIngestMppXML(String action, String mppCode, boolean isActive, String title, String description, - String startDate, String endDate, String internalDiscount, String productCode, - boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, - String pricePlanCode2, String channel1, String channel2, String fileType1, - String fileType2, String couponGroup, String productCodes) { - return "\n" + - "\n" + - "\n" + - "\n" + - "" + title + "\n" + - "\n" + - "\n" + - "" + description + "" + - "\n" + - "" + startDate + "\n" + - "" + endDate + "\n" + - "" + internalDiscount + "\n" + - "\n" + - "" + productCode + "\n" + - "" + isRenewable + "\n" + - "\n" + - "" + gracePeriodMinute + "\n" + - "\n" + - "" + pricePlanCode1 + "\n" + - "" + pricePlanCode2 + "\n" + - "\n" + - "\n" + - "" + channel1 + "\n" + - "" + channel2 + "\n" + - "\n" + - "\n" + - "" + fileType1 + "\n" + - "" + fileType2 + "\n" + - "\n" + - "\n" + - "" + couponGroup + "\n" + - "" + productCodes + "\n" + - "\n" + - "\n" + - "\n"; - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java deleted file mode 100644 index f894a007a..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.Logger; -import com.kaltura.client.types.PricePlan; -import io.restassured.RestAssured; -import io.restassured.response.Response; -import java.util.HashMap; -import java.util.Optional; -import static com.kaltura.client.test.IngestProperties.*; -import static io.restassured.path.xml.XmlPath.from; - -public class IngestPPUtils extends BaseUtils { - - private static boolean DEFAULT_IS_ACTIVE_VALUE = true; - private static int DEFAULT_MAX_VIEWS_VALUE = 0; - private static boolean DEFAULT_IS_RENEWABLE_VALUE = false; - private static int DEFAULT_RECURRING_PERIODS_VALUE = 1; - - // ingest new PP - public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, - Optional fullLifeCycle, Optional viewLifeCycle, Optional maxViews, - Optional price, Optional currency, - Optional discount, Optional isRenewable, - Optional recurringPeriods) { - String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); - String actionValue = action.orElse(INGEST_ACTION_INSERT); - boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); - String fullLifeCycleValue = fullLifeCycle.orElse(FIVE_MINUTES_PERIOD); - String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); - int maxViewsValue = maxViews.orElse(DEFAULT_MAX_VIEWS_VALUE); - String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT_4_99)); - String currencyValue = currency.orElse(CURRENCY_EUR); - String discountValue = discount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); - boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); - int recurringPeriodsValue = recurringPeriods.orElse(DEFAULT_RECURRING_PERIODS_VALUE); - - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - - Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); - - Logger.getLogger(IngestPPUtils.class).debug(reqBody); - Logger.getLogger(IngestPPUtils.class).debug(resp.asString()); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); - - url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - Logger.getLogger(IngestPPUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); - //Logger.getLogger(IngestPPUtils.class).debug("ID: " + id); - - PricePlan pricePlan = new PricePlan(); - pricePlan.setId(Long.valueOf(id)); - pricePlan.setMaxViewsNumber(maxViewsValue); - pricePlan.setIsRenewable(isRenewableValue); - pricePlan.setRenewalsNumber(recurringPeriodsValue); - pricePlan.setName(ppCodeValue); - // TODO: complete COMMENTED IF NEEDED - //pricePlan.setFullLifeCycle(); - //pricePlan.setViewLifeCycle(); - //pricePlan.setPriceDetailsId(); - //pricePlan.setDiscountId(); - return pricePlan; - } - - private static String buildIngestPpXML(String action, String ppCode, boolean isActive, String fullLifeCycle, - String viewLifeCycle, int maxViews, String price, String currency, - String discount, boolean isRenewable, int recurringPeriods) { - String id = "reportIngestPricePlan" + action.substring(0, 1).toUpperCase() + action.substring(1); - return "\n" + - "\n" + - "\n" + - "" + fullLifeCycle + "\n" + - "" + viewLifeCycle + "\n" + - "" + maxViews + "\n" + - "\n" + - "" + price + "\n" + - "" + currency + "\n" + - "\n" + - "" + discount + "\n" + - "" + isRenewable + "\n" + - "" + recurringPeriods + "\n" + - "\n" + - "\n" + - "\n"; - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java deleted file mode 100644 index 9070fcf0a..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.types.*; -import io.restassured.RestAssured; -import io.restassured.response.Response; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import static com.kaltura.client.test.IngestProperties.*; -import static io.restassured.path.xml.XmlPath.from; - -public class IngestPPVUtils extends BaseUtils { - - // ingest new PPV - public static Ppv ingestPPV(Optional action, Optional isActive, Optional description, - Optional discount, Optional price, Optional currency, - Optional usageModule, Optional isSubscriptionOnly, - Optional isFirstDeviceLimitation, Optional productCode, - Optional firstFileType, Optional secondFileType) { - String ppvCode = getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST); - - String actionValue = action.orElse(INGEST_ACTION_INSERT); - boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; - String descriptionValue = description.orElse("My ingest PPV"); - String discountValue = discount.orElseGet(() -> getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); - double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99))); - String currencyValue = currency.orElseGet(() -> getProperty(CURRENCY_EUR)); - String usageModuleValue = usageModule.orElseGet(() -> getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); - boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; - boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; - String productCodeValue = productCode.orElseGet(() -> getProperty(DEFAULT_PRODUCT_CODE)); - String firstFileTypeValue = firstFileType.orElseGet(() -> getProperty(WEB_FILE_TYPE)); - String secondFileTypeValue = secondFileType.orElseGet(() -> getProperty(MOBILE_FILE_TYPE)); - - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - - Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //System.out.println("ReportId = " + reportId); - - url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - System.out.println(resp.asString()); - System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); - - Ppv ppv = new Ppv(); - ppv.setId(id); - List descriptions = new ArrayList<>(); - TranslationToken translationToken = new TranslationToken(); - translationToken.setValue(descriptionValue); - descriptions.add(translationToken); - ppv.setDescriptions(descriptions); - PriceDetails priceDetails = new PriceDetails(); - Price priceObj = new Price(); - priceObj.setAmount(priceValue); - priceObj.setCurrency(currencyValue); - priceDetails.setPrice(priceObj); - ppv.setPrice(priceDetails); - UsageModule usageModuleObj = new UsageModule(); - usageModuleObj.setName(usageModuleValue); - ppv.setUsageModule(usageModuleObj); - ppv.setIsSubscriptionOnly(isSubscriptionOnlyValue); - ppv.setFirstDeviceLimitation(isFirstDeviceLimitationValue); - ppv.setProductCode(productCodeValue); - - return ppv; - } - - private static String buildIngestPpvXML(String action, String ppvCode, boolean isActive, String description, String discount, - double price, String currency, String usageModule, boolean isSubscriptionOnly, - boolean isFirstDeviceLimitation, String productCode, String firstFileType, - String secondFileType) { - return "\n" + - " \n" + - " \n" + - " \n" + - " " + description + "\n" + - " \n" + - " \n" + - " " + price + "\n" + - " " + currency + "\n" + - " \n" + - " " + usageModule + "\n" + - " " + discount + "\n" + - " \n" + - " " + isSubscriptionOnly + "\n" + - " " + isFirstDeviceLimitation + "\n" + - " " + productCode + "\n" + - " \n" + - " " + firstFileType + "\n" + - " " + secondFileType + "\n" + - " \n" + - " \n" + - " \n" + - "\n"; - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java new file mode 100644 index 000000000..6eeef4cad --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -0,0 +1,807 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.Logger; +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.restassured.RestAssured; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import static com.kaltura.client.test.IngestConstants.*; +import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; +import static com.kaltura.client.test.tests.BaseTest.getClient; +import static io.restassured.path.xml.XmlPath.from; +import static org.awaitility.Awaitility.await; + +public class IngestUtils extends BaseUtils { + + // INGEST EPG PARAMS + // TODO: think about ENUMS if we really need it here? should we create new ENUM class for it? where? + public static final String DURATION_PERIOD_DAYS = "days"; + public static final String DURATION_PERIOD_HOURS = "hours"; + public static final String DURATION_PERIOD_MINUTES = "minutes"; + public static final String DURATION_PERIOD_SECONDS = "seconds"; + + // default values + public static final int EPG_DEFAULT_COUNT_OF_SEASONS = 1; + public static final int EPG_DEFAULT_COUNT_OF_PROGRAMMES = 2; + public static final int EPG_DEFAULT_PROGRAM_DURATION = 30; + public static final String EPG_DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; + + private static List durationPeriodNames = new ArrayList<>(); + static { + durationPeriodNames.add(DURATION_PERIOD_DAYS); + durationPeriodNames.add(DURATION_PERIOD_HOURS); + durationPeriodNames.add(DURATION_PERIOD_MINUTES); + durationPeriodNames.add(DURATION_PERIOD_SECONDS); + } + + private static String titleOfIngestedItem = ""; + + // INGEST MPP PARAMS + private static boolean MPP_DEFAULT_IS_ACTIVE_VALUE = true; + private static String MPP_DEFAULT_TITLE_VALUE = "Ingest MPP title"; + private static String MPP_DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; + private static String MPP_DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; + private static String MPP_DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; + private static boolean MPP_DEFAULT_IS_RENEWABLE_VALUE = false; + private static int MPP_DEFAULT_GRACE_PERIOD_VALUE = 0; + + // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon + private static String MPP_DEFAULT_COUPON_GROUP_VALUE = + "\n" + + "01/05/2017 00:00:00\n" + + "31/12/2099 23:59:59\n" + + "100% unlimited\n" + + "\n" + + "\n" + + "01/05/2017 00:00:00\n" + + "31/05/2017 23:59:59\n" + + "Expired coupon group 1\n" + + ""; + private static String MPP_DEFAULT_PRODUCT_CODES_VALUE = + "\n" + + "ProductCode1\n" + + "Google\n" + + "\n" + + "\n" + + "ProductCode2\n" + + "Apple\n" + + ""; + + // INGEST PP PARAMS + private static boolean PP_DEFAULT_IS_ACTIVE_VALUE = true; + private static int PP_DEFAULT_MAX_VIEWS_VALUE = 0; + private static boolean PP_DEFAULT_IS_RENEWABLE_VALUE = false; + private static int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; + + // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project + public static Response> ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, + Optional programDuration, Optional programDurationPeriodName, + Optional isCridUnique4AllPrograms, Optional seasonCount, + Optional coguid, Optional crid, Optional seriesId) { + + int programCountValue = programCount.orElse(EPG_DEFAULT_COUNT_OF_PROGRAMMES); + if (programCountValue <= 0) { + Logger.getLogger(IngestUtils.class).error("Invalid programCount value " + programCount.get() + + ". Should be bigger than 0"); + return null; + } + int seasonCountValue = seasonCount.orElse(EPG_DEFAULT_COUNT_OF_SEASONS); + + String datePattern = "MM/yy/dd HH:mm:ss"; + SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); + String firstProgramStartDateValue = firstProgramStartDate.orElse(getCurrentDataInFormat(datePattern)); + Calendar startDate = Calendar.getInstance(); + try { + startDate.setTime(dateFormat.parse(firstProgramStartDateValue)); + } catch (ParseException e) { + e.printStackTrace(); + } + + int programDurationValue = programDuration.orElse(EPG_DEFAULT_PROGRAM_DURATION); + if (programDurationValue <= 0) { + Logger.getLogger(IngestUtils.class).error("Invalid programDuration value " + programDuration.get() + + ". Should be bigger than 0"); + return null; + } + String programDurationPeriodNameValue = programDurationPeriodName.orElse(EPG_DEFAULT_PROGRAM_DURATION_PERIOD_NAME); + if (!durationPeriodNames.contains(programDurationPeriodNameValue)) { + Logger.getLogger(IngestUtils.class).error("Invalid programDurationPeriodName value " + programDurationPeriodName.get() + + ". Should be one from " + durationPeriodNames); + return null; + } + boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); + + String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); + String cridValue = crid.orElse(coguidValue); + String seriesIdValue = seriesId.orElse(coguidValue); + int seasonId = 1; + Date endDate; + String output = ""; + String oneProgrammOutput = ""; + SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss"); + Date now = Calendar.getInstance().getTime(); + while (seasonId <= seasonCountValue) { + int idx = 1; + while(idx <= programCountValue) { + endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); + oneProgrammOutput = getProgrammeXML(idx, df2.format(startDate.getTime()), df2.format(endDate), + epgChannelName, coguidValue, cridValue, "Program", df2.format(now), + seriesIdValue, String.valueOf(seasonId), isCridUnique4AllProgramsValue); + startDate.setTime(endDate); + output = output + oneProgrammOutput; + idx = idx + 1; + } + seasonId = seasonId + 1; + } + String epgChannelIngestXml = getChannelXML(PARTNER_ID, epgChannelName, output); + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); + String reqBody = "\n" + + " \n" + + " \n" + + " " + + " " + + " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + epgChannelIngestXml + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + io.restassured.response.Response resp = RestAssured.given() + .log().all() + .headers(headerMap) + .body(reqBody) + .post(url); + //System.out.println("RESPONSE: " + resp.asString()); + int epgChannelId = DBUtils.getEpgChannelId(epgChannelName); + // TODO: create method getting epoch value from String and pattern + long epoch = 0L; + try { + Date firstProgramStartDateAsDate = dateFormat.parse(firstProgramStartDateValue); + epoch = firstProgramStartDateAsDate.getTime()/1000; // 1000 milliseconds in 1 second + } catch (ParseException e) { + e.printStackTrace(); + } + String firstProgramStartDateEpoch = String.valueOf(epoch); + + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); + assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + int delayBetweenRetriesInSeconds = 3; + int maxTimeExpectingValidResponseInSeconds = 60; + await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(isDataReturned(assetFilter, programCountValue*seasonCountValue)); + + Response> ingestedProgrammes = AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null); + // TODO: complete Asset.json at least for programs + return ingestedProgrammes; + } + + private static Callable isDataReturned(SearchAssetFilter assetFilter, int totalCount) { + return () -> (AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).error == null && + AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).results.getTotalCount() == totalCount); + } + + private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { + return " " + + "" + + "" + + programsXml + + "" + + "]]>"; + } + + // generate XML for ingest of 1 program + private static String getProgrammeXML(int idx, String startDate, String endDate, String channel, String coguid, String crid, + String programNamePrefix, String currentDate, String seriesId, String seasonNumber, + boolean isCridUnique4AllPrograms) { + String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; + if ("".equals(titleOfIngestedItem)) { + titleOfIngestedItem = name; + } + // TODO: complete to cover util from old project completely + String CRID = "" + crid + "_" + idx + ""; + if (isCridUnique4AllPrograms) { + CRID = "" + crid + "_" + seasonNumber + "_" + idx + ""; + } + String output = + "" + + "" + name + "" + + CRID + + "" + startDate + " until " + endDate + "" + + "" + currentDate + "" + + "eng" + + //"" + + //"" + enableCDVR + "" + + //"" + enableCatchUp + ""+ + //"" + enableStartOver + "" + + //"" + enableTrickPlay + "" + + //"" + + //"" + metaName + "" + + //"" + metaValue + "" + + //"" + + "" + + // TODO: that meta should be added into property file + "season_num" + + "" + seasonNumber + "" + + "" + + "" + + // TODO: that meta should be added into property file + "Series_ID" + + "" + seriesId + "" + + "" + + "" + + // TODO: that meta should be added into property file + "Episode number" + + "" + idx + "" + + "" + + /* "" + + "Season" + + "" + seasonNumber + "" + + "" + + "" + + "Episode" + + "" + id + "" + + "" + + */ + //"" + + //"Country" + + //"Israel" + + //"" + + //"" + + //"YEAR" + + //"2015" + + //"" + + //"" + + //"Genre" + + //"" + genre + "" + + //"" + + //"" + + //"Actors" + + //"Shay" + + //"Ortal" + + //"" + + //"" + + //"" + tagName + "" + + //"" + tagValue + "" + + //"" + + //"" + + //"" + parentalFieldName + "" + + //"" + parentalValue + "" + + //"" + + //"" + + //"" + parentalFieldName + "" + + //"" + parentalValue2 + "" + + //"" + + ""; + return output; + } + + private static Date loadEndDate(Date startDate, int durationValue, String periodName) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + switch (periodName) { + case DURATION_PERIOD_DAYS: + calendar.add(Calendar.DATE, durationValue); + break; + case DURATION_PERIOD_HOURS: + calendar.add(Calendar.HOUR, durationValue); + break; + case DURATION_PERIOD_MINUTES: + calendar.add(Calendar.MINUTE, durationValue); + break; + case DURATION_PERIOD_SECONDS: + calendar.add(Calendar.SECOND, durationValue); + } + return calendar.getTime(); + } + + // ingest new MPP + public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, + Optional title, Optional description, Optional startDate, + Optional endDate, Optional internalDiscount, + Optional productCode, Optional isRenewable, + Optional gracePeriodMinute, Optional pricePlanCode1, + Optional pricePlanCode2, Optional channel1, + Optional channel2, Optional fileType1, + Optional fileType2, Optional couponGroup, Optional productCodes) { + String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); + String actionValue = action.orElse(INGEST_ACTION_INSERT); + boolean isActiveValue = isActive.orElse(MPP_DEFAULT_IS_ACTIVE_VALUE); + String titleValue = title.orElse(MPP_DEFAULT_TITLE_VALUE); + String descriptionValue = description.orElse(MPP_DEFAULT_DESCRIPTION_VALUE); + String startDateValue = startDate.orElse(MPP_DEFAULT_START_DATE_VALUE); + String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); + String internalDiscountValue = internalDiscount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); + String productCodeValue = productCode.orElse(""); + boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); + int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); + + String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); + String pricePlanCode2Value = pricePlanCode2.orElse(""); + String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); + String channel2Value = channel2.orElse(""); + String fileType1Value = fileType1.orElse(""); + String fileType2Value = fileType2.orElse(""); + String couponGroupValue = couponGroup.orElse(MPP_DEFAULT_COUPON_GROUP_VALUE); + String productCodesValue = productCodes.orElse(MPP_DEFAULT_PRODUCT_CODES_VALUE); + + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + + io.restassured.response.Response resp = RestAssured.given() + .log().all() + .headers(headerMap) + .body(reqBody) + .post(url); + + //Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); + + url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); + + Subscription subscription = new Subscription(); + subscription.setId(id); + subscription.setName(titleValue); + subscription.setDescription(descriptionValue); + // TODO: complete COMMENTED IF NEEDED + //subscription.setStartDate(); + //subscription.setEndDate(); + //subscription.setDiscountModule(); + //subscription.setProductCodes(); + subscription.isRenewable(String.valueOf(isRenewableValue)); + subscription.setGracePeriodMinutes(gracePeriodMinuteValue); + //subscription.setPricePlanIds(); + //subscription.setChannels(); + //subscription.setFileTypes(); + //subscription.setCouponsGroups(); + return subscription; + } + + private static String buildIngestMppXML(String action, String mppCode, boolean isActive, String title, String description, + String startDate, String endDate, String internalDiscount, String productCode, + boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, + String pricePlanCode2, String channel1, String channel2, String fileType1, + String fileType2, String couponGroup, String productCodes) { + return "\n" + + "\n" + + "\n" + + "\n" + + "" + title + "\n" + + "\n" + + "\n" + + "" + description + "" + + "\n" + + "" + startDate + "\n" + + "" + endDate + "\n" + + "" + internalDiscount + "\n" + + "\n" + + "" + productCode + "\n" + + "" + isRenewable + "\n" + + "\n" + + "" + gracePeriodMinute + "\n" + + "\n" + + "" + pricePlanCode1 + "\n" + + "" + pricePlanCode2 + "\n" + + "\n" + + "\n" + + "" + channel1 + "\n" + + "" + channel2 + "\n" + + "\n" + + "\n" + + "" + fileType1 + "\n" + + "" + fileType2 + "\n" + + "\n" + + "\n" + + "" + couponGroup + "\n" + + "" + productCodes + "\n" + + "\n" + + "\n" + + "\n"; + } + + // ingest new PP + public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, + Optional fullLifeCycle, Optional viewLifeCycle, Optional maxViews, + Optional price, Optional currency, + Optional discount, Optional isRenewable, + Optional recurringPeriods) { + String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); + String actionValue = action.orElse(INGEST_ACTION_INSERT); + boolean isActiveValue = isActive.orElse(PP_DEFAULT_IS_ACTIVE_VALUE); + String fullLifeCycleValue = fullLifeCycle.orElse(FIVE_MINUTES_PERIOD); + String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); + int maxViewsValue = maxViews.orElse(PP_DEFAULT_MAX_VIEWS_VALUE); + String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT_4_99)); + String currencyValue = currency.orElse(CURRENCY_EUR); + String discountValue = discount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); + boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); + int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + + io.restassured.response.Response resp = RestAssured.given() + .log().all() + .headers(headerMap) + .body(reqBody) + .post(url); + + Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); + + url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); + //Logger.getLogger(IngestUtils.class).debug("ID: " + id); + + PricePlan pricePlan = new PricePlan(); + pricePlan.setId(Long.valueOf(id)); + pricePlan.setMaxViewsNumber(maxViewsValue); + pricePlan.setIsRenewable(isRenewableValue); + pricePlan.setRenewalsNumber(recurringPeriodsValue); + pricePlan.setName(ppCodeValue); + // TODO: complete COMMENTED IF NEEDED + //pricePlan.setFullLifeCycle(); + //pricePlan.setViewLifeCycle(); + //pricePlan.setPriceDetailsId(); + //pricePlan.setDiscountId(); + return pricePlan; + } + + private static String buildIngestPpXML(String action, String ppCode, boolean isActive, String fullLifeCycle, + String viewLifeCycle, int maxViews, String price, String currency, + String discount, boolean isRenewable, int recurringPeriods) { + String id = "reportIngestPricePlan" + action.substring(0, 1).toUpperCase() + action.substring(1); + return "\n" + + "\n" + + "\n" + + "" + fullLifeCycle + "\n" + + "" + viewLifeCycle + "\n" + + "" + maxViews + "\n" + + "\n" + + "" + price + "\n" + + "" + currency + "\n" + + "\n" + + "" + discount + "\n" + + "" + isRenewable + "\n" + + "" + recurringPeriods + "\n" + + "\n" + + "\n" + + "\n"; + } + + // ingest new PPV + public static Ppv ingestPPV(Optional action, Optional isActive, Optional description, + Optional discount, Optional price, Optional currency, + Optional usageModule, Optional isSubscriptionOnly, + Optional isFirstDeviceLimitation, Optional productCode, + Optional firstFileType, Optional secondFileType) { + String ppvCode = getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST); + + String actionValue = action.orElse(INGEST_ACTION_INSERT); + boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; + String descriptionValue = description.orElse("My ingest PPV"); + String discountValue = discount.orElseGet(() -> getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); + double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99))); + String currencyValue = currency.orElseGet(() -> getProperty(CURRENCY_EUR)); + String usageModuleValue = usageModule.orElseGet(() -> getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); + boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; + boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; + String productCodeValue = productCode.orElseGet(() -> getProperty(DEFAULT_PRODUCT_CODE)); + String firstFileTypeValue = firstFileType.orElseGet(() -> getProperty(WEB_FILE_TYPE)); + String secondFileTypeValue = secondFileType.orElseGet(() -> getProperty(MOBILE_FILE_TYPE)); + + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_BUSINESS_MODULE_USER_NAME) + "" + + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + + io.restassured.response.Response resp = RestAssured.given() + .log().all() + .headers(headerMap) + .body(reqBody) + .post(url); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //System.out.println("ReportId = " + reportId); + + url = INGEST_REPORT_URL + "/" + PARTNER_ID + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + System.out.println(resp.asString()); + System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); + + Ppv ppv = new Ppv(); + ppv.setId(id); + List descriptions = new ArrayList<>(); + TranslationToken translationToken = new TranslationToken(); + translationToken.setValue(descriptionValue); + descriptions.add(translationToken); + ppv.setDescriptions(descriptions); + PriceDetails priceDetails = new PriceDetails(); + Price priceObj = new Price(); + priceObj.setAmount(priceValue); + priceObj.setCurrency(currencyValue); + priceDetails.setPrice(priceObj); + ppv.setPrice(priceDetails); + UsageModule usageModuleObj = new UsageModule(); + usageModuleObj.setName(usageModuleValue); + ppv.setUsageModule(usageModuleObj); + ppv.setIsSubscriptionOnly(isSubscriptionOnlyValue); + ppv.setFirstDeviceLimitation(isFirstDeviceLimitationValue); + ppv.setProductCode(productCodeValue); + + return ppv; + } + + private static String buildIngestPpvXML(String action, String ppvCode, boolean isActive, String description, String discount, + double price, String currency, String usageModule, boolean isSubscriptionOnly, + boolean isFirstDeviceLimitation, String productCode, String firstFileType, + String secondFileType) { + return "\n" + + " \n" + + " \n" + + " \n" + + " " + description + "\n" + + " \n" + + " \n" + + " " + price + "\n" + + " " + currency + "\n" + + " \n" + + " " + usageModule + "\n" + + " " + discount + "\n" + + " \n" + + " " + isSubscriptionOnly + "\n" + + " " + isFirstDeviceLimitation + "\n" + + " " + productCode + "\n" + + " \n" + + " " + firstFileType + "\n" + + " " + secondFileType + "\n" + + " \n" + + " \n" + + " \n" + + "\n"; + } + + // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project + public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, + Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, + Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { + String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; + String coguidDatePattern = "yyMMddHHmmssSS"; + String maxEndDateValue = "14/10/2099 17:00:00"; + String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value + int defaultDayOffset =-1; + + String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat(coguidDatePattern)); + String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); + String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); + String descriptionValue = description.orElseGet(() -> "description of " + coguidValue); + String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); + String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String endDateValue = endDate.orElse(maxEndDateValue); + String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); + String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); + String ppvMobileNameValue = ppvMobileName.orElse(ppvModuleName); + // TODO: check if ingest url is the same for all ingest actions + String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; + HashMap headerMap = new HashMap<>(); + headerMap.put("Content-Type", "text/xml;charset=UTF-8"); + headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + io.restassured.response.Response resp = RestAssured.given() + .log().all() + .headers(headerMap) + .body(reqBody) + .post(url); + //System.out.println("RESPONSE: " + resp.asString()); + String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); + + MediaAsset mediaAsset = new MediaAsset(); + mediaAsset.setName(nameValue); + mediaAsset.setId(Long.valueOf(id)); + mediaAsset.setDescription(descriptionValue); + //mediaAsset.setStartDate(startDate); + //mediaAsset.setEndDate(endDate); + + int delayBetweenRetriesInSeconds = 3; + int maxTimeExpectingValidResponseInSeconds = 45; + await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(id)); + Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); + mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + + // TODO: 4/15/2018 add log for ingest and index failures + return mediaAsset; + } + + private static Callable isDataReturned(String mediaId) { + return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; + } + + private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, + String description, String catalogStartDate, String catalogEndDate, + String startDate, String endDate, String mediaType, String ppvWebName, + String ppvMobileName) { + return "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " " + name + "\n" + + " \n" + + " \n" + + " \n" + + " " + description + "\n" + + " \n" + + " \n" + + " " + catalogStartDate + "\n" + + " " + startDate + "\n" + + " " + catalogEndDate + "\n" + + " " + endDate + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " " + mediaType + "\n" + + " \n" + + //" ${#TestCase#i_geo_block_rule}\n" + + // TODO: check where to put that value (is it env-dependent?) + " Parent Allowed\n" + + //" ${#TestCase#i_device_block_rule}\n" + + " \n" + + " \n" + + " \n" + + //" \n" + + //" \n" + + //" syno pino sister\n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_meta_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_double_meta_value}\n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_date_meta_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" Costa Rica;Israel\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" GIH\n" + + //" \n" + + //" \n" + + //" ABC\n" + + //" \n" + + //" \n" + + //" DEF\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" Shay_Series\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_tag_free_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_parental_value}\n" + + //" \n" + + //" \n" + + //" \n" + + //" \n" + + //" ${#TestCase#i_tag_value}\n" + + //" \n" + + //" \n" + + //" \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java deleted file mode 100644 index b209517b9..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.MediaAsset; -import com.kaltura.client.utils.response.base.Response; -import io.restassured.RestAssured; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.IngestProperties.*; -import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; -import static io.restassured.path.xml.XmlPath.from; -import static org.awaitility.Awaitility.await; - -public class IngestVODUtils extends BaseUtils { - - // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, - Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, - Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { - String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; - String coguidDatePattern = "yyMMddHHmmssSS"; - String maxEndDateValue = "14/10/2099 17:00:00"; - String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value - int defaultDayOffset =-1; - - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat(coguidDatePattern)); - String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); - String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); - String descriptionValue = description.orElseGet(() -> "description of " + coguidValue); - String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); - String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); - String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); - String endDateValue = endDate.orElse(maxEndDateValue); - String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); - String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); - String ppvMobileNameValue = ppvMobileName.orElse(ppvModuleName); - // TODO: check if ingest url is the same for all ingest actions - String url = SOAP_BASE_URL + "/Ingest_" + API_URL_VERSION + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_USER_NAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); - //System.out.println("RESPONSE: " + resp.asString()); - String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - - MediaAsset mediaAsset = new MediaAsset(); - mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id)); - mediaAsset.setDescription(descriptionValue); - //mediaAsset.setStartDate(startDate); - //mediaAsset.setEndDate(endDate); - - int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 45; - await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(id)); - Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); - mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); - - // TODO: 4/15/2018 add log for ingest and index failures - return mediaAsset; - } - - private static Callable isDataReturned(String mediaId) { - return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; - } - - private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, - String description, String catalogStartDate, String catalogEndDate, - String startDate, String endDate, String mediaType, String ppvWebName, - String ppvMobileName) { - return "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + name + "\n" + - " \n" + - " \n" + - " \n" + - " " + description + "\n" + - " \n" + - " \n" + - " " + catalogStartDate + "\n" + - " " + startDate + "\n" + - " " + catalogEndDate + "\n" + - " " + endDate + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + mediaType + "\n" + - " \n" + - //" ${#TestCase#i_geo_block_rule}\n" + - // TODO: check where to put that value (is it env-dependent?) - " Parent Allowed\n" + - //" ${#TestCase#i_device_block_rule}\n" + - " \n" + - " \n" + - " \n" + - //" \n" + - //" \n" + - //" syno pino sister\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_double_meta_value}\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_date_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Costa Rica;Israel\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" GIH\n" + - //" \n" + - //" \n" + - //" ABC\n" + - //" \n" + - //" \n" + - //" DEF\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Shay_Series\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_free_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_parental_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_value}\n" + - //" \n" + - //" \n" + - //" \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - } -} From d9c4368126b4098827b7359c3d46c70c609f8c37 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 26 Apr 2018 17:01:19 +0300 Subject: [PATCH 142/605] no message --- .../test/TestAPIOkRequestsExecutor.java | 2 +- .../entitlementTests/GrantTests.java | 67 ++++++++++--------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index f8f3a4ea1..952d4e837 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -60,7 +60,7 @@ protected ResponseElement onGotResponse(Response response, RequestElement action ResponseElement responseElement = new ExecutedRequest().requestId(requestId).response(responseString).code(response.code()).success(responseString != null); com.kaltura.client.utils.response.base.Response response1 = action.parseResponse(responseElement); - if (response1.isSuccess()) { + if (response1.results != null && response1.isSuccess()) { String s1 = "schemas/"; String s3 = ".json"; String s2 = response1.results.getClass().getSimpleName(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index 69e5ebebc..e9de2a850 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -5,9 +5,7 @@ import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionHistoryOrderBy; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; -import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; -import com.kaltura.client.test.servicesImpl.TransactionHistoryServiceImpl; +import com.kaltura.client.test.servicesImpl.*; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.HouseholdUtils; @@ -27,13 +25,18 @@ public class GrantTests extends BaseTest { private final int ppvId = 30297; private final int assetId = 607368; + private final int numberOfUsersInHousehold = 2; + private final int numberOfDevicesInHousehold = 1; + private Response> billingTransactionListResponse; private int contentId; + private Household testSharedHousehold; @BeforeClass private void grant_test_before_class() { contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + testSharedHousehold = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } @Test(description = "entitlement/action/grant - grant subscription with history = true") @@ -41,7 +44,7 @@ private void grant_subscription_with_history() { Client client = getClient(getAdministratorKs()); // set household - Household household = HouseholdUtils.createHouseHold(2, 1, false); + Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -93,10 +96,8 @@ private void grant_subscription_with_history() { assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(subscriptionId)); - // force cancel subscription - client.setKs(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); + //delete household for cleanup + HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); } @Test(description = "entitlement/action/grant - grant subscription with history = false") @@ -104,7 +105,7 @@ private void grant_subscription_without_history() { Client client = getClient(getAdministratorKs()); // set household - Household household = HouseholdUtils.createHouseHold(2, 1, false); + Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -134,10 +135,8 @@ private void grant_subscription_without_history() { assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); - // force cancel subscription - client.setKs(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - EntitlementServiceImpl.forceCancel(client, subscriptionId, TransactionType.SUBSCRIPTION); + //delete household for cleanup + HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); } @Test(description = "entitlement/action/grant - grant ppv with history = true") @@ -145,7 +144,7 @@ private void grant_ppv_with_history() { Client client = getClient(getAdministratorKs()); // set household - Household household = HouseholdUtils.createHouseHold(2, 1, false); + Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -197,10 +196,8 @@ private void grant_ppv_with_history() { assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(assetId)); - // force cancel subscription - client.setKs(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); + //delete household for cleanup + HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); } @Test(description = "entitlement/action/grant - grant ppv with history = false") @@ -208,7 +205,7 @@ private void grant_ppv_without_history() { Client client = getClient(getAdministratorKs()); // set household - Household household = HouseholdUtils.createHouseHold(2, 1, false); + Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -246,28 +243,38 @@ private void grant_ppv_without_history() { assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(String.valueOf(assetId)); - // force cancel subscription - client.setKs(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - EntitlementServiceImpl.forceCancel(client, ppvId, TransactionType.PPV); + //delete household for cleanup + HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); } - @Test(description = "entitlement/action/grant - wrong ppv id - error 6001") + @Test(description = "entitlement/action/grant - grant ppv with wrong id - error 6001") private void grant_ppv_with_wrong_id() { - Client client = getClient(getAdministratorKs()); + int productId = 1; - // set household - Household household = HouseholdUtils.createHouseHold(2, 1, false); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + // get user form test shared household + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); - // grant subscription - history = true + // grant ppv with wrong id + Client client = getClient(getAdministratorKs()); client.setUserId(Integer.valueOf(user.getUserId())); - Response booleanResponse = EntitlementServiceImpl.grant(client, 1, TransactionType.PPV, true, contentId); + Response booleanResponse = EntitlementServiceImpl.grant(client, productId, TransactionType.PPV, true, contentId); + // assert error 6001 is return assertThat(booleanResponse.results).isEqualTo(null); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); } +/* @Test(description = "entitlement/action/grant - grant purchased ppv - error 3021") + private void grant_purchased_ppv() { + // get user form test shared household + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + + // purchase ppv + Client client = getClient(getAdministratorKs()); + client.setUserId(Integer.valueOf(user.getUserId())); + + }*/ + // TODO: 4/16/2018 finish negative scenarios // @Test(description = "entitlement/action/grant - ppv - error 3021") // @Test(description = "entitlement/action/grant - subscription - error 3024") From a6fd59ada871ae03dfecb70401c63e374592316c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 26 Apr 2018 17:19:35 +0300 Subject: [PATCH 143/605] Added more tests to AssetHistoryActionCleanLists class --- .../AssetHistoryActionCleanLists.java | 96 ++++++++++++++++++- .../AssetHistoryListTests.java | 53 ++++------ .../client/test/utils/AssetHistoryUtils.java | 25 +++++ 3 files changed, 136 insertions(+), 38 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index afa27c524..2c64c0cb6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -1,4 +1,98 @@ package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; -public class AssetHistoryActionCleanLists { +import com.kaltura.client.Client; +import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetHistoryUtils; +import com.kaltura.client.types.AssetHistory; +import com.kaltura.client.types.AssetHistoryFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.Properties.*; +import static org.assertj.core.api.Assertions.assertThat; + +public class AssetHistoryActionCleanLists extends BaseTest { + + private Client client; + private int position1 = 10; + private int position2 = 20; + + @BeforeClass + private void add_tests_before_class() { + client = getClient(getsharedMasterUserKs()); + + } + + @Description("/assetHistory/action/clean - bo filtering") + @Test + private void cleanHistory() { + // Ingest and bookmark first asset + AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset + AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + + //assetHistory/action/list - both assets should returned + AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); + + //assetHistory/action/clean + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + // assetHistory/action/list - after clean - no object returned + assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); + } + + @Description("/assetHistory/action/clean - filtered by asset id") + @Test + private void cleanSpecifcAssetHistory() { + // Ingest and bookmark first asset + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId1), null, WatchStatus.ALL, null); + + //assetHistory/action/clean + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + // Update assetHistoryFilter object (assetIdIn = null) + assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + + // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + } + + @Description("/assetHistory/action/clean - filtered by asset type") + @Test + private void cleanSpecifcAssetTypeHistory() { + // Ingest and bookmark first asset + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, EPISODE_MEDIA_TYPE_ID); + + //assetHistory/action/clean - only episode type (asset id 2) + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + // Update assetHistoryFilter object (assetIdIn = null) + assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + + // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 7939d87f3..fadd3a39d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -1,12 +1,10 @@ package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; import com.kaltura.client.Client; -import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; -import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; import com.kaltura.client.types.*; @@ -15,14 +13,14 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.test.Properties.*; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { private Client client; private AssetType assetType = AssetType.MEDIA; + private int position1 = 10; + private int position2 = 20; @BeforeClass private void add_tests_before_class() { @@ -33,13 +31,10 @@ private void add_tests_before_class() { @Test private void vodAssetHistory() { - int asset1Position = 10; - int asset2Position = 20; - // Ingest and bookmark first asset - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, asset1Position, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, asset2Position, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); //assetHistory/action/list - both assets should returned @@ -53,7 +48,7 @@ private void vodAssetHistory() { // Assertions for first object returned assertThat(assetHistoryObject1.getAssetId()).isEqualTo(assetId2); assertThat(assetHistoryObject1.getAssetType()).isEqualTo(assetType); - assertThat(assetHistoryObject1.getPosition()).isEqualTo(asset2Position); + assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); // Verify that flag is set to false (user hasn't finish watching the asset) assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); @@ -62,7 +57,7 @@ private void vodAssetHistory() { // Assertions for second object returned assertThat(assetHistoryObject2.getAssetId()).isEqualTo(assetId1); assertThat(assetHistoryObject2.getAssetType()).isEqualTo(assetType); - assertThat(assetHistoryObject2.getPosition()).isEqualTo(asset1Position); + assertThat(assetHistoryObject2.getPosition()).isEqualTo(position1); // Assert total count = 2 (two bookmarks) assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); @@ -73,10 +68,10 @@ private void vodAssetHistory() { private void vodAssetHistoryFilteredByAssetId() { // Ingest and bookmark first asset - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); - Long assetId3 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId3 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId2), null, WatchStatus.ALL, null); //assetHistory/action/list - filter by asset 2 id @@ -84,13 +79,13 @@ private void vodAssetHistoryFilteredByAssetId() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); - String concatenatedString = BaseUtils.getConcatenatedString(String.valueOf(assetId2),String.valueOf(assetId3)); + String concatenatedString = BaseUtils.getConcatenatedString(String.valueOf(assetId2), String.valueOf(assetId3)); - //assetHistory/action/list - filter by asset 2 and asset 3 ids + //assetHistory/action/list - filter by asset 2 and asset 3 ids assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, null, WatchStatus.ALL, null); assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId3); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId3); assertThat(assetHistoryListResponse.results.getObjects().get(1).getAssetId()).isEqualTo(assetId2); } @@ -99,9 +94,9 @@ private void vodAssetHistoryFilteredByAssetId() { private void vodAssetHistoryFilteredByAssetType() { // Ingest and bookmark first asset (movie in first play) - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, MOVIE_MEDIA_TYPE_ID); //assetHistory/action/list - filter by in progress assets only @@ -115,9 +110,9 @@ private void vodAssetHistoryFilteredByAssetType() { @Test private void vodAssetHistoryFilteredByAssetProgress() { // Ingest and bookmark first asset (movie in first play) - Long assetId1 = ingestAssetAndPerformBookmark(MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = ingestAssetAndPerformBookmark(EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); @@ -133,20 +128,4 @@ private void vodAssetHistoryFilteredByAssetProgress() { assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); } - - // Ingest asset, bookmark it and return the asset id - private Long ingestAssetAndPerformBookmark(String mediaType, int position, BookmarkActionType bookmarkActionType) { - // Ingest asset - MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); - Long assetId = mediaAsset.getId(); - int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); - // Movie asset bookmark - assetType = AssetType.MEDIA; - Bookmark bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, assetType, bookmarkActionType); - //bookmark/action/add - Movie asset - BookmarkServiceImpl.add(client, bookmark); - - return assetId; - } } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java index c3448a0e1..8080bc84f 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java @@ -1,9 +1,18 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; import com.kaltura.client.types.AssetHistoryFilter; +import com.kaltura.client.types.Bookmark; +import com.kaltura.client.types.MediaAsset; import javax.annotation.Nullable; +import java.util.Optional; + +import static com.kaltura.client.test.tests.BaseTest.getClient; public class AssetHistoryUtils extends BaseUtils { @@ -17,4 +26,20 @@ public static AssetHistoryFilter getAssetHistoryFilter(@Nullable String assetIdI return assetHistoryFilter; } + + // Ingest asset, bookmark it and return the asset id + public static Long ingestAssetAndPerformBookmark(Client client, String mediaType, int position, BookmarkActionType bookmarkActionType) { + // Ingest asset + MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); + Long assetId = mediaAsset.getId(); + int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + // Movie asset bookmark + AssetType assetType = AssetType.MEDIA; + Bookmark bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, assetType, bookmarkActionType); + //bookmark/action/add - Movie asset + BookmarkServiceImpl.add(client, bookmark); + + return assetId; + } } From 83e6fa11fcbbe2253e8c78e338f8998c028f2258 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Sun, 29 Apr 2018 15:27:05 +0300 Subject: [PATCH 144/605] Updated class - AssetHistoryCleanTests.java --- .../AssetHistoryActionCleanLists.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index 2c64c0cb6..9f3685ce5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -29,7 +29,7 @@ private void add_tests_before_class() { } - @Description("/assetHistory/action/clean - bo filtering") + @Description("/assetHistory/action/clean - no filtering") @Test private void cleanHistory() { // Ingest and bookmark first asset @@ -95,4 +95,27 @@ private void cleanSpecifcAssetTypeHistory() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); } + + @Description("/assetHistory/action/clean - filtered by asset progress") + @Test + private void cleanAssetsAccordingToWatchStatus() { + // Ingest and bookmark first asset + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); + + //assetHistory/action/clean - only asset that were finished (asset 2) + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + + // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + } + + } From b45de74cceb6d9b412d7559bea559929bd1c2165 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 30 Apr 2018 13:44:57 +0300 Subject: [PATCH 145/605] Updated several classes in project --- .../AssetHistoryActionCleanLists.java | 21 ++++++++++++++-- .../AssetHistoryListTests.java | 24 +++++++++++++++++-- .../appTokenTests/AppTokenAddTests.java | 4 +++- .../AssetCommentAddTests.java | 12 ++++------ .../AssetCommentListTests.java | 15 ++++++++---- 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index 97836ae3e..7ec96d8db 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -6,8 +6,10 @@ import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; +import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.AssetHistory; import com.kaltura.client.types.AssetHistoryFilter; +import com.kaltura.client.types.Household; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -17,7 +19,6 @@ import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryActionCleanLists extends BaseTest { @@ -28,13 +29,17 @@ public class AssetHistoryActionCleanLists extends BaseTest { @BeforeClass private void add_tests_before_class() { - client = getClient(getSharedMasterUserKs()); + } @Description("/assetHistory/action/clean - no filtering") @Test private void cleanHistory() { + + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset @@ -58,6 +63,10 @@ private void cleanHistory() { @Description("/assetHistory/action/clean - filtered by asset id") @Test private void cleanSpecifcAssetHistory() { + + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset @@ -80,6 +89,10 @@ private void cleanSpecifcAssetHistory() { @Description("/assetHistory/action/clean - filtered by asset type") @Test private void cleanSpecifcAssetTypeHistory() { + + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset @@ -102,6 +115,10 @@ private void cleanSpecifcAssetTypeHistory() { @Description("/assetHistory/action/clean - filtered by asset progress") @Test private void cleanAssetsAccordingToWatchStatus() { + + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index c1b198c75..b07b905b9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -16,7 +16,6 @@ import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { @@ -27,13 +26,16 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - client = getClient(getSharedMasterUserKs()); + } @Description("/AssetHistory/action/list - with no filter") @Test private void vodAssetHistory() { + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset @@ -64,12 +66,17 @@ private void vodAssetHistory() { // Assert total count = 2 (two bookmarks) assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); + + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); } @Description("/AssetHistory/action/list -filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset @@ -90,12 +97,17 @@ private void vodAssetHistoryFilteredByAssetId() { assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId3); assertThat(assetHistoryListResponse.results.getObjects().get(1).getAssetId()).isEqualTo(assetId2); + + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); } @Description("/AssetHistory/action/list -filtered by movie type id") @Test private void vodAssetHistoryFilteredByAssetType() { + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset (movie in first play) Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) @@ -106,12 +118,18 @@ private void vodAssetHistoryFilteredByAssetType() { Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); } @Description("/AssetHistory/action/list -filtered by assets progress") @Test private void vodAssetHistoryFilteredByAssetProgress() { + + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + // Ingest and bookmark first asset (movie in first play) Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) @@ -129,6 +147,8 @@ private void vodAssetHistoryFilteredByAssetProgress() { assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 6de3a07f6..a8ec7c4cc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -19,7 +19,7 @@ public class AppTokenAddTests extends BaseTest { private AppTokenHashType hashType; - private String sessionUserId = getSharedUser().getUserId(); + private String sessionUserId; private AppToken appToken = new AppToken(); public static Client client; private String sessionPrivileges; @@ -27,7 +27,9 @@ public class AppTokenAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { hashType = AppTokenHashType.SHA1; + sessionUserId = getSharedUser().getUserId(); appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); + } @Description("appToken/action/add") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 89f41ddf5..6ebbdd80e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -7,11 +7,9 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.IngestUtils; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.AssetComment; -import com.kaltura.client.types.AssetCommentFilter; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; @@ -19,8 +17,6 @@ import java.util.Optional; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedUserKs; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class AssetCommentAddTests extends BaseTest { @@ -34,8 +30,8 @@ public class AssetCommentAddTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - getSharedHousehold(); - client = getClient(getSharedUserKs()); + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); } @Description("AssetComment/action/add - vod asset") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index 3db75b3c3..6f6df4d9d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -6,16 +6,20 @@ import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.IngestVODUtils; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; +import com.kaltura.client.types.Household; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedHousehold; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedUserKs; +import java.util.Optional; + +import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; public class AssetCommentListTests extends BaseTest { @@ -24,8 +28,8 @@ public class AssetCommentListTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - getSharedHousehold(); - client = getClient(getSharedUserKs()); + Household household = HouseholdUtils.createHouseHold(1, 1, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); } @Description("AssetComment/action/list - check order by functionality") @@ -39,7 +43,8 @@ private void checkCommentsOrder() { String subHeader = "subHeader"; String text = "A lot of text"; - Long assetId = BaseTest.getSharedMediaAsset().getId(); + Long assetId = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(MOVIE_MEDIA_TYPE)), Optional.empty(), Optional.empty()).getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); From fec755d411cbfcca8ad45de07d296851f8acadfb Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 30 Apr 2018 15:27:35 +0300 Subject: [PATCH 146/605] Added more logs into ingest methods and documentation into ingestPP, IngestPPV and IngestMPP methods. Removed useless classes --- .../client/test/utils/IngestEPGUtils.java | 272 ------------------ .../client/test/utils/IngestMPPUtils.java | 177 ------------ .../client/test/utils/IngestPPUtils.java | 117 -------- .../client/test/utils/IngestPPVUtils.java | 136 --------- .../client/test/utils/IngestUtils.java | 95 +++++- .../client/test/utils/IngestVODUtils.java | 176 ------------ 6 files changed, 84 insertions(+), 889 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java diff --git a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java deleted file mode 100644 index 27b4c7313..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestEPGUtils.java +++ /dev/null @@ -1,272 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.Logger; -import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.SearchAssetFilter; -import com.kaltura.client.utils.response.base.Response; -import io.restassured.RestAssured; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.*; -import static org.awaitility.Awaitility.await; - -public class IngestEPGUtils extends BaseUtils { - // TODO: think about ENUMS if we really need it here? should we create new ENUM class for it? where? - public static final String DURATION_PERIOD_DAYS = "days"; - public static final String DURATION_PERIOD_HOURS = "hours"; - public static final String DURATION_PERIOD_MINUTES = "minutes"; - public static final String DURATION_PERIOD_SECONDS = "seconds"; - - // default values - public static final int DEFAULT_COUNT_OF_SEASONES = 1; - public static final int DEFAULT_COUNT_OF_PROGRAMMES = 2; - public static final int DEFAULT_PROGRAM_DURATION = 30; - public static final String DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; - - private static List durationPeriodNames = new ArrayList<>(); - - static { - durationPeriodNames.add(DURATION_PERIOD_DAYS); - durationPeriodNames.add(DURATION_PERIOD_HOURS); - durationPeriodNames.add(DURATION_PERIOD_MINUTES); - durationPeriodNames.add(DURATION_PERIOD_SECONDS); - } - - private static String titleOfIngestedItem = ""; - - // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project - public static Response> ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, - Optional programDuration, Optional programDurationPeriodName, - Optional isCridUnique4AllPrograms, Optional seasonCount, - Optional coguid, Optional crid, Optional seriesId) { - - int programCountValue = programCount.orElse(DEFAULT_COUNT_OF_PROGRAMMES); - if (programCountValue <= 0) { - Logger.getLogger(IngestEPGUtils.class).error("Invalid programCount value " + programCount.get() + - ". Should be bigger than 0"); - return null; - } - int seasonCountValue = seasonCount.orElse(DEFAULT_COUNT_OF_SEASONES); - - String datePattern = "MM/yy/dd HH:mm:ss"; - SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); - String firstProgramStartDateValue = firstProgramStartDate.orElse(getCurrentDataInFormat(datePattern)); - Calendar startDate = Calendar.getInstance(); - try { - startDate.setTime(dateFormat.parse(firstProgramStartDateValue)); - } catch (ParseException e) { - e.printStackTrace(); - } - - int programDurationValue = programDuration.orElse(DEFAULT_PROGRAM_DURATION); - if (programDurationValue <= 0) { - Logger.getLogger(IngestEPGUtils.class).error("Invalid programDuration value " + programDuration.get() + - ". Should be bigger than 0"); - return null; - } - String programDurationPeriodNameValue = programDurationPeriodName.orElse(DEFAULT_PROGRAM_DURATION_PERIOD_NAME); - if (!durationPeriodNames.contains(programDurationPeriodNameValue)) { - Logger.getLogger(IngestEPGUtils.class).error("Invalid programDurationPeriodName value " + programDurationPeriodName.get() + - ". Should be one from " + durationPeriodNames); - return null; - } - boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); - - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); - String cridValue = crid.orElse(coguidValue); - String seriesIdValue = seriesId.orElse(coguidValue); - int seasonId = 1; - Date endDate; - String output = ""; - String oneProgrammOutput = ""; - SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss"); - Date now = Calendar.getInstance().getTime(); - while (seasonId <= seasonCountValue) { - int idx = 1; - while(idx <= programCountValue) { - endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); - oneProgrammOutput = getProgrammeXML(idx, df2.format(startDate.getTime()), df2.format(endDate), - epgChannelName, coguidValue, cridValue, "Program", df2.format(now), - seriesIdValue, String.valueOf(seasonId), isCridUnique4AllProgramsValue); - startDate.setTime(endDate); - output = output + oneProgrammOutput; - idx = idx + 1; - } - seasonId = seasonId + 1; - } - String epgChannelIngestXml = getChannelXML(partnerId, epgChannelName, output); - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); - String reqBody = "\n" + - " \n" + - " \n" + - " " + - " " + - " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + - epgChannelIngestXml + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headermap) - .body(reqBody) - .post(url); - //System.out.println("RESPONSE: " + resp.asString()); - int epgChannelId = DBUtils.getEpgChannelId(epgChannelName); - // TODO: create method getting epoch value from String and pattern - long epoch = 0L; - try { - Date firstProgramStartDateAsDate = dateFormat.parse(firstProgramStartDateValue); - epoch = firstProgramStartDateAsDate.getTime()/1000; - } catch (ParseException e) { - e.printStackTrace(); - } - String firstProgramStartDateEpoch = String.valueOf(epoch); - - SearchAssetFilter assetFilter = new SearchAssetFilter(); - assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); - assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); - await().pollInterval(3, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS) - .until(isDataReturned(epgChannelId, assetFilter, programCountValue*seasonCountValue)); - - Response> ingestedProgrammes = AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null); - // TODO: complete Asset.json at least for programs - return ingestedProgrammes; - } - - private static Callable isDataReturned(int epgChannelId, SearchAssetFilter assetFilter, int totalCount) { - return () -> (AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).error == null && - AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).results.getTotalCount() == totalCount); - } - - private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { - return " " + - "" + - "" + - programsXml + - "" + - "]]>"; - } - - // generate XML for ingest of 1 program - private static String getProgrammeXML(int idx, String startDate, String endDate, String channel, String coguid, String crid, - String programNamePrefix, String currentDate, String seriesId, String seasonNumber, - boolean isCridUnique4AllPrograms) { - String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; - if ("".equals(titleOfIngestedItem)) { - titleOfIngestedItem = name; - } - // TODO: complete to cover util from old project completely - String CRID = "" + crid + "_" + idx + ""; - if (isCridUnique4AllPrograms) { - CRID = "" + crid + "_" + seasonNumber + "_" + idx + ""; - } - String output = - "" + - "" + name + "" + - CRID + - "" + startDate + " until " + endDate + "" + - "" + currentDate + "" + - "eng" + - //"" + - //"" + enableCDVR + "" + - //"" + enableCatchUp + ""+ - //"" + enableStartOver + "" + - //"" + enableTrickPlay + "" + - //"" + - //"" + metaName + "" + - //"" + metaValue + "" + - //"" + - "" + - // TODO: that meta should be added into property file - "season_num" + - "" + seasonNumber + "" + - "" + - "" + - // TODO: that meta should be added into property file - "Series_ID" + - "" + seriesId + "" + - "" + - "" + - // TODO: that meta should be added into property file - "Episode number" + - "" + idx + "" + - "" + - /* "" + - "Season" + - "" + seasonNumber + "" + - "" + - "" + - "Episode" + - "" + id + "" + - "" + - */ - //"" + - //"Country" + - //"Israel" + - //"" + - //"" + - //"YEAR" + - //"2015" + - //"" + - //"" + - //"Genre" + - //"" + genre + "" + - //"" + - //"" + - //"Actors" + - //"Shay" + - //"Ortal" + - //"" + - //"" + - //"" + tagName + "" + - //"" + tagValue + "" + - //"" + - //"" + - //"" + parentalFieldName + "" + - //"" + parentalValue + "" + - //"" + - //"" + - //"" + parentalFieldName + "" + - //"" + parentalValue2 + "" + - //"" + - ""; - return output; - } - - private static Date loadEndDate(Date startDate, int durationValue, String periodName) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(startDate); - switch (periodName) { - case DURATION_PERIOD_DAYS: - calendar.add(Calendar.DATE, durationValue); - break; - case DURATION_PERIOD_HOURS: - calendar.add(Calendar.HOUR, durationValue); - break; - case DURATION_PERIOD_MINUTES: - calendar.add(Calendar.MINUTE, durationValue); - break; - case DURATION_PERIOD_SECONDS: - calendar.add(Calendar.SECOND, durationValue); - } - return calendar.getTime(); - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java deleted file mode 100644 index ecdbb91e1..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestMPPUtils.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.Logger; -import com.kaltura.client.types.Subscription; -import io.restassured.RestAssured; -import io.restassured.response.Response; - -import java.util.HashMap; -import java.util.Optional; - -import static com.kaltura.client.test.Properties.*; -import static io.restassured.path.xml.XmlPath.from; - -public class IngestMPPUtils extends BaseUtils { - - private static String DEFAULT_ACTION_VALUE = "insert"; - private static boolean DEFAULT_IS_ACTIVE_VALUE = true; - private static String DEFAULT_TITLE_VALUE = "Ingest MPP title"; - private static String DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; - private static String DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; - private static String DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; - private static boolean DEFAULT_IS_RENEWABLE_VALUE = false; - private static int DEFAULT_GRACE_PERIOD_VALUE = 0; - - // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon - private static String DEFAULT_COUPON_GROUP_VALUE = - "\n" + - "01/05/2017 00:00:00\n" + - "31/12/2099 23:59:59\n" + - "100% unlimited\n" + - "\n" + - "\n" + - "01/05/2017 00:00:00\n" + - "31/05/2017 23:59:59\n" + - "Expired coupon group 1\n" + - ""; - - private static String DEFAULT_PRODUCT_CODES_VALUE = - "\n" + - "ProductCode1\n" + - "Google\n" + - "\n" + - "\n" + - "ProductCode2\n" + - "Apple\n" + - ""; - - // ingest new MPP - public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, - Optional title, Optional description, Optional startDate, - Optional endDate, Optional internalDiscount, - Optional productCode, Optional isRenewable, - Optional gracePeriodMinute, Optional pricePlanCode1, - Optional pricePlanCode2, Optional channel1, - Optional channel2, Optional fileType1, - Optional fileType2, Optional couponGroup, Optional productCodes) { - String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); - String actionValue = action.orElse(DEFAULT_ACTION_VALUE); - boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); - String titleValue = title.orElse(DEFAULT_TITLE_VALUE); - String descriptionValue = description.orElse(DEFAULT_DESCRIPTION_VALUE); - String startDateValue = startDate.orElse(DEFAULT_START_DATE_VALUE); - String endDateValue = endDate.orElse(DEFAULT_END_DATE_VALUE); - String internalDiscountValue = internalDiscount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); - String productCodeValue = productCode.orElse(""); - boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); - int gracePeriodMinuteValue = gracePeriodMinute.orElse(DEFAULT_GRACE_PERIOD_VALUE); - String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); - String pricePlanCode2Value = pricePlanCode2.orElse(""); - String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); - String channel2Value = channel2.orElse(""); - String fileType1Value = fileType1.orElse(""); - String fileType2Value = fileType2.orElse(""); - String couponGroupValue = couponGroup.orElse(DEFAULT_COUPON_GROUP_VALUE); - String productCodesValue = productCodes.orElse(DEFAULT_PRODUCT_CODES_VALUE); - - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - - Response resp = RestAssured.given() - .log().all() - .headers(headermap) - .body(reqBody) - .post(url); - - //Logger.getLogger(IngestMPPUtils.class).debug(reqBody); - Logger.getLogger(IngestMPPUtils.class).debug(resp.asString()); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); - - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - Logger.getLogger(IngestMPPUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); - - Subscription subscription = new Subscription(); - subscription.setId(id); - subscription.setName(titleValue); - subscription.setDescription(descriptionValue); - // TODO: complete COMMENTED IF NEEDED - //subscription.setStartDate(); - //subscription.setEndDate(); - //subscription.setDiscountModule(); - //subscription.setProductCodes(); - subscription.isRenewable(String.valueOf(isRenewableValue)); - subscription.setGracePeriodMinutes(gracePeriodMinuteValue); - //subscription.setPricePlanIds(); - //subscription.setChannels(); - //subscription.setFileTypes(); - //subscription.setCouponsGroups(); - return subscription; - } - - private static String buildIngestMppXML(String action, String mppCode, boolean isActive, String title, String description, - String startDate, String endDate, String internalDiscount, String productCode, - boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, - String pricePlanCode2, String channel1, String channel2, String fileType1, - String fileType2, String couponGroup, String productCodes) { - return "\n" + - "\n" + - "\n" + - "\n" + - "" + title + "\n" + - "\n" + - "\n" + - "" + description + "" + - "\n" + - "" + startDate + "\n" + - "" + endDate + "\n" + - "" + internalDiscount + "\n" + - "\n" + - "" + productCode + "\n" + - "" + isRenewable + "\n" + - "\n" + - "" + gracePeriodMinute + "\n" + - "\n" + - "" + pricePlanCode1 + "\n" + - "" + pricePlanCode2 + "\n" + - "\n" + - "\n" + - "" + channel1 + "\n" + - "" + channel2 + "\n" + - "\n" + - "\n" + - "" + fileType1 + "\n" + - "" + fileType2 + "\n" + - "\n" + - "\n" + - "" + couponGroup + "\n" + - "" + productCodes + "\n" + - "\n" + - "\n" + - "\n"; - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java deleted file mode 100644 index bca5e6252..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPUtils.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.Logger; -import com.kaltura.client.types.PricePlan; -import io.restassured.RestAssured; -import io.restassured.response.Response; - -import java.util.HashMap; -import java.util.Optional; - -import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; -import static com.kaltura.client.test.Properties.*; -import static io.restassured.path.xml.XmlPath.from; - -public class IngestPPUtils extends BaseUtils { - - private static String DEFAULT_ACTION_VALUE = "insert"; - private static boolean DEFAULT_IS_ACTIVE_VALUE = true; - private static String DEFAULT_FULL_LIFE_CYCLE_VALUE = "5 Minutes"; - private static String DEFAULT_VIEW_LIFE_CYCLE_VALUE = "5 Minutes"; - private static int DEFAULT_MAX_VIEWS_VALUE = 0; - private static boolean DEFAULT_IS_RENEWABLE_VALUE = false; - private static int DEFAULT_RECURRING_PERIODS_VALUE = 1; - - // ingest new PP - public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, - Optional fullLifeCycle, Optional viewLifeCycle, Optional maxViews, - Optional price, Optional currency, - Optional discount, Optional isRenewable, - Optional recurringPeriods) { - String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", 9999999999L)); - String actionValue = action.orElse(DEFAULT_ACTION_VALUE); - boolean isActiveValue = isActive.orElse(DEFAULT_IS_ACTIVE_VALUE); - String fullLifeCycleValue = fullLifeCycle.orElse(DEFAULT_FULL_LIFE_CYCLE_VALUE); - String viewLifeCycleValue = viewLifeCycle.orElse(DEFAULT_VIEW_LIFE_CYCLE_VALUE); - int maxViewsValue = maxViews.orElse(DEFAULT_MAX_VIEWS_VALUE); - String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT)); - String currencyValue = currency.orElse(CURRENCY_EUR); - String discountValue = discount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); - boolean isRenewableValue = isRenewable.orElse(DEFAULT_IS_RENEWABLE_VALUE); - int recurringPeriodsValue = recurringPeriods.orElse(DEFAULT_RECURRING_PERIODS_VALUE); - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - - Response resp = RestAssured.given() - .log().all() - .headers(headermap) - .body(reqBody) - .post(url); - - Logger.getLogger(IngestPPUtils.class).debug(reqBody); - Logger.getLogger(IngestPPUtils.class).debug(resp.asString()); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestMPPUtils.class).debug("ReportId = " + reportId); - - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - Logger.getLogger(IngestPPUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); - //Logger.getLogger(IngestPPUtils.class).debug("ID: " + id); - - PricePlan pricePlan = new PricePlan(); - pricePlan.setId(Long.valueOf(id)); - pricePlan.setMaxViewsNumber(maxViewsValue); - pricePlan.setIsRenewable(isRenewableValue); - pricePlan.setRenewalsNumber(recurringPeriodsValue); - // TODO: complete COMMENTED IF NEEDED - //pricePlan.setFullLifeCycle(); - //pricePlan.setViewLifeCycle(); - //pricePlan.setPriceDetailsId(); - //pricePlan.setDiscountId(); - return pricePlan; - } - - private static String buildIngestPpXML(String action, String ppCode, boolean isActive, String fullLifeCycle, - String viewLifeCycle, int maxViews, String price, String currency, - String discount, boolean isRenewable, int recurringPeriods) { - String id = "reportIngestPricePlan" + action.substring(0, 1).toUpperCase() + action.substring(1); - return "\n" + - "\n" + - "\n" + - "" + fullLifeCycle + "\n" + - "" + viewLifeCycle + "\n" + - "" + maxViews + "\n" + - "\n" + - "" + price + "\n" + - "" + currency + "\n" + - "\n" + - "" + discount + "\n" + - "" + isRenewable + "\n" + - "" + recurringPeriods + "\n" + - "\n" + - "\n" + - "\n"; - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java deleted file mode 100644 index 8c034dd4a..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.types.*; -import io.restassured.RestAssured; -import io.restassured.response.Response; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; - -import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; -import static com.kaltura.client.test.Properties.*; -import static io.restassured.path.xml.XmlPath.from; - -public class IngestPPVUtils extends BaseUtils { - - - // way to ingest PPV using predefined default values for any of input parameters - public static Ppv ingestPPVWithDefaultValues(Optional action, Optional isActive, Optional description, - Optional discount, Optional price, Optional currency, - Optional usageModule, Optional isSubscriptionOnly, - Optional isFirstDeviceLimitation, Optional productCode, - Optional firstFileType, Optional secondFileType) { - String actionValue = action.orElse("insert"); - boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; - String descriptionValue = description.orElse("My ingest PPV"); - String discountValue = discount.orElseGet(() -> getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); - double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); - String currencyValue = currency.orElseGet(() -> getProperty(CURRENCY_EUR)); - String usageModuleValue = usageModule.orElseGet(() -> getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); - boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; - boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; - String productCodeValue = productCode.orElseGet(() -> getProperty(DEFAULT_PRODUCT_CODE)); - String firstFileTypeValue = firstFileType.orElseGet(() -> getProperty(WEB_FILE_TYPE)); - String secondFileTypeValue = secondFileType.orElseGet(() -> getProperty(MOBILE_FILE_TYPE)); - - return ingestPPV(actionValue, isActiveValue, descriptionValue, discountValue, priceValue, currencyValue, - usageModuleValue, isSubscriptionOnlyValue, isFirstDeviceLimitationValue, productCodeValue, - firstFileTypeValue, secondFileTypeValue); - } - - // ingest new PPV - public static Ppv ingestPPV(String action, boolean isActive, String description, String discount, - double price, String currency, String usageModule, boolean isSubscriptionOnly, - boolean isFirstDeviceLimitation, String productCode, String firstFileType, - String secondFileType) { - String ppvCode = getRandomValue("PPV_", 9999999999L); - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - - Response resp = RestAssured.given() - .log().all() - .headers(headermap) - .body(reqBody) - .post(url); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //System.out.println("ReportId = " + reportId); - - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - System.out.println(resp.asString()); - System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); - - Ppv ppv = new Ppv(); - ppv.setId(id); - List descriptions = new ArrayList<>(); - TranslationToken translationToken = new TranslationToken(); - translationToken.setValue(description); - descriptions.add(translationToken); - ppv.setDescriptions(descriptions); - PriceDetails priceDetails = new PriceDetails(); - Price priceObj = new Price(); - priceObj.setAmount(price); - priceObj.setCurrency(currency); - priceDetails.setPrice(priceObj); - ppv.setPrice(priceDetails); - UsageModule usageModuleObj = new UsageModule(); - usageModuleObj.setName(usageModule); - ppv.setUsageModule(usageModuleObj); - ppv.setIsSubscriptionOnly(isSubscriptionOnly); - ppv.setFirstDeviceLimitation(isFirstDeviceLimitation); - ppv.setProductCode(productCode); - - return ppv; - } - - private static String buildIngestPpvXML(String action, String ppvCode, boolean isActive, String description, String discount, - double price, String currency, String usageModule, boolean isSubscriptionOnly, - boolean isFirstDeviceLimitation, String productCode, String firstFileType, - String secondFileType) { - return "\n" + - " \n" + - " \n" + - " \n" + - " " + description + "\n" + - " \n" + - " \n" + - " " + price + "\n" + - " " + currency + "\n" + - " \n" + - " " + usageModule + "\n" + - " " + discount + "\n" + - " \n" + - " " + isSubscriptionOnly + "\n" + - " " + isFirstDeviceLimitation + "\n" + - " " + productCode + "\n" + - " \n" + - " " + firstFileType + "\n" + - " " + secondFileType + "\n" + - " \n" + - " \n" + - " \n" + - "\n"; - } -} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 3a8d9e780..e32e97c74 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -7,13 +7,11 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; @@ -47,7 +45,6 @@ public class IngestUtils extends BaseUtils { // INGEST MPP PARAMS private static boolean MPP_DEFAULT_IS_ACTIVE_VALUE = true; - private static String MPP_DEFAULT_TITLE_VALUE = "Ingest MPP title"; private static String MPP_DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; private static String MPP_DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; private static String MPP_DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; @@ -165,7 +162,9 @@ public static Response> ingestEPG(String epgChannelName, Opt .headers(headerMap) .body(reqBody) .post(url); - //System.out.println("RESPONSE: " + resp.asString()); + + Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug(resp.asString()); int epgChannelId = DBUtils.getEpgChannelId(epgChannelName); // TODO: create method getting epoch value from String and pattern long epoch = 0L; @@ -311,6 +310,36 @@ private static Date loadEndDate(Date startDate, int durationValue, String period return calendar.getTime(); } + /** + * @param action - can be "insert", "update" and "delete" + * * @param ppCode - should have value in case "action" one of {"update" and "delete"} + * + * @param action - can be "insert" or "delete" ("update" looks like broken) + * @param mppCode - should have value in case "action" is "delete" + * @param isActive + * @param title + * @param description + * @param startDate + * @param endDate + * @param internalDiscount + * @param productCode + * @param isRenewable + * @param gracePeriodMinute + * @param pricePlanCode1 + * @param pricePlanCode2 + * @param channel1 + * @param channel2 + * @param fileType1 + * @param fileType2 + * @param couponGroup + * @param productCodes + * @return MPP data + * + * to delete existed MPP use corresponded action and value mpp.getName() as "mppCode" + * (where mpp is a variable that contains mpp data) + * + * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created manually) + */ // ingest new MPP public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, Optional title, Optional description, Optional startDate, @@ -323,7 +352,7 @@ public static Subscription ingestMPP(Optional action, Optional m String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); String actionValue = action.orElse(INGEST_ACTION_INSERT); boolean isActiveValue = isActive.orElse(MPP_DEFAULT_IS_ACTIVE_VALUE); - String titleValue = title.orElse(MPP_DEFAULT_TITLE_VALUE); + String titleValue = "insert".equals(actionValue) ? mppCodeValue : title.orElse(mppCodeValue); String descriptionValue = description.orElse(MPP_DEFAULT_DESCRIPTION_VALUE); String startDateValue = startDate.orElse(MPP_DEFAULT_START_DATE_VALUE); String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); @@ -443,6 +472,25 @@ private static String buildIngestMppXML(String action, String mppCode, boolean i } // ingest new PP + + /** + * + * @param action - can be "insert", "update" and "delete" + * @param ppCode - should have value in case "action" one of {"update" and "delete"} + * @param isActive + * @param fullLifeCycle + * @param viewLifeCycle + * @param maxViews + * @param price + * @param currency + * @param discount + * @param isRenewable + * @param recurringPeriods + * @return PricePlan data + * + * to update or delete existed price plan use corresponded action and value pricePlan.getName() as "ppCode" + * (where pricePlan is a variable that contains price plan data) + */ public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, Optional fullLifeCycle, Optional viewLifeCycle, Optional maxViews, Optional price, Optional currency, @@ -536,20 +584,38 @@ private static String buildIngestPpXML(String action, String ppCode, boolean isA "\n"; } + /** + * @param action - can be "insert", "update" and "delete" + * @param ppvCode - should have value in case "action" one of {"update" and "delete"} + * @param isActive + * @param description + * @param discount + * @param price + * @param currency + * @param usageModule + * @param isSubscriptionOnly + * @param isFirstDeviceLimitation + * @param productCode + * @param firstFileType + * @param secondFileType + * @return PPV data + * + * to update or delete existed ppv use corresponded action and value ppv.getName() as "ppvCode" + * (where ppv is a variable that contains ppv data) + */ // ingest new PPV - public static Ppv ingestPPV(Optional action, Optional isActive, Optional description, + public static Ppv ingestPPV(Optional action, Optional ppvCode, Optional isActive, Optional description, Optional discount, Optional price, Optional currency, Optional usageModule, Optional isSubscriptionOnly, Optional isFirstDeviceLimitation, Optional productCode, Optional firstFileType, Optional secondFileType) { - String ppvCode = getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST); - String actionValue = action.orElse(INGEST_ACTION_INSERT); + String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; String descriptionValue = description.orElse("My ingest PPV"); String discountValue = discount.orElseGet(() -> getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); - String currencyValue = currency.orElseGet(() -> getProperty(CURRENCY_EUR)); + String currencyValue = currency.orElse(CURRENCY_EUR); String usageModuleValue = usageModule.orElseGet(() -> getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; @@ -567,7 +633,7 @@ public static Ppv ingestPPV(Optional action, Optional isActive, " \n" + " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + - " \n" + @@ -580,6 +646,9 @@ public static Ppv ingestPPV(Optional action, Optional isActive, .body(reqBody) .post(url); + Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //System.out.println("ReportId = " + reportId); @@ -612,6 +681,7 @@ public static Ppv ingestPPV(Optional action, Optional isActive, ppv.setIsSubscriptionOnly(isSubscriptionOnlyValue); ppv.setFirstDeviceLimitation(isFirstDeviceLimitationValue); ppv.setProductCode(productCodeValue); + ppv.setName(ppvCodeValue); return ppv; } @@ -685,7 +755,10 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op .headers(headerMap) .body(reqBody) .post(url); - //System.out.println("RESPONSE: " + resp.asString()); + + Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); MediaAsset mediaAsset = new MediaAsset(); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java deleted file mode 100644 index 65808dea3..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.MediaAsset; -import com.kaltura.client.utils.response.base.Response; -import io.restassured.RestAssured; - -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import static com.kaltura.client.test.IngestConstants.INGEST_VOD_DEFAULT_THUMB; -import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; -import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; -import static io.restassured.path.xml.XmlPath.from; -import static org.awaitility.Awaitility.await; - -public class IngestVODUtils extends BaseUtils { - - // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, - Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, - Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); - String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); - String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); - String descriptionValue = description.orElseGet(() -> "description of " + coguidValue); - String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); - String catalogEndDateValue = catalogEndDate.orElse("14/10/2099 17:00:00"); - String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); - String endDateValue = endDate.orElse("14/10/2099 17:00:00"); - String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); - String ppvWebNameValue = ppvWebName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value - String ppvMobileNameValue = ppvMobileName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value - // TODO: check if ingest url is the same for all ingest actions - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headermap) - .body(reqBody) - .post(url); - //System.out.println("RESPONSE: " + resp.asString()); - String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - - MediaAsset mediaAsset = new MediaAsset(); - mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id)); - mediaAsset.setDescription(descriptionValue); - //mediaAsset.setStartDate(startDate); - //mediaAsset.setEndDate(endDate); - - await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(id)); - Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); - mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); - - // TODO: 4/15/2018 add log for ingest and index failures - return mediaAsset; - } - - private static Callable isDataReturned(String mediaId) { - return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; - } - - private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, - String description, String catalogStartDate, String catalogEndDate, - String startDate, String endDate, String mediaType, String ppvWebName, - String ppvMobileName) { - return "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + name + "\n" + - " \n" + - " \n" + - " \n" + - " " + description + "\n" + - " \n" + - " \n" + - " " + catalogStartDate + "\n" + - " " + startDate + "\n" + - " " + catalogEndDate + "\n" + - " " + endDate + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + mediaType + "\n" + - " \n" + - //" ${#TestCase#i_geo_block_rule}\n" + - //" Parent Allowed\n" + - //" ${#TestCase#i_device_block_rule}\n" + - " \n" + - " \n" + - " \n" + - //" \n" + - //" \n" + - //" syno pino sister\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_double_meta_value}\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_date_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Costa Rica;Israel\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" GIH\n" + - //" \n" + - //" \n" + - //" ABC\n" + - //" \n" + - //" \n" + - //" DEF\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Shay_Series\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_free_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_parental_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_value}\n" + - //" \n" + - //" \n" + - //" \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - } -} From b3ba28a2614523e1b938503f3a10784b6fa500c9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 30 Apr 2018 16:14:53 +0300 Subject: [PATCH 147/605] Updated test.template.properties and remove hardcoded values from AssetHistoryClean and AssetHistoryList classes --- .../AssetHistoryActionCleanLists.java | 35 ++++++++++++++++--- .../AssetHistoryListTests.java | 12 ++++--- src/test/resources/test.template.properties | 6 +++- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index 7ec96d8db..aaae7d93a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -26,6 +26,8 @@ public class AssetHistoryActionCleanLists extends BaseTest { private Client client; private int position1 = 10; private int position2 = 20; + int numbOfDevices = 1; + int numOfUsers = 1; @BeforeClass private void add_tests_before_class() { @@ -37,7 +39,7 @@ private void add_tests_before_class() { @Test private void cleanHistory() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset @@ -64,7 +66,7 @@ private void cleanHistory() { @Test private void cleanSpecifcAssetHistory() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset @@ -90,7 +92,7 @@ private void cleanSpecifcAssetHistory() { @Test private void cleanSpecifcAssetTypeHistory() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset @@ -114,9 +116,9 @@ private void cleanSpecifcAssetTypeHistory() { @Description("/assetHistory/action/clean - filtered by asset progress") @Test - private void cleanAssetsAccordingToWatchStatus() { + private void cleanAssetsAccordingToWatchStatusDone() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset @@ -137,5 +139,28 @@ private void cleanAssetsAccordingToWatchStatus() { assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); } + @Description("/assetHistory/action/clean - filtered by asset progress") + @Test + private void cleanAssetsAccordingToWatchStatusProgress() { + + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + + // Ingest and bookmark first asset + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + // Ingest and bookmark second asset + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); + //assetHistory/action/clean - only asset that in progress (asset 1) + AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + + // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) + Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index b07b905b9..118be92ad 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -23,6 +23,8 @@ public class AssetHistoryListTests extends BaseTest { private AssetType assetType = AssetType.MEDIA; private int position1 = 10; private int position2 = 20; + int numbOfDevices = 1; + int numOfUsers = 1; @BeforeClass private void add_tests_before_class() { @@ -33,7 +35,7 @@ private void add_tests_before_class() { @Test private void vodAssetHistory() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset @@ -74,7 +76,7 @@ private void vodAssetHistory() { @Test private void vodAssetHistoryFilteredByAssetId() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset @@ -105,7 +107,7 @@ private void vodAssetHistoryFilteredByAssetId() { @Test private void vodAssetHistoryFilteredByAssetType() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset (movie in first play) @@ -127,7 +129,7 @@ private void vodAssetHistoryFilteredByAssetType() { @Test private void vodAssetHistoryFilteredByAssetProgress() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); + Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset (movie in first play) @@ -151,4 +153,6 @@ private void vodAssetHistoryFilteredByAssetProgress() { AssetHistoryServiceImpl.clean(client, assetHistoryFilter); } + //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] + } diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index badaa4d22..ae27d08d9 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -48,4 +48,8 @@ default_usage_module_4_ingest_ppv=@DEFAULT_USAGE_MODULE_4_INGEST_PPV@ default_usage_module_4_ingest_mpp=@DEFAULT_USAGE_MODULE_4_INGEST_MPP@ # Product Codes -default_product_code=@DEFAULT_PRODUCT_CODE@ \ No newline at end of file +default_product_code=@DEFAULT_PRODUCT_CODE@ + +# media types ids +movie_media_type_id=@MOVIE_MEDIA_TYPE_ID@ +episode_media_type_id=@EPISODE_MEDIA_TYPE_ID@ \ No newline at end of file From ce333c02d84ae3c58259ced809a038247eaa58d9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 30 Apr 2018 17:23:08 +0300 Subject: [PATCH 148/605] Added new class - ChannelAddTests.java --- .../channelTests/ChannelAddTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java new file mode 100644 index 000000000..00d8285cb --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -0,0 +1,25 @@ +package com.kaltura.client.test.tests.servicesTests.channelTests; + +import com.kaltura.client.Client; +import com.kaltura.client.test.tests.BaseTest; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class ChannelAddTests extends BaseTest { + + private Client client; + + @BeforeClass + private void get_tests_before_class() { + + } + + @Description ("channel/action/add") + @Test + + private void addChannel() { + + } + +} From dfcbaf001ea6b3c5dff1cb634b085e9ce8c32036 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 30 Apr 2018 18:03:52 +0300 Subject: [PATCH 149/605] Added grant tests --- .../test/TestAPIOkRequestsExecutor.java | 2 +- .../servicesImpl/HouseholdServiceImpl.java | 19 ++- .../kaltura/client/test/tests/BaseTest.java | 3 +- .../entitlementTests/CancelTests.java | 13 ++ .../entitlementTests/GrantTests.java | 152 +++++++++++++----- .../client/test/utils/IngestPPVUtils.java | 1 - src/test/resources/schemas/MediaAsset.json | 3 +- 7 files changed, 146 insertions(+), 47 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/CancelTests.java diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 3263be196..697f1c80c 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -35,7 +35,7 @@ public static TestAPIOkRequestsExecutor getExecutor() { protected ResponseElement onGotResponse(Response response, RequestElement action) { ResponseElement responseElement = super.onGotResponse(response, action); // logger.debug("response body:\n" + responseElement.getResponse()); // was found in base class - logger.debug("response headers:\n" + response.headers()); +// logger.debug("response headers:\n" + response.headers()); if (responseElement.isSuccess()) { com.kaltura.client.utils.response.base.Response response1 = action.parseResponse(responseElement); diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java index 6f2ae1f1e..c124034e6 100644 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java @@ -125,11 +125,20 @@ public static Response resume(Client client) { // suspend public static Response suspend(Client client, @Nullable Integer roleId) { - SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(roleId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); + SuspendHouseholdBuilder suspendHouseholdBuilder; + if (roleId == null) { + suspendHouseholdBuilder = HouseholdService.suspend() + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + } else { + suspendHouseholdBuilder = HouseholdService.suspend(roleId) + .setCompletion((ApiCompletion) result -> { + booleanResponse = result; + done.set(true); + }); + } TestAPIOkRequestsExecutor.getExecutor().queue(suspendHouseholdBuilder.build(client)); await().untilTrue(done); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index a077ac9e6..b4fea4302 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -11,8 +11,9 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; +import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; +import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/CancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/CancelTests.java new file mode 100644 index 000000000..6b8bf4c0e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/CancelTests.java @@ -0,0 +1,13 @@ +package com.kaltura.client.test.tests.servicesTests.entitlementTests; + +import com.kaltura.client.test.tests.BaseTest; +import org.testng.annotations.Test; + +public class CancelTests extends BaseTest { + + @Test(description = "entitlement/action/cancel") + private void cancel() { +// EntitlementServiceImpl + + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index e9de2a850..ec6ae413e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -12,6 +12,7 @@ import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Issue; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -71,7 +72,7 @@ private void grant_subscription_with_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); client.setUserId(null); BillingTransaction billingTransaction; @@ -79,7 +80,7 @@ private void grant_subscription_with_history() { transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -89,7 +90,7 @@ private void grant_subscription_with_history() { // check transaction return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -117,21 +118,21 @@ private void grant_subscription_without_history() { // check transaction not return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); client.setUserId(null); TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); // check transaction not return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); @@ -171,7 +172,7 @@ private void grant_ppv_with_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); client.setUserId(null); BillingTransaction billingTransaction; @@ -179,7 +180,7 @@ private void grant_ppv_with_history() { transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -189,7 +190,7 @@ private void grant_ppv_with_history() { // check transaction return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -218,7 +219,7 @@ private void grant_ppv_without_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()),null)); + client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); client.setUserId(null); BillingTransaction billingTransaction; @@ -226,7 +227,7 @@ private void grant_ppv_without_history() { transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -236,7 +237,7 @@ private void grant_ppv_without_history() { // check transaction return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -247,37 +248,114 @@ private void grant_ppv_without_history() { HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); } - @Test(description = "entitlement/action/grant - grant ppv with wrong id - error 6001") - private void grant_ppv_with_wrong_id() { - int productId = 1; + @Test(description = "entitlement/action/grant - grant ppv with wrong id - error 6001") + private void grant_ppv_with_wrong_id() { + int productId = 1; - // get user form test shared household - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + // get user form test shared household + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); - // grant ppv with wrong id - Client client = getClient(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - Response booleanResponse = EntitlementServiceImpl.grant(client, productId, TransactionType.PPV, true, contentId); + // grant ppv with wrong id + Client client = getClient(getAdministratorKs()); + client.setUserId(Integer.valueOf(user.getUserId())); + Response booleanResponse = EntitlementServiceImpl.grant(client, productId, TransactionType.PPV, true, contentId); + + // assert error 6001 is return + assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); + } + + @Test(description = "entitlement/action/grant - grant purchased ppv - error 3021") + private void grant_purchased_ppv() { + // get user form test shared household + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); - // assert error 6001 is return - assertThat(booleanResponse.results).isEqualTo(null); - assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); - } + // set client + Client client = getClient(getAdministratorKs()); + client.setUserId(Integer.valueOf(user.getUserId())); -/* @Test(description = "entitlement/action/grant - grant purchased ppv - error 3021") - private void grant_purchased_ppv() { - // get user form test shared household - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + // grant ppv - first time + EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); - // purchase ppv - Client client = getClient(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); + // grant ppv - second time + Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); - }*/ + // assert error 3021 is return + assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3021).getCode()); + } - // TODO: 4/16/2018 finish negative scenarios -// @Test(description = "entitlement/action/grant - ppv - error 3021") -// @Test(description = "entitlement/action/grant - subscription - error 3024") -// @Test(description = "entitlement/action/grant - subscription - error 3023") + @Test(description = "entitlement/action/grant - grant purchased subscription - error 3024") + private void grant_purchased_subscription() { + // get user form test shared household + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + + // set client + Client client = getClient(getAdministratorKs()); + client.setUserId(Integer.valueOf(user.getUserId())); + + // grant subscription - first time + EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + + // grant subscription - second time + Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + + // assert error 3024 is return + assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3024).getCode()); + } + + @Issue("BEO-5022") + @Test(description = "entitlement/action/grant - error 3023") + private void grant_3023() { + // TODO: 4/30/2018 implement test + } + @Issue("BEO-5022") + @Test(description = "entitlement/action/grant - grant ppv with missing content id - error 3018") + private void grant_ppv_with_missing_contentId() { + // TODO: 4/30/2018 implement test + } + + @Test(description = "entitlement/action/grant - user not in domain - error 1005") + private void grant_ppv_user_not_in_domain() { + // get user form test shared household + Client client = getClient(null); + Response ottUserResponse = OttUserServiceImpl.register(client, partnerId, OttUserUtils.generateOttUser(), defaultUserPassword); + OTTUser user = ottUserResponse.results; + + // set client with user not from household + client.setKs(getAdministratorKs()); + client.setUserId(Integer.valueOf(user.getId())); + + // grant subscription + Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, false, contentId); + + // assert error 1005 is return + assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1005).getCode()); + } + + @Test(description = "entitlement/action/grant - user suspend - error 2001") + private void grant_ppv_user_suspend() { + + // set household + Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // suspend household + Client client = getClient(getAdministratorKs()); + client.setUserId(Integer.valueOf(masterUser.getUserId())); + HouseholdServiceImpl.suspend(client, null); + + // grant subscription to suspend user + Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + + // assert error 2001 is return + assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2001).getCode()); + } + + // TODO: 4/16/2018 finish negative scenarios +// @Test(description = "entitlement/action/grant - UnableToPurchaseFree - error 3022") } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java index 8c034dd4a..7d302a476 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestPPVUtils.java @@ -15,7 +15,6 @@ public class IngestPPVUtils extends BaseUtils { - // way to ingest PPV using predefined default values for any of input parameters public static Ppv ingestPPVWithDefaultValues(Optional action, Optional isActive, Optional description, Optional discount, Optional price, Optional currency, diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index 336f5290a..f9c21435b 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -122,8 +122,7 @@ "type": "object", "properties": { "value": { - "type": "string", - "minLength": 1 + "type": "string" }, "objectType": { "type": "string", From a42d8fbadd73904d81877b274360a96547c9d306 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 1 May 2018 11:21:01 +0300 Subject: [PATCH 150/605] Completed documentation for ingest related actions "delete" and "update" --- .../kaltura/client/test/IngestConstants.java | 2 + .../kaltura/client/test/tests/BaseTest.java | 2 +- .../client/test/utils/IngestUtils.java | 53 +++++++++++++------ 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/IngestConstants.java b/src/test/java/com/kaltura/client/test/IngestConstants.java index 7785214ea..cc72c7955 100644 --- a/src/test/java/com/kaltura/client/test/IngestConstants.java +++ b/src/test/java/com/kaltura/client/test/IngestConstants.java @@ -3,6 +3,8 @@ public class IngestConstants { public static final String INGEST_ACTION_INSERT = "insert"; + public static final String INGEST_ACTION_DELETE = "delete"; + public static final Long MAX_RANDOM_GENERATED_VALUE_4_INGEST = 9999999999L; public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index a077ac9e6..8ca79b8be 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -126,7 +126,7 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { - mediaAsset = IngestUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } return mediaAsset; diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index e32e97c74..ba661f5a1 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -335,8 +335,11 @@ private static Date loadEndDate(Date startDate, int durationValue, String period * @param productCodes * @return MPP data * + * !!!Only created by that method MPP can be deleted!!! + * * to delete existed MPP use corresponded action and value mpp.getName() as "mppCode" - * (where mpp is a variable that contains mpp data) + * (where mpp is a variable that contains mpp data). + * * * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created manually) */ @@ -352,7 +355,7 @@ public static Subscription ingestMPP(Optional action, Optional m String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); String actionValue = action.orElse(INGEST_ACTION_INSERT); boolean isActiveValue = isActive.orElse(MPP_DEFAULT_IS_ACTIVE_VALUE); - String titleValue = "insert".equals(actionValue) ? mppCodeValue : title.orElse(mppCodeValue); + String titleValue = INGEST_ACTION_INSERT.equals(actionValue) ? mppCodeValue : title.orElse(mppCodeValue); String descriptionValue = description.orElse(MPP_DEFAULT_DESCRIPTION_VALUE); String startDateValue = startDate.orElse(MPP_DEFAULT_START_DATE_VALUE); String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); @@ -490,6 +493,8 @@ private static String buildIngestMppXML(String action, String mppCode, boolean i * * to update or delete existed price plan use corresponded action and value pricePlan.getName() as "ppCode" * (where pricePlan is a variable that contains price plan data) + * + * !!!Only created by that method PP can be deleted/updated!!! */ public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, Optional fullLifeCycle, Optional viewLifeCycle, Optional maxViews, @@ -602,6 +607,8 @@ private static String buildIngestPpXML(String action, String ppCode, boolean isA * * to update or delete existed ppv use corresponded action and value ppv.getName() as "ppvCode" * (where ppv is a variable that contains ppv data) + * + * !!!Only created by that method PPV can be deleted/update!!! */ // ingest new PPV public static Ppv ingestPPV(Optional action, Optional ppvCode, Optional isActive, Optional description, @@ -716,7 +723,7 @@ private static String buildIngestPpvXML(String action, String ppvCode, boolean i } // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, + public static MediaAsset ingestVOD(Optional action, Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; @@ -725,13 +732,14 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value int defaultDayOffset =-1; - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat(coguidDatePattern)); - String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); + String actionValue = action.orElse(INGEST_ACTION_INSERT); + String coguidValue = coguid.orElse(getCurrentDataInFormat(coguidDatePattern)); + String nameValue = INGEST_ACTION_INSERT.equals(actionValue) ? coguidValue : name.orElse(coguidValue); String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); - String descriptionValue = description.orElseGet(() -> "description of " + coguidValue); - String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String descriptionValue = description.orElse("description of " + coguidValue); + String catalogStartDateValue = catalogStartDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); - String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String startDateValue = startDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); String endDateValue = endDate.orElse(maxEndDateValue); String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); @@ -745,7 +753,7 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op " \n" + " \n" + " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + - " \n" + " \n" + @@ -759,7 +767,12 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op Logger.getLogger(IngestUtils.class).debug(reqBody); Logger.getLogger(IngestUtils.class).debug(resp.asString()); - String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); + String id; + if (INGEST_ACTION_INSERT.equals(actionValue)) { + id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); + } else { + id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); + } MediaAsset mediaAsset = new MediaAsset(); mediaAsset.setName(nameValue); @@ -769,26 +782,32 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op //mediaAsset.setEndDate(endDate); int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 45; - await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(id)); + int maxTimeExpectingValidResponseInSeconds = 60; + await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(id, actionValue)); Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); - mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + if (!INGEST_ACTION_DELETE.equals(actionValue)) { + mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + } // TODO: 4/15/2018 add log for ingest and index failures return mediaAsset; } - private static Callable isDataReturned(String mediaId) { - return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; + private static Callable isDataReturned(String mediaId, String action) { + if (INGEST_ACTION_DELETE.equals(action)) { + return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error != null; + } else { + return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; + } } - private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, + private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName) { return "\n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " " + name + "\n" + From 2bd2a9468737339a7953bd6f034d9eafdda37f0d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 1 May 2018 11:25:24 +0300 Subject: [PATCH 151/605] small refactoring done. added draft for new test "subscriptionTest()" --- .../productPriceTests/ListTests.java | 69 ++++++++++++++++++- .../client/test/utils/PurchaseUtils.java | 28 ++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index b58af71a0..9546a9787 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -11,10 +11,11 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.Optional; - import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; @@ -25,6 +26,9 @@ public class ListTests extends BaseTest { private Client client; private EntitlementFilter entitlementPpvsFilter; + private EntitlementFilter entitlementSubsFilter; + private Household household; + private String classMasterUserKs; @BeforeClass public void beforeClass() { @@ -36,6 +40,12 @@ public void beforeClass() { entitlementPpvsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); entitlementPpvsFilter.setIsExpiredEqual(false); + entitlementSubsFilter = new EntitlementFilter(); + entitlementSubsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); + entitlementSubsFilter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + entitlementSubsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + entitlementSubsFilter.setIsExpiredEqual(false); + /*Ppv ppv = IngestUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ @@ -43,6 +53,11 @@ public void beforeClass() { /*Response> ingestedProgrammes = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ + + int numberOfUsers = 2; + int numberOfDevices = 1; + household = HouseholdUtils.createHouseHold(numberOfUsers, numberOfDevices, true); + classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); } @Description("productPrice/action/list - subscription test by Operator without currency") @@ -116,6 +131,7 @@ public void ppvTest() { assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); + // only 1 item mention in filter assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); @@ -141,6 +157,7 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { filter.setFileIdIn(String.valueOf(getSharedWebMediaFile().getId())); filter.setIsLowest(false); Response> productPriceListBeforePurchase = list(client, filter); + // should be 2 ss one item is subscription an another is media file assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(2); assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); @@ -149,4 +166,54 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { assertThat(productPriceListBeforePurchase.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); assertThat(((PpvPrice) productPriceListBeforePurchase.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); } + + @Description("productPrice/action/list - subscription test") + @Test(enabled = false) // as not completed + public void subscriptionTest() { + String sharedWebMediaFileId = String.valueOf(getSharedWebMediaFile().getId()); + + // TODO: 3/7/2018 add remarks when possible such as below - show to Shmulik / Michael and see if test is clear + client = getClient(classMasterUserKs); + Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementSubsFilter, null); + assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setSubscriptionIdIn(get5MinRenewableSubscription().getId().trim()); + ppFilter.setIsLowest(false); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); + + Response> productPriceListBeforePurchase4Anonymous = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceListBeforePurchase4Anonymous.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); + + PurchaseUtils.purchaseSubscription(client, Integer.valueOf(get5MinRenewableSubscription().getId().trim())); + + Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementSubsFilter, null); + assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()).isGreaterThan( + entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); + MatcherAssert.assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod(), + Matchers.anyOf(Matchers.is(PaymentMethodType.OFFLINE), Matchers.is(PaymentMethodType.UNKNOWN))); + + ppFilter.setFileIdIn(sharedWebMediaFileId); + Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(2); + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceListAfterPurchase.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + // TODO: should we use ENUM containing subs of KalturaProductPrice class such as: KalturaCollectionPrice, KalturaPpvPrice, KalturaSubscriptionPrice??? + // that logic can't be checked by schema as schema can't check that exactly 1st item is Subscription and 2nd one is PPV + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getClass().getSimpleName()).isEqualToIgnoringCase("SubscriptionPrice"); + assertThat(productPriceListAfterPurchase.results.getObjects().get(1).getClass().getSimpleName()).isEqualToIgnoringCase("PpvPrice"); + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceListAfterPurchase.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(1)).getFileId()).isEqualTo(sharedWebMediaFileId); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 2e061b45f..00e38899d 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -16,6 +16,7 @@ public class PurchaseUtils { public static Map purchasePpvDetailsMap; + public static Map purchaseSubscriptionDetailsMap; // TODO: 14/MAR/2018 add return public static void purchasePpv(Client client, Optional mediaId, Optional fileId) { @@ -57,4 +58,31 @@ public static void purchasePpv(Client client, Optional mediaId, Optiona purchasePpvDetailsMap.put("ppvModuleId", ppvModuleId); purchasePpvDetailsMap.put("fileId", String.valueOf(internalFileId)); } + + // TODO: 3/7/2018 add return + // private as not completed + private static void purchaseSubscription(Client client, int subscriptionId) { + purchaseSubscriptionDetailsMap = new HashMap<>(); + int paymentGatewayId = 0; + + ProductPriceFilter filter = new ProductPriceFilter(); + filter.setSubscriptionIdIn(String.valueOf(subscriptionId)); + filter.setIsLowest(false); + Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, filter); + String currency = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getCurrency(); + double price = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getAmount(); + + Purchase purchase = new Purchase(); + purchase.setProductId(subscriptionId); + purchase.setContentId(0); + purchase.setCurrency(currency); + purchase.setPrice(price); + purchase.setProductType(Optional.of(TransactionType.SUBSCRIPTION).get()); + purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); + TransactionServiceImpl.purchase(client, purchase); + + // TODO: complete the purchase subscription test + purchaseSubscriptionDetailsMap.put("price", String.valueOf(price)); + purchaseSubscriptionDetailsMap.put("currency", currency); + } } From 8a9f63d833569f5ed27c5daaee40fba05fba0c55 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 11:28:33 +0300 Subject: [PATCH 152/605] Added new json schema (Channel.json) + channelUtils class + 3 new classes for channel API (delete, add ,get) --- .../bookmarkTests/BookmarkAddTests.java | 8 -- .../channelTests/ChannelAddTests.java | 80 ++++++++++++++++++- .../channelTests/ChannelDeleteTests.java | 52 ++++++++++++ .../channelTests/ChannelGetTests.java | 37 +++++++++ .../client/test/utils/ChannelUtils.java | 26 ++++++ src/test/resources/schemas/Channel.json | 64 +++++++++++++++ 6 files changed, 257 insertions(+), 10 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/ChannelUtils.java create mode 100644 src/test/resources/schemas/Channel.json diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 00305ade2..b062c63c5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -41,14 +41,6 @@ private void add_tests_before_class() { client = getClient(getSharedMasterUserKs()); assetId = BaseTest.getSharedMediaAsset().getId(); fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); -//======= -// getSharedHousehold(); -// client = getClient(getSharedMasterUserKs()); -// assetId = 608775; -// AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); -// Response assetResponse = AssetServiceImpl.get(client, String.valueOf(assetId), assetReferenceType); -// fileId = assetResponse.results.getMediaFiles().get(0).getId(); -// actionType = BookmarkActionType.get(BookmarkActionType.FIRST_PLAY.getValue()); assetList.add(String.valueOf(assetId)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 00d8285cb..19b6e57a6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -1,25 +1,101 @@ package com.kaltura.client.test.tests.servicesTests.channelTests; import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.ChannelUtils; +import com.kaltura.client.types.Channel; +import com.kaltura.client.types.IntegerValue; +import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static org.assertj.core.api.Assertions.assertThat; + public class ChannelAddTests extends BaseTest { private Client client; + private Channel channel = new Channel(); + private String channelName; + private String Description; + private Boolean isActive = true; + private String filterExpression; + private IntegerValue integerValue = new IntegerValue(); + private List assetTypes = new ArrayList<>(); + @BeforeClass private void get_tests_before_class() { + client = getClient(getManagerKs()); + channelName = "Channel_12345"; + Description = "description of channel"; } - @Description ("channel/action/add") + @Description("channel/action/add - with all asset types") @Test - private void addChannel() { + filterExpression = "name ~ 'movie'"; + client = getClient(getManagerKs()); + channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add + Response channelResponse = ChannelServiceImpl.add(client, channel); + assertThat(channelResponse.results.getName()).isEqualTo(channelName); + } + + @Description("channel/action/add - order by NAME_DESC") + @Test + private void checkOrderOfAssetsInChannel() { + filterExpression = "name ~ 'movie'"; + client = getClient(getManagerKs()); + channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add + Response channelResponse = ChannelServiceImpl.add(client, channel); + assertThat(channelResponse.results.getName()).isEqualTo(channelName); + } + + + @Description("channel/action/add - with invalid asset type") + @Test + private void addChannelWithInvalidAssetType() { + integerValue.setValue(666); + assetTypes.add(integerValue); + channel = ChannelUtils.addChannel(channelName, Description, isActive, null, AssetOrderBy.LIKES_DESC, assetTypes, null); + //channel/action/add + Response channelResponse = ChannelServiceImpl.add(client, channel); + // KalturaAPIException","code":"4020","message":"KSQL Channel media type 666 does not belong to group" + assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4020).getCode()); + } + + @Description("channel/action/add - mandatory channel name not provided") + @Test + private void addChannelWithNoName() { + channel = ChannelUtils.addChannel(null, Description, isActive, null, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add + Response channelResponse = ChannelServiceImpl.add(client, channel); + + // KalturaAPIException","code":"5005","message":"KSQL Channel must have a name" + assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(5005).getCode()); + } + + @Description("channel/action/add - syntax error in filter expression") + @Test + private void addChannelWithSyntaxErrorInFilterExpression() { + filterExpression = "name = 'syntax error"; + channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add + Response channelResponse = ChannelServiceImpl.add(client, channel); + // KalturaAPIException","code":"4004","message":"Invalid expression structure" + assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4004).getCode()); } + + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java new file mode 100644 index 000000000..bfeb1a4a3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -0,0 +1,52 @@ +package com.kaltura.client.test.tests.servicesTests.channelTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.ChannelUtils; +import com.kaltura.client.types.Channel; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static org.assertj.core.api.Assertions.assertThat; + +public class ChannelDeleteTests extends BaseTest { + + private Client client; + private Channel channel = new Channel(); + private String channelName = "Channel_12345"; + private String Description = "description of channel"; + private Boolean isActive = true; + private String filterExpression; + private int channelId; + + + @BeforeClass + private void get_tests_before_class() { + } + + @Description("channel/action/delete") + @Test + private void DeleteChannel() { + filterExpression = "name ~ 'movie'"; + client = getClient(getManagerKs()); + channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + + // channel/action/add + Response channelResponse = ChannelServiceImpl.add(client, channel); + + channelId = Math.toIntExact(channelResponse.results.getId()); + + // channel/action/delete + Response deleteResponse = ChannelServiceImpl.delete(client, Math.toIntExact(channelId)); + assertThat(deleteResponse.results.booleanValue()).isTrue(); + + // channel/action/get - verify channel wasn't found + Response getResponse = ChannelServiceImpl.get(client, channelId); + assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java new file mode 100644 index 000000000..725195336 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java @@ -0,0 +1,37 @@ +package com.kaltura.client.test.tests.servicesTests.channelTests; + +import com.kaltura.client.Client; +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.ChannelUtils; +import com.kaltura.client.types.Channel; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class ChannelGetTests extends BaseTest { + + private Client client; + private Channel channel = new Channel(); + private String channelName = "Channel_12345"; + private String Description = "description of channel"; + private Boolean isActive = true; + private String filterExpression; + +public class ChannelActionGet extends BaseTest { + + @BeforeClass + private void get_tests_before_class() { + } + + @Description + @Test + private void channelGetTests() { + + } +} + +} diff --git a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java new file mode 100644 index 000000000..c6e3aaf52 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java @@ -0,0 +1,26 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.types.Channel; +import com.kaltura.client.types.IntegerValue; +import com.kaltura.client.types.MediaImage; + +import javax.annotation.Nullable; +import java.util.List; + +public class ChannelUtils extends BaseUtils { + + public static Channel addChannel(String name, @Nullable String description, @Nullable Boolean isActive, @Nullable String filterExpression, + @Nullable AssetOrderBy orderBy, @Nullable List assetTypes, @Nullable List images) { + Channel channel = new Channel(); + channel.setName(name); + channel.setDescription(description); + channel.setIsActive(isActive); + channel.setFilterExpression(filterExpression); + channel.setOrder(orderBy); + channel.setAssetTypes(assetTypes); + channel.setImages(images); + + return channel; + } +} diff --git a/src/test/resources/schemas/Channel.json b/src/test/resources/schemas/Channel.json new file mode 100644 index 000000000..6514a3d1d --- /dev/null +++ b/src/test/resources/schemas/Channel.json @@ -0,0 +1,64 @@ +{ + "$id": "Channel", + "type": "object", + "definitions": { + "Channel": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 0 + }, + "description": { + "type": "string", + "minLength": 0 + }, + "assetTypes": { + "type": "array" + }, + "filterExpression": { + "type": "string", + "minLength": 0 + }, + "isActive": { + "type": "boolean" + }, + "order": { + "type": "string", + "minLength": 0 + }, + "groupBy": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "id": { + "type": "integer", + "minimum": 1 + }, + "objectType": { + "type": "string", + "minLength": 1 + } + }, + "required":["id","name"] + } + }, + "properties": { + "result": { + "ref": "#/definitions/Channel" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From 33c485a08d4f6cca9542a5d6aee6893a62f7231d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 1 May 2018 11:57:47 +0300 Subject: [PATCH 153/605] fixed merge problems --- .../AssetCommentListTests.java | 4 +- .../productPriceTests/ListTests.java | 2 +- .../client/test/utils/AssetHistoryUtils.java | 2 +- .../client/test/utils/IngestUtils.java | 31 ++- .../client/test/utils/IngestVODUtils.java | 177 ------------------ 5 files changed, 32 insertions(+), 184 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index 6f6df4d9d..f18135e1c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -7,7 +7,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.IngestVODUtils; +import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; import com.kaltura.client.types.Household; @@ -43,7 +43,7 @@ private void checkCommentsOrder() { String subHeader = "subHeader"; String text = "A lot of text"; - Long assetId = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Long assetId = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(MOVIE_MEDIA_TYPE)), Optional.empty(), Optional.empty()).getId(); // Initialize assetComment object diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 9546a9787..481bdb659 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -192,7 +192,7 @@ public void subscriptionTest() { assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); - PurchaseUtils.purchaseSubscription(client, Integer.valueOf(get5MinRenewableSubscription().getId().trim())); + //PurchaseUtils.purchaseSubscription(client, Integer.valueOf(get5MinRenewableSubscription().getId().trim())); Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementSubsFilter, null); assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java index 8080bc84f..d218cd5ce 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java @@ -30,7 +30,7 @@ public static AssetHistoryFilter getAssetHistoryFilter(@Nullable String assetIdI // Ingest asset, bookmark it and return the asset id public static Long ingestAssetAndPerformBookmark(Client client, String mediaType, int position, BookmarkActionType bookmarkActionType) { // Ingest asset - MediaAsset mediaAsset = IngestVODUtils.ingestVOD(Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); Long assetId = mediaAsset.getId(); int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index ba661f5a1..030030c9b 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -311,8 +311,7 @@ private static Date loadEndDate(Date startDate, int durationValue, String period } /** - * @param action - can be "insert", "update" and "delete" - * * @param ppCode - should have value in case "action" one of {"update" and "delete"} + * IMPORTANT: please delete inserted by that method items * * @param action - can be "insert" or "delete" ("update" looks like broken) * @param mppCode - should have value in case "action" is "delete" @@ -341,7 +340,7 @@ private static Date loadEndDate(Date startDate, int durationValue, String period * (where mpp is a variable that contains mpp data). * * - * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created manually) + * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created by ingestPP method) */ // ingest new MPP public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, @@ -477,6 +476,7 @@ private static String buildIngestMppXML(String action, String mppCode, boolean i // ingest new PP /** + * IMPORTANT: please delete inserted by that method items * * @param action - can be "insert", "update" and "delete" * @param ppCode - should have value in case "action" one of {"update" and "delete"} @@ -590,6 +590,8 @@ private static String buildIngestPpXML(String action, String ppCode, boolean isA } /** + * IMPORTANT: please delete inserted by that method items + * * @param action - can be "insert", "update" and "delete" * @param ppvCode - should have value in case "action" one of {"update" and "delete"} * @param isActive @@ -722,6 +724,29 @@ private static String buildIngestPpvXML(String action, String ppvCode, boolean i "\n"; } + /** + * IMPORTANT: please delete inserted by that method items + * + * @param action - can be "insert", "update" and "delete" + * @param coguid - should have value in case "action" one of {"update" and "delete"} + * @param isActive + * @param name + * @param thumbUrl + * @param description + * @param catalogStartDate + * @param catalogEndDate + * @param startDate + * @param endDate + * @param mediaType + * @param ppvWebName + * @param ppvMobileName + * @return + * + * to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" + * (where vod is a variable that contains VOD data) + * + * !!!Only created by that method VOD can be deleted/update!!! + */ // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project public static MediaAsset ingestVOD(Optional action, Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java deleted file mode 100644 index 152bd6d15..000000000 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.MediaAsset; -import com.kaltura.client.utils.response.base.Response; -import io.restassured.RestAssured; - -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import static com.kaltura.client.test.IngestConstants.INGEST_VOD_DEFAULT_THUMB; -import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; -import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; -import static io.restassured.path.xml.XmlPath.from; -import static org.awaitility.Awaitility.await; - -public class IngestVODUtils extends BaseUtils { - - // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, - Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, - Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); - String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); - String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); - String descriptionValue = description.orElseGet(() -> "description of " + coguidValue); - String catalogStartDateValue = catalogStartDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); - String catalogEndDateValue = catalogEndDate.orElse("14/10/2099 17:00:00"); - String startDateValue = startDate.orElseGet(() -> getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss")); - String endDateValue = endDate.orElse("14/10/2099 17:00:00"); - String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); - String ppvWebNameValue = ppvWebName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value - String ppvMobileNameValue = ppvMobileName.orElse("Shai_Regression_PPV"); // TODO: update on any generated value - // TODO: check if ingest url is the same for all ingest actions - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); - String reqBody = "\n" + - " \n" + - " \n" + - " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + - " \n" + - " \n" + - ""; - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headermap) - .body(reqBody) - .post(url); - //System.out.println("RESPONSE: " + resp.asString()); - String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - - MediaAsset mediaAsset = new MediaAsset(); - mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id)); - mediaAsset.setDescription(descriptionValue); - //mediaAsset.setStartDate(startDate); - //mediaAsset.setEndDate(endDate); - - await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(id)); - Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); - mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); - - // TODO: 4/15/2018 add log for ingest and index failures - return mediaAsset; - } - - - private static Callable isDataReturned(String mediaId) { - return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; - } - - private static String buildIngestVodXml(String coguid, boolean isActive, String name, String thumbUrl, - String description, String catalogStartDate, String catalogEndDate, - String startDate, String endDate, String mediaType, String ppvWebName, - String ppvMobileName) { - return "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + name + "\n" + - " \n" + - " \n" + - " \n" + - " " + description + "\n" + - " \n" + - " \n" + - " " + catalogStartDate + "\n" + - " " + startDate + "\n" + - " " + catalogEndDate + "\n" + - " " + endDate + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + mediaType + "\n" + - " \n" + - //" ${#TestCase#i_geo_block_rule}\n" + - " Parent Allowed\n" + - //" ${#TestCase#i_device_block_rule}\n" + - " \n" + - " \n" + - " \n" + - //" \n" + - //" \n" + - //" syno pino sister\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_double_meta_value}\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_date_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Costa Rica;Israel\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" GIH\n" + - //" \n" + - //" \n" + - //" ABC\n" + - //" \n" + - //" \n" + - //" DEF\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Shay_Series\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_free_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_parental_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_value}\n" + - //" \n" + - //" \n" + - //" \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - } -} From 7c1bccce078f452b780ad19f70d1300b10de07c7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 13:58:39 +0300 Subject: [PATCH 154/605] Added new util to IngetVodUtil (Basic VOD ingest) --- .../client/test/utils/IngestVODUtils.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java index 152bd6d15..e1005960f 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestVODUtils.java @@ -74,6 +74,56 @@ public static MediaAsset ingestVOD(Optional coguid, boolean isActive, Op return mediaAsset; } + // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) + public static MediaAsset ingestBasicVOD(Optional name, String mediaType) { + String coguidValue = getCurrentDataInFormat("yyMMddHHmmssSS"); + String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); + String thumbUrlValue = INGEST_VOD_DEFAULT_THUMB; + String descriptionValue = "description of " + coguidValue; + String catalogStartDateValue = getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss"); + String catalogEndDateValue = "14/10/2099 17:00:00"; + String startDateValue = getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss"); + String endDateValue = "14/10/2099 17:00:00"; + String mediaTypeValue = mediaType; + String ppvWebNameValue = "Shai_Regression_PPV"; + String ppvMobileNameValue = "Shai_Regression_PPV"; // TODO: update on any generated value + // TODO: check if ingest url is the same for all ingest actions + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + HashMap headermap = new HashMap<>(); + headermap.put("Content-Type", "text/xml;charset=UTF-8"); + headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); + String reqBody = "\n" + + " \n" + + " \n" + + " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " \n" + + " \n" + + ""; + io.restassured.response.Response resp = RestAssured.given() + .log().all() + .headers(headermap) + .body(reqBody) + .post(url); + //System.out.println("RESPONSE: " + resp.asString()); + String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); + + MediaAsset mediaAsset = new MediaAsset(); + mediaAsset.setName(nameValue); + mediaAsset.setId(Long.valueOf(id)); + mediaAsset.setDescription(descriptionValue); + //mediaAsset.setStartDate(startDate); + //mediaAsset.setEndDate(endDate); + + await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(id)); + Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); + mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + + // TODO: 4/15/2018 add log for ingest and index failures + return mediaAsset; + } + private static Callable isDataReturned(String mediaId) { return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; From 61d2cadb0d5e1f780a0cf4ebab803c330b1a6d14 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 13:59:02 +0300 Subject: [PATCH 155/605] Removed unnessery import from BaseUtils class --- src/test/java/com/kaltura/client/test/utils/BaseUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 50b8db617..8cc0c182b 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -2,7 +2,6 @@ import com.kaltura.client.Logger; import com.kaltura.client.types.APIException; -import com.kaltura.client.types.Collection; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; From 22c1a4a3190f5fd01f41534f2266021bb331e593 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 13:59:18 +0300 Subject: [PATCH 156/605] Added new util to AssetUtils --- .../kaltura/client/test/utils/AssetUtils.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 1d5a0255b..a4b475ec7 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -3,10 +3,10 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.MediaFile; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; @@ -15,6 +15,21 @@ public class AssetUtils extends BaseUtils { + + public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nullable String idIn, @Nullable String typeIn, + @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(ksql); + searchAssetFilter.setIdIn(idIn); + searchAssetFilter.setTypeIn(typeIn); + searchAssetFilter.setDynamicOrderBy(dynamicOrderBy); + searchAssetFilter.setGroupBy(groupBy); + searchAssetFilter.setName(name); + searchAssetFilter.setOrderBy(orderBy); + + return searchAssetFilter; + } + public static List getAssetFileIds(String assetId) { Client client = getClient(getSharedMasterUserKs()); From acada2f2cd1e9c2a5080112f95c9a243e9a1bc94 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 13:59:43 +0300 Subject: [PATCH 157/605] Updated ChannelAddTest class --- .../channelTests/ChannelAddTests.java | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 19b6e57a6..9a137b73f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -2,11 +2,15 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; +import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.ChannelUtils; -import com.kaltura.client.types.Channel; -import com.kaltura.client.types.IntegerValue; +import com.kaltura.client.test.utils.IngestVODUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; @@ -14,7 +18,9 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -49,15 +55,33 @@ private void addChannel() { assertThat(channelResponse.results.getName()).isEqualTo(channelName); } + // TODO @Description("channel/action/add - order by NAME_DESC") @Test private void checkOrderOfAssetsInChannel() { - filterExpression = "name ~ 'movie'"; + + String asset1Name = "Movie_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); + String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); + + // Ingest first asset + MediaAsset movieAsset = IngestVODUtils.ingestBasicVOD(Optional.of(asset1Name), MOVIE_MEDIA_TYPE); + + // Ingest second asset + MediaAsset episodeAsset = IngestVODUtils.ingestBasicVOD(Optional.of(asset2Name), MOVIE_MEDIA_TYPE); + + filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; + // "(or name = 'name' name= 'name2')" client = getClient(getManagerKs()); channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add Response channelResponse = ChannelServiceImpl.add(client, channel); assertThat(channelResponse.results.getName()).isEqualTo(channelName); + + SearchAssetFilter searchAssetFilter = AssetUtils.getSearchAssetFilter() + + //asset/action/list + AssetServiceImpl.list(client,searchAssetFilter,null); } @@ -97,5 +121,4 @@ private void addChannelWithSyntaxErrorInFilterExpression() { } - } From 54bb06eaadbb8d72c1508bc0fa32a1f1b01384fa Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 1 May 2018 14:35:53 +0300 Subject: [PATCH 158/605] Added tags Severety --- .../tests/servicesTests/productPriceTests/ListTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 481bdb659..7feb513d9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -11,6 +11,8 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.testng.annotations.BeforeClass; @@ -60,6 +62,7 @@ public void beforeClass() { classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); } + @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription test by Operator without currency") @Test(enabled = false) // as used in feature tests public void listSubscription() { @@ -71,6 +74,7 @@ public void listSubscription() { assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); } + @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription test with currency by Operator") @Test() public void listSubscriptionWithCurrencyTest() { @@ -85,6 +89,7 @@ public void listSubscriptionWithCurrencyTest() { assertThat(productPriceList.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CURRENCY_EUR); } + @Severity(SeverityLevel.MINOR) @Description("productPrice/action/list - without required fields (subscriptionIdIn, collectionIdIn and fileIdIn are empty)") @Test() public void listWithoutRequiredFields() { @@ -98,6 +103,7 @@ public void listWithoutRequiredFields() { "One of the arguments [KalturaProductPriceFilter.subscriptionIdIn, KalturaProductPriceFilter.fileIdIn, KalturaProductPriceFilter.collectionIdIn] must have a value"); } + @Severity(SeverityLevel.CRITICAL) @Description("productPrice/action/list - ppv test") @Test() public void ppvTest() { @@ -143,6 +149,7 @@ public void ppvTest() { assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); } + @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - common test for PPV and subscription to check before purchase") @Test() public void productPriceSubscriptionAndPpvBeforePurchaseTest() { @@ -167,6 +174,7 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { assertThat(((PpvPrice) productPriceListBeforePurchase.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); } + @Severity(SeverityLevel.CRITICAL) @Description("productPrice/action/list - subscription test") @Test(enabled = false) // as not completed public void subscriptionTest() { From 447142d7030e72c59ec3acbf6cf6899c8e12c2ee Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 15:10:30 +0300 Subject: [PATCH 159/605] Added new util to AssetUtils --- .../com/kaltura/client/test/utils/AssetUtils.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index a4b475ec7..d96e21902 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -17,7 +17,7 @@ public class AssetUtils extends BaseUtils { public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nullable String idIn, @Nullable String typeIn, - @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { + @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); searchAssetFilter.setKSql(ksql); searchAssetFilter.setIdIn(idIn); @@ -30,6 +30,16 @@ public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nul return searchAssetFilter; } + public static ChannelFilter getChannelFilter(int idEqual, @Nullable String ksql, @Nullable DynamicOrderBy dynamicOrderBy, @Nullable String orderBy) { + ChannelFilter channelFilter = new ChannelFilter(); + channelFilter.setIdEqual(idEqual); + channelFilter.setKSql(ksql); + channelFilter.setDynamicOrderBy(dynamicOrderBy); + channelFilter.setOrderBy(orderBy); + + return channelFilter; + } + public static List getAssetFileIds(String assetId) { Client client = getClient(getSharedMasterUserKs()); From 7c3a3e830ccf2e5e927874822895d95c6b39ce8a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 15:10:45 +0300 Subject: [PATCH 160/605] Updated ChannelAddTests class --- .../channelTests/ChannelAddTests.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 9a137b73f..f18e6cc24 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; import com.kaltura.client.test.servicesImpl.AssetServiceImpl; import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; import com.kaltura.client.test.tests.BaseTest; @@ -41,7 +40,6 @@ private void get_tests_before_class() { client = getClient(getManagerKs()); channelName = "Channel_12345"; Description = "description of channel"; - } @Description("channel/action/add - with all asset types") @@ -70,18 +68,25 @@ private void checkOrderOfAssetsInChannel() { MediaAsset episodeAsset = IngestVODUtils.ingestBasicVOD(Optional.of(asset2Name), MOVIE_MEDIA_TYPE); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; - // "(or name = 'name' name= 'name2')" client = getClient(getManagerKs()); - channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); //channel/action/add Response channelResponse = ChannelServiceImpl.add(client, channel); assertThat(channelResponse.results.getName()).isEqualTo(channelName); - SearchAssetFilter searchAssetFilter = AssetUtils.getSearchAssetFilter() + int channelId = Math.toIntExact(channelResponse.results.getId()); + + ChannelFilter channelFilter = AssetUtils.getChannelFilter(channelId, null, null, null); //asset/action/list - AssetServiceImpl.list(client,searchAssetFilter,null); + Response> listResponse = AssetServiceImpl.list(client, channelFilter, null); + assertThat(listResponse.results.getTotalCount()).isEqualTo(2); + // Verify movie asset id returned first (because order is by name_desc) + assertThat(listResponse.results.getObjects().get(0).getId()).isEqualTo(movieAsset.getId()); + + // Cleanup - channel/action/delete + ChannelServiceImpl.delete(client, channelId); } @@ -119,6 +124,4 @@ private void addChannelWithSyntaxErrorInFilterExpression() { // KalturaAPIException","code":"4004","message":"Invalid expression structure" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4004).getCode()); } - - } From 2667440ef94e9635e2234b1846a844003ddc4012 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 1 May 2018 15:43:32 +0300 Subject: [PATCH 161/605] tantan executeSync() impl --- .../test/TestAPIOkRequestsExecutor.java | 61 ++++++++++++++----- .../kaltura/client/test/tests/BaseTest.java | 4 +- .../ottUserTests/ActivateTests.java | 31 +++++++++- 3 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 697f1c80c..b10fa0eb5 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -1,17 +1,23 @@ package com.kaltura.client.test; import com.kaltura.client.APIOkRequestsExecutor; +import com.kaltura.client.Client; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; +import com.kaltura.client.utils.request.RequestBuilder; import com.kaltura.client.utils.request.RequestElement; +import com.kaltura.client.utils.response.base.ApiCompletion; +import com.kaltura.client.utils.response.base.Response; import com.kaltura.client.utils.response.base.ResponseElement; -import okhttp3.Response; + +import java.util.concurrent.atomic.AtomicBoolean; + import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; +import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; /** - * @hide - * That class allows to validate json schemas of responses + * @hide That class allows to validate json schemas of responses */ // public class TestAPIOkRequestsExecutor extends APIOkRequestsExecutor { @@ -21,7 +27,8 @@ public class TestAPIOkRequestsExecutor extends APIOkRequestsExecutor { private static TestAPIOkRequestsExecutor executor; - private TestAPIOkRequestsExecutor() {} + private TestAPIOkRequestsExecutor() { + } public static TestAPIOkRequestsExecutor getExecutor() { if (executor == null) { @@ -32,29 +39,53 @@ public static TestAPIOkRequestsExecutor getExecutor() { @SuppressWarnings("rawtypes") @Override - protected ResponseElement onGotResponse(Response response, RequestElement action) { - ResponseElement responseElement = super.onGotResponse(response, action); + protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, RequestElement action) { + ResponseElement responseElement = super.onGotResponse(okhttpResponse, action); // logger.debug("response body:\n" + responseElement.getResponse()); // was found in base class // logger.debug("response headers:\n" + response.headers()); if (responseElement.isSuccess()) { - com.kaltura.client.utils.response.base.Response response1 = action.parseResponse(responseElement); + Response response = action.parseResponse(responseElement); - if (response1.results != null && response1.isSuccess()) { - String s1 = "schemas/"; - String s2 = response1.results.getClass().getSimpleName(); - String s3 = ".json"; + if (response.results != null && response.isSuccess()) { + String s1 = "schemas/"; + String s2 = response.results.getClass().getSimpleName(); + String s3 = ".json"; - String schema = s1 + s2 + s3; - Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); + String schema = s1 + s2 + s3; + Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); /*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); Date date = new Date(); System.out.println("BEFORE VALIDATION: " + formatter.format(date));*/ - assertThat(responseElement.getResponse(), matchesJsonSchemaInClasspath(schema)); + assertThat(responseElement.getResponse(), matchesJsonSchemaInClasspath(schema)); /*date = new Date(); System.out.println("AFTER VALIDATION: " + formatter.format(date));*/ - } + } } return responseElement; } + + public Response executeSync(Client client, RequestBuilder requestBuilder) { + SyncExecutor syncExecutor = new SyncExecutor<>(); + return syncExecutor.exec(client, requestBuilder); + } + + private class SyncExecutor { + private AtomicBoolean done = new AtomicBoolean(false); + private Response response; + + public Response exec(Client client, RequestBuilder requestBuilder) { + requestBuilder + .setCompletion((ApiCompletion) result -> { + response = result; + done.set(true); + }); + + queue(requestBuilder.build(client)); + await().untilTrue(done); + done.set(false); + + return response; + } + } } diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index b4fea4302..538c964cb 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,6 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -24,8 +25,9 @@ public class BaseTest { private static Client client; - private static Response loginResponse; private static Configuration config; + protected static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); + private static Response loginResponse; /*================================================================================ testing shared params list - used as a helper common params across tests diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index b75131d13..243906e57 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -2,15 +2,19 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.UserState; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.DBUtils; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -20,23 +24,44 @@ public class ActivateTests extends BaseTest { private Client client; private OTTUser user; + private Response ottUserResponse; @BeforeClass private void ottUser_activate_tests_setup() { client = getClient(null); - user = generateOttUser(); - register(client, partnerId, user, defaultUserPassword); + ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + user = ottUserResponse.results; + login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/activate - activate") @Test private void activate() { String activationToken = DBUtils.getActivationToken(user.getUsername()); - Response ottUserResponse = OttUserServiceImpl.activate(client, partnerId, user.getUsername(),activationToken); + ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, user.getUsername(), activationToken); + ottUserResponse = executor.executeSync(client, OttUserService.activate(partnerId, user.getUsername(), activationToken)); + + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); + } + + @Severity(SeverityLevel.MINOR) + @Description("ottUser/action/activate - activate twice with the same token") + @Test + private void activate_with_sa() { + String activationToken = DBUtils.getActivationToken(user.getUsername()); + + + ottUserResponse = OttUserServiceImpl.activate(client, partnerId, user.getUsername(), activationToken); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); + + } + + } From 6dd2e7a9c0adcb434f8b982c152f4959fb2d1c35 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 1 May 2018 16:30:45 +0300 Subject: [PATCH 162/605] remove serviceImpl package --- .../test/TestAPIOkRequestsExecutor.java | 10 +- .../servicesImpl/AnnouncementServiceImpl.java | 116 ------- .../servicesImpl/AppTokenServiceImpl.java | 82 ----- .../servicesImpl/AssetCommentServiceImpl.java | 56 ---- .../servicesImpl/AssetFileServiceImpl.java | 51 --- .../servicesImpl/AssetHistoryServiceImpl.java | 46 --- .../test/servicesImpl/AssetServiceImpl.java | 102 ------ .../AssetStatisticsServiceImpl.java | 35 -- .../test/servicesImpl/BaseServiceImpl.java | 21 -- .../servicesImpl/BookmarkServiceImpl.java | 55 ---- .../CDVRAdapterProfileServiceImpl.java | 98 ------ .../CdnAdapterProfilesServiceImpl.java | 99 ------ .../CdnPartnerSettingsServiceImpl.java | 50 --- .../test/servicesImpl/ChannelServiceImpl.java | 81 ----- .../servicesImpl/CollectionServiceImpl.java | 37 --- .../servicesImpl/CompensationServiceImpl.java | 60 ---- .../ConfigurationGroupDeviceServiceImpl.java | 83 ----- .../ConfigurationGroupServiceImpl.java | 98 ------ .../ConfigurationGroupTagServiceImpl.java | 84 ----- .../ConfigurationsServiceImpl.java | 116 ------- .../test/servicesImpl/CountryServiceImpl.java | 37 --- .../test/servicesImpl/CouponServiceImpl.java | 35 -- .../servicesImpl/CurrencyServiceImpl.java | 37 --- .../servicesImpl/DeviceBrandServiceImpl.java | 36 --- .../servicesImpl/DeviceFamilyServiceImpl.java | 36 --- .../test/servicesImpl/EmailServiceImpl.java | 35 -- .../EngagementAdapterServiceImpl.java | 113 ------- .../servicesImpl/EngagementServiceImpl.java | 84 ----- .../servicesImpl/EntitlementServiceImpl.java | 175 ---------- .../servicesImpl/ExportTaskServiceImpl.java | 100 ------ .../ExternalChannelProfileServiceImpl.java | 83 ----- .../servicesImpl/FavoriteServiceImpl.java | 70 ---- .../FollowTvSeriesServiceImpl.java | 72 ----- .../servicesImpl/HomeNetworkServiceImpl.java | 82 ----- .../HouseholdDeviceServiceImpl.java | 161 ---------- .../HouseholdLimitationsServiceImpl.java | 35 -- .../HouseholdPaymentGatewayServiceImpl.java | 138 -------- .../HouseholdPaymentMethodServiceImpl.java | 100 ------ .../HouseholdPremiumServiceImpl.java | 36 --- .../HouseholdQuotaServiceImpl.java | 34 -- .../servicesImpl/HouseholdServiceImpl.java | 164 ---------- .../HouseholdUserServiceImpl.java | 73 ----- .../servicesImpl/InboxMessageServiceImpl.java | 72 ----- .../servicesImpl/LanguageServiceImpl.java | 37 --- .../servicesImpl/LicensedUrlServiceImpl.java | 35 -- .../MessageTemplateServiceImpl.java | 51 --- .../test/servicesImpl/MetaServiceImpl.java | 54 ---- .../servicesImpl/NotificationServiceImpl.java | 73 ----- ...tificationsPartnerSettingsServiceImpl.java | 51 --- .../NotificationsSettingsServiceImpl.java | 52 --- .../OssAdapterProfileServiceImpl.java | 114 ------- .../servicesImpl/OttCategoryServiceImpl.java | 35 -- .../test/servicesImpl/OttUserServiceImpl.java | 303 ------------------ .../servicesImpl/ParentalRuleServiceImpl.java | 84 ----- .../PartnerConfigurationServiceImpl.java | 35 -- .../PaymentGatewayProfileServiceImpl.java | 119 ------- .../PaymentMethodProfileServiceImpl.java | 83 ----- .../servicesImpl/PersonalFeedServiceImpl.java | 36 --- .../test/servicesImpl/PinServiceImpl.java | 69 ---- .../test/servicesImpl/PpvServiceImpl.java | 34 -- .../servicesImpl/PriceDetailsServiceImpl.java | 38 --- .../servicesImpl/PricePlanServiceImpl.java | 54 ---- .../servicesImpl/ProductPriceServiceImpl.java | 39 --- .../PurchaseSettingsServiceImpl.java | 51 --- .../RecommendationProfileServiceImpl.java | 99 ------ .../servicesImpl/RecordingServiceImpl.java | 112 ------- .../test/servicesImpl/RegionServiceImpl.java | 37 --- .../RegistrySettingsServiceImpl.java | 36 --- .../servicesImpl/ReminderServiceImpl.java | 72 ----- .../test/servicesImpl/ReportServiceImpl.java | 52 --- .../SearchHistoryServiceImpl.java | 67 ---- .../SeriesRecordingServiceImpl.java | 129 -------- .../test/servicesImpl/SessionServiceImpl.java | 69 ---- .../servicesImpl/SocialActionServiceImpl.java | 69 ---- .../SocialCommentServiceImpl.java | 36 --- .../SocialFriendActivityServiceImpl.java | 37 --- .../test/servicesImpl/SocialServiceImpl.java | 146 --------- .../servicesImpl/SubscriptionServiceImpl.java | 55 ---- .../SubscriptionSetServiceImpl.java | 98 ------ .../test/servicesImpl/SystemServiceImpl.java | 67 ---- ...meShiftedTvPartnerSettingsServiceImpl.java | 51 --- .../test/servicesImpl/TopicServiceImpl.java | 85 ----- .../TransactionHistoryServiceImpl.java | 38 --- .../servicesImpl/TransactionServiceImpl.java | 121 ------- .../UnifiedPaymentServiceImpl.java | 35 -- .../UserAssetRuleServiceImpl.java | 37 --- .../UserAssetsListItemServiceImpl.java | 69 ---- .../servicesImpl/UserInterestServiceImpl.java | 68 ---- .../servicesImpl/UserLoginPinServiceImpl.java | 82 ----- .../servicesImpl/UserRoleServiceImpl.java | 86 ----- .../kaltura/client/test/tests/BaseTest.java | 81 ++--- .../ottUserTests/ActivateTests.java | 7 +- 92 files changed, 56 insertions(+), 6520 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java delete mode 100644 src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index b10fa0eb5..46a020c1f 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -1,7 +1,6 @@ package com.kaltura.client.test; import com.kaltura.client.APIOkRequestsExecutor; -import com.kaltura.client.Client; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; import com.kaltura.client.utils.request.RequestBuilder; @@ -12,6 +11,7 @@ import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.test.tests.BaseTest.client; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; @@ -65,16 +65,16 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request return responseElement; } - public Response executeSync(Client client, RequestBuilder requestBuilder) { + public Response executeSync(RequestBuilder requestBuilder) { SyncExecutor syncExecutor = new SyncExecutor<>(); - return syncExecutor.exec(client, requestBuilder); + return syncExecutor.exec(requestBuilder); } - private class SyncExecutor { + public class SyncExecutor { private AtomicBoolean done = new AtomicBoolean(false); private Response response; - public Response exec(Client client, RequestBuilder requestBuilder) { + public Response exec(RequestBuilder requestBuilder) { requestBuilder .setCompletion((ApiCompletion) result -> { response = result; diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java deleted file mode 100644 index 41a84afb4..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AnnouncementServiceImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.AnnouncementService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Announcement; -import com.kaltura.client.types.AnnouncementFilter; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.AnnouncementService.*; -import static org.awaitility.Awaitility.await; - -public class AnnouncementServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response announcementResponse; - private static Response booleanResponse; - private static Response> announcementListResponse; - - // activate - public static Response add(Client client, Announcement announcement) { - AddAnnouncementBuilder addAnnouncementBuilder = AnnouncementService.add(announcement) - .setCompletion((ApiCompletion) result -> { - announcementResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addAnnouncementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return announcementResponse; - } - - // delete - public static Response delete(Client client, long id) { - DeleteAnnouncementBuilder deleteAnnouncementBuilder = AnnouncementService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteAnnouncementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // enableSystemAnnouncements - public static Response enableSystemAnnouncements(Client client) { - EnableSystemAnnouncementsAnnouncementBuilder enableSystemAnnouncementsAnnouncementBuilder = - AnnouncementService.enableSystemAnnouncements().setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(enableSystemAnnouncementsAnnouncementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, AnnouncementFilter announcementFilter, @Nullable FilterPager filterPager) { - ListAnnouncementBuilder listAnnouncementBuilder = AnnouncementService.list(announcementFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - announcementListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listAnnouncementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return announcementListResponse; - } - - // update - public static Response update(Client client, int announcementId, Announcement announcement) { - UpdateAnnouncementBuilder updateAnnouncementBuilder = AnnouncementService.update(announcementId, announcement) - .setCompletion((ApiCompletion) result -> { - announcementResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateAnnouncementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return announcementResponse; - } - - // updateStatus - public static Response updateStatus(Client client, long id, boolean status) { - UpdateStatusAnnouncementBuilder updateStatusAnnouncementBuilder = AnnouncementService.updateStatus(id, status) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusAnnouncementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java deleted file mode 100644 index d40d20885..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AppTokenServiceImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.AppTokenService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.AppToken; -import com.kaltura.client.types.SessionInfo; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.AppTokenService.*; -import static org.awaitility.Awaitility.await; - -public class AppTokenServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response appTokenResponse; - private static Response booleanResponse; - private static Response sessionInfoResponse; - - // AppToken/action/add - public static Response add(Client client, AppToken appToken) { - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) - .setCompletion((ApiCompletion) result -> { - appTokenResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addAppTokenBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return appTokenResponse; - } - - //AppToken/acton/get - public static Response get(Client client, String id) { - GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(id) - .setCompletion((ApiCompletion) result -> { - appTokenResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getAppTokenBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return appTokenResponse; - } - - // AppToken/action/delete - public static Response delete(Client client, String id) { - DeleteAppTokenBuilder deleteAppTokenBuilder = AppTokenService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteAppTokenBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - //AppToken/action/startSession - public static Response startSession(Client client, String id, String hashToken, String userId, int expiry, String udid) { - StartSessionAppTokenBuilder startSessionAppTokenBuilder = AppTokenService.startSession(id, hashToken, userId, expiry, udid) - .setCompletion((ApiCompletion) result -> { - sessionInfoResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(startSessionAppTokenBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return sessionInfoResponse; - } -} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java deleted file mode 100644 index 5b45ffe60..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetCommentServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.AssetCommentService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.AssetComment; -import com.kaltura.client.types.AssetCommentFilter; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.AssetCommentService.*; -import static org.awaitility.Awaitility.await; - -public class AssetCommentServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response assetCommentResponse; - private static Response> assetCommentListResponse; - - - // add - public static Response add(Client client, AssetComment assetComment) { - AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment) - .setCompletion((ApiCompletion) result -> { - assetCommentResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addAssetCommentBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetCommentResponse; - } - - // list - public static Response> list(Client client, AssetCommentFilter assetCommentFilter, @Nullable FilterPager filterPager) { - ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - assetCommentListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listAssetCommentBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetCommentListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java deleted file mode 100644 index f0ad0d956..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetFileServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.ContextType; -import com.kaltura.client.enums.PlaybackContextType; -import com.kaltura.client.services.AssetFileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.AssetFileContext; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.AssetFileService.*; -import static org.awaitility.Awaitility.await; - -public class AssetFileServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response assetFileContextResponse; - - // getContext - public static Response getContext(Client client, String id, ContextType contextType) { - GetContextAssetFileBuilder getContextAssetFileBuilder = AssetFileService.getContext(id, contextType) - .setCompletion((ApiCompletion) result -> { - assetFileContextResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getContextAssetFileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetFileContextResponse; - } - - // playManifest - public static void playManifest(Client client, int partnerId, String assetId, AssetType assetType, long assetFileId, - PlaybackContextType playbackContextType, @Nullable String ks) { - PlayManifestAssetFileBuilder playManifestAssetFileBuilder = AssetFileService.playManifest(partnerId, assetId, assetType, - assetFileId, playbackContextType, ks); - playManifestAssetFileBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(playManifestAssetFileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java deleted file mode 100644 index 5f27e9e70..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetHistoryServiceImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.AssetHistoryService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.AssetHistoryService.*; -import static org.awaitility.Awaitility.await; - -public class AssetHistoryServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> assetHistoryListResponse; - - // clean - public static void clean(Client client, AssetHistoryFilter assetHistoryFilter) { - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(cleanAssetHistoryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } - - // list - public static Response> list(Client client, AssetHistoryFilter assetHistoryFilter, @Nullable FilterPager filterPager) { - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - assetHistoryListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listAssetHistoryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetHistoryListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java deleted file mode 100644 index 44d36bde9..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetServiceImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.AssetService.*; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; -import static org.awaitility.Awaitility.await; - -public class AssetServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response assetResponse; - private static Response> assetListResponse; - private static Response assetCountResponse; - private static Response adsContextResponse; - private static Response playbackContextResponse; - - // get - public static Response get(Client client, String id, AssetReferenceType assetReferenceType) { - GetAssetBuilder assetBuilder = AssetService.get(id, assetReferenceType) - .setCompletion((ApiCompletion) result -> { - assetResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(assetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetResponse; - } - - // list - public static Response> list(Client client, AssetFilter assetFilter, @Nullable FilterPager filterPager) { - ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - assetListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listAssetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetListResponse; - } - - // count - public static Response get(Client client, @Nullable SearchAssetFilter searchAssetFilter) { - CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) - .setCompletion((ApiCompletion) result -> { - assetCountResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(countAssetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetCountResponse; - } - - // getAdsContext - public static Response getAdsContext(Client client, String assetId, AssetType assetType, PlaybackContextOptions playbackContextOptions) { - GetAdsContextAssetBuilder getAdsContextAssetBuilder = AssetService.getAdsContext(assetId, assetType, playbackContextOptions) - .setCompletion((ApiCompletion) result -> { - adsContextResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getAdsContextAssetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return adsContextResponse; - } - - // getPlaybackContext - public static Response getPlaybackContext(Client client, String assetId, AssetType assetType, PlaybackContextOptions playbackContextOptions) { - GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = AssetService.getPlaybackContext(assetId, assetType, playbackContextOptions) - .setCompletion((ApiCompletion) result -> { - playbackContextResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getPlaybackContextAssetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return playbackContextResponse; - } -} - - diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java deleted file mode 100644 index 1d7c5bebe..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/AssetStatisticsServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.AssetStatisticsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.AssetStatisticsService.*; -import static org.awaitility.Awaitility.await; - -public class AssetStatisticsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> assetStatisticsListResponse; - - // query - public static Response> query(Client client, AssetStatisticsQuery assetStatisticsQuery) { - QueryAssetStatisticsBuilder queryAssetStatisticsBuilder = AssetStatisticsService.query(assetStatisticsQuery) - .setCompletion((ApiCompletion>) result -> { - assetStatisticsListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(queryAssetStatisticsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return assetStatisticsListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java deleted file mode 100644 index 25c48f9a1..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/BaseServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.utils.request.RequestBuilder; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static org.awaitility.Awaitility.await; - -public class BaseServiceImpl { - - protected static final AtomicBoolean done = new AtomicBoolean(false); - - // TODO: 4/22/2018 use executeRequest() method in all services and check behavior in parallel execution - static void executeRequest(Client client, RequestBuilder requestBuilder) { - TestAPIOkRequestsExecutor.getExecutor().queue(requestBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java deleted file mode 100644 index 3edc76fca..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/BookmarkServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - - -import com.kaltura.client.Client; -import com.kaltura.client.services.BookmarkService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Bookmark; -import com.kaltura.client.types.BookmarkFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; -import static com.kaltura.client.services.BookmarkService.ListBookmarkBuilder; -import static org.awaitility.Awaitility.await; - -public class BookmarkServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - private static Response booleanResponse; - private static Response> bookmarkListResponse; - - - // Bookmark/action/add - public static Response add(Client client, Bookmark bookmark) { - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addBookmarkBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // Bookmark/action/list - public static Response> list(Client client, BookmarkFilter bookmarkFilter) { - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter) - .setCompletion((ApiCompletion>) result -> { - bookmarkListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listBookmarkBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return bookmarkListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java deleted file mode 100644 index a1f20d6b1..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CDVRAdapterProfileServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CDVRAdapterProfileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.CDVRAdapterProfile; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CDVRAdapterProfileService.*; -import static org.awaitility.Awaitility.await; - -public class CDVRAdapterProfileServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response cdvrAdapterProfileResponse; - private static Response booleanResponse; - private static Response> cdvrAdapterProfileListResponse; - - // add - public static Response add(Client client, CDVRAdapterProfile cdvrAdapterProfile) { - AddCDVRAdapterProfileBuilder addCDVRAdapterProfileBuilder = CDVRAdapterProfileService.add(cdvrAdapterProfile) - .setCompletion((ApiCompletion) result -> { - cdvrAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addCDVRAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdvrAdapterProfileResponse; - } - - // delete - public static Response delete(Client client, int adapterId) { - DeleteCDVRAdapterProfileBuilder deleteCDVRAdapterProfileBuilder = CDVRAdapterProfileService.delete(adapterId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteCDVRAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // generateSharedSecret - public static Response generateSharedSecret(Client client, int adapterId) { - GenerateSharedSecretCDVRAdapterProfileBuilder generateSharedSecretCDVRAdapterProfileBuilder = - CDVRAdapterProfileService.generateSharedSecret(adapterId).setCompletion((ApiCompletion) result -> { - cdvrAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretCDVRAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdvrAdapterProfileResponse; - } - - // list - public static Response> list(Client client) { - ListCDVRAdapterProfileBuilder listCDVRAdapterProfileBuilder = CDVRAdapterProfileService.list() - .setCompletion((ApiCompletion>) result -> { - cdvrAdapterProfileListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listCDVRAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdvrAdapterProfileListResponse; - } - - // update - public static Response update(Client client, int adapterId, CDVRAdapterProfile cdvrAdapterProfile) { - UpdateCDVRAdapterProfileBuilder updateCDVRAdapterProfileBuilder = CDVRAdapterProfileService.update(adapterId, cdvrAdapterProfile) - .setCompletion((ApiCompletion) result -> { - cdvrAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateCDVRAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdvrAdapterProfileResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java deleted file mode 100644 index 49ce36b74..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CdnAdapterProfilesServiceImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CdnAdapterProfileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.CDNAdapterProfile; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CdnAdapterProfileService.*; -import static com.kaltura.client.services.CdnAdapterProfileService.AddCdnAdapterProfileBuilder; -import static org.awaitility.Awaitility.await; - -public class CdnAdapterProfilesServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response cdnAdapterProfileResponse; - private static Response booleanResponse; - private static Response> cdnAdapterProfileListResponse; - - // add - public static Response add(Client client, CDNAdapterProfile cdnAdapterProfile) { - AddCdnAdapterProfileBuilder addCdnAdapterProfileBuilder = CdnAdapterProfileService.add(cdnAdapterProfile) - .setCompletion((ApiCompletion) result -> { - cdnAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addCdnAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdnAdapterProfileResponse; - } - - // delete - public static Response delete(Client client, int adapterId) { - DeleteCdnAdapterProfileBuilder deleteCdnAdapterProfileBuilder = CdnAdapterProfileService.delete(adapterId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteCdnAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // generateSharedSecret - public static Response generateSharedSecret(Client client, int adapterId) { - GenerateSharedSecretCdnAdapterProfileBuilder generateSharedSecretCdnAdapterProfileBuilder = - CdnAdapterProfileService.generateSharedSecret(adapterId).setCompletion((ApiCompletion) result -> { - cdnAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretCdnAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdnAdapterProfileResponse; - } - - // list - public static Response> list(Client client) { - ListCdnAdapterProfileBuilder listCdnAdapterProfileBuilder = CdnAdapterProfileService.list() - .setCompletion((ApiCompletion>) result -> { - cdnAdapterProfileListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listCdnAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdnAdapterProfileListResponse; - } - - // update - public static Response update(Client client, int adapterId, CDNAdapterProfile cdnAdapterProfile) { - UpdateCdnAdapterProfileBuilder updateCdnAdapterProfileBuilder = CdnAdapterProfileService.update(adapterId, cdnAdapterProfile) - .setCompletion((ApiCompletion) result -> { - cdnAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateCdnAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdnAdapterProfileResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java deleted file mode 100644 index 126e0de19..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CdnPartnerSettingsServiceImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CdnPartnerSettingsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.CDNPartnerSettings; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CdnPartnerSettingsService.*; -import static org.awaitility.Awaitility.await; - -public class CdnPartnerSettingsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response cdnPartnerSettingsResponse; - - // get - public static Response get(Client client) { - GetCdnPartnerSettingsBuilder getCdnPartnerSettingsBuilder = CdnPartnerSettingsService.get() - .setCompletion((ApiCompletion) result -> { - cdnPartnerSettingsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getCdnPartnerSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdnPartnerSettingsResponse; - } - - // update - public static Response update(Client client, CDNPartnerSettings cdnPartnerSettings) { - UpdateCdnPartnerSettingsBuilder updateCdnPartnerSettingsBuilder = CdnPartnerSettingsService.update(cdnPartnerSettings) - .setCompletion((ApiCompletion) result -> { - cdnPartnerSettingsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateCdnPartnerSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return cdnPartnerSettingsResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java deleted file mode 100644 index 16cd3cbf9..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ChannelServiceImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ChannelService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Channel; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ChannelService.*; -import static org.awaitility.Awaitility.await; - -public class ChannelServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response channelResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, Channel channel) { - AddChannelBuilder addChannelBuilder = ChannelService.add(channel) - .setCompletion((ApiCompletion) result -> { - channelResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addChannelBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return channelResponse; - } - - // delete - public static Response delete(Client client, int channelId) { - DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteChannelBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, int channelId) { - GetChannelBuilder getChannelBuilder = ChannelService.get(channelId) - .setCompletion((ApiCompletion) result -> { - channelResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getChannelBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return channelResponse; - } - - // update - public static Response update(Client client, int channelId, Channel channel) { - UpdateChannelBuilder updateChannelBuilder = ChannelService.update(channelId, channel) - .setCompletion((ApiCompletion) result -> { - channelResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateChannelBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return channelResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java deleted file mode 100644 index 4d0c5218a..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CollectionServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CollectionService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Collection; -import com.kaltura.client.types.CollectionFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CollectionService.ListCollectionBuilder; -import static org.awaitility.Awaitility.await; - -public class CollectionServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> collectionListResponse; - - // list - public static Response> list(Client client, CollectionFilter collectionFilter) { - ListCollectionBuilder listCollectionBuilder = CollectionService.list(collectionFilter) - .setCompletion((ApiCompletion>) result -> { - collectionListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listCollectionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return collectionListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java deleted file mode 100644 index 5c85a651f..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CompensationServiceImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CompensationService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Compensation; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CompensationService.*; -import static org.awaitility.Awaitility.await; - -public class CompensationServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response compensationResponse; - - // add - public static Response add(Client client, Compensation compensation) { - AddCompensationBuilder addCompensationBuilder = CompensationService.add(compensation) - .setCompletion((ApiCompletion) result -> { - compensationResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addCompensationBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return compensationResponse; - } - - // delete - public static void delete(Client client, long id) { - DeleteCompensationBuilder deleteCompensationBuilder = CompensationService.delete(id); - deleteCompensationBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteCompensationBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } - - // get - public static Response get(Client client, long id) { - GetCompensationBuilder getCompensationBuilder = CompensationService.get(id) - .setCompletion((ApiCompletion) result -> { - compensationResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getCompensationBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return compensationResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java deleted file mode 100644 index 0844c75e2..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupDeviceServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ConfigurationGroupDeviceService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ConfigurationGroupDeviceService.*; -import static org.awaitility.Awaitility.await; - -public class ConfigurationGroupDeviceServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response configurationGroupDeviceResponse; - private static Response booleanResponse; - private static Response> configurationGroupDeviceListResponse; - - // add - public static Response add(Client client, ConfigurationGroupDevice configurationGroupDevice) { - AddConfigurationGroupDeviceBuilder addConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.add(configurationGroupDevice) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationGroupDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // delete - public static Response delete(Client client, String udid) { - DeleteConfigurationGroupDeviceBuilder deleteConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.delete(udid) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationGroupDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, String udid) { - GetConfigurationGroupDeviceBuilder getConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.get(udid) - .setCompletion((ApiCompletion) result -> { - configurationGroupDeviceResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationGroupDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupDeviceResponse; - } - - // list - public static Response> list(Client client, ConfigurationGroupDeviceFilter configurationGroupDeviceFilter, @Nullable FilterPager filterPager) { - ListConfigurationGroupDeviceBuilder listConfigurationGroupDeviceBuilder = ConfigurationGroupDeviceService.list(configurationGroupDeviceFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - configurationGroupDeviceListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationGroupDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupDeviceListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java deleted file mode 100644 index ac6687d23..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ConfigurationGroupService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ConfigurationGroup; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ConfigurationGroupService.*; -import static org.awaitility.Awaitility.await; - -public class ConfigurationGroupServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response configurationGroupResponse; - private static Response booleanResponse; - private static Response> configurationGroupListResponse; - - // add - public static Response add(Client client, ConfigurationGroup configurationGroup) { - AddConfigurationGroupBuilder addConfigurationGroupBuilder = ConfigurationGroupService.add(configurationGroup) - .setCompletion((ApiCompletion) result -> { - configurationGroupResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationGroupBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupResponse; - } - - // delete - public static Response delete(Client client, String id) { - DeleteConfigurationGroupBuilder deleteConfigurationGroupBuilder = ConfigurationGroupService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationGroupBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, String id) { - GetConfigurationGroupBuilder getConfigurationGroupBuilder = ConfigurationGroupService.get(id) - .setCompletion((ApiCompletion) result -> { - configurationGroupResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationGroupBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupResponse; - } - - // list - public static Response> list(Client client) { - ListConfigurationGroupBuilder listConfigurationGroupBuilder = ConfigurationGroupService.list() - .setCompletion((ApiCompletion>) result -> { - configurationGroupListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationGroupBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupListResponse; - } - - // update - public static Response update(Client client, String id, ConfigurationGroup configurationGroup) { - UpdateConfigurationGroupBuilder updateConfigurationGroupBuilder = ConfigurationGroupService.update(id, configurationGroup) - .setCompletion((ApiCompletion) result -> { - configurationGroupResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateConfigurationGroupBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java deleted file mode 100644 index cdf3236fe..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationGroupTagServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ConfigurationGroupTagService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ConfigurationGroupTag; -import com.kaltura.client.types.ConfigurationGroupTagFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ConfigurationGroupTagService.*; -import static org.awaitility.Awaitility.await; - -public class ConfigurationGroupTagServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response configurationGroupTagResponse; - private static Response booleanResponse; - private static Response> configurationGroupTagListResponse; - - // add - public static Response add(Client client, ConfigurationGroupTag configurationGroupTag) { - AddConfigurationGroupTagBuilder addConfigurationGroupTagBuilder = ConfigurationGroupTagService.add(configurationGroupTag) - .setCompletion((ApiCompletion) result -> { - configurationGroupTagResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationGroupTagBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupTagResponse; - } - - // delete - public static Response delete(Client client, String tag) { - DeleteConfigurationGroupTagBuilder deleteConfigurationGroupTagBuilder = ConfigurationGroupTagService.delete(tag) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationGroupTagBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, String tag) { - GetConfigurationGroupTagBuilder getConfigurationGroupTagBuilder = ConfigurationGroupTagService.get(tag) - .setCompletion((ApiCompletion) result -> { - configurationGroupTagResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationGroupTagBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupTagResponse; - } - - // list - public static Response> list(Client client, ConfigurationGroupTagFilter configurationGroupTagFilter) { - ListConfigurationGroupTagBuilder listConfigurationGroupTagBuilder = ConfigurationGroupTagService.list(configurationGroupTagFilter) - .setCompletion((ApiCompletion>) result -> { - configurationGroupTagListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationGroupTagBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationGroupTagListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java deleted file mode 100644 index 066581d34..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ConfigurationsServiceImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ConfigurationsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Configurations; -import com.kaltura.client.types.ConfigurationsFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ConfigurationsService.*; -import static org.awaitility.Awaitility.await; - -public class ConfigurationsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response configurationsResponse; - private static Response booleanResponse; - private static Response> configurationsListResponse; - private static Response stringResponse; - - // add - public static Response add(Client client, Configurations configurations) { - AddConfigurationsBuilder addConfigurationsBuilder = ConfigurationsService.add(configurations) - .setCompletion((ApiCompletion) result -> { - configurationsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addConfigurationsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationsResponse; - } - - // delete - public static Response delete(Client client, String id) { - DeleteConfigurationsBuilder deleteConfigurationsBuilder = ConfigurationsService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteConfigurationsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, String id) { - GetConfigurationsBuilder getConfigurationsBuilder = ConfigurationsService.get(id) - .setCompletion((ApiCompletion) result -> { - configurationsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationsResponse; - } - - // list - public static Response> list(Client client, ConfigurationsFilter configurationsFilter) { - ListConfigurationsBuilder listConfigurationsBuilder = ConfigurationsService.list(configurationsFilter) - .setCompletion((ApiCompletion>) result -> { - configurationsListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listConfigurationsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationsListResponse; - } - - // update - public static Response update(Client client, String id, Configurations configurations) { - UpdateConfigurationsBuilder updateConfigurationsBuilder = ConfigurationsService.update(id, configurations) - .setCompletion((ApiCompletion) result -> { - configurationsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateConfigurationsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return configurationsResponse; - } - - // serveByDevice - public static Response serveByDevice(Client client, String applicationName, String clientVersion, String platform, String udid, String tag, @Nullable int partnerId) { - ServeByDeviceConfigurationsBuilder serveByDeviceConfigurationsBuilder = ConfigurationsService.serveByDevice(applicationName, clientVersion, platform, udid, tag, partnerId); - serveByDeviceConfigurationsBuilder.setCompletion((ApiCompletion) result -> { - stringResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(serveByDeviceConfigurationsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return stringResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java deleted file mode 100644 index e25ec56f4..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CountryServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CountryService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Country; -import com.kaltura.client.types.CountryFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CountryService.*; -import static org.awaitility.Awaitility.await; - -public class CountryServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> countryListResponse; - - // list - public static Response> list(Client client, CountryFilter countryFilter) { - ListCountryBuilder listCountryBuilder = CountryService.list(countryFilter) - .setCompletion((ApiCompletion>) result -> { - countryListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listCountryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return countryListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java deleted file mode 100644 index 2b0653969..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CouponServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CouponService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Coupon; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CouponService.*; -import static org.awaitility.Awaitility.await; - -public class CouponServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response couponResponse; - - // get - public static Response get(Client client, String code) { - GetCouponBuilder getCouponBuilder = CouponService.get(code) - .setCompletion((ApiCompletion) result -> { - couponResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getCouponBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return couponResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java deleted file mode 100644 index e1e48f476..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/CurrencyServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.CurrencyService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Currency; -import com.kaltura.client.types.CurrencyFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.CurrencyService.*; -import static org.awaitility.Awaitility.await; - -public class CurrencyServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> currencyListResponse; - - // list - public static Response> list(Client client, CurrencyFilter currencyFilter) { - ListCurrencyBuilder listCurrencyBuilder = CurrencyService.list(currencyFilter) - .setCompletion((ApiCompletion>) result -> { - currencyListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listCurrencyBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return currencyListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java deleted file mode 100644 index 53b590b14..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/DeviceBrandServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.DeviceBrandService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.DeviceBrand; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.DeviceBrandService.*; -import static org.awaitility.Awaitility.await; - -public class DeviceBrandServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> deviceBrandListResponse; - - // list - public static Response> list(Client client) { - ListDeviceBrandBuilder listDeviceBrandBuilder = DeviceBrandService.list() - .setCompletion((ApiCompletion>) result -> { - deviceBrandListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listDeviceBrandBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return deviceBrandListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java deleted file mode 100644 index fc1506bcf..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/DeviceFamilyServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.DeviceFamilyService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.DeviceFamily; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.DeviceFamilyService.*; -import static org.awaitility.Awaitility.await; - -public class DeviceFamilyServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> deviceFamilyListResponse; - - // list - public static Response> list(Client client) { - ListDeviceFamilyBuilder listDeviceFamilyBuilder = DeviceFamilyService.list() - .setCompletion((ApiCompletion>) result -> { - deviceFamilyListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listDeviceFamilyBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return deviceFamilyListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java deleted file mode 100644 index 69552eda6..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EmailServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.EmailService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.EmailMessage; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.EmailService.*; -import static org.awaitility.Awaitility.await; - -public class EmailServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response booleanResponse; - - // send - public static Response send(Client client, EmailMessage emailMessage) { - SendEmailBuilder sendEmailBuilder = EmailService.send(emailMessage) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(sendEmailBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java deleted file mode 100644 index f9e5195e9..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EngagementAdapterServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.EngagementAdapterService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.EngagementAdapter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.EngagementAdapterService.*; -import static org.awaitility.Awaitility.await; - -public class EngagementAdapterServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response engagementAdapterResponse; - private static Response booleanResponse; - private static Response> engagementAdapterListResponse; - - // add - public static Response add(Client client, EngagementAdapter engagementAdapter) { - AddEngagementAdapterBuilder addEngagementAdapterBuilder = EngagementAdapterService.add(engagementAdapter) - .setCompletion((ApiCompletion) result -> { - engagementAdapterResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addEngagementAdapterBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementAdapterResponse; - } - - // delete - public static Response delete(Client client, int id) { - DeleteEngagementAdapterBuilder deleteEngagementAdapterBuilder = EngagementAdapterService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteEngagementAdapterBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, int id) { - GetEngagementAdapterBuilder getEngagementAdapterBuilder = EngagementAdapterService.get(id) - .setCompletion((ApiCompletion) result -> { - engagementAdapterResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getEngagementAdapterBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementAdapterResponse; - } - - // list - public static Response> list(Client client) { - ListEngagementAdapterBuilder listEngagementAdapterBuilder = EngagementAdapterService.list() - .setCompletion((ApiCompletion>) result -> { - engagementAdapterListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listEngagementAdapterBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementAdapterListResponse; - } - - // update - public static Response update(Client client, int id, EngagementAdapter engagementAdapter) { - UpdateEngagementAdapterBuilder updateEngagementAdapterBuilder = EngagementAdapterService.update(id, engagementAdapter) - .setCompletion((ApiCompletion) result -> { - engagementAdapterResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateEngagementAdapterBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementAdapterResponse; - } - - // generateSharedSecret - public static Response generateSharedSecret(Client client, int id) { - GenerateSharedSecretEngagementAdapterBuilder generateSharedSecretEngagementAdapterBuilder = EngagementAdapterService.generateSharedSecret(id) - .setCompletion((ApiCompletion) result -> { - engagementAdapterResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretEngagementAdapterBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementAdapterResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java deleted file mode 100644 index a08fc83c3..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EngagementServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.EngagementService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Engagement; -import com.kaltura.client.types.EngagementFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.EngagementService.*; -import static org.awaitility.Awaitility.await; - -public class EngagementServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response engagementResponse; - private static Response booleanResponse; - private static Response> engagementListResponse; - - // add - public static Response add(Client client, Engagement engagement) { - AddEngagementBuilder addEngagementBuilder = EngagementService.add(engagement) - .setCompletion((ApiCompletion) result -> { - engagementResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addEngagementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementResponse; - } - - // delete - public static Response delete(Client client, int id) { - DeleteEngagementBuilder deleteEngagementBuilder = EngagementService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteEngagementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, int id) { - GetEngagementBuilder getEngagementBuilder = EngagementService.get(id) - .setCompletion((ApiCompletion) result -> { - engagementResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getEngagementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementResponse; - } - - // list - public static Response> list(Client client, EngagementFilter engagementFilter) { - ListEngagementBuilder listEngagementBuilder = EngagementService.list(engagementFilter) - .setCompletion((ApiCompletion>) result -> { - engagementListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listEngagementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return engagementListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java deleted file mode 100644 index 918333d76..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/EntitlementServiceImpl.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.EntitlementService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.EntitlementService.*; -import static org.awaitility.Awaitility.await; - -public class EntitlementServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> entitlementListResponse; - private static Response booleanResponse; - private static Response entitlementRenewalResponse; - private static Response entitlementResponse; - - // list - public static Response> list(Client client, EntitlementFilter filter, @Nullable FilterPager pager) { - ListEntitlementBuilder productPriceBuilder = EntitlementService.list(filter, pager) - .setCompletion((ApiCompletion>) result -> { - entitlementListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return entitlementListResponse; - } - - // cancel - public static Response cancel(Client client, int assetId, TransactionType transactionType) { - CancelEntitlementBuilder cancelEntitlementBuilder = EntitlementService.cancel(assetId, transactionType) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(cancelEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // cancelScheduledSubscription - public static Response cancelScheduledSubscription(Client client, long scheduledSubscriptionId) { - CancelScheduledSubscriptionEntitlementBuilder cancelScheduledSubscriptionEntitlementBuilder = - EntitlementService.cancelScheduledSubscription(scheduledSubscriptionId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(cancelScheduledSubscriptionEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // externalReconcile - public static Response externalReconcile(Client client) { - ExternalReconcileEntitlementBuilder externalReconcileEntitlementBuilder = - EntitlementService.externalReconcile() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(externalReconcileEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // forceCancel - public static Response forceCancel(Client client, int assetId, TransactionType transactionType) { - ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel(assetId, transactionType) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(forceCancelEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // getNextRenewal - public static Response getNextRenewal(Client client, int id) { - GetNextRenewalEntitlementBuilder getNextRenewalEntitlementBuilder = EntitlementService.getNextRenewal(id) - .setCompletion((ApiCompletion) result -> { - entitlementRenewalResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getNextRenewalEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return entitlementRenewalResponse; - } - - // grant - public static Response grant(Client client, int productId, TransactionType transactionType, boolean history, @Nullable Integer contentId) { - if (contentId == null) contentId = 0; - GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(productId, transactionType, history, contentId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(grantEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // swap - public static Response swap(Client client, int currentProductId, int newProductId, boolean history) { - SwapEntitlementBuilder swapEntitlementBuilder = EntitlementService.swap(currentProductId, newProductId, history) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(swapEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // update - public static Response update(Client client, int id, Entitlement entitlement) { - UpdateEntitlementBuilder updateEntitlementBuilder = EntitlementService.update(id, entitlement) - .setCompletion((ApiCompletion) result -> { - entitlementResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return entitlementResponse; - } - - // cancelRenewal - public static void cancelRenewal(Client client, String subscriptionId) { - CancelRenewalEntitlementBuilder cancelRenewalEntitlementBuilder = EntitlementService.cancelRenewal(subscriptionId); - cancelRenewalEntitlementBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(cancelRenewalEntitlementBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } -} - - diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java deleted file mode 100644 index d227ef05b..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ExportTaskServiceImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ExportTaskService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ExportTask; -import com.kaltura.client.types.ExportTaskFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ExportTaskService.*; -import static org.awaitility.Awaitility.await; - -public class ExportTaskServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response exportTaskResponse; - private static Response> exportTaskListResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, ExportTask exportTask) { - AddExportTaskBuilder addExportTaskBuilder = ExportTaskService.add(exportTask) - .setCompletion((ApiCompletion) result -> { - exportTaskResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addExportTaskBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return exportTaskResponse; - } - - // delete - public static Response delete(Client client, long id) { - DeleteExportTaskBuilder deleteExportTaskBuilder = ExportTaskService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteExportTaskBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, long id) { - GetExportTaskBuilder getExportTaskBuilder = ExportTaskService.get(id) - .setCompletion((ApiCompletion) result -> { - exportTaskResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getExportTaskBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return exportTaskResponse; - } - - // list - public static Response> list(Client client, @Nullable ExportTaskFilter exportTaskFilter) { - ListExportTaskBuilder listExportTaskBuilder = ExportTaskService.list(exportTaskFilter) - .setCompletion((ApiCompletion>) result -> { - exportTaskListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listExportTaskBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return exportTaskListResponse; - } - - // update - public static Response update(Client client, long id, ExportTask exportTask) { - UpdateExportTaskBuilder updateExportTaskBuilder = ExportTaskService.update(id, exportTask) - .setCompletion((ApiCompletion) result -> { - exportTaskResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateExportTaskBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return exportTaskResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java deleted file mode 100644 index d6f69e9f3..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ExternalChannelProfileServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ExternalChannelProfileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ExternalChannelProfile; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ExternalChannelProfileService.*; -import static org.awaitility.Awaitility.await; - -public class ExternalChannelProfileServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response externalChannelProfileResponse; - private static Response> externalChannelProfileListResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, ExternalChannelProfile externalChannelProfile) { - AddExternalChannelProfileBuilder addExternalChannelProfileBuilder = ExternalChannelProfileService.add(externalChannelProfile) - .setCompletion((ApiCompletion) result -> { - externalChannelProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addExternalChannelProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return externalChannelProfileResponse; - } - - // delete - public static Response delete(Client client, int externalChannelId) { - DeleteExternalChannelProfileBuilder deleteExternalChannelProfileBuilder = ExternalChannelProfileService.delete(externalChannelId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteExternalChannelProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client) { - ListExternalChannelProfileBuilder listExternalChannelProfileBuilder = ExternalChannelProfileService.list() - .setCompletion((ApiCompletion>) result -> { - externalChannelProfileListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listExternalChannelProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return externalChannelProfileListResponse; - } - - // update - public static Response update(Client client, int externalChannelId, ExternalChannelProfile externalChannelProfile) { - UpdateExternalChannelProfileBuilder updateExternalChannelProfileBuilder = ExternalChannelProfileService.update(externalChannelId, externalChannelProfile) - .setCompletion((ApiCompletion) result -> { - externalChannelProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateExternalChannelProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return externalChannelProfileResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java deleted file mode 100644 index fcfb229eb..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/FavoriteServiceImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.FavoriteService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Favorite; -import com.kaltura.client.types.FavoriteFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.FavoriteService.*; -import static org.awaitility.Awaitility.await; - -public class FavoriteServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response favoriteResponse; - private static Response> favoriteListResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, Favorite favorite) { - AddFavoriteBuilder addFavoriteBuilder = FavoriteService.add(favorite) - .setCompletion((ApiCompletion) result -> { - favoriteResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addFavoriteBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return favoriteResponse; - } - - // delete - public static Response delete(Client client, int id) { - DeleteFavoriteBuilder deleteFavoriteBuilder = FavoriteService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteFavoriteBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, @Nullable FavoriteFilter favoriteFilter) { - ListFavoriteBuilder listFavoriteBuilder = FavoriteService.list(favoriteFilter) - .setCompletion((ApiCompletion>) result -> { - favoriteListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listFavoriteBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return favoriteListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java deleted file mode 100644 index beb4513cf..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/FollowTvSeriesServiceImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.FollowTvSeriesService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.FollowTvSeries; -import com.kaltura.client.types.FollowTvSeriesFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.FollowTvSeriesService.*; -import static org.awaitility.Awaitility.await; - -public class FollowTvSeriesServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response followTvSeriesResponse; - private static Response> followTvSeriesListResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, FollowTvSeries followTvSeries) { - - AddFollowTvSeriesBuilder addFollowTvSeriesBuilder = FollowTvSeriesService.add(followTvSeries) - .setCompletion((ApiCompletion) result -> { - followTvSeriesResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addFollowTvSeriesBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return followTvSeriesResponse; - } - - // delete - public static Response delete(Client client, int assetId) { - DeleteFollowTvSeriesBuilder deleteFollowTvSeriesBuilder = FollowTvSeriesService.delete(assetId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteFollowTvSeriesBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, FollowTvSeriesFilter followTvSeriesFilter, @Nullable FilterPager filterPager) { - ListFollowTvSeriesBuilder listFollowTvSeriesBuilder = FollowTvSeriesService.list(followTvSeriesFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - followTvSeriesListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listFollowTvSeriesBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return followTvSeriesListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java deleted file mode 100644 index 557208082..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HomeNetworkServiceImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.HomeNetworkService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HomeNetworkService.*; -import static org.awaitility.Awaitility.await; - -public class HomeNetworkServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response homeNetworkResponse; - private static Response> homeNetworkListResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, HomeNetwork homeNetwork) { - AddHomeNetworkBuilder addHomeNetworkBuilder = HomeNetworkService.add(homeNetwork) - .setCompletion((ApiCompletion) result -> { - homeNetworkResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addHomeNetworkBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return homeNetworkResponse; - } - - // delete - public static Response delete(Client client, String externalId) { - DeleteHomeNetworkBuilder deleteHomeNetworkBuilder = HomeNetworkService.delete(externalId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteHomeNetworkBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return homeNetworkResponse; - } - - // list - public static Response> list(Client client) { - ListHomeNetworkBuilder listHomeNetworkBuilder = HomeNetworkService.list() - .setCompletion((ApiCompletion>) result -> { - homeNetworkListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listHomeNetworkBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return homeNetworkListResponse; - } - - // update - public static Response list(Client client, String externalId, HomeNetwork homeNetwork) { - UpdateHomeNetworkBuilder updateHomeNetworkBuilder = HomeNetworkService.update(externalId, homeNetwork) - .setCompletion((ApiCompletion) result -> { - homeNetworkResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateHomeNetworkBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return homeNetworkResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java deleted file mode 100644 index aa38e33b2..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdDeviceServiceImpl.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.DeviceStatus; -import com.kaltura.client.services.HouseholdDeviceService; -import com.kaltura.client.services.HouseholdDeviceService.*; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; -import static org.awaitility.Awaitility.await; - -public class HouseholdDeviceServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response householdDeviceResponse; - private static Response> householdDevicesListResponse; - private static Response booleanResponse; - private static Response devicePinResponse; - private static Response loginResponse; - - - // add - public static Response add(Client client, HouseholdDevice householdDevice) { - AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice) - .setCompletion((ApiCompletion) result -> { - householdDeviceResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdDeviceResponse; - } - - // list - public static Response> list(Client client, HouseholdDeviceFilter householdDeviceFilter) { - ListHouseholdDeviceBuilder listHouseholdDeviceBuilder = HouseholdDeviceService.list(householdDeviceFilter) - .setCompletion((ApiCompletion>) result -> { - householdDevicesListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdDevicesListResponse; - } - - // addByPin - public static Response addByPin(Client client, String deviceName, String pin) { - AddByPinHouseholdDeviceBuilder addByPinHouseholdDeviceBuilder = HouseholdDeviceService.addByPin(deviceName, pin) - .setCompletion((ApiCompletion) result -> { - householdDeviceResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addByPinHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdDeviceResponse; - } - - // delete - public static Response delete(Client client, String udid) { - DeleteHouseholdDeviceBuilder deleteHouseholdDeviceBuilder = HouseholdDeviceService.delete(udid) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // generatePin - public static Response generatePin(Client client, String udid, int brandId) { - GeneratePinHouseholdDeviceBuilder generatePinHouseholdDeviceBuilder = HouseholdDeviceService.generatePin(udid, brandId) - .setCompletion((ApiCompletion) result -> { - devicePinResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(generatePinHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return devicePinResponse; - } - - // get - public static Response get(Client client) { - GetHouseholdDeviceBuilder getHouseholdDeviceBuilder = HouseholdDeviceService.get() - .setCompletion((ApiCompletion) result -> { - householdDeviceResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdDeviceResponse; - } - - // loginWithPin - public static Response loginWithPin(Client client, int partnerId, String pin, @Nullable String udid) { - LoginWithPinHouseholdDeviceBuilder loginWithPinHouseholdDeviceBuilder = HouseholdDeviceService.loginWithPin(partnerId, pin, udid) - .setCompletion((ApiCompletion) result -> { - loginResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(loginWithPinHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return loginResponse; - } - - // update - public static Response update(Client client, String udid, HouseholdDevice householdDevice) { - UpdateHouseholdDeviceBuilder updateHouseholdDeviceBuilder = HouseholdDeviceService.update(udid, householdDevice) - .setCompletion((ApiCompletion) result -> { - householdDeviceResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdDeviceResponse; - } - - // updateStatus - public static Response updateStatus(Client client, String udid, DeviceStatus deviceStatus) { - UpdateStatusHouseholdDeviceBuilder updateStatusHouseholdDeviceBuilder = HouseholdDeviceService.updateStatus(udid, deviceStatus) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusHouseholdDeviceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java deleted file mode 100644 index 83de2a94c..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdLimitationsServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.HouseholdLimitationsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HouseholdLimitationsService.*; -import static org.awaitility.Awaitility.await; - -public class HouseholdLimitationsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response householdLimitationsResponse; - - // get - public static Response get(Client client, int id) { - GetHouseholdLimitationsBuilder getHouseholdLimitationsBuilder = HouseholdLimitationsService.get(id) - .setCompletion((ApiCompletion) result -> { - householdLimitationsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdLimitationsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdLimitationsResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java deleted file mode 100644 index 3f342610c..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentGatewayServiceImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.HouseholdPaymentGatewayService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.HouseholdPaymentGateway; -import com.kaltura.client.types.KeyValue; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.PaymentGatewayConfiguration; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HouseholdPaymentGatewayService.*; -import static org.awaitility.Awaitility.await; - -public class HouseholdPaymentGatewayServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response booleanResponse; - private static Response stringResponse; - private static Response paymentGatewayConfigurationResponse; - private static Response> householdPaymentGatewayListResponse; - - // setChargeId - public static Response setChargeId(Client client, String paymentGatewayExternalId, String chargeId) { - SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = - setChargeID(paymentGatewayExternalId, chargeId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(setChargeIDHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // disable - public static Response disable(Client client, int paymentGateway) { - DisableHouseholdPaymentGatewayBuilder disableHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.disable(paymentGateway) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(disableHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // enable - public static Response enable(Client client, int paymentGateway) { - EnableHouseholdPaymentGatewayBuilder enableHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.enable(paymentGateway) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(enableHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // getChargeID - public static Response getChargeID(Client client, String paymentGatewayExternalId) { - GetChargeIDHouseholdPaymentGatewayBuilder getChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService - .getChargeID(paymentGatewayExternalId).setCompletion((ApiCompletion) result -> { - stringResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getChargeIDHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return stringResponse; - } - - // invoke - public static Response invoke(Client client, int paymentGateway, String intent, List extraParams) { - InvokeHouseholdPaymentGatewayBuilder invokeHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService - .invoke(paymentGateway, intent, extraParams).setCompletion((ApiCompletion) result -> { - paymentGatewayConfigurationResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(invokeHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentGatewayConfigurationResponse; - } - - // list - public static Response> list(Client client) { - ListHouseholdPaymentGatewayBuilder listHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.list() - .setCompletion((ApiCompletion>) result -> { - householdPaymentGatewayListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdPaymentGatewayListResponse; - } - - // resume - public static void resume(Client client, int paymentGateway) { - ResumeHouseholdPaymentGatewayBuilder resumeHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.resume(paymentGateway); - resumeHouseholdPaymentGatewayBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(resumeHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } - - // suspend - public static void suspend(Client client, int paymentGateway) { - SuspendHouseholdPaymentGatewayBuilder suspendHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.suspend(paymentGateway); - suspendHouseholdPaymentGatewayBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(suspendHouseholdPaymentGatewayBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java deleted file mode 100644 index 3f8055d3d..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPaymentMethodServiceImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.HouseholdPaymentMethodService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.HouseholdPaymentMethod; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.PaymentGatewayConfiguration; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HouseholdPaymentMethodService.*; -import static org.awaitility.Awaitility.await; - -public class HouseholdPaymentMethodServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response booleanResponse; - private static Response householdPaymentMethodResponse; - private static Response paymentGatewayConfigurationResponse; - private static Response> householdPaymentMethodListResponse; - - // add - public static Response add(Client client, HouseholdPaymentMethod householdPaymentMethod) { - AddHouseholdPaymentMethodBuilder addHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService.add(householdPaymentMethod) - .setCompletion((ApiCompletion) result -> { - householdPaymentMethodResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdPaymentMethodBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdPaymentMethodResponse; - } - - // forceRemove - public static Response forceRemove(Client client, int paymentGatewayId, int paymentMethodId) { - ForceRemoveHouseholdPaymentMethodBuilder forceRemoveHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService - .forceRemove(paymentGatewayId, paymentMethodId).setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(forceRemoveHouseholdPaymentMethodBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client) { - ListHouseholdPaymentMethodBuilder listHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService.list() - .setCompletion((ApiCompletion>) result -> { - householdPaymentMethodListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdPaymentMethodBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdPaymentMethodListResponse; - } - - // remove - public static Response remove(Client client, int paymentGatewayId, int paymentMethodId) { - RemoveHouseholdPaymentMethodBuilder removeHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService - .remove(paymentGatewayId, paymentMethodId).setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(removeHouseholdPaymentMethodBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // setAsDefault - public static Response setAsDefault(Client client, int paymentGatewayId, int paymentMethodId) { - SetAsDefaultHouseholdPaymentMethodBuilder setAsDefaultHouseholdPaymentMethodBuilder = HouseholdPaymentMethodService - .setAsDefault(paymentGatewayId, paymentMethodId).setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(setAsDefaultHouseholdPaymentMethodBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java deleted file mode 100644 index 83751e220..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdPremiumServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.HouseholdPremiumServiceService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.HouseholdPremiumService; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HouseholdPremiumServiceService.*; -import static org.awaitility.Awaitility.await; - -public class HouseholdPremiumServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> householdPremiumServiceListResponse; - - // list - public static Response> list(Client client) { - ListHouseholdPremiumServiceBuilder listHouseholdPremiumServiceBuilder = HouseholdPremiumServiceService.list() - .setCompletion((ApiCompletion>) result -> { - householdPremiumServiceListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdPremiumServiceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdPremiumServiceListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java deleted file mode 100644 index 46378d037..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdQuotaServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.HouseholdQuotaService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.HouseholdQuota; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static org.awaitility.Awaitility.await; - -public class HouseholdQuotaServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response householdQuotaResponse; - - // get - public static Response get(Client client) { - HouseholdQuotaService.GetHouseholdQuotaBuilder getHouseholdQuotaBuilder = HouseholdQuotaService.get() - .setCompletion((ApiCompletion) result -> { - householdQuotaResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdQuotaBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdQuotaResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java deleted file mode 100644 index c124034e6..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdServiceImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.HouseholdFrequencyType; -import com.kaltura.client.services.HouseholdService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Household; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HouseholdService.*; -import static com.kaltura.client.services.HouseholdService.AddHouseholdBuilder; -import static com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; -import static org.awaitility.Awaitility.await; - -public class HouseholdServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response householdResponse; - private static Response booleanResponse; - - - // add - public static Response add(Client client, Household household) { - AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household) - .setCompletion((ApiCompletion) result -> { - householdResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdResponse; - } - - // delete - public static Response delete(Client client, @Nullable int householdId) { - DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(householdId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, @Nullable Integer id) { - GetHouseholdBuilder getHouseholdBuilder; - if (id == null) { - getHouseholdBuilder = HouseholdService.get() - .setCompletion((ApiCompletion) result -> { - householdResponse = result; - done.set(true); - }); - } else { - getHouseholdBuilder = HouseholdService.get(id) - .setCompletion((ApiCompletion) result -> { - householdResponse = result; - done.set(true); - }); - } - - TestAPIOkRequestsExecutor.getExecutor().queue(getHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdResponse; - } - - // purge - public static Response purge(Client client, int id) { - PurgeHouseholdBuilder purgeHouseholdBuilder = HouseholdService.purge(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(purgeHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // resetFrequency - public static Response resetFrequency(Client client, HouseholdFrequencyType frequencyType) { - ResetFrequencyHouseholdBuilder resetFrequencyHouseholdBuilder = HouseholdService.resetFrequency(frequencyType) - .setCompletion((ApiCompletion) result -> { - householdResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(resetFrequencyHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdResponse; - } - - // resume - public static Response resume(Client client) { - ResumeHouseholdBuilder resumeHouseholdBuilder = HouseholdService.resume() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(resumeHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // suspend - public static Response suspend(Client client, @Nullable Integer roleId) { - SuspendHouseholdBuilder suspendHouseholdBuilder; - if (roleId == null) { - suspendHouseholdBuilder = HouseholdService.suspend() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - } else { - suspendHouseholdBuilder = HouseholdService.suspend(roleId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - } - - TestAPIOkRequestsExecutor.getExecutor().queue(suspendHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // update - public static Response update(Client client, Household household) { - UpdateHouseholdBuilder updateHouseholdBuilder = HouseholdService.update(household) - .setCompletion((ApiCompletion) result -> { - householdResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateHouseholdBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java deleted file mode 100644 index dcf997615..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/HouseholdUserServiceImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.HouseholdUserService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.HouseholdUser; -import com.kaltura.client.types.HouseholdUserFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.HouseholdUserService.*; -import static com.kaltura.client.services.HouseholdUserService.AddHouseholdUserBuilder; -import static com.kaltura.client.services.HouseholdUserService.ListHouseholdUserBuilder; -import static org.awaitility.Awaitility.await; - -public class HouseholdUserServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response householdUserResponse; - private static Response> householdUserListResponse; - private static Response booleanResponse; - - - // add - public static Response add(Client client, HouseholdUser householdUser) { - AddHouseholdUserBuilder addHouseholdUserBuilder = HouseholdUserService.add(householdUser) - .setCompletion((ApiCompletion) result -> { - householdUserResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addHouseholdUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdUserResponse; - } - - // list - public static Response> list(Client client, @Nullable HouseholdUserFilter householdUserFilter) { - ListHouseholdUserBuilder listHouseholdUserBuilder = HouseholdUserService.list(householdUserFilter) - .setCompletion((ApiCompletion>) result -> { - householdUserListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listHouseholdUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return householdUserListResponse; - } - - // delete - public static Response delete(Client client, String id) { - DeleteHouseholdUserBuilder deleteHouseholdUserBuilder = HouseholdUserService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteHouseholdUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java deleted file mode 100644 index 29da4d440..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/InboxMessageServiceImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.InboxMessageStatus; -import com.kaltura.client.services.InboxMessageService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.InboxMessage; -import com.kaltura.client.types.InboxMessageFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.InboxMessageService.*; -import static org.awaitility.Awaitility.await; - -public class InboxMessageServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response inboxMessageResponse; - private static Response> inboxMessageListResponse; - private static Response booleanResponse; - - // get - public static Response get(Client client, String id) { - GetInboxMessageBuilder getInboxMessageBuilder = InboxMessageService.get(id) - .setCompletion((ApiCompletion) result -> { - inboxMessageResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getInboxMessageBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return inboxMessageResponse; - } - - // list - public static Response> list(Client client, @Nullable InboxMessageFilter inboxMessageFilter, @Nullable FilterPager filterPager) { - ListInboxMessageBuilder listInboxMessageBuilder = InboxMessageService.list(inboxMessageFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - inboxMessageListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listInboxMessageBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return inboxMessageListResponse; - } - - // updateStatus - public static Response updateStatus(Client client, String id, InboxMessageStatus inboxMessageStatus) { - UpdateStatusInboxMessageBuilder updateStatusInboxMessageBuilder = InboxMessageService.updateStatus(id, inboxMessageStatus) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusInboxMessageBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java deleted file mode 100644 index 9dd5daa2f..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/LanguageServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.LanguageService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Language; -import com.kaltura.client.types.LanguageFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.LanguageService.*; -import static org.awaitility.Awaitility.await; - -public class LanguageServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> languageListResponse; - - // list - public static Response> list(Client client, LanguageFilter languageFilter) { - ListLanguageBuilder listLanguageBuilder = LanguageService.list(languageFilter) - .setCompletion((ApiCompletion>) result -> { - languageListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listLanguageBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return languageListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java deleted file mode 100644 index 6110319f2..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/LicensedUrlServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.LicensedUrlService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.LicensedUrlService.*; -import static org.awaitility.Awaitility.await; - -public class LicensedUrlServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response licensedUrlResponse; - - // get - public static Response get(Client client, LicensedUrlBaseRequest licensedUrlBaseRequest) { - GetLicensedUrlBuilder getLicensedUrlBuilder = LicensedUrlService.get(licensedUrlBaseRequest) - .setCompletion((ApiCompletion) result -> { - licensedUrlResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getLicensedUrlBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return licensedUrlResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java deleted file mode 100644 index 0729d9075..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/MessageTemplateServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.MessageTemplateType; -import com.kaltura.client.services.MessageTemplateService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.MessageTemplate; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.MessageTemplateService.*; -import static org.awaitility.Awaitility.await; - -public class MessageTemplateServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response messageTemplateResponse; - - // get - public static Response get(Client client, MessageTemplateType messageTemplateType) { - GetMessageTemplateBuilder getMessageTemplateBuilder = MessageTemplateService.get(messageTemplateType) - .setCompletion((ApiCompletion) result -> { - messageTemplateResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getMessageTemplateBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return messageTemplateResponse; - } - - // update - public static Response update(Client client, MessageTemplateType messageTemplateType, MessageTemplate messageTemplate) { - UpdateMessageTemplateBuilder updateMessageTemplateBuilder = MessageTemplateService.update(messageTemplateType, messageTemplate) - .setCompletion((ApiCompletion) result -> { - messageTemplateResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateMessageTemplateBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return messageTemplateResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java deleted file mode 100644 index 9fc3daacc..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/MetaServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.MetaService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.Meta; -import com.kaltura.client.types.MetaFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.MetaService.*; -import static org.awaitility.Awaitility.await; - -public class MetaServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> metaListResponse; - private static Response metaResponse; - - // list - public static Response> list(Client client, @Nullable MetaFilter metaFilter) { - ListMetaBuilder listMetaBuilder = MetaService.list(metaFilter) - .setCompletion((ApiCompletion>) result -> { - metaListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listMetaBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return metaListResponse; - } - - // update - public static Response update(Client client, String id, Meta meta) { - UpdateMetaBuilder updateMetaBuilder = MetaService.update(id, meta) - .setCompletion((ApiCompletion) result -> { - metaResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateMetaBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return metaResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java deleted file mode 100644 index 61966f0e3..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationServiceImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.NotificationType; -import com.kaltura.client.services.NotificationService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.PushMessage; -import com.kaltura.client.types.RegistryResponse; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.NotificationService.*; -import static com.kaltura.client.services.NotificationService.RegisterNotificationBuilder; -import static com.kaltura.client.services.NotificationService.SendPushNotificationBuilder; -import static org.awaitility.Awaitility.await; - -public class NotificationServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response registryResponse; - private static Response booleanResponse; - - // register - public static Response register(Client client, String identifier, NotificationType notificationType) { - RegisterNotificationBuilder registerNotificationBuilder = NotificationService.register(identifier, notificationType) - .setCompletion((ApiCompletion) result -> { - registryResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(registerNotificationBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return registryResponse; - } - - // sendPush - public static Response sendPush(Client client, int userId, PushMessage pushMessage) { - SendPushNotificationBuilder sendPushNotificationBuilder = NotificationService.sendPush(userId, pushMessage) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(sendPushNotificationBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // setDevicePushToken - public static Response setDevicePushToken(Client client, String pushToken) { - SetDevicePushTokenNotificationBuilder setDevicePushTokenNotificationBuilder = NotificationService.setDevicePushToken(pushToken) - .setCompletion(new ApiCompletion() { - @Override - public void onComplete(Response result) { - booleanResponse = result; - done.set(true); - } - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(setDevicePushTokenNotificationBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java deleted file mode 100644 index 2a1191270..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsPartnerSettingsServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.NotificationsPartnerSettingsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.NotificationsPartnerSettings; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.NotificationsPartnerSettingsService.*; -import static org.awaitility.Awaitility.await; - -public class NotificationsPartnerSettingsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response notificationsPartnerSettingsResponse; - private static Response booleanResponse; - - // get - public static Response get(Client client) { - GetNotificationsPartnerSettingsBuilder getNotificationsPartnerSettingsBuilder = - NotificationsPartnerSettingsService.get().setCompletion((ApiCompletion) result -> { - notificationsPartnerSettingsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getNotificationsPartnerSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return notificationsPartnerSettingsResponse; - } - - // update - public static Response update(Client client, NotificationsPartnerSettings notificationsPartnerSettings) { - UpdateNotificationsPartnerSettingsBuilder updateNotificationsPartnerSettingsBuilder = NotificationsPartnerSettingsService - .update(notificationsPartnerSettings).setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateNotificationsPartnerSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java deleted file mode 100644 index 92f59cbae..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/NotificationsSettingsServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.NotificationsSettingsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.NotificationsSettings; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.NotificationsSettingsService.GetNotificationsSettingsBuilder; -import static com.kaltura.client.services.NotificationsSettingsService.UpdateNotificationsSettingsBuilder; -import static org.awaitility.Awaitility.await; - -public class NotificationsSettingsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response notificationsSettingsResponse; - private static Response booleanResponse; - - // get - public static Response get(Client client) { - GetNotificationsSettingsBuilder getNotificationsSettingsBuilder = NotificationsSettingsService.get() - .setCompletion((ApiCompletion) result -> { - notificationsSettingsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getNotificationsSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return notificationsSettingsResponse; - } - - // update - public static Response update(Client client, NotificationsSettings notificationsSettings) { - UpdateNotificationsSettingsBuilder updateNotificationsSettingsBuilder = NotificationsSettingsService.update(notificationsSettings) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateNotificationsSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java deleted file mode 100644 index f72aaec2c..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OssAdapterProfileServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.OssAdapterProfileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.OSSAdapterProfile; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.OssAdapterProfileService.*; -import static org.awaitility.Awaitility.await; - -public class OssAdapterProfileServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response ossAdapterProfileResponse; - private static Response booleanResponse; - private static Response> ossAdapterProfileListResponse; - - // add - public static Response add(Client client, OSSAdapterProfile ossAdapterProfile) { - AddOssAdapterProfileBuilder addOssAdapterProfileBuilder = OssAdapterProfileService.add(ossAdapterProfile) - .setCompletion((ApiCompletion) result -> { - ossAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addOssAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ossAdapterProfileResponse; - } - - // delete - public static Response delete(Client client, int ossAdapterId) { - DeleteOssAdapterProfileBuilder deleteOssAdapterProfileBuilder = OssAdapterProfileService.delete(ossAdapterId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteOssAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // generateSharedSecret - public static Response generateSharedSecret(Client client, int ossAdapterId) { - GenerateSharedSecretOssAdapterProfileBuilder generateSharedSecretOssAdapterProfileBuilder = - OssAdapterProfileService.generateSharedSecret(ossAdapterId) - .setCompletion((ApiCompletion) result -> { - ossAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretOssAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ossAdapterProfileResponse; - } - - // get - public static Response get(Client client, int id) { - GetOssAdapterProfileBuilder getOssAdapterProfileBuilder = OssAdapterProfileService.get(id) - .setCompletion((ApiCompletion) result -> { - ossAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getOssAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ossAdapterProfileResponse; - } - - // list - public static Response> list(Client client) { - ListOssAdapterProfileBuilder listOssAdapterProfileBuilder = OssAdapterProfileService.list() - .setCompletion((ApiCompletion>) result -> { - ossAdapterProfileListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listOssAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ossAdapterProfileListResponse; - } - - // update - public static Response update(Client client, int ossAdapterId, OSSAdapterProfile ossAdapterProfile) { - UpdateOssAdapterProfileBuilder updateOssAdapterProfileBuilder = OssAdapterProfileService.update(ossAdapterId, ossAdapterProfile) - .setCompletion((ApiCompletion) result -> { - ossAdapterProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateOssAdapterProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ossAdapterProfileResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java deleted file mode 100644 index a01b70f8f..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttCategoryServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.OttCategoryService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.OTTCategory; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.OttCategoryService.*; -import static org.awaitility.Awaitility.await; - -public class OttCategoryServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response ottCategoryResponse; - - // get - public static Response get(Client client, int id) { - GetOttCategoryBuilder getOttCategoryBuilder = OttCategoryService.get(id) - .setCompletion((ApiCompletion) result -> { - ottCategoryResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getOttCategoryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottCategoryResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java deleted file mode 100644 index 99d579172..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/OttUserServiceImpl.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.OttUserService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.OttUserService.*; -import static org.awaitility.Awaitility.await; - -public class OttUserServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response loginResponse; - private static Response ottUserResponse; - private static Response loginSessionResponse; - private static Response booleanResponse; - private static Response> ottUserListResponse; - private static Response stringValueResponse; - private static Response ottUserDynamicDataResponse; - - - // activate - public static Response activate(Client client, int partnerId, String username, String activationToken) { - ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, username, activationToken) - .setCompletion((ApiCompletion) result -> { - ottUserResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(activateOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottUserResponse; - } - - // addRole - public static Response addRole(Client client, int roleId) { - AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(roleId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addRoleOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // anonymousLogin - public static Response anonymousLogin(Client client, int partnerId, @Nullable String udid) { - AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid) - .setCompletion((ApiCompletion) result -> { - loginSessionResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(anonymousLoginOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return loginSessionResponse; - } - - // delete - public static Response delete(Client client) { - DeleteOttUserBuilder deleteOttUserBuilder = OttUserService.delete() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client) { - GetOttUserBuilder getOttUserBuilder = OttUserService.get() - .setCompletion((ApiCompletion) result -> { - ottUserResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottUserResponse; - } - - // getEncryptedUserId - public static Response getEncryptedUserId(Client client) { - GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = OttUserService.getEncryptedUserId() - .setCompletion((ApiCompletion) result -> { - stringValueResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getEncryptedUserIdOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return stringValueResponse; - } - - // list - public static Response> list(Client client, @Nullable OTTUserFilter ottUserFilter) { - ListOttUserBuilder listOttUserBuilder = OttUserService.list(ottUserFilter) - .setCompletion((ApiCompletion>) result -> { - ottUserListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottUserListResponse; - } - - // login - public static Response login(Client client, int partnerId, @Nullable String username, @Nullable String password, - @Nullable Map extraParams, @Nullable String udid) { - LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, username, password, extraParams, udid) - .setCompletion((ApiCompletion) result -> { - loginResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(loginOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return loginResponse; - } - - // loginWithPin - public static Response loginWithPin(Client client, int partnerId, String pin, @Nullable String udid, String secret) { - - LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = OttUserService.loginWithPin(partnerId, pin, udid, secret) - .setCompletion((ApiCompletion) result -> { - loginResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(loginWithPinOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return loginResponse; - } - - // logout - public static Response logout(Client client) { - LogoutOttUserBuilder logoutOttUserBuilder = OttUserService.logout() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(logoutOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // register - public static Response register(Client client, int partnerId, OTTUser user, String password) { - RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, password) - .setCompletion((ApiCompletion) result -> { - ottUserResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(registerOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottUserResponse; - } - - // resendActivationToken - public static Response resendActivationToken(Client client, int partnerId, String username) { - ResendActivationTokenOttUserBuilder resendActivationTokenOttUserBuilder = OttUserService.resendActivationToken(partnerId, username) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(resendActivationTokenOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // resetPassword - public static Response resetPassword(Client client, int partnerId, String username) { - ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, username) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(resetPasswordOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // setInitialPassword - public static Response setInitialPassword(Client client, int partnerId, String token, String password) { - SetInitialPasswordOttUserBuilder setInitialPasswordOttUserBuilder = OttUserService.setInitialPassword(partnerId, token, password) - .setCompletion((ApiCompletion) result -> { - ottUserResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(setInitialPasswordOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottUserResponse; - } - - // update - public static Response update(Client client, OTTUser user, @Nullable String id) { - UpdateOttUserBuilder updateOttUserBuilder = OttUserService.update(user, id) - .setCompletion((ApiCompletion) result -> { - ottUserResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottUserResponse; - } - - // updateDynamicData - public static Response updateDynamicData(Client client, String key, StringValue value) { - UpdateDynamicDataOttUserBuilder updateDynamicDataOttUserBuilder = OttUserService.updateDynamicData(key, value) - .setCompletion((ApiCompletion) result -> { - ottUserDynamicDataResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateDynamicDataOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ottUserDynamicDataResponse; - } - - // updateLoginData - public static Response updateLoginData(Client client, String username, String oldPassword, String newPassword) { - UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(username, oldPassword, newPassword) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateLoginDataOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // updatePassword - public static Response updatePassword(Client client, int partnerId, String username) { - ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, username) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(resetPasswordOttUserBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} - - diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java deleted file mode 100644 index e3df6d39f..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ParentalRuleServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.EntityReferenceBy; -import com.kaltura.client.services.ParentalRuleService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.ParentalRule; -import com.kaltura.client.types.ParentalRuleFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ParentalRuleService.*; -import static org.awaitility.Awaitility.await; - -public class ParentalRuleServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> parentalRuleListResponse; - private static Response booleanResponse; - - // disable - public static Response disable(Client client, long ruleId, EntityReferenceBy entityReferenceBy) { - DisableParentalRuleBuilder disableParentalRuleBuilder = ParentalRuleService.disable(ruleId, entityReferenceBy) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(disableParentalRuleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // disableDefault - public static Response disableDefault(Client client, EntityReferenceBy entityReferenceBy) { - DisableDefaultParentalRuleBuilder disableDefaultParentalRuleBuilder = ParentalRuleService - .disableDefault(entityReferenceBy).setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(disableDefaultParentalRuleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // enable - public static Response enable(Client client, long ruleId, EntityReferenceBy entityReferenceBy) { - EnableParentalRuleBuilder enableParentalRuleBuilder = ParentalRuleService.enable(ruleId, entityReferenceBy) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(enableParentalRuleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, ParentalRuleFilter parentalRuleFilter) { - ListParentalRuleBuilder listParentalRuleBuilder = ParentalRuleService.list(parentalRuleFilter) - .setCompletion((ApiCompletion>) result -> { - parentalRuleListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listParentalRuleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return parentalRuleListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java deleted file mode 100644 index aa1a55314..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PartnerConfigurationServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.PartnerConfigurationService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.PartnerConfiguration; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PartnerConfigurationService.UpdatePartnerConfigurationBuilder; -import static org.awaitility.Awaitility.await; - -public class PartnerConfigurationServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response booleanResponse; - - // update - public static Response update(Client client, PartnerConfiguration partnerConfiguration) { - UpdatePartnerConfigurationBuilder updatePartnerConfigurationBuilder = PartnerConfigurationService.update(partnerConfiguration) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updatePartnerConfigurationBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java deleted file mode 100644 index 037f8466d..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PaymentGatewayProfileServiceImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.PaymentGatewayProfileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.KeyValue; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.PaymentGatewayConfiguration; -import com.kaltura.client.types.PaymentGatewayProfile; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PaymentGatewayProfileService.*; -import static org.awaitility.Awaitility.await; - -public class PaymentGatewayProfileServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response paymentGatewayProfileResponse; - private static Response paymentGatewayConfigurationResponse; - private static Response> paymentGatewayProfileListResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, PaymentGatewayProfile paymentGatewayProfile) { - AddPaymentGatewayProfileBuilder addPaymentGatewayProfileBuilder = PaymentGatewayProfileService - .add(paymentGatewayProfile).setCompletion((ApiCompletion) result -> { - paymentGatewayProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addPaymentGatewayProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentGatewayProfileResponse; - } - - // delete - public static Response delete(Client client, int paymentGatewayId) { - DeletePaymentGatewayProfileBuilder deletePaymentGatewayProfileBuilder = PaymentGatewayProfileService.delete(paymentGatewayId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deletePaymentGatewayProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // generateSharedSecret - public static Response generateSharedSecret(Client client, int paymentGatewayId) { - GenerateSharedSecretPaymentGatewayProfileBuilder generateSharedSecretPaymentGatewayProfileBuilder = - PaymentGatewayProfileService.generateSharedSecret(paymentGatewayId) - .setCompletion((ApiCompletion) result -> { - paymentGatewayProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretPaymentGatewayProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentGatewayProfileResponse; - } - - // getConfiguration - public static Response getConfiguration(Client client, String alias, String intent, List extraParams) { - GetConfigurationPaymentGatewayProfileBuilder getConfigurationPaymentGatewayProfileBuilder = - PaymentGatewayProfileService.getConfiguration(alias, intent, extraParams) - .setCompletion((ApiCompletion) result -> { - paymentGatewayConfigurationResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationPaymentGatewayProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentGatewayConfigurationResponse; - } - - // list - public static Response> list(Client client) { - ListPaymentGatewayProfileBuilder listPaymentGatewayProfileBuilder = PaymentGatewayProfileService.list() - .setCompletion((ApiCompletion>) result -> { - paymentGatewayProfileListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listPaymentGatewayProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentGatewayProfileListResponse; - } - - // update - public static Response update(Client client, int paymentGatewayId, PaymentGatewayProfile paymentGatewayProfile) { - UpdatePaymentGatewayProfileBuilder updatePaymentGatewayProfileBuilder = PaymentGatewayProfileService - .update(paymentGatewayId, paymentGatewayProfile).setCompletion((ApiCompletion) result -> { - paymentGatewayProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updatePaymentGatewayProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentGatewayProfileResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java deleted file mode 100644 index 0b2afdca0..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PaymentMethodProfileServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.PaymentMethodProfileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PaymentMethodProfileService.*; -import static org.awaitility.Awaitility.await; - -public class PaymentMethodProfileServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response paymentMethodProfileResponse; - private static Response paymentGatewayConfigurationResponse; - private static Response> paymentMethodProfileListResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, PaymentMethodProfile paymentMethodProfile) { - AddPaymentMethodProfileBuilder addPaymentMethodProfileBuilder = PaymentMethodProfileService.add(paymentMethodProfile) - .setCompletion((ApiCompletion) result -> { - paymentMethodProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addPaymentMethodProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentMethodProfileResponse; - } - - // delete - public static Response delete(Client client, int paymentMethodId) { - DeletePaymentMethodProfileBuilder deletePaymentMethodProfileBuilder = PaymentMethodProfileService.delete(paymentMethodId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deletePaymentMethodProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, PaymentMethodProfileFilter paymentMethodProfileFilter) { - ListPaymentMethodProfileBuilder listPaymentMethodProfileBuilder = PaymentMethodProfileService.list(paymentMethodProfileFilter) - .setCompletion((ApiCompletion>) result -> { - paymentMethodProfileListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listPaymentMethodProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentMethodProfileListResponse; - } - - // update - public static Response update(Client client, int paymentMethodId, PaymentMethodProfile paymentMethodProfile) { - UpdatePaymentMethodProfileBuilder updatePaymentMethodProfileBuilder = PaymentMethodProfileService.update(paymentMethodId, paymentMethodProfile) - .setCompletion((ApiCompletion) result -> { - paymentMethodProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updatePaymentMethodProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return paymentMethodProfileResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java deleted file mode 100644 index fa7983ba8..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PersonalFeedServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.PersonalFeedService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PersonalFeedService.*; -import static org.awaitility.Awaitility.await; - -public class PersonalFeedServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> personalFeedListResponse; - - // list - public static Response> list(Client client, PersonalFeedFilter personalFeedFilter, @Nullable FilterPager filterPager) { - ListPersonalFeedBuilder listPersonalFeedBuilder = PersonalFeedService.list(personalFeedFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - personalFeedListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listPersonalFeedBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return personalFeedListResponse; - } -} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java deleted file mode 100644 index 9a93d93c0..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PinServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.EntityReferenceBy; -import com.kaltura.client.enums.PinType; -import com.kaltura.client.services.PinService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Pin; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PinService.*; -import static org.awaitility.Awaitility.await; - -public class PinServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response pinResponse; - private static Response booleanResponse; - - // get - public static Response get(Client client, EntityReferenceBy entityReferenceBy, PinType pinType) { - GetPinBuilder getPinBuilder = PinService.get(entityReferenceBy, pinType) - .setCompletion((ApiCompletion) result -> { - pinResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getPinBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return pinResponse; - } - - // update - public static Response update(Client client, EntityReferenceBy entityReferenceBy, PinType pinType, Pin pin, @Nullable int ruleId) { - UpdatePinBuilder updatePinBuilder = PinService.update(entityReferenceBy, pinType, pin, ruleId) - .setCompletion((ApiCompletion) result -> { - pinResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updatePinBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return pinResponse; - } - - // validate - public static Response validate(Client client, String pin, PinType pinType, int ruleId) { - ValidatePinBuilder validatePinBuilder = PinService.validate(pin, pinType, ruleId) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(validatePinBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java deleted file mode 100644 index f46a331b7..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PpvServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.PpvService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Ppv; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PpvService.*; -import static org.awaitility.Awaitility.await; - -public class PpvServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response ppvResponse; - - // get - public static Response get(Client client, long id) { - GetPpvBuilder getPpvBuilder = PpvService.get(id).setCompletion((ApiCompletion) result -> { - ppvResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getPpvBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return ppvResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java deleted file mode 100644 index 2bd04fcb5..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PriceDetailsServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.PriceDetailsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.PriceDetails; -import com.kaltura.client.types.PriceDetailsFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PriceDetailsService.*; -import static org.awaitility.Awaitility.await; - -public class PriceDetailsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> priceDetailsListResponse; - - // list - public static Response> list(Client client, @Nullable PriceDetailsFilter priceDetailsFilter) { - ListPriceDetailsBuilder listPriceDetailsBuilder = PriceDetailsService.list(priceDetailsFilter) - .setCompletion((ApiCompletion>) result -> { - priceDetailsListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listPriceDetailsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return priceDetailsListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java deleted file mode 100644 index 44fe9355f..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PricePlanServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.PricePlanService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.PricePlan; -import com.kaltura.client.types.PricePlanFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PricePlanService.*; -import static org.awaitility.Awaitility.await; - -public class PricePlanServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> pricePlanListResponse; - private static Response pricePlanResponse; - - // list - public static Response> list(Client client, @Nullable PricePlanFilter pricePlanFilter) { - ListPricePlanBuilder listPricePlanBuilder = PricePlanService.list(pricePlanFilter) - .setCompletion((ApiCompletion>) result -> { - pricePlanListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listPricePlanBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return pricePlanListResponse; - } - - // update - public static Response update(Client client, long id, PricePlan pricePlan) { - UpdatePricePlanBuilder updatePricePlanBuilder = PricePlanService.update(id, pricePlan) - .setCompletion((ApiCompletion) result -> { - pricePlanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updatePricePlanBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return pricePlanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java deleted file mode 100644 index 3235362a1..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ProductPriceServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ProductPriceService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.ProductPrice; -import com.kaltura.client.types.ProductPriceFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; -import static org.awaitility.Awaitility.await; - -public class ProductPriceServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> productPriceResponse; - - // list - public static Response> list(Client client, ProductPriceFilter filter) { - ListProductPriceBuilder productPriceBuilder = ProductPriceService.list(filter) - .setCompletion((ApiCompletion>) result -> { - productPriceResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(productPriceBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return productPriceResponse; - } -} - - diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java deleted file mode 100644 index 7fb27cda0..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/PurchaseSettingsServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.EntityReferenceBy; -import com.kaltura.client.services.PurchaseSettingsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.PurchaseSettings; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.PurchaseSettingsService.*; -import static org.awaitility.Awaitility.await; - -public class PurchaseSettingsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response purchaseSettingsResponse; - - // get - public static Response get(Client client, EntityReferenceBy entityReferenceBy) { - GetPurchaseSettingsBuilder getPurchaseSettingsBuilder = PurchaseSettingsService.get(entityReferenceBy) - .setCompletion((ApiCompletion) result -> { - purchaseSettingsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getPurchaseSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return purchaseSettingsResponse; - } - - // update - public static Response update(Client client, EntityReferenceBy entityReferenceBy, PurchaseSettings purchaseSettings) { - UpdatePurchaseSettingsBuilder updatePurchaseSettingsBuilder = PurchaseSettingsService.update(entityReferenceBy, purchaseSettings) - .setCompletion((ApiCompletion) result -> { - purchaseSettingsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updatePurchaseSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return purchaseSettingsResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java deleted file mode 100644 index f9d900c54..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/RecommendationProfileServiceImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.RecommendationProfileService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.RecommendationProfile; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.RecommendationProfileService.*; -import static org.awaitility.Awaitility.await; - -public class RecommendationProfileServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response recommendationProfileResponse; - private static Response booleanResponse; - private static Response> recommendationProfileListResponse; - - // add - public static Response add(Client client, RecommendationProfile recommendationProfile) { - AddRecommendationProfileBuilder addRecommendationProfileBuilder = RecommendationProfileService.add(recommendationProfile) - .setCompletion((ApiCompletion) result -> { - recommendationProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addRecommendationProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recommendationProfileResponse; - } - - // delete - public static Response delete(Client client, int id) { - DeleteRecommendationProfileBuilder deleteRecommendationProfileBuilder = RecommendationProfileService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteRecommendationProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // generateSharedSecret - public static Response generateSharedSecret(Client client, int recommendationProfieId) { - GenerateSharedSecretRecommendationProfileBuilder generateSharedSecretRecommendationProfileBuilder = - RecommendationProfileService.generateSharedSecret(recommendationProfieId) - .setCompletion((ApiCompletion) result -> { - recommendationProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(generateSharedSecretRecommendationProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recommendationProfileResponse; - } - - // list - public static Response> list(Client client) { - ListRecommendationProfileBuilder listRecommendationProfileBuilder = RecommendationProfileService.list() - .setCompletion((ApiCompletion>) result -> { - recommendationProfileListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listRecommendationProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recommendationProfileListResponse; - } - - // update - public static Response update(Client client, int recommendationProfieId, RecommendationProfile recommendationProfile) { - UpdateRecommendationProfileBuilder updateRecommendationProfileBuilder = RecommendationProfileService.update(recommendationProfieId, recommendationProfile) - .setCompletion((ApiCompletion) result -> { - recommendationProfileResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateRecommendationProfileBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recommendationProfileResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java deleted file mode 100644 index 4e857e3bf..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/RecordingServiceImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.RecordingService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.RecordingService.*; -import static org.awaitility.Awaitility.await; - -public class RecordingServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response recordingResponse; - private static Response> recordingListResponse; - - // add - public static Response add(Client client, Recording recording) { - AddRecordingBuilder addRecordingBuilder = RecordingService.add(recording) - .setCompletion((ApiCompletion) result -> { - recordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recordingResponse; - } - - // cancel - public static Response cancel(Client client, long id) { - CancelRecordingBuilder cancelRecordingBuilder = RecordingService.cancel(id) - .setCompletion((ApiCompletion) result -> { - recordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(cancelRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recordingResponse; - } - - // delete - public static Response delete(Client client, long id) { - DeleteRecordingBuilder deleteRecordingBuilder = RecordingService.delete(id) - .setCompletion((ApiCompletion) result -> { - recordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recordingResponse; - } - - // get - public static Response get(Client client, long id) { - GetRecordingBuilder getRecordingBuilder = RecordingService.get(id) - .setCompletion((ApiCompletion) result -> { - recordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recordingResponse; - } - - // list - public static Response> list(Client client, @Nullable RecordingFilter recordingFilter, @Nullable FilterPager filterPager) { - ListRecordingBuilder listRecordingBuilder = RecordingService.list(recordingFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - recordingListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recordingListResponse; - } - - // protect - public static Response protect(Client client, long id) { - ProtectRecordingBuilder protectRecordingBuilder = RecordingService.protect(id) - .setCompletion((ApiCompletion) result -> { - recordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(protectRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return recordingResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java deleted file mode 100644 index 659df1f19..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/RegionServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.RegionService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.Region; -import com.kaltura.client.types.RegionFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.RegionService.*; -import static org.awaitility.Awaitility.await; - -public class RegionServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> regionListResponse; - - // list - public static Response> list(Client client, RegionFilter regionFilter) { - ListRegionBuilder listRegionBuilder = RegionService.list(regionFilter) - .setCompletion((ApiCompletion>) result -> { - regionListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listRegionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return regionListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java deleted file mode 100644 index e00df8596..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/RegistrySettingsServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.RegistrySettingsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.RegistrySettings; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.RegistrySettingsService.*; -import static org.awaitility.Awaitility.await; - -public class RegistrySettingsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> registrySettingsListResponse; - - // list - public static Response> list(Client client) { - ListRegistrySettingsBuilder listRegistrySettingsBuilder = RegistrySettingsService.list() - .setCompletion((ApiCompletion>) result -> { - registrySettingsListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listRegistrySettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return registrySettingsListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java deleted file mode 100644 index d67540cf1..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ReminderServiceImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.ReminderType; -import com.kaltura.client.services.ReminderService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.Reminder; -import com.kaltura.client.types.ReminderFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ReminderService.*; -import static org.awaitility.Awaitility.await; - -public class ReminderServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response reminderResponse; - private static Response booleanResponse; - private static Response> reminderListResponse; - - // add - public static Response add(Client client, Reminder reminder) { - AddReminderBuilder addReminderBuilder = ReminderService.add(reminder) - .setCompletion((ApiCompletion) result -> { - reminderResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addReminderBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return reminderResponse; - } - - // delete - public static Response add(Client client, long id, ReminderType reminderType) { - DeleteReminderBuilder deleteReminderBuilder = ReminderService.delete(id, reminderType) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteReminderBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, ReminderFilter reminderFilter, @Nullable FilterPager filterPager) { - ListReminderBuilder listReminderBuilder = ReminderService.list(reminderFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - reminderListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listReminderBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return reminderListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java deleted file mode 100644 index 8bfc98322..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/ReportServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.ReportService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.ReportService.*; -import static org.awaitility.Awaitility.await; - -public class ReportServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response reportResponse; - private static Response> reportListResponse; - - // get - public static Response get(Client client, String udid) { - GetReportBuilder getReportBuilder = ReportService.get(udid) - .setCompletion((ApiCompletion) result -> { - reportResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getReportBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return reportResponse; - } - - // list - public static Response> list(Client client, ReportFilter reportFilter, @Nullable FilterPager filterPager) { - ListReportBuilder listReportBuilder = ReportService.list(reportFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - reportListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listReportBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return reportListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java deleted file mode 100644 index 5f97566a2..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SearchHistoryServiceImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SearchHistoryService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SearchHistoryService.*; -import static org.awaitility.Awaitility.await; - -public class SearchHistoryServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response booleanResponse; - private static Response> searchHistoryListResponse; - - // clean - public static Response clean(Client client, @Nullable SearchHistoryFilter searchHistoryFilter) { - CleanSearchHistoryBuilder cleanSearchHistoryBuilder = SearchHistoryService.clean(searchHistoryFilter) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(cleanSearchHistoryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // delete - public static Response delete(Client client, String id) { - DeleteSearchHistoryBuilder deleteSearchHistoryBuilder = SearchHistoryService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteSearchHistoryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, @Nullable SearchHistoryFilter searchHistoryFilter, @Nullable FilterPager filterPager) { - ListSearchHistoryBuilder listSearchHistoryBuilder = SearchHistoryService.list(searchHistoryFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - searchHistoryListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listSearchHistoryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return searchHistoryListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java deleted file mode 100644 index d9bc3d8fe..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SeriesRecordingServiceImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SeriesRecordingService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.SeriesRecording; -import com.kaltura.client.types.SeriesRecordingFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SeriesRecordingService.*; -import static org.awaitility.Awaitility.await; - -public class SeriesRecordingServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response seriesRecordingResponse; - private static Response> seriesRecordingListResponse; - - // add - public static Response add(Client client, SeriesRecording seriesRecording) { - AddSeriesRecordingBuilder addSeriesRecordingBuilder = SeriesRecordingService.add(seriesRecording) - .setCompletion((ApiCompletion) result -> { - seriesRecordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addSeriesRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return seriesRecordingResponse; - } - - // cancel - public static Response cancel(Client client, long id) { - CancelSeriesRecordingBuilder cancelSeriesRecordingBuilder = SeriesRecordingService.cancel(id) - .setCompletion((ApiCompletion) result -> { - seriesRecordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(cancelSeriesRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return seriesRecordingResponse; - } - - // cancelByEpgId - public static Response cancelByEpgId(Client client, long id, long epgId) { - CancelByEpgIdSeriesRecordingBuilder cancelByEpgIdSeriesRecordingBuilder = SeriesRecordingService.cancelByEpgId(id, epgId) - .setCompletion((ApiCompletion) result -> { - seriesRecordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(cancelByEpgIdSeriesRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return seriesRecordingResponse; - } - - // cancelBySeasonNumber - public static Response cancelBySeasonNumber(Client client, long id, long seasonNumber) { - CancelBySeasonNumberSeriesRecordingBuilder cancelBySeasonNumberSeriesRecordingBuilder = SeriesRecordingService - .cancelBySeasonNumber(id, seasonNumber).setCompletion((ApiCompletion) result -> { - seriesRecordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(cancelBySeasonNumberSeriesRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return seriesRecordingResponse; - } - - // delete - public static Response delete(Client client, long id) { - DeleteSeriesRecordingBuilder deleteSeriesRecordingBuilder = SeriesRecordingService.delete(id) - .setCompletion((ApiCompletion) result -> { - seriesRecordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteSeriesRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return seriesRecordingResponse; - } - - // deleteBySeasonNumber - public static Response deleteBySeasonNumber(Client client, long id, int seasonNumber) { - DeleteBySeasonNumberSeriesRecordingBuilder deleteBySeasonNumberSeriesRecordingBuilder = - SeriesRecordingService.deleteBySeasonNumber(id, seasonNumber).setCompletion((ApiCompletion) result -> { - seriesRecordingResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteBySeasonNumberSeriesRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return seriesRecordingResponse; - } - - // list - public static Response> list(Client client, @Nullable SeriesRecordingFilter seriesRecordingFilter) { - ListSeriesRecordingBuilder listSeriesRecordingBuilder = SeriesRecordingService.list(seriesRecordingFilter) - .setCompletion((ApiCompletion>) result -> { - seriesRecordingListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listSeriesRecordingBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return seriesRecordingListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java deleted file mode 100644 index fa0a8a031..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SessionServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SessionService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.LoginSession; -import com.kaltura.client.types.Session; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SessionService.*; -import static org.awaitility.Awaitility.await; - -public class SessionServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response sessionResponse; - private static Response booleanResponse; - private static Response loginSessionResponse; - - // get - public static Response get(Client client, @Nullable String session) { - GetSessionBuilder getSessionBuilder = SessionService.get(session) - .setCompletion((ApiCompletion) result -> { - sessionResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getSessionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return sessionResponse; - } - - // revoke - public static Response revoke(Client client) { - RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(revokeSessionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // switchUser - public static Response switchUser(Client client, String userIdToSwitch) { - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(userIdToSwitch) - .setCompletion((ApiCompletion) result -> { - loginSessionResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(switchUserSessionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return loginSessionResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java deleted file mode 100644 index 7aca2b606..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SocialActionServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SocialActionService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SocialActionService.*; -import static org.awaitility.Awaitility.await; - -public class SocialActionServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response userSocialActionResponseResponse; - private static Response> networkActionStatusList; - private static Response> socialActionListResponse; - - // add - public static Response add(Client client, SocialAction socialAction) { - AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialAction) - .setCompletion((ApiCompletion) result -> { - userSocialActionResponseResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addSocialActionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userSocialActionResponseResponse; - } - - // delete - public static Response> delete(Client client, String id) { - DeleteSocialActionBuilder deleteSocialActionBuilder = SocialActionService.delete(id) - .setCompletion((ApiCompletion>) result -> { - networkActionStatusList = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteSocialActionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return networkActionStatusList; - } - - // list - public static Response> list(Client client, SocialActionFilter socialActionFilter, @Nullable FilterPager filterPager) { - ListSocialActionBuilder listSocialActionBuilder = SocialActionService.list(socialActionFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - socialActionListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listSocialActionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialActionListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java deleted file mode 100644 index ba66c3dfc..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SocialCommentServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SocialCommentService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SocialCommentService.*; -import static org.awaitility.Awaitility.await; - -public class SocialCommentServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> socialCommentListResponse; - - // list - public static Response> list(Client client, SocialCommentFilter socialCommentFilter, @Nullable FilterPager filterPager) { - ListSocialCommentBuilder listSocialCommentBuilder = SocialCommentService.list(socialCommentFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - socialCommentListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listSocialCommentBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialCommentListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java deleted file mode 100644 index 33c2c597a..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SocialFriendActivityServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SocialFriendActivityService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SocialFriendActivityService.*; -import static org.awaitility.Awaitility.await; - -public class SocialFriendActivityServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> socialFriendActivityListResponse; - - // list - public static Response> list(Client client, @Nullable SocialFriendActivityFilter socialFriendActivityFilter, - @Nullable FilterPager filterPager) { - ListSocialFriendActivityBuilder listSocialFriendActivityBuilder = SocialFriendActivityService.list(socialFriendActivityFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - socialFriendActivityListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listSocialFriendActivityBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialFriendActivityListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java deleted file mode 100644 index b5c52a603..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SocialServiceImpl.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.SocialNetwork; -import com.kaltura.client.services.SocialService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.LoginResponse; -import com.kaltura.client.types.Social; -import com.kaltura.client.types.SocialConfig; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SocialService.*; -import static org.awaitility.Awaitility.await; - -public class SocialServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response socialResponse; - private static Response loginResponse; - private static Response socialConfigResponse; - - // get - public static Response get(Client client, SocialNetwork socialNetwork) { - GetSocialBuilder getSocialBuilder = SocialService.get(socialNetwork) - .setCompletion((ApiCompletion) result -> { - socialResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialResponse; - } - - // getByToken - public static Response getByToken(Client client, int partnerId, String token, SocialNetwork socialNetwork) { - GetByTokenSocialBuilder getByTokenSocialBuilder = SocialService.getByToken(partnerId, token, socialNetwork) - .setCompletion((ApiCompletion) result -> { - socialResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getByTokenSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialResponse; - } - - // getConfiguration - public static Response getConfiguration(Client client, SocialNetwork socialNetwork, @Nullable int partnerId) { - GetConfigurationSocialBuilder getConfigurationSocialBuilder = SocialService.getConfiguration(socialNetwork, partnerId) - .setCompletion((ApiCompletion) result -> { - socialConfigResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getConfigurationSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialConfigResponse; - } - - // login - public static Response login(Client client, int partnerId, String token, SocialNetwork socialNetwork, @Nullable String udid) { - LoginSocialBuilder loginSocialBuilder = SocialService.login(partnerId, token, socialNetwork, udid) - .setCompletion((ApiCompletion) result -> { - loginResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(loginSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return loginResponse; - } - - // merge - public static Response merge(Client client, String token, SocialNetwork socialNetwork) { - MergeSocialBuilder mergeSocialBuilder = SocialService.merge(token, socialNetwork) - .setCompletion((ApiCompletion) result -> { - socialResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(mergeSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialResponse; - } - - // register - public static Response register(Client client, int partnerId, String token, SocialNetwork socialNetwork, @Nullable String email) { - RegisterSocialBuilder registerSocialBuilder = SocialService.register(partnerId, token, socialNetwork, email) - .setCompletion((ApiCompletion) result -> { - socialResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(registerSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialResponse; - } - - // unmerge - public static Response unmerge(Client client, SocialNetwork socialNetwork) { - UnmergeSocialBuilder unmergeSocialBuilder = SocialService.unmerge(socialNetwork) - .setCompletion((ApiCompletion) result -> { - socialResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(unmergeSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialResponse; - } - - // updateConfiguration - public static Response updateConfiguration(Client client, SocialConfig socialConfig) { - UpdateConfigurationSocialBuilder updateConfigurationSocialBuilder = SocialService.UpdateConfiguration(socialConfig) - .setCompletion((ApiCompletion) result -> { - socialConfigResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateConfigurationSocialBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return socialConfigResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java deleted file mode 100644 index 1275672d3..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SubscriptionService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.Coupon; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.Subscription; -import com.kaltura.client.types.SubscriptionFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SubscriptionService.*; -import static com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; -import static org.awaitility.Awaitility.await; - -public class SubscriptionServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> subscriptionListResponse; - private static Response couponResponse; - - // list - public static Response> list(Client client, SubscriptionFilter subscriptionFilter) { - ListSubscriptionBuilder listSubscriptionBuilder = SubscriptionService.list(subscriptionFilter) - .setCompletion((ApiCompletion>) result -> { - subscriptionListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listSubscriptionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return subscriptionListResponse; - } - - // validateCoupon - public static Response validateCoupon(Client client, int id, String code) { - ValidateCouponSubscriptionBuilder validateCouponSubscriptionBuilder = SubscriptionService.validateCoupon(id, code) - .setCompletion((ApiCompletion) result -> { - couponResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(validateCouponSubscriptionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return couponResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java deleted file mode 100644 index b4e73b0a2..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SubscriptionSetServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SubscriptionSetService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SubscriptionSetService.*; -import static org.awaitility.Awaitility.await; - -public class SubscriptionSetServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> subscriptionSetListResponse; - private static Response subscriptionSetResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, SubscriptionSet subscriptionSet) { - AddSubscriptionSetBuilder addSubscriptionSetBuilder = SubscriptionSetService.add(subscriptionSet) - .setCompletion((ApiCompletion) result -> { - subscriptionSetResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addSubscriptionSetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return subscriptionSetResponse; - } - - // delete - public static Response delete(Client client, long id) { - DeleteSubscriptionSetBuilder deleteSubscriptionSetBuilder = SubscriptionSetService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteSubscriptionSetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, long id) { - GetSubscriptionSetBuilder getSubscriptionSetBuilder = SubscriptionSetService.get(id) - .setCompletion((ApiCompletion) result -> { - subscriptionSetResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getSubscriptionSetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return subscriptionSetResponse; - } - - // list - public static Response> delete(Client client, @Nullable SubscriptionSetFilter subscriptionSetFilter) { - ListSubscriptionSetBuilder listSubscriptionSetBuilder = SubscriptionSetService.list(subscriptionSetFilter) - .setCompletion((ApiCompletion>) result -> { - subscriptionSetListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listSubscriptionSetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return subscriptionSetListResponse; - } - - // update - public static Response delete(Client client, long id, SubscriptionSet subscriptionSet) { - UpdateSubscriptionSetBuilder updateSubscriptionSetBuilder = SubscriptionSetService.update(id, subscriptionSet) - .setCompletion((ApiCompletion) result -> { - subscriptionSetResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateSubscriptionSetBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return subscriptionSetResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java deleted file mode 100644 index f417d62ea..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/SystemServiceImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.SystemService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.SubscriptionSet; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.SystemService.*; -import static org.awaitility.Awaitility.await; - -public class SystemServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response longResponse; - private static Response stringResponse; - private static Response booleanResponse; - - // getTime - public static Response getTime(Client client, SubscriptionSet subscriptionSet) { - GetTimeSystemBuilder getTimeSystemBuilder = SystemService.getTime() - .setCompletion((ApiCompletion) result -> { - longResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getTimeSystemBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return longResponse; - } - - // getVersion - public static Response getTime(Client client) { - GetVersionSystemBuilder getVersionSystemBuilder = SystemService.getVersion() - .setCompletion((ApiCompletion) result -> { - stringResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getVersionSystemBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return stringResponse; - } - - // ping - public static Response ping(Client client) { - PingSystemBuilder pingSystemBuilder = SystemService.ping() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(pingSystemBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java deleted file mode 100644 index 9b0da4a62..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/TimeShiftedTvPartnerSettingsServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.TimeShiftedTvPartnerSettingsService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.TimeShiftedTvPartnerSettings; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.TimeShiftedTvPartnerSettingsService.*; -import static org.awaitility.Awaitility.await; - -public class TimeShiftedTvPartnerSettingsServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response timeShiftedTvPartnerSettingsResponse; - private static Response booleanResponse; - - // get - public static Response get(Client client) { - GetTimeShiftedTvPartnerSettingsBuilder getTimeShiftedTvPartnerSettingsBuilder = - TimeShiftedTvPartnerSettingsService.get().setCompletion((ApiCompletion) result -> { - timeShiftedTvPartnerSettingsResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getTimeShiftedTvPartnerSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return timeShiftedTvPartnerSettingsResponse; - } - - // update - public static Response update(Client client, TimeShiftedTvPartnerSettings timeShiftedTvPartnerSettings) { - UpdateTimeShiftedTvPartnerSettingsBuilder updateTimeShiftedTvPartnerSettingsBuilder = TimeShiftedTvPartnerSettingsService - .update(timeShiftedTvPartnerSettings).setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateTimeShiftedTvPartnerSettingsBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java deleted file mode 100644 index ab7d8e16b..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/TopicServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.TopicAutomaticIssueNotification; -import com.kaltura.client.services.TopicService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.TopicService.*; -import static org.awaitility.Awaitility.await; - -public class TopicServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response topicResponse; - private static Response booleanResponse; - private static Response> topicListResponse; - - // get - public static Response get(Client client, int id) { - GetTopicBuilder getTopicBuilder = TopicService.get(id) - .setCompletion((ApiCompletion) result -> { - topicResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getTopicBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return topicResponse; - } - - // delete - public static Response delete(Client client, int id) { - DeleteTopicBuilder deleteTopicBuilder = TopicService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteTopicBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, @Nullable TopicFilter topicFilter, @Nullable FilterPager filterPager) { - ListTopicBuilder listTopicBuilder = TopicService.list(topicFilter, filterPager) - .setCompletion((ApiCompletion>) result -> { - topicListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listTopicBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return topicListResponse; - } - - // updateStatus - public static Response updateStatus(Client client, int id, TopicAutomaticIssueNotification topicAutomaticIssueNotification) { - UpdateStatusTopicBuilder updateStatusTopicBuilder = TopicService.updateStatus(id, topicAutomaticIssueNotification) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusTopicBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java deleted file mode 100644 index 2d098a091..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionHistoryServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.TransactionHistoryService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.BillingTransaction; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.TransactionHistoryFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; -import static org.awaitility.Awaitility.await; - -public class TransactionHistoryServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> billingTransactionListResponse; - - // list - public static Response> list(Client client, TransactionHistoryFilter filter, FilterPager pager) { - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(filter, pager) - .setCompletion((ApiCompletion>) result -> { - billingTransactionListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listTransactionHistoryBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return billingTransactionListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java deleted file mode 100644 index 6cbb23665..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/TransactionServiceImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.TransactionService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.TransactionService.*; -import static org.awaitility.Awaitility.await; - -public class TransactionServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response transactionResponse; - private static Response longResponse; - private static Response booleanResponse; - - // purchase - public static Response purchase(Client client, Purchase purchase) { - PurchaseTransactionBuilder purchaseBuilder = TransactionService.purchase(purchase) - .setCompletion((ApiCompletion) result -> { - transactionResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(purchaseBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return transactionResponse; - } - - // getPurchaseSessionId - public static Response getPurchaseSessionId(Client client, PurchaseSession purchaseSession) { - GetPurchaseSessionIdTransactionBuilder getPurchaseSessionIdTransactionBuilder = - TransactionService.getPurchaseSessionId(purchaseSession) - .setCompletion((ApiCompletion) result -> { - longResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getPurchaseSessionIdTransactionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return longResponse; - } - - // setWaiver - public static Response setWaiver(Client client, int assetId, TransactionType transactionType) { - SetWaiverTransactionBuilder setWaiverTransactionBuilder = TransactionService.setWaiver(assetId, transactionType) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(setWaiverTransactionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // updateStatus - public static void updateStatus(Client client, String paymentGatewayId, String externalTransactionId, String signature, TransactionStatus transactionStatus) { - UpdateStatusTransactionBuilder updateStatusTransactionBuilder = TransactionService.updateStatus(paymentGatewayId, externalTransactionId, signature, transactionStatus); - updateStatusTransactionBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateStatusTransactionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } - - // upgrade - public static Response upgrade(Client client, Purchase purchase) { - UpgradeTransactionBuilder upgradeTransactionBuilder = TransactionService.upgrade(purchase) - .setCompletion((ApiCompletion) result -> { - transactionResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(upgradeTransactionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return transactionResponse; - } - - // validateReceipt - public static Response validateReceipt(Client client, ExternalReceipt externalReceipt) { - ValidateReceiptTransactionBuilder validateReceiptTransactionBuilder = TransactionService.validateReceipt(externalReceipt) - .setCompletion((ApiCompletion) result -> { - transactionResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(validateReceiptTransactionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return transactionResponse; - } - - // downgrade - public static void downgrade(Client client, Purchase purchase) { - DowngradeTransactionBuilder downgradeTransactionBuilder = TransactionService.downgrade(purchase); - downgradeTransactionBuilder.setCompletion((ApiCompletion) result -> done.set(true)); - - TestAPIOkRequestsExecutor.getExecutor().queue(downgradeTransactionBuilder.build(client)); - await().untilTrue(done); - done.set(false); - } -} - - diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java deleted file mode 100644 index 5e3e3437c..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UnifiedPaymentServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.UnifiedPaymentService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.UnifiedPaymentRenewal; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.UnifiedPaymentService.GetNextRenewalUnifiedPaymentBuilder; -import static org.awaitility.Awaitility.await; - -public class UnifiedPaymentServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response unifiedPaymentRenewalResponse; - - // getNextRenewal - public static Response getNextRenewal(Client client, int id) { - GetNextRenewalUnifiedPaymentBuilder getNextRenewalUnifiedPaymentBuilder = UnifiedPaymentService.getNextRenewal(id) - .setCompletion((ApiCompletion) result -> { - unifiedPaymentRenewalResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getNextRenewalUnifiedPaymentBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return unifiedPaymentRenewalResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java deleted file mode 100644 index 9f2bd74a2..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetRuleServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.UserAssetRuleService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.UserAssetRule; -import com.kaltura.client.types.UserAssetRuleFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.UserAssetRuleService.*; -import static org.awaitility.Awaitility.await; - -public class UserAssetRuleServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> userAssetRuleListResponse; - - // list - public static Response> list(Client client, UserAssetRuleFilter userAssetRuleFilter) { - ListUserAssetRuleBuilder listUserAssetRuleBuilder = UserAssetRuleService.list(userAssetRuleFilter) - .setCompletion((ApiCompletion>) result -> { - userAssetRuleListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listUserAssetRuleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userAssetRuleListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java deleted file mode 100644 index 1aba08844..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserAssetsListItemServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.enums.UserAssetsListItemType; -import com.kaltura.client.enums.UserAssetsListType; -import com.kaltura.client.services.UserAssetsListItemService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.UserAssetsListItem; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.UserAssetsListItemService.*; -import static org.awaitility.Awaitility.await; - -public class UserAssetsListItemServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response userAssetsListItemResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, UserAssetsListItem userAssetsListItem) { - AddUserAssetsListItemBuilder addUserAssetsListItemBuilder = UserAssetsListItemService.add(userAssetsListItem) - .setCompletion((ApiCompletion) result -> { - userAssetsListItemResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addUserAssetsListItemBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userAssetsListItemResponse; - } - - // delete - public static Response delete(Client client, String assetId, UserAssetsListType userAssetsListType) { - DeleteUserAssetsListItemBuilder deleteUserAssetsListItemBuilder = UserAssetsListItemService.delete(assetId, userAssetsListType) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserAssetsListItemBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // get - public static Response get(Client client, String assetId, UserAssetsListType userAssetsListType, - UserAssetsListItemType userAssetsListItemType) { - GetUserAssetsListItemBuilder getUserAssetsListItemBuilder = UserAssetsListItemService.get(assetId, userAssetsListType, userAssetsListItemType) - .setCompletion((ApiCompletion) result -> { - userAssetsListItemResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(getUserAssetsListItemBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userAssetsListItemResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java deleted file mode 100644 index 8ea00d879..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserInterestServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.UserInterestService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.UserInterest; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.UserInterestService.*; -import static org.awaitility.Awaitility.await; - -public class UserInterestServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response userInterestResponse; - private static Response booleanResponse; - private static Response> userInterestListResponse; - - // add - public static Response add(Client client, UserInterest userInterest) { - AddUserInterestBuilder addUserInterestBuilder = UserInterestService.add(userInterest) - .setCompletion((ApiCompletion) result -> { - userInterestResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addUserInterestBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userInterestResponse; - } - - // delete - public static Response add(Client client, String id) { - DeleteUserInterestBuilder deleteUserInterestBuilder = UserInterestService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserInterestBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // list - public static Response> list(Client client, String id) { - ListUserInterestBuilder listUserInterestBuilder = UserInterestService.list() - .setCompletion((ApiCompletion>) result -> { - userInterestListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listUserInterestBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userInterestListResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java deleted file mode 100644 index 8732c9e17..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserLoginPinServiceImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.UserLoginPinService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.UserLoginPin; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.UserLoginPinService.*; -import static org.awaitility.Awaitility.await; - -public class UserLoginPinServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response userLoginPinResponse; - private static Response booleanResponse; - - // add - public static Response add(Client client, @Nullable String secret) { - AddUserLoginPinBuilder addUserLoginPinBuilder = UserLoginPinService.add(secret) - .setCompletion((ApiCompletion) result -> { - userLoginPinResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addUserLoginPinBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userLoginPinResponse; - } - - // delete - public static Response delete(Client client, String pinCode) { - DeleteUserLoginPinBuilder deleteUserLoginPinBuilder = UserLoginPinService.delete(pinCode) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserLoginPinBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // deleteAll - public static Response deleteAll(Client client) { - DeleteAllUserLoginPinBuilder deleteAllUserLoginPinBuilder = UserLoginPinService.deleteAll() - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteAllUserLoginPinBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // update - public static Response update(Client client, String pinCode, @Nullable String secret) { - UpdateUserLoginPinBuilder updateUserLoginPinBuilder = UserLoginPinService.update(pinCode, secret) - .setCompletion((ApiCompletion) result -> { - userLoginPinResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateUserLoginPinBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userLoginPinResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java b/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java deleted file mode 100644 index 0611fde67..000000000 --- a/src/test/java/com/kaltura/client/test/servicesImpl/UserRoleServiceImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.kaltura.client.test.servicesImpl; - -import com.kaltura.client.Client; -import com.kaltura.client.services.UserRoleService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.UserRole; -import com.kaltura.client.types.UserRoleFilter; -import com.kaltura.client.utils.response.base.ApiCompletion; -import com.kaltura.client.utils.response.base.Response; - -import javax.annotation.Nullable; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.kaltura.client.services.UserRoleService.*; -import static com.kaltura.client.services.UserRoleService.ListUserRoleBuilder; -import static org.awaitility.Awaitility.await; - -public class UserRoleServiceImpl { - - private static final AtomicBoolean done = new AtomicBoolean(false); - - private static Response> userRoleListResponse; - private static Response userRoleResponse; - private static Response booleanResponse; - - // list - public static Response> list(Client client, @Nullable UserRoleFilter userRoleFilter) { - ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(userRoleFilter) - .setCompletion((ApiCompletion>) result -> { - userRoleListResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(listUserRoleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userRoleListResponse; - } - - // add - public static Response add(Client client, UserRole userRole) { - AddUserRoleBuilder addUserRoleBuilder = UserRoleService.add(userRole) - .setCompletion((ApiCompletion) result -> { - userRoleResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(addUserRoleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userRoleResponse; - } - - // delete - public static Response delete(Client client, long id) { - DeleteUserRoleBuilder deleteUserRoleBuilder = UserRoleService.delete(id) - .setCompletion((ApiCompletion) result -> { - booleanResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(deleteUserRoleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return booleanResponse; - } - - // update - public static Response update(Client client, long id, UserRole userRole) { - UpdateUserRoleBuilder updateUserRoleBuilder = UserRoleService.update(id, userRole) - .setCompletion((ApiCompletion) result -> { - userRoleResponse = result; - done.set(true); - }); - - TestAPIOkRequestsExecutor.getExecutor().queue(updateUserRoleBuilder.build(client)); - await().untilTrue(done); - done.set(false); - - return userRoleResponse; - } -} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 538c964cb..241bd351f 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,6 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; @@ -12,11 +13,10 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; +import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.anonymousLogin; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; import static com.kaltura.client.test.utils.OttUserUtils.getUserById; @@ -24,11 +24,30 @@ public class BaseTest { - private static Client client; - private static Configuration config; - protected static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); + public static Client client; + public static Configuration config; + public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); + private static Response loginResponse; + + // shared common params + public static int partnerId; + public static String defaultUserPassword; + + // shared ks's + private static String administratorKs, operatorKs, managerKs, anonymousKs; + + // shared VOD + private static MediaAsset mediaAsset; + + // shared files + private static MediaFile webMediaFile; + private static MediaFile mobileMediaFile; + + // shared MPP + private static Subscription fiveMinRenewableSubscription; + /*================================================================================ testing shared params list - used as a helper common params across tests @@ -54,50 +73,37 @@ public class BaseTest { String sharedUserKs ================================================================================*/ - // shared common params - public static int partnerId; - public static String defaultUserPassword; - - // shared ks's - private static String administratorKs, operatorKs, managerKs, anonymousKs; - - // shared VOD - private static MediaAsset mediaAsset; - - // shared files - private static MediaFile webMediaFile; - private static MediaFile mobileMediaFile; - - // shared MPP - private static Subscription fiveMinRenewableSubscription; - @BeforeSuite public void base_test_before_suite() { - partnerId = Integer.parseInt(getProperty(PARTNER_ID)); - defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); - // set configuration config = new Configuration(); config.setEndpoint(getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION)); config.setAcceptGzipEncoding(false); - client = getClient(null); - // Set default awaitility timeout + // set client + client = new Client(config); + + // set default awaitility timeout setDefaultTimeout(30, TimeUnit.SECONDS); + + // set shared common params + partnerId = Integer.parseInt(getProperty(PARTNER_ID)); + defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } - public static Client getClient(String ks) { +/* public static Client getClient(String ks) { Client client = new Client(config); client.setKs(ks); return client; - } + }*/ // getters for shared params public static String getAdministratorKs() { if (administratorKs == null) { - loginResponse = login(client, partnerId, getProperty(ADMINISTRATOR_USER_USERNAME), getProperty(ADMINISTRATOR_USER_PASSWORD), null, null); + loginResponse = executor.executeSync(login(partnerId, getProperty(ADMINISTRATOR_USER_USERNAME), getProperty(ADMINISTRATOR_USER_PASSWORD), + null,null)); administratorKs = loginResponse.results.getLoginSession().getKs(); } return administratorKs; @@ -105,7 +111,8 @@ public static String getAdministratorKs() { public static String getOperatorKs() { if (operatorKs == null) { - loginResponse = login(client, partnerId, getProperty(OPERATOR_USER_USERNAME), getProperty(OPERATOR_USER_PASSWORD), null, null); + loginResponse = executor.executeSync(login(partnerId, getProperty(OPERATOR_USER_USERNAME), getProperty(OPERATOR_USER_PASSWORD), + null,null)); operatorKs = loginResponse.results.getLoginSession().getKs(); } return operatorKs; @@ -113,7 +120,8 @@ public static String getOperatorKs() { public static String getManagerKs() { if (managerKs == null) { - loginResponse = login(client, partnerId, getProperty(MANAGER_USER_USERNAME), getProperty(MANAGER_USER_PASSWORD), null, null); + loginResponse = executor.executeSync(login(partnerId, getProperty(MANAGER_USER_USERNAME), getProperty(MANAGER_USER_PASSWORD), + null,null)); managerKs = loginResponse.results.getLoginSession().getKs(); } return managerKs; @@ -121,7 +129,7 @@ public static String getManagerKs() { public static String getAnonymousKs() { if (anonymousKs == null) { - Response loginSession = anonymousLogin(client, partnerId, null); + Response loginSession = executor.executeSync(OttUserService.anonymousLogin(partnerId)); anonymousKs = loginSession.results.getKs(); } return anonymousKs; @@ -180,7 +188,6 @@ public static class SharedHousehold { public static Household getSharedHousehold() { - Client client = getClient(null); int numOfUsers = 2; int numOfDevices = 2; @@ -196,10 +203,12 @@ public static Household getSharedHousehold() { } } - loginResponse = login(client, partnerId, getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(), defaultUserPassword, null, null); + String sharedMasterUserName = getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(); + loginResponse = executor.executeSync(login(partnerId, sharedMasterUserName, defaultUserPassword,null,null)); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - loginResponse = login(client, partnerId, getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(), defaultUserPassword, null, null); + String sharedUserName = getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(); + loginResponse = executor.executeSync(login(partnerId, sharedUserName, defaultUserPassword,null,null)); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } return sharedHousehold; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index 243906e57..9c218e521 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.UserState; import com.kaltura.client.services.OttUserService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.DBUtils; @@ -43,7 +44,11 @@ private void activate() { String activationToken = DBUtils.getActivationToken(user.getUsername()); ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, user.getUsername(), activationToken); - ottUserResponse = executor.executeSync(client, OttUserService.activate(partnerId, user.getUsername(), activationToken)); +// activateOttUserBuilder.setKs(""); +// activateOttUserBuilder.setUserId(1); + + ottUserResponse = executor.executeSync(activateOttUserBuilder); +// ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, user.getUsername(), activationToken)); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); From 50c130f20c1f4d9e728465bd42918a3c11b08b08 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Tue, 1 May 2018 17:23:26 +0300 Subject: [PATCH 163/605] Finish refactoring BookmarkAddTests class --- .../bookmarkTests/BookmarkAddTests.java | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index b062c63c5..886c5f16b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -1,9 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.*; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; +import com.kaltura.client.services.BookmarkService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; @@ -16,6 +14,7 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -23,7 +22,6 @@ public class BookmarkAddTests extends BaseTest { - private Client client; private long assetId; private int fileId; private BookmarkActionType actionType; @@ -38,7 +36,6 @@ public class BookmarkAddTests extends BaseTest { private void add_tests_before_class() { getSharedHousehold(); - client = getClient(getSharedMasterUserKs()); assetId = BaseTest.getSharedMediaAsset().getId(); fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); @@ -56,7 +53,10 @@ private void firstPlayback() { bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response booleanResponse = executor.executeSync(addBookmarkBuilder); + // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); // Verify no error returned @@ -64,7 +64,10 @@ private void firstPlayback() { // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); + listBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); // Match content of asset id @@ -96,18 +99,22 @@ private void pausePlayback() { bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response booleanResponse = executor.executeSync(addBookmarkBuilder); // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); // Verify no error returned assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse2 = BookmarkServiceImpl.list(client, bookmarkFilter); - Bookmark bookmark2 = bookmarkListResponse2.results.getObjects().get(0); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); + listBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Match content of asset position - assertThat(bookmark2.getPosition()).isEqualTo(this.position); + assertThat(bookmark.getPosition()).isEqualTo(this.position); } @Description("bookmark/action/add - 95% watching == finish watching") @@ -118,14 +125,18 @@ private void watchingNinetyFive() { bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response booleanResponse = executor.executeSync(addBookmarkBuilder); // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); // Verify no error returned assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); + listBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark3 = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = true @@ -140,9 +151,13 @@ private void backToStart() { position = 0; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); - Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); + listBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = false assertThat(bookmark.getFinishedWatching()).isFalse(); @@ -157,14 +172,18 @@ private void finishWatching() { bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); // Invoke bookmark/action/add request - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response booleanResponse = executor.executeSync(addBookmarkBuilder); // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); // Verify no error returned assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse = BookmarkServiceImpl.list(client, bookmarkFilter); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); + listBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = true @@ -178,7 +197,9 @@ private void finishWatching() { @Test private void emptyAssetId() { bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results).isNull(); // Verify exception returned - code: 500003 ("Invalid Asset id") assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500003).getCode()); From 8359384a3ec22414aae1b0dd5f9568433f3995cc Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 10:22:04 +0300 Subject: [PATCH 164/605] Refactored bookmark classes --- .../bookmarkTests/BookmarkAddTests.java | 1 + .../bookmarkTests/BookmarkListTests.java | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 886c5f16b..294466672 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -102,6 +102,7 @@ private void pausePlayback() { AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); addBookmarkBuilder.setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); + // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); // Verify no error returned diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index cee7998aa..ba818af51 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -1,10 +1,9 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.BookmarkOrderBy; -import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; +import com.kaltura.client.services.BookmarkService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; @@ -19,12 +18,12 @@ import java.util.ArrayList; import java.util.List; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; +import static com.kaltura.client.services.BookmarkService.*; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; public class BookmarkListTests extends BaseTest { - private Client client; private Long assetId; private int fileId; @@ -36,7 +35,6 @@ public class BookmarkListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { - client = getClient(getSharedMasterUserKs()); assetId = BaseTest.getSharedMediaAsset().getId(); List assetFileIds = AssetUtils.getAssetFileIds(String.valueOf(assetId)); @@ -56,17 +54,24 @@ private void BookmarkOrderBy() { // Bookmark asset1 Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - Response booleanResponse = BookmarkServiceImpl.add(client, bookmark); + BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response booleanResponse = executor.executeSync(addBookmarkBuilder); + assertThat(booleanResponse.results.booleanValue()).isTrue(); // Bookmark asset2 Bookmark bookmark2 = BookmarkUtils.addBookmark(10, String.valueOf(assetId2), fileId2, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - Response booleanResponse2 = BookmarkServiceImpl.add(client, bookmark2); - assertThat(booleanResponse2.results.booleanValue()).isTrue(); + AddBookmarkBuilder addBookmarkBuilder2 = BookmarkService.add(bookmark2); + addBookmarkBuilder2.setKs(getSharedMasterUserKs()); + Response booleanResponse2 = executor.executeSync(addBookmarkBuilder2); + assertThat(booleanResponse2.results.booleanValue()).isTrue(); BookmarkFilter bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_DESC,AssetType.MEDIA, assetList); - Response> bookmarkListResponse = BookmarkServiceImpl.list(client,bookmarkFilter); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); + listBookmarkBuilder.setKs(getSharedMasterUserKs()); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmarkObject = bookmarkListResponse.results.getObjects().get(0); Bookmark bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); @@ -76,7 +81,9 @@ private void BookmarkOrderBy() { assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId)); bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC,AssetType.MEDIA, assetList); - bookmarkListResponse = BookmarkServiceImpl.list(client,bookmarkFilter); + listBookmarkBuilder = BookmarkService.list(bookmarkFilter); + listBookmarkBuilder.setKs(getSharedMasterUserKs()); + bookmarkListResponse = executor.executeSync(listBookmarkBuilder); bookmarkObject = bookmarkListResponse.results.getObjects().get(0); bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); From e1943a533410a3a122c3a84d7b1a104921f357c1 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 10:22:20 +0300 Subject: [PATCH 165/605] refactored assetComment classes --- .../AssetCommentAddTests.java | 25 ++++++++++++------- .../AssetCommentListTests.java | 21 +++++++++++----- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 6ebbdd80e..be6222db6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -1,9 +1,8 @@ package com.kaltura.client.test.tests.servicesTests.assetCommentTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetCommentOrderBy; import com.kaltura.client.enums.AssetType; -import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; +import com.kaltura.client.services.AssetCommentService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.BaseUtils; @@ -17,21 +16,21 @@ import java.util.Optional; +import static com.kaltura.client.services.AssetCommentService.*; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class AssetCommentAddTests extends BaseTest { - private Client client; private String writer = "Shmulik"; private Long createDate = 0L; private String header = "header"; private String subHeader = "subHeader"; private String text = "A lot of text"; + private Household household; @BeforeClass private void add_tests_before_class() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + household = HouseholdUtils.createHouseHold(1, 1, false); } @Description("AssetComment/action/add - vod asset") @@ -44,7 +43,9 @@ private void addCommentForVod() { AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); // AssetComment/action/add - Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment); + addAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response assetCommentResponse = executor.executeSync(addAssetCommentBuilder); //Assertions for AssetComment/action/add assertThat(assetCommentResponse.results.getId()).isGreaterThan(0); @@ -62,7 +63,9 @@ private void addCommentForVod() { AssetCommentOrderBy.CREATE_DATE_DESC); //AssetComment/action/list - Response> assetCommentListResponse = AssetCommentServiceImpl.list(client, assetCommentFilter, null); + ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null); + listAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response> assetCommentListResponse = executor.executeSync(listAssetCommentBuilder); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); //Assertions for AssetComment/action/list @@ -90,7 +93,9 @@ private void addCommentForEPGProgram() { AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(epgProgramId), AssetType.EPG, writer, text, createDate, subHeader, header); // AssetComment/action/add - Response assetCommentResponse = AssetCommentServiceImpl.add(client, assetComment); + AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment); + addAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response assetCommentResponse = executor.executeSync(addAssetCommentBuilder); //Assertions for AssetComment/action/add assertThat(assetCommentResponse.results.getId()).isGreaterThan(0); @@ -102,7 +107,9 @@ private void addCommentForEPGProgram() { AssetCommentOrderBy.CREATE_DATE_DESC); //AssetComment/action/list - Response> assetCommentListResponse = AssetCommentServiceImpl.list(client, assetCommentFilter, null); + ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null); + listAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response> assetCommentListResponse = executor.executeSync(listAssetCommentBuilder); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); //Assertions for AssetComment/action/list diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index f18135e1c..217242656 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -3,7 +3,7 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetCommentOrderBy; import com.kaltura.client.enums.AssetType; -import com.kaltura.client.test.servicesImpl.AssetCommentServiceImpl; +import com.kaltura.client.services.AssetCommentService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.HouseholdUtils; @@ -19,17 +19,18 @@ import java.util.Optional; +import static com.kaltura.client.services.AssetCommentService.*; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; public class AssetCommentListTests extends BaseTest { private Client client; + Household household; @BeforeClass private void add_tests_before_class() { - Household household = HouseholdUtils.createHouseHold(1, 1, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + household = HouseholdUtils.createHouseHold(1, 1, false); } @Description("AssetComment/action/list - check order by functionality") @@ -50,17 +51,25 @@ private void checkCommentsOrder() { AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); // AssetComment/action/add - first comment - Response assetComment1Response = AssetCommentServiceImpl.add(client, assetComment); + + AssetCommentService.AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment); + addAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response assetComment1Response = executor.executeSync(addAssetCommentBuilder); // AssetComment/action/add - second comment comment - Response assetComment2Response = AssetCommentServiceImpl.add(client, assetComment); + AssetCommentService.AddAssetCommentBuilder addAssetCommentBuilder2 = AssetCommentService.add(assetComment); + addAssetCommentBuilder2.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response assetComment2Response = executor.executeSync(addAssetCommentBuilder2); //Initialize assetCommentFilter object AssetCommentFilter assetCommentFilter = AssetCommentUtils.assetCommentFilter(Math.toIntExact(assetId), AssetType.MEDIA, AssetCommentOrderBy.CREATE_DATE_DESC); //AssetComment/action/list - return both comments - Response> assetCommentListResponse = AssetCommentServiceImpl.list(client, assetCommentFilter, null); + + ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null); + listAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response> assetCommentListResponse = executor.executeSync(listAssetCommentBuilder); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); AssetComment assetComment2ObjectResponse = assetCommentListResponse.results.getObjects().get(1); From 5d5bbf8aac9d750fe35be69b2e953096affd7e18 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 10:22:37 +0300 Subject: [PATCH 166/605] refactored AssetHistory classes --- .../AssetHistoryActionCleanLists.java | 75 +++++++++++++------ .../AssetHistoryListTests.java | 64 ++++++++++++---- 2 files changed, 100 insertions(+), 39 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index aaae7d93a..5c6868da2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -1,9 +1,8 @@ package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; -import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; +import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.HouseholdUtils; @@ -21,18 +20,18 @@ import static com.kaltura.client.test.Properties.*; import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.AssetHistoryService.*; + public class AssetHistoryActionCleanLists extends BaseTest { - private Client client; private int position1 = 10; private int position2 = 20; - int numbOfDevices = 1; - int numOfUsers = 1; + private int numbOfDevices = 1; + private int numOfUsers = 1; @BeforeClass private void add_tests_before_class() { - } @Description("/assetHistory/action/clean - no filtering") @@ -40,7 +39,6 @@ private void add_tests_before_class() { private void cleanHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -50,15 +48,23 @@ private void cleanHistory() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); //assetHistory/action/list - both assets should returned - AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); //assetHistory/action/clean - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - no object returned - assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); + assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); } @@ -67,7 +73,6 @@ private void cleanHistory() { private void cleanSpecifcAssetHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -77,13 +82,19 @@ private void cleanSpecifcAssetHistory() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId1), null, WatchStatus.ALL, null); //assetHistory/action/clean - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); } @@ -93,7 +104,6 @@ private void cleanSpecifcAssetHistory() { private void cleanSpecifcAssetTypeHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -103,13 +113,20 @@ private void cleanSpecifcAssetTypeHistory() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(EPISODE_MEDIA_TYPE_ID)); //assetHistory/action/clean - only episode type (asset id 2) - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); } @@ -119,7 +136,6 @@ private void cleanSpecifcAssetTypeHistory() { private void cleanAssetsAccordingToWatchStatusDone() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -129,12 +145,19 @@ private void cleanAssetsAccordingToWatchStatusDone() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); //assetHistory/action/clean - only asset that were finished (asset 2) - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); } @@ -144,7 +167,6 @@ private void cleanAssetsAccordingToWatchStatusDone() { private void cleanAssetsAccordingToWatchStatusProgress() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -154,12 +176,19 @@ private void cleanAssetsAccordingToWatchStatusProgress() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); //assetHistory/action/clean - only asset that in progress (asset 1) - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 118be92ad..d4cd64997 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -4,7 +4,7 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; -import com.kaltura.client.test.servicesImpl.AssetHistoryServiceImpl; +import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; import com.kaltura.client.types.*; @@ -18,6 +18,8 @@ import static com.kaltura.client.test.Properties.*; import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.AssetHistoryService.*; + public class AssetHistoryListTests extends BaseTest { private Client client; private AssetType assetType = AssetType.MEDIA; @@ -36,7 +38,6 @@ private void add_tests_before_class() { private void vodAssetHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -44,8 +45,12 @@ private void vodAssetHistory() { Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + //assetHistory/action/list - both assets should returned - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + // First object AssetHistory assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); @@ -57,6 +62,7 @@ private void vodAssetHistory() { assertThat(assetHistoryObject1.getAssetType()).isEqualTo(assetType); assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); + // Verify that flag is set to false (user hasn't finish watching the asset) assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); @@ -69,7 +75,9 @@ private void vodAssetHistory() { // Assert total count = 2 (two bookmarks) assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); } @Description("/AssetHistory/action/list -filtered by movie asset id") @@ -77,7 +85,6 @@ private void vodAssetHistory() { private void vodAssetHistoryFilteredByAssetId() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -86,8 +93,12 @@ private void vodAssetHistoryFilteredByAssetId() { Long assetId3 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId2), null, WatchStatus.ALL, null); + //assetHistory/action/list - filter by asset 2 id - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); @@ -96,11 +107,16 @@ private void vodAssetHistoryFilteredByAssetId() { //assetHistory/action/list - filter by asset 2 and asset 3 ids assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, null, WatchStatus.ALL, null); - assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId3); assertThat(assetHistoryListResponse.results.getObjects().get(1).getAssetId()).isEqualTo(assetId2); - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); } @Description("/AssetHistory/action/list -filtered by movie type id") @@ -108,20 +124,27 @@ private void vodAssetHistoryFilteredByAssetId() { private void vodAssetHistoryFilteredByAssetType() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset (movie in first play) Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(MOVIE_MEDIA_TYPE_ID)); + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, + getProperty(MOVIE_MEDIA_TYPE_ID)); + //assetHistory/action/list - filter by in progress assets only - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); } @@ -130,7 +153,6 @@ private void vodAssetHistoryFilteredByAssetType() { private void vodAssetHistoryFilteredByAssetProgress() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - client = getClient(HouseholdUtils.getHouseholdMasterUserKs(household,null)); // Ingest and bookmark first asset (movie in first play) Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); @@ -140,17 +162,27 @@ private void vodAssetHistoryFilteredByAssetProgress() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); //assetHistory/action/list - filter by in progress assets only - Response> assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); + //assetHistory/action/list - filter by finished assets only - assetHistoryListResponse = AssetHistoryServiceImpl.list(client, assetHistoryFilter, null); + + listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); - AssetHistoryServiceImpl.clean(client, assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + executor.executeSync(cleanAssetHistoryBuilder); } //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] From 2a633e7dafd8e25f5cb0e494cfdd462ceabd8fbf Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 10:22:47 +0300 Subject: [PATCH 167/605] refactored Session classes --- .../sessionTests/SessionGetTests.java | 27 +++++--- .../sessionTests/SessionRevokeTests.java | 28 +++++--- .../sessionTests/SessionSwitchUserTests.java | 64 ++++++++++++++----- 3 files changed, 84 insertions(+), 35 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index 9f10e1b67..38c4cfc11 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.services.SessionService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; @@ -14,6 +14,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.SessionService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -29,12 +30,14 @@ private void get_tests_before_class() { @Description("session/action/get - master user") @Test private void getMasterUserSession() { - client = getClient(getAdministratorKs()); Household household = HouseholdUtils.createHouseHold(2, 1, false); HouseholdUser user = HouseholdUtils.getMasterUserFromHousehold(household); String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String session = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), udid); - Response getSessionResponse = SessionServiceImpl.get(client, session); + + GetSessionBuilder getSessionBuilder = SessionService.get(session); + getSessionBuilder.setKs(getAdministratorKs()); + Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); assertThat(getSessionResponse.results.getPartnerId()).isEqualTo(partnerId); @@ -47,9 +50,11 @@ private void getMasterUserSession() { @Description("session/action/get - Anonymous user") @Test private void getAnonymousUserSession() { - client = getClient(getAdministratorKs()); String session = BaseTest.getAnonymousKs(); - Response getSessionResponse = SessionServiceImpl.get(client, session); + + GetSessionBuilder getSessionBuilder = SessionService.get(session); + getSessionBuilder.setKs(getAdministratorKs()); + Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); assertThat(getSessionResponse.results.getUserId()).isEqualTo("0"); @@ -59,9 +64,11 @@ private void getAnonymousUserSession() { @Description("session/action/get - operator user") @Test private void getOperatorUserSession() { - client = getClient(getAdministratorKs()); String session = getOperatorKs(); - Response getSessionResponse = SessionServiceImpl.get(client, session); + + GetSessionBuilder getSessionBuilder = SessionService.get(session); + getSessionBuilder.setKs(getAdministratorKs()); + Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); assertThat(getSessionResponse.results.getUserId()).isEqualTo(SessionUtils.getUserIdByKs(getOperatorKs())); @@ -71,9 +78,11 @@ private void getOperatorUserSession() { @Description("session/action/get - invalid ks") @Test private void getSessionWithInvalidSessionKs() { - client = getClient(getAdministratorKs()); String session = getOperatorKs() + 1; - Response getSessionResponse = SessionServiceImpl.get(client, session); + + GetSessionBuilder getSessionBuilder = SessionService.get(session); + getSessionBuilder.setKs(getAdministratorKs()); + Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500015).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java index ae3bdaeef..5609583b0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java @@ -1,8 +1,8 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; -import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.services.OttUserService; +import com.kaltura.client.services.SessionService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; @@ -15,11 +15,12 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.SessionService.*; +import static com.kaltura.client.services.OttUserService.*; public class SessionRevokeTests extends BaseTest { public static Client client; - private String udid; @BeforeClass private void revoke_tests_before_class() { @@ -33,7 +34,6 @@ private void RevokeKs() { String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); String masterUserKs2 = HouseholdUtils.getHouseholdMasterUserKs(household, udid); - client = getClient(masterUserKs); try { Thread.sleep(2000); @@ -42,7 +42,11 @@ private void RevokeKs() { } // Revoke all sessions for specific user - Response booleanResponse = SessionServiceImpl.revoke(client); + + RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke(); + revokeSessionBuilder.setKs(masterUserKs); + Response booleanResponse = executor.executeSync(revokeSessionBuilder); + assertThat(booleanResponse.results).isTrue(); try { @@ -52,14 +56,18 @@ private void RevokeKs() { } // Verify ks is expired - Response ottUserResponse2 = OttUserServiceImpl.get(client); - assertThat(ottUserResponse2.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); - client = getClient(masterUserKs2); + GetOttUserBuilder getOttUserBuilder = OttUserService.get(); + getOttUserBuilder.setKs(masterUserKs); + Response ottUserResponse = executor.executeSync(getOttUserBuilder); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); // Verify ks2 is expired - Response ottUserResponse3 = OttUserServiceImpl.get(client); - assertThat(ottUserResponse3.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); + + GetOttUserBuilder getOttUserBuilder2 = OttUserService.get(); + getOttUserBuilder2.setKs(masterUserKs2); + Response ottUserResponse2 = executor.executeSync(getOttUserBuilder); + assertThat(ottUserResponse2.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index edcae5ca2..95c6ec1ab 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -2,7 +2,8 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.UserState; -import com.kaltura.client.test.servicesImpl.*; +import com.kaltura.client.services.OttUserService; +import com.kaltura.client.services.SessionService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; @@ -14,9 +15,12 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.SessionService.*; +import static com.kaltura.client.services.OttUserService.*; public class SessionSwitchUserTests extends BaseTest { + //TODO - replace hardcoded user id private String UserId = "1543798"; private String userKs; public static Client client; @@ -34,10 +38,13 @@ private void SwitchUser() { String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); String secondUserId = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0).getUserId(); - client = getClient(masterUserKs); // Invoke session/action/switchUser - second user replace master user in the session - Response loginSessionResponse = SessionServiceImpl.switchUser(client, secondUserId); + + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(secondUserId); + switchUserSessionBuilder.setKs(masterUserKs); + Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + // Verify new session ks returned assertThat(loginSessionResponse.results.getKs()).isNotEmpty(); String secondUserKs = loginSessionResponse.results.getKs(); @@ -45,20 +52,31 @@ private void SwitchUser() { ///----- After User was switched ------ // Invoke OttUser/action/get - with master user (expired) ks - Response ottUserResponse = OttUserServiceImpl.get(client); + + OttUserService.GetOttUserBuilder getOttUserBuilder = OttUserService.get(); + getOttUserBuilder.setKs(masterUserKs); + Response ottUserResponse = executor.executeSync(getOttUserBuilder); + // Verify master user ks is now expired (after the switch) assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); - client = getClient(secondUserKs); // Invoke OttUser/action/get with second user new ks - Response ottUserResponse2 = OttUserServiceImpl.get(client); + + GetOttUserBuilder getOttUserBuilder2 = OttUserService.get(); + getOttUserBuilder2.setKs(secondUserKs); + Response ottUserResponse2 = executor.executeSync(getOttUserBuilder); + // Verify second user id return in the response assertThat(ottUserResponse2.results.getId()).isEqualTo(secondUserId); assertThat(ottUserResponse2.results.getUserState()).isEqualTo(UserState.OK); - client = getClient(getAdministratorKs()); + // Invoke session/action/get - Response getSessionResponse = SessionServiceImpl.get(client, secondUserKs); + + GetSessionBuilder getSessionBuilder = SessionService.get(secondUserKs); + getSessionBuilder.setKs(getAdministratorKs()); + Response getSessionResponse = executor.executeSync(getSessionBuilder); + // Verify second user id returned in the response assertThat(getSessionResponse.results.getUserId()).isEqualTo(secondUserId); assertThat(getSessionResponse.results.getUdid()).isEqualTo(udid); @@ -71,10 +89,12 @@ private void SwitchUserToHimself() { String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); - client = getClient(masterUserKs); // Invoke session/action/switchUser - Should return an error (user can't switched to himself - Response loginSessionResponse = SessionServiceImpl.switchUser(client, masterUserId); + + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(masterUserId); + switchUserSessionBuilder.setKs(masterUserKs); + Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); // Verify exception returned assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1).getCode()); @@ -84,23 +104,32 @@ private void SwitchUserToHimself() { @Test private void SwitchInactiveUser() { + //TODO - replace hardcoded user id String inactiveUserId = "1543797"; String UserKs = OttUserUtils.getKs(Integer.valueOf(UserId), null); - client = getClient(UserKs); - Response loginSessionResponse = SessionServiceImpl.switchUser(client, inactiveUserId); + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(inactiveUserId); + switchUserSessionBuilder.setKs(UserKs); + Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2016).getCode()); } @Description("/session/action/switchUser - switch to user from another HH") @Test private void switchToUserFromAnotherHousehold() { + + //TODO - replace hardcoded user id String userIdFromHousehold1 = "1543798"; String Use1rKs = OttUserUtils.getKs(Integer.valueOf(userIdFromHousehold1), null); - client = getClient(Use1rKs); + + //TODO - replace hardcoded user id String userIdFromHousehold2 = "638731"; - Response loginSessionResponse = SessionServiceImpl.switchUser(client, userIdFromHousehold2); + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(userIdFromHousehold2); + switchUserSessionBuilder.setKs(Use1rKs); + Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } @@ -108,8 +137,11 @@ private void switchToUserFromAnotherHousehold() { @Description("/session/action/switchUser - No user id to switch provided") @Test private void switchToUserWithoutUserId() { - client = getClient(userKs); - Response loginSessionResponse = SessionServiceImpl.switchUser(client, null); + + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(null); + switchUserSessionBuilder.setKs(userKs); + Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500053).getCode()); } } From d7f4d046f8380ce976aa4739affc9c5e2bda4624 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 11:30:55 +0300 Subject: [PATCH 168/605] Refactored AppTokenTests classes --- .../appTokenTests/AppTokenAddTests.java | 50 ++++++++---- .../appTokenTests/AppTokenDeleteTests.java | 28 +++++-- .../appTokenTests/AppTokenGetTests.java | 19 +++-- .../AppTokenStartSessionTests.java | 78 ++++++++++++++----- 4 files changed, 126 insertions(+), 49 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index a8ec7c4cc..7dfa495f6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -2,7 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; +import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.test.utils.BaseUtils; @@ -15,6 +15,7 @@ import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.AppTokenService.*; public class AppTokenAddTests extends BaseTest { @@ -29,14 +30,15 @@ private void add_tests_before_class() { hashType = AppTokenHashType.SHA1; sessionUserId = getSharedUser().getUserId(); appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); - } @Description("appToken/action/add") @Test private void addAppToken() { - client = getClient(getOperatorKs()); - Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response appTokenResponse = executor.executeSync(addAppTokenBuilder); // Verify no error returned assertThat(appTokenResponse.error).isNull(); @@ -53,10 +55,13 @@ private void addAppToken() { @Description("appToken/action/add - without hash type") @Test private void addAppTokenWithDefaultHashType() { - client = getClient(getOperatorKs()); appToken = AppTokenUtils.addAppToken(sessionUserId, null, null, null); // Invoke AppToken/action/add - with no hash type (will return the default hash type) - Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response appTokenResponse = executor.executeSync(addAppTokenBuilder); + // Verify that hashType = SHA256 assertThat(appTokenResponse.results.getHashType()).isEqualTo(AppTokenHashType.SHA256); } @@ -64,10 +69,12 @@ private void addAppTokenWithDefaultHashType() { @Description("appToken/action/add - with privileges") @Test private void addAppTokenWithPrivileges() { - client = getClient(getOperatorKs()); sessionPrivileges = "key1:value1,key2:value2"; appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, null); - Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response appTokenResponse = executor.executeSync(addAppTokenBuilder); assertThat(appTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); } @@ -75,10 +82,13 @@ private void addAppTokenWithPrivileges() { @Description("appToken/action/add - with expiry date") @Test(groups = "slow") private void addAppTokenWithExpiryDate() { - client = getClient(getOperatorKs()); Long expiryDate = BaseUtils.getTimeInEpoch(1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); - Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); + assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); // Wait until token is expired (according to expiry date) @@ -90,7 +100,11 @@ private void addAppTokenWithExpiryDate() { e.printStackTrace(); } - Response getAppTokenResponse = AppTokenServiceImpl.get(client, addAppTokenResponse.results.getId()); + + GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponse.results.getId()); + getAppTokenBuilder.setKs(getOperatorKs()); + Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); + assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } @@ -100,20 +114,26 @@ private void addAppTokenWithExpiryDate() { //todo - Add specific mark indicating the version of the feature private void addAppTokenWithNoExpiryDate() { getSharedHousehold(); - client = getClient(getSharedMasterUserKs()); int expiryDate = 0; //int cbExpiryDateValue = 2592000; appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, expiryDate); - Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getSharedMasterUserKs()); + Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); + assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(BaseUtils.getTimeInEpoch(0))); } @Description("appToken/action/add - with no specific user id") @Test private void addAppTokenWithoutSpecificUserId() { - client = getClient(getOperatorKs()); appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, null); - Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); + assertThat(addAppTokenResponse.error).isNull(); assertThat(addAppTokenResponse.results.getExpiry()).isNull(); assertThat(addAppTokenResponse.results.getId()).isNotEmpty(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java index 98df78a8a..f81c40dff 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java @@ -1,8 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.appTokenTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; +import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.types.AppToken; @@ -11,6 +10,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.AppTokenService.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedUser; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -20,12 +20,10 @@ public class AppTokenDeleteTests extends BaseTest { private AppTokenHashType hashType; private String sessionUserId; private AppToken appToken = new AppToken(); - public static Client client; @BeforeClass private void add_tests_before_class() { sessionUserId = getSharedUser().getUserId(); - client = getClient(getOperatorKs()); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); } @@ -34,20 +32,34 @@ private void add_tests_before_class() { @Test private void addAppToken() { // Add token - Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response appTokenResponse = executor.executeSync(addAppTokenBuilder); + assertThat(appTokenResponse.error).isNull(); assertThat(appTokenResponse.results.getExpiry()).isNull(); // Delete token - Response deleteTokenResponse = AppTokenServiceImpl.delete(client, appTokenResponse.results.getId()); + + DeleteAppTokenBuilder deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()); + deleteAppTokenBuilder.setKs(getOperatorKs()); + Response deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); + assertThat(deleteTokenResponse.results).isTrue(); // Try to delete token using invalid token id - deleteTokenResponse = AppTokenServiceImpl.delete(client, "1234"); + + deleteAppTokenBuilder = AppTokenService.delete("1234"); + deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); + assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); // Try to delete token again - exception returned - deleteTokenResponse = AppTokenServiceImpl.delete(client, appTokenResponse.results.getId()); + + deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()); + deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); + assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index 492232f06..ff67572f4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -2,7 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; +import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.test.utils.BaseUtils; @@ -29,7 +29,6 @@ public class AppTokenGetTests extends BaseTest { @BeforeClass private void get_tests_before_class() { - client = getClient(getOperatorKs()); hashType = AppTokenHashType.SHA1; sessionUserId = getSharedUser().getUserId(); @@ -41,8 +40,14 @@ private void get_tests_before_class() { private void getAppToken() { appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); - Response addAppTokenResponse = AppTokenServiceImpl.add(client, appToken); - Response getAppTokenResponse = AppTokenServiceImpl.get(client, addAppTokenResponse.results.getId()); + + AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); + + AppTokenService.GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponse.results.getId()); + getAppTokenBuilder.setKs(getOperatorKs()); + Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); assertThat(getAppTokenResponse.results.getId()).isEqualTo(addAppTokenResponse.results.getId()); assertThat(getAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); @@ -57,7 +62,11 @@ private void getAppToken() { @Description("AppToken/action/get") @Test private void getAppTokenWithInvalidId() { - Response getAppTokenResponse = AppTokenServiceImpl.get(client, "1234"); + + AppTokenService.GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get("1234"); + getAppTokenBuilder.setKs(getOperatorKs()); + Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); + assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index 729adae79..e71e22793 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -2,8 +2,8 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.test.servicesImpl.AppTokenServiceImpl; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.services.AppTokenService; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.test.utils.BaseUtils; @@ -17,10 +17,13 @@ import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.AppTokenService.*; public class AppTokenStartSessionTests extends BaseTest { private AppTokenHashType hashType; + //TODO - remove hardcoded values private String sessionUserId = "1577578"; private String udid1 = "1234567890"; private String udid2 = "9876543210"; @@ -33,11 +36,15 @@ public class AppTokenStartSessionTests extends BaseTest { @BeforeClass private void add_tests_before_class() { - client = getClient(null); + // Invoke ottUser/action/anonymousLogin to receive LoginSession object (and anonymous KS) - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, partnerId, udid1); + + AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid1); + anonymousLoginOttUserBuilder.setKs(null); + Response loginSessionResponse = executor.executeSync(anonymousLoginOttUserBuilder); + anonymousKs = loginSessionResponse.results.getKs(); - client.setKs(getOperatorKs()); + client.setKs(null); expiryDate = BaseUtils.getTimeInEpoch(1); } @@ -47,16 +54,24 @@ private void startSessionSha1() { hashType = AppTokenHashType.SHA1; // Build appToken object appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + // Invoke AppToken/action/add - client.setKs(getOperatorKs()); - Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response appTokenResponse = executor.executeSync(addAppTokenBuilder); + client.setKs(anonymousKs); // Generate new token hash String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + // Invoke AppToken/action/startSession - with udid1 - Response sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() - , tokenHash, null, Math.toIntExact(expiryDate), udid1); + + StartSessionAppTokenBuilder startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, + Math.toIntExact(expiryDate), udid1); + startSessionAppTokenBuilder.setKs(anonymousKs); + Response sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(partnerId); @@ -67,8 +82,11 @@ private void startSessionSha1() { assertThat(sessionInfoResponse.results.getCreateDate()).isNotZero(); // Invoke AppToken/action/startSession - with udid2 - sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() - , tokenHash, null, Math.toIntExact(expiryDate), udid2); + + startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, + Math.toIntExact(expiryDate), udid2); + startSessionAppTokenBuilder.setKs(anonymousKs); + sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); @@ -82,15 +100,25 @@ private void startSessionSha256() { hashType = AppTokenHashType.SHA256; // Build appToken object appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + // Invoke AppToken/action/add client.setKs(getOperatorKs()); - Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); + + AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getOperatorKs()); + Response appTokenResponse = executor.executeSync(addAppTokenBuilder); + client.setKs(anonymousKs); + // Generate new token hash String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + // // Invoke AppToken/action/startSession - with udid1 - Response sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() - , tokenHash, null, Math.toIntExact(expiryDate), udid1); + + StartSessionAppTokenBuilder startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, + Math.toIntExact(expiryDate), udid1); + startSessionAppTokenBuilder.setKs(anonymousKs); + Response sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); assertThat(sessionInfoResponse.results.getPartnerId()).isEqualTo(partnerId); @@ -101,8 +129,11 @@ private void startSessionSha256() { assertThat(sessionInfoResponse.results.getCreateDate()).isNotZero(); // Invoke AppToken/action/startSession - with udid2 - sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() - , tokenHash, null, Math.toIntExact(expiryDate), udid2); + + startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, + Math.toIntExact(expiryDate), udid2); + startSessionAppTokenBuilder.setKs(anonymousKs); + sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); @@ -115,14 +146,19 @@ private void startSessionSha256() { private void startSessionDefaultExpiryDate() { int expiryDate = 0; getSharedHousehold(); - client = getClient(getSharedMasterUserKs()); hashType = AppTokenHashType.SHA1; appToken = AppTokenUtils.addAppToken(null, hashType, null, expiryDate); - Response appTokenResponse = AppTokenServiceImpl.add(client, appToken); - client = getClient(anonymousKs); + + AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); + addAppTokenBuilder.setKs(getSharedMasterUserKs()); + Response appTokenResponse = executor.executeSync(addAppTokenBuilder); + String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); - Response sessionInfoResponse = AppTokenServiceImpl.startSession(client, appTokenResponse.results.getId() - , tokenHash, null, expiryDate, udid1); + + StartSessionAppTokenBuilder startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, + Math.toIntExact(expiryDate), udid1); + startSessionAppTokenBuilder.setKs(anonymousKs); + Response sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); } From b8a65040e43669b9c91272f40a5f95d0ee6b2e9c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 11:49:00 +0300 Subject: [PATCH 169/605] Refactored ChannelTest classes --- .../channelTests/ChannelAddTests.java | 50 ++++++++++++++----- .../channelTests/ChannelDeleteTests.java | 35 +++++++++---- .../channelTests/ChannelGetTests.java | 7 --- 3 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 9740292ae..1a0c0688e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -2,8 +2,8 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BaseUtils; @@ -19,13 +19,14 @@ import java.util.List; import java.util.Optional; +import static com.kaltura.client.services.AssetService.*; +import static com.kaltura.client.services.ChannelService.*; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class ChannelAddTests extends BaseTest { - private Client client; private Channel channel = new Channel(); private String channelName; private String Description; @@ -37,7 +38,6 @@ public class ChannelAddTests extends BaseTest { @BeforeClass private void get_tests_before_class() { - client = getClient(getManagerKs()); channelName = "Channel_12345"; Description = "description of channel"; } @@ -46,10 +46,13 @@ private void get_tests_before_class() { @Test private void addChannel() { filterExpression = "name ~ 'movie'"; - client = getClient(getManagerKs()); channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add - Response channelResponse = ChannelServiceImpl.add(client, channel); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + addChannelBuilder.setKs(getManagerKs()); + Response channelResponse = executor.executeSync(addChannelBuilder); + assertThat(channelResponse.results.getName()).isEqualTo(channelName); } @@ -68,11 +71,13 @@ private void checkOrderOfAssetsInChannel() { MediaAsset episodeAsset = IngestUtils.ingestBasicVOD(Optional.of(asset2Name), MOVIE_MEDIA_TYPE); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; - client = getClient(getManagerKs()); channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); //channel/action/add - Response channelResponse = ChannelServiceImpl.add(client, channel); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + addChannelBuilder.setKs(getManagerKs()); + Response channelResponse = executor.executeSync(addChannelBuilder); + assertThat(channelResponse.results.getName()).isEqualTo(channelName); int channelId = Math.toIntExact(channelResponse.results.getId()); @@ -80,13 +85,19 @@ private void checkOrderOfAssetsInChannel() { ChannelFilter channelFilter = AssetUtils.getChannelFilter(channelId, null, null, null); //asset/action/list - Response> listResponse = AssetServiceImpl.list(client, channelFilter, null); + ListAssetBuilder listAssetBuilder = AssetService.list(channelFilter); + listAssetBuilder.setKs(getManagerKs()); + Response> listResponse = executor.executeSync(listAssetBuilder); + assertThat(listResponse.results.getTotalCount()).isEqualTo(2); // Verify movie asset id returned first (because order is by name_desc) assertThat(listResponse.results.getObjects().get(0).getId()).isEqualTo(movieAsset.getId()); // Cleanup - channel/action/delete - ChannelServiceImpl.delete(client, channelId); + DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId); + deleteChannelBuilder.setKs(getManagerKs()); + executor.executeSync(deleteChannelBuilder); + } @@ -96,8 +107,13 @@ private void addChannelWithInvalidAssetType() { integerValue.setValue(666); assetTypes.add(integerValue); channel = ChannelUtils.addChannel(channelName, Description, isActive, null, AssetOrderBy.LIKES_DESC, assetTypes, null); + //channel/action/add - Response channelResponse = ChannelServiceImpl.add(client, channel); + + AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + addChannelBuilder.setKs(getManagerKs()); + Response channelResponse = executor.executeSync(addChannelBuilder); + // KalturaAPIException","code":"4020","message":"KSQL Channel media type 666 does not belong to group" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4020).getCode()); } @@ -106,8 +122,12 @@ private void addChannelWithInvalidAssetType() { @Test private void addChannelWithNoName() { channel = ChannelUtils.addChannel(null, Description, isActive, null, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add - Response channelResponse = ChannelServiceImpl.add(client, channel); + + AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + addChannelBuilder.setKs(getManagerKs()); + Response channelResponse = executor.executeSync(addChannelBuilder); // KalturaAPIException","code":"5005","message":"KSQL Channel must have a name" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(5005).getCode()); @@ -118,8 +138,12 @@ private void addChannelWithNoName() { private void addChannelWithSyntaxErrorInFilterExpression() { filterExpression = "name = 'syntax error"; channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + //channel/action/add - Response channelResponse = ChannelServiceImpl.add(client, channel); + + AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + addChannelBuilder.setKs(getManagerKs()); + Response channelResponse = executor.executeSync(addChannelBuilder); // KalturaAPIException","code":"4004","message":"Invalid expression structure" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4004).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index bfeb1a4a3..12543b98e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -2,7 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; +import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.ChannelUtils; import com.kaltura.client.types.Channel; @@ -11,42 +11,57 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.ChannelService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class ChannelDeleteTests extends BaseTest { - private Client client; private Channel channel = new Channel(); - private String channelName = "Channel_12345"; - private String Description = "description of channel"; - private Boolean isActive = true; + private String channelName; + private String Description; + private Boolean isActive; private String filterExpression; private int channelId; @BeforeClass private void get_tests_before_class() { + channelName = "Channel_12345"; + Description = "description of channel"; + isActive = true; + filterExpression = "name ~ 'movie'"; } @Description("channel/action/delete") @Test private void DeleteChannel() { - filterExpression = "name ~ 'movie'"; - client = getClient(getManagerKs()); + channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); // channel/action/add - Response channelResponse = ChannelServiceImpl.add(client, channel); + // channel/action/add + + ChannelService.AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + addChannelBuilder.setKs(getManagerKs()); + Response channelResponse = executor.executeSync(addChannelBuilder); channelId = Math.toIntExact(channelResponse.results.getId()); // channel/action/delete - Response deleteResponse = ChannelServiceImpl.delete(client, Math.toIntExact(channelId)); + + ChannelService.DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId); + deleteChannelBuilder.setKs(getManagerKs()); + Response deleteResponse = executor.executeSync(deleteChannelBuilder); + assertThat(deleteResponse.results.booleanValue()).isTrue(); // channel/action/get - verify channel wasn't found - Response getResponse = ChannelServiceImpl.get(client, channelId); + + GetChannelBuilder getChannelBuilder = ChannelService.get(channelId); + getChannelBuilder.setKs(getManagerKs()); + Response getResponse = executor.executeSync(getChannelBuilder); + assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java index 725195336..f8cbc9d3c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java @@ -1,20 +1,13 @@ package com.kaltura.client.test.tests.servicesTests.channelTests; -import com.kaltura.client.Client; -import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.test.servicesImpl.ChannelServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.ChannelUtils; import com.kaltura.client.types.Channel; -import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.assertj.core.api.Assertions.assertThat; public class ChannelGetTests extends BaseTest { - private Client client; private Channel channel = new Channel(); private String channelName = "Channel_12345"; private String Description = "description of channel"; From 384bebd30c073a3e3cc960f9bea282ae3c13d7c8 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 13:28:50 +0300 Subject: [PATCH 170/605] Refactored HouseholdUtils class + updated channelAddTests class --- .../channelTests/ChannelAddTests.java | 1 - .../client/test/utils/HouseholdUtils.java | 81 ++++++++++++++----- 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 1a0c0688e..d14d5cb9d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.channelTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.ChannelService; diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 637249689..3d5d9665c 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -2,7 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.Logger; -import com.kaltura.client.test.servicesImpl.*; +import com.kaltura.client.services.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -11,42 +11,64 @@ import java.util.List; import java.util.Random; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.HouseholdDeviceService.*; +import static com.kaltura.client.services.HouseholdPaymentGatewayService.*; +import static com.kaltura.client.services.HouseholdUserService.*; +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.BaseTest.getAdministratorKs; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class HouseholdUtils extends BaseUtils { // create household public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold, boolean isPreparePG) { - Client client = getClient(null); // create and register - Response masterUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + + RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, generateOttUser(), defaultUserPassword); + registerOttUserBuilder.setKs(null); + Response masterUserResponse = executor.executeSync(registerOttUserBuilder); + OTTUser masterUser = masterUserResponse.results; // login master user - Response loginResponse = login(client, partnerId, masterUser.getUsername(), defaultUserPassword, null, null); + + LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, masterUser.getUsername(), defaultUserPassword, null, null); + loginOttUserBuilder.setKs(null); + Response loginResponse = executor.executeSync(loginOttUserBuilder); + masterUser = loginResponse.results.getUser(); - client.setKs(loginResponse.results.getLoginSession().getKs()); // create and add household Household household = new Household(); household.setName(masterUser.getFirstName() + "s Domain"); household.setDescription(masterUser.getLastName() + " Description"); - Response householdResponse = HouseholdServiceImpl.add(client, household); + AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household); + addHouseholdBuilder.setKs(loginResponse.results.getLoginSession().getKs()); + Response householdResponse = executor.executeSync(addHouseholdBuilder); + household = householdResponse.results; // create, register and add non-master user to household for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { - Response additionalUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + + registerOttUserBuilder = OttUserService.register(partnerId, generateOttUser(), defaultUserPassword); + registerOttUserBuilder.setKs(null); + Response additionalUserResponse = executor.executeSync(registerOttUserBuilder); + OTTUser additionalUser = additionalUserResponse.results; HouseholdUser householdUser = new HouseholdUser(); householdUser.setUserId(additionalUser.getId()); householdUser.setIsMaster(false); - HouseholdUserServiceImpl.add(client, householdUser); + + // HouseholdUser/action/add - add user to household + + AddHouseholdUserBuilder addHouseholdUserBuilder = HouseholdUserService.add(householdUser); + addHouseholdBuilder.setKs(loginResponse.results.getLoginSession().getKs()); + executor.executeSync(addHouseholdUserBuilder); } // create, add and save household device @@ -57,21 +79,34 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO Random r = new Random(); householdDevice.setBrandId(r.nextInt(30 - 1) + 1); householdDevice.setName(String.valueOf(uniqueString) + "device"); - HouseholdDeviceServiceImpl.add(client, householdDevice); + + + AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice); + addHouseholdDeviceBuilder.setKs(loginResponse.results.getLoginSession().getKs()); + executor.executeSync(addHouseholdDeviceBuilder); + } - // login as Master with Udid + // login as Master with udid if (numberOfDevicesInHousehold > 0) { List householdDevices = getDevicesListFromHouseHold(household); - OttUserServiceImpl.login(client, partnerId, masterUser.getUsername(), defaultUserPassword, null, householdDevices.get(0).getUdid()); + + loginOttUserBuilder = OttUserService.login(partnerId, masterUser.getUsername(), defaultUserPassword, null, householdDevices.get(0).getUdid()); + loginOttUserBuilder.setKs(null); + executor.executeSync(loginOttUserBuilder); + } if (isPreparePG) { // TODO: there should be added logic with getting and using default PG currently it all hardcoded - client = getClient(null); client.setKs(getOperatorKs()); client.setUserId(Integer.valueOf(masterUser.getId())); - HouseholdPaymentGatewayServiceImpl.setChargeId(client, "0110151474255957105", "1234"); + + //HouseholdPaymentGateway/action/setChargeId + SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.setChargeID("0110151474255957105", "1234"); + setChargeIDHouseholdPaymentGatewayBuilder.setKs(getOperatorKs()); + setChargeIDHouseholdPaymentGatewayBuilder.setUserId(Integer.valueOf(masterUser.getId())); + executor.executeSync(setChargeIDHouseholdPaymentGatewayBuilder); } return household; @@ -79,19 +114,27 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO // get users list from given household public static List getDevicesListFromHouseHold(Household household) { - Client client = getClient(getAdministratorKs()); + HouseholdDeviceFilter filter = new HouseholdDeviceFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); - Response> devicesResponse = HouseholdDeviceServiceImpl.list(client, filter); + + //HouseholdDevice/action/list + ListHouseholdDeviceBuilder listHouseholdDeviceBuilder = HouseholdDeviceService.list(filter); + listHouseholdDeviceBuilder.setKs(getAdministratorKs()); + Response> devicesResponse = executor.executeSync(listHouseholdDeviceBuilder); + return devicesResponse.results.getObjects(); } // get users list from given household public static List getUsersListFromHouseHold(Household household) { - Client client = getClient(getAdministratorKs()); HouseholdUserFilter filter = new HouseholdUserFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); - Response> usersResponse = HouseholdUserServiceImpl.list(client, filter); + + ListHouseholdUserBuilder listHouseholdUserBuilder = HouseholdUserService.list(filter); + listHouseholdUserBuilder.setKs(getAdministratorKs()); + Response> usersResponse = executor.executeSync(listHouseholdUserBuilder); + return usersResponse.results.getObjects(); } From 9a6af9a76bda8c965acfdea17003fc6effcff29d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 13:29:28 +0300 Subject: [PATCH 171/605] Started refacotring OttUserUtils class --- src/test/java/com/kaltura/client/test/utils/OttUserUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 8ca0cec20..cac47860c 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; From 92d5d0a73452fe49daf00b0d9d60d57746c27576 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 13:57:04 +0300 Subject: [PATCH 172/605] Refactored OttUserUtils class --- .../client/test/utils/OttUserUtils.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index cac47860c..bea516dab 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -1,6 +1,6 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import java.util.Random; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.tests.BaseTest.*; public class OttUserUtils extends BaseUtils { @@ -34,17 +35,25 @@ public static OTTUser generateOttUser() { } public static OTTUser getUserById(int userId) { - Client client = getClient(getAdministratorKs()); - client.setUserId(userId); - Response userResponse = OttUserServiceImpl.get(client); + + // OttUser/action/get + GetOttUserBuilder getOttUserBuilder = OttUserService.get(); + getOttUserBuilder.setKs(getAdministratorKs()); + getOttUserBuilder.setUserId(userId); + Response userResponse = executor.executeSync(getOttUserBuilder); return userResponse.results; } public static String getKs(int userId, @Nullable String udid) { - Client client = getClient(null); OTTUser ottUser = getUserById(userId); - Response loginResponse = OttUserServiceImpl.login(client, partnerId, ottUser.getUsername(), defaultUserPassword, null, udid); + + //OttUser/action/login + LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, ottUser.getUsername(), defaultUserPassword, null, udid); + loginOttUserBuilder.setKs(null); + loginOttUserBuilder.setUserId(userId); + Response loginResponse = executor.executeSync(loginOttUserBuilder); + return loginResponse.results.getLoginSession().getKs(); } } From 646a2c3ac28ae7e83e2d48c4784397c27ce41107 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 2 May 2018 14:13:40 +0300 Subject: [PATCH 173/605] Updated ProductPrice/ListTests.java. --- .../productPriceTests/ListTests.java | 185 ++++++++++-------- .../client/test/utils/PurchaseUtils.java | 57 ++++-- 2 files changed, 136 insertions(+), 106 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 7feb513d9..57223ec24 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -1,9 +1,10 @@ package com.kaltura.client.test.tests.servicesTests.productPriceTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.*; -import com.kaltura.client.test.servicesImpl.EntitlementServiceImpl; -import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; +import com.kaltura.client.services.ProductPriceService; +import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; @@ -19,22 +20,21 @@ import org.testng.annotations.Test; import java.util.Optional; import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; -import static com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl.list; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class ListTests extends BaseTest { - private Client client; private EntitlementFilter entitlementPpvsFilter; private EntitlementFilter entitlementSubsFilter; private Household household; private String classMasterUserKs; + private Response> productPriceResponse; + private Response> entitlementResponse; + @BeforeClass public void beforeClass() { - client = getClient(getOperatorKs()); entitlementPpvsFilter = new EntitlementFilter(); entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); @@ -68,10 +68,12 @@ public void beforeClass() { public void listSubscription() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - Response> productPriceList = list(client, filter); - assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); - assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); + + ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); + productPriceResponse = executor.executeSync(productPriceList); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); } @Severity(SeverityLevel.NORMAL) @@ -80,13 +82,14 @@ public void listSubscription() { public void listSubscriptionWithCurrencyTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - client.setCurrency(CURRENCY_EUR); - Response> productPriceList = list(client, filter); + ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); + productPriceList.setCurrency(CURRENCY_EUR); + productPriceResponse = executor.executeSync(productPriceList); // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them - assertThat(productPriceList.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); - assertThat(productPriceList.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceList.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); - assertThat(productPriceList.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CURRENCY_EUR); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CURRENCY_EUR); } @Severity(SeverityLevel.MINOR) @@ -94,7 +97,8 @@ public void listSubscriptionWithCurrencyTest() { @Test() public void listWithoutRequiredFields() { ProductPriceFilter filter = new ProductPriceFilter(); - Response> productPriceResponse = list(client, filter); + ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); + productPriceResponse = executor.executeSync(productPriceList); int errorCode = 500056; assertThat(productPriceResponse.results).isNull(); @@ -108,45 +112,48 @@ public void listWithoutRequiredFields() { @Test() public void ppvTest() { // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType - client.setKs(getSharedMasterUserKs()); - Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); - assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); + ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementPpvsFilter, null); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); int webMediaFileId = getSharedMediaAsset().getMediaFiles().get(0).getId(); int mobileMediaFileId = getSharedMediaAsset().getMediaFiles().get(1).getId(); ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); ppFilter.setIsLowest(false); - Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase); // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) - assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - - PurchaseUtils.purchasePpv(client, Optional.empty(), Optional.of(webMediaFileId)); - - Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementPpvsFilter, null); - assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); - assertThat(((PpvEntitlement) entitlementListAfterPurchase.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()) - .isGreaterThan(entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); - - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); - - Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); + + PurchaseUtils.purchasePpv(Optional.empty(), Optional.of(webMediaFileId), null); + + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); + assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); + assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()) + .isGreaterThan(entitlementResponse.results.getObjects().get(0).getCurrentDate()); + assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + + ListProductPriceBuilder productPriceListAfterPurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListAfterPurchase); // only 1 item mention in filter - assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); - Response> productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); - assertThat(((PpvPrice) productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); + ListProductPriceBuilder productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia); + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); } @Severity(SeverityLevel.NORMAL) @@ -157,21 +164,22 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { int numberOfDevices = 1; Household household = HouseholdUtils.createHouseHold(numberOfUsers, numberOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - client.setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null)); ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); filter.setFileIdIn(String.valueOf(getSharedWebMediaFile().getId())); filter.setIsLowest(false); - Response> productPriceListBeforePurchase = list(client, filter); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); + productPriceListBeforePurchase.setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null)); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase); // should be 2 ss one item is subscription an another is media file - assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(2); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); - assertThat(productPriceListBeforePurchase.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(((PpvPrice) productPriceListBeforePurchase.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(2); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceResponse.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); } @Severity(SeverityLevel.CRITICAL) @@ -181,47 +189,52 @@ public void subscriptionTest() { String sharedWebMediaFileId = String.valueOf(getSharedWebMediaFile().getId()); // TODO: 3/7/2018 add remarks when possible such as below - show to Shmulik / Michael and see if test is clear - client = getClient(classMasterUserKs); - Response> entitlementListBeforePurchase = EntitlementServiceImpl.list(client, entitlementSubsFilter, null); - assertThat(entitlementListBeforePurchase.results.getTotalCount()).isEqualTo(0); + ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(get5MinRenewableSubscription().getId().trim()); ppFilter.setIsLowest(false); - Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListBeforePurchase.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceListBeforePurchase.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); - - Response> productPriceListBeforePurchase4Anonymous = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListBeforePurchase4Anonymous.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceListBeforePurchase4Anonymous.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); + + ListProductPriceBuilder productPriceListBeforePurchase4Anonymous = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase4Anonymous); + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); //PurchaseUtils.purchaseSubscription(client, Integer.valueOf(get5MinRenewableSubscription().getId().trim())); - Response> entitlementListAfterPurchase = EntitlementServiceImpl.list(client, entitlementSubsFilter, null); - assertThat(entitlementListAfterPurchase.results.getTotalCount()).isEqualTo(1); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); - assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getEndDate()).isGreaterThan( - entitlementListAfterPurchase.results.getObjects().get(0).getCurrentDate()); - MatcherAssert.assertThat(entitlementListAfterPurchase.results.getObjects().get(0).getPaymentMethod(), + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isGreaterThan( + entitlementResponse.results.getObjects().get(0).getCurrentDate()); + MatcherAssert.assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod(), Matchers.anyOf(Matchers.is(PaymentMethodType.OFFLINE), Matchers.is(PaymentMethodType.UNKNOWN))); ppFilter.setFileIdIn(sharedWebMediaFileId); - Response> productPriceListAfterPurchase = ProductPriceServiceImpl.list(client, ppFilter); - assertThat(productPriceListAfterPurchase.results.getTotalCount()).isEqualTo(2); - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); - assertThat(productPriceListAfterPurchase.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + ListProductPriceBuilder productPriceListAfterPurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListAfterPurchase); + + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(2); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); // TODO: should we use ENUM containing subs of KalturaProductPrice class such as: KalturaCollectionPrice, KalturaPpvPrice, KalturaSubscriptionPrice??? // that logic can't be checked by schema as schema can't check that exactly 1st item is Subscription and 2nd one is PPV - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getClass().getSimpleName()).isEqualToIgnoringCase("SubscriptionPrice"); - assertThat(productPriceListAfterPurchase.results.getObjects().get(1).getClass().getSimpleName()).isEqualToIgnoringCase("PpvPrice"); - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceListAfterPurchase.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(productPriceListAfterPurchase.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); - assertThat(((PpvPrice) productPriceListAfterPurchase.results.getObjects().get(1)).getFileId()).isEqualTo(sharedWebMediaFileId); + assertThat(productPriceResponse.results.getObjects().get(0).getClass().getSimpleName()).isEqualToIgnoringCase("SubscriptionPrice"); + assertThat(productPriceResponse.results.getObjects().get(1).getClass().getSimpleName()).isEqualToIgnoringCase("PpvPrice"); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(sharedWebMediaFileId); } -} +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 00e38899d..ec2c08d49 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -1,25 +1,32 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.enums.ProductPriceOrderBy; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; -import com.kaltura.client.test.servicesImpl.ProductPriceServiceImpl; -import com.kaltura.client.test.servicesImpl.TransactionServiceImpl; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.AssetService.GetAssetBuilder; +import com.kaltura.client.services.ProductPriceService; +import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; +import com.kaltura.client.services.TransactionService; +import com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import static com.kaltura.client.test.tests.BaseTest.executor; public class PurchaseUtils { public static Map purchasePpvDetailsMap; public static Map purchaseSubscriptionDetailsMap; + private static Response> productPriceResponse; + private static Response assetResponse; + // TODO: 14/MAR/2018 add return - public static void purchasePpv(Client client, Optional mediaId, Optional fileId) { + public static void purchasePpv(Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { purchasePpvDetailsMap = new HashMap<>(); int paymentGatewayId = 0; @@ -27,50 +34,58 @@ public static void purchasePpv(Client client, Optional mediaId, Optiona if (fileId.isPresent()) { internalFileId = fileId.get(); } else { - Response mediaAsset = AssetServiceImpl.get(client, String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); - internalFileId = mediaAsset.results.getMediaFiles().get(0).getId(); + GetAssetBuilder mediaAsset = AssetService.get(String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); + assetResponse = executor.executeSync(mediaAsset); + internalFileId = assetResponse.results.getMediaFiles().get(0).getId(); } ProductPriceFilter filter = new ProductPriceFilter(); filter.setOrderBy(ProductPriceOrderBy.PRODUCT_ID_ASC.getValue()); filter.setFileIdIn(String.valueOf(internalFileId)); filter.setIsLowest(false); - Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, filter); - double price = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getAmount(); - String ppvModuleId = ((PpvPrice)productPriceListBeforePurchase.results.getObjects().get(0)).getPpvModuleId(); + + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + + double price = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); + String ppvModuleId = ((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvModuleId(); Purchase purchase = new Purchase(); purchase.setProductId(Integer.valueOf(ppvModuleId)); purchase.setContentId(internalFileId); - String currency = client.getCurrency(); - if (client.getCurrency() == null || client.getCurrency().isEmpty()) { - currency = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getCurrency(); + String currency = purchaseCurrency; + if (purchaseCurrency == null || purchaseCurrency.isEmpty()) { + currency = productPriceResponse.results.getObjects().get(0).getPrice().getCurrency(); } purchase.setCurrency(currency); purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.PPV).get()); purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); - TransactionServiceImpl.purchase(client, purchase); + + PurchaseTransactionBuilder transactionBuilder = TransactionService.purchase(purchase); + executor.executeSync(transactionBuilder); // TODO: complete the purchase ppv test purchasePpvDetailsMap.put("price", String.valueOf(price)); - purchasePpvDetailsMap.put("currency", client.getCurrency()); + purchasePpvDetailsMap.put("currency", currency); purchasePpvDetailsMap.put("ppvModuleId", ppvModuleId); purchasePpvDetailsMap.put("fileId", String.valueOf(internalFileId)); } // TODO: 3/7/2018 add return // private as not completed - private static void purchaseSubscription(Client client, int subscriptionId) { + private static void purchaseSubscription(int subscriptionId) { purchaseSubscriptionDetailsMap = new HashMap<>(); int paymentGatewayId = 0; ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(String.valueOf(subscriptionId)); filter.setIsLowest(false); - Response> productPriceListBeforePurchase = ProductPriceServiceImpl.list(client, filter); - String currency = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getCurrency(); - double price = productPriceListBeforePurchase.results.getObjects().get(0).getPrice().getAmount(); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + + String currency = productPriceResponse.results.getObjects().get(0).getPrice().getCurrency(); + double price = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); Purchase purchase = new Purchase(); purchase.setProductId(subscriptionId); @@ -79,7 +94,9 @@ private static void purchaseSubscription(Client client, int subscriptionId) { purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.SUBSCRIPTION).get()); purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); - TransactionServiceImpl.purchase(client, purchase); + + PurchaseTransactionBuilder transactionBuilder = TransactionService.purchase(purchase); + executor.executeSync(transactionBuilder); // TODO: complete the purchase subscription test purchaseSubscriptionDetailsMap.put("price", String.valueOf(price)); From 3f4ab03f94c560bf65ba2b3fca58b6ce382071d9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Wed, 2 May 2018 14:27:40 +0300 Subject: [PATCH 174/605] start refactoring AddRoleTests class --- .../servicesTests/ottUserTests/AddRoleTests.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index 1c8352e54..b34bfc0c8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -1,8 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; -import com.kaltura.client.test.servicesImpl.UserRoleServiceImpl; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.OTTUser; @@ -15,19 +13,19 @@ import java.util.List; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class AddRoleTests extends BaseTest { - - private Client client; private OTTUser user; @BeforeClass private void ottUser_addRole_tests_setup() { - client = getClient(null); user = generateOttUser(); - Response ottUserResponse = register(client, partnerId, user, defaultUserPassword); + + // OttUser/action/register + OttUserService.RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, defaultUserPassword); + registerOttUserBuilder.setKs(null); + Response ottUserResponse = executor.executeSync(registerOttUserBuilder); user = ottUserResponse.results; } From 56e8afc840cf04d9174b39f73c6cf6c300b401df Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 2 May 2018 15:42:40 +0300 Subject: [PATCH 175/605] refactor ottUser deleteTests --- .../ottUserTests/DeleteTests.java | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index f5886de7d..05c08ce5c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -1,8 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.HouseholdServiceImpl; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.Household; @@ -14,8 +13,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.get; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.HouseholdUtils.getDefaultUserFromHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUserFromHousehold; @@ -24,51 +23,71 @@ public class DeleteTests extends BaseTest { - private Client client; private Household household; + private Response booleanResponse; + private Response ottUserResponse; + private DeleteOttUserBuilder deleteOttUserBuilder; @BeforeClass private void ottUser_delete_tests_setup() { - client = getClient(getAdministratorKs()); - household = HouseholdUtils.createHouseHold(2, 0, false); + int numberOfDevicesInHousehold = 0; + int numberOfUsersInHousehold = 2; + household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } @Description("ottUser/action/delete - delete") @Test private void delete() { - Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); - OTTUser user = ottUserResponse.results; + // register user + RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword); + registerOttUserBuilder.setKs(getAdministratorKs()); + OTTUser user = executor.executeSync(registerOttUserBuilder).results; + + // delete user and assert success + deleteOttUserBuilder = OttUserService.delete(); + deleteOttUserBuilder.setKs(getAdministratorKs()); + deleteOttUserBuilder.setUserId(Integer.valueOf(user.getId())); - client.setUserId(Integer.valueOf(user.getId())); - Response booleanResponse = OttUserServiceImpl.delete(client); - boolean result = booleanResponse.results; + boolean result = executor.executeSync(deleteOttUserBuilder).results; assertThat(result).isTrue(); - ottUserResponse = get(client); - assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); + // try to get user and assert error + GetOttUserBuilder getOttUserBuilder = OttUserService.get(); + getOttUserBuilder.setKs(getAdministratorKs()); + ottUserResponse = executor.executeSync(getOttUserBuilder); + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); } @Description("ottUser/action/delete - delete master user: error 2031") @Test(enabled = true) private void delete_master_user() { + // get household master user HouseholdUser masterUser = getMasterUserFromHousehold(household); - client.setUserId(Integer.valueOf(masterUser.getUserId())); - booleanResponse = OttUserServiceImpl.delete(client); + // try to delete master user and assert error + deleteOttUserBuilder = OttUserService.delete(); + deleteOttUserBuilder.setKs(getAdministratorKs()); + deleteOttUserBuilder.setUserId(Integer.valueOf(masterUser.getUserId())); + booleanResponse = executor.executeSync(deleteOttUserBuilder); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2031).getCode()); } - + @Description("ottUser/action/delete - delete default user: error 2030") @Test(enabled = true) private void delete_default_user() { + // get household default user HouseholdUser defaultUser = getDefaultUserFromHousehold(household); - client.setUserId(Integer.valueOf(defaultUser.getUserId())); - booleanResponse = OttUserServiceImpl.delete(client); + // try to delete default user and assert error + deleteOttUserBuilder = OttUserService.delete(); + deleteOttUserBuilder.setKs(getAdministratorKs()); + deleteOttUserBuilder.setUserId(Integer.valueOf(defaultUser.getUserId())); + booleanResponse = executor.executeSync(deleteOttUserBuilder); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2030).getCode()); @@ -76,7 +95,9 @@ private void delete_default_user() { @AfterClass private void ottUser_delete_tests_tearDown() { - HouseholdServiceImpl.delete(client, Math.toIntExact(household.getId())); + DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())); + deleteHouseholdBuilder.setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); } } From 12fd4f6e55ec340990af7f2f4341b55e54b5348a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 2 May 2018 16:32:10 +0300 Subject: [PATCH 176/605] Global users remved from test.properties --- .../com/kaltura/client/test/Properties.java | 9 ------ .../kaltura/client/test/tests/BaseTest.java | 10 +++++-- .../kaltura/client/test/utils/DBUtils.java | 29 +++++++++++++++++++ src/test/resources/test.template.properties | 9 ------ 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 96ef6bae9..7e35ddd1d 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -21,15 +21,6 @@ public class Properties { public static final String PARTNER_ID = "partner_id"; // global users - public static final String ADMINISTRATOR_USER_USERNAME = "administrator_user_username"; - public static final String ADMINISTRATOR_USER_PASSWORD = "administrator_user_password"; - - public static final String OPERATOR_USER_USERNAME = "operator_user_username"; - public static final String OPERATOR_USER_PASSWORD = "operator_user_password"; - - public static final String MANAGER_USER_USERNAME = "manager_user_username"; - public static final String MANAGER_USER_PASSWORD = "manager_user_password"; - public static final String DEFAULT_USER_PASSWORD = "default_user_password"; // file types diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 91e1fdd83..64b4e6538 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -4,6 +4,7 @@ import com.kaltura.client.Configuration; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.test.utils.DBUtils; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -102,7 +103,8 @@ public void base_test_before_suite() { // getters for shared params public static String getAdministratorKs() { if (administratorKs == null) { - loginResponse = executor.executeSync(login(partnerId, getProperty(ADMINISTRATOR_USER_USERNAME), getProperty(ADMINISTRATOR_USER_PASSWORD), + String[] userInfo = DBUtils.getUserDataByRole("Administrator").split(":"); + loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], null,null)); administratorKs = loginResponse.results.getLoginSession().getKs(); } @@ -111,7 +113,8 @@ public static String getAdministratorKs() { public static String getOperatorKs() { if (operatorKs == null) { - loginResponse = executor.executeSync(login(partnerId, getProperty(OPERATOR_USER_USERNAME), getProperty(OPERATOR_USER_PASSWORD), + String[] userInfo = DBUtils.getUserDataByRole("Operator").split(":"); + loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], null,null)); operatorKs = loginResponse.results.getLoginSession().getKs(); } @@ -120,7 +123,8 @@ public static String getOperatorKs() { public static String getManagerKs() { if (managerKs == null) { - loginResponse = executor.executeSync(login(partnerId, getProperty(MANAGER_USER_USERNAME), getProperty(MANAGER_USER_PASSWORD), + String[] userInfo = DBUtils.getUserDataByRole("Manager").split(":"); + loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], null,null)); managerKs = loginResponse.results.getLoginSession().getKs(); } diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index c759e6f5b..79d1a43f1 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -21,6 +21,11 @@ public class DBUtils extends BaseUtils { //selects private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + + "from [Users].[dbo].[users] u with(nolock)\n" + + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + + "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; //TODO - change existing methods to work with the new convertToJSON method @@ -82,6 +87,30 @@ public static JSONArray convertToJSON(String query) throws Exception { } + public static String getUserDataByRole(String userRole) { + openConnection(); + try { + rs = stam.executeQuery(String.format(USER_BY_ROLE_SELECT, userRole, BaseTest.partnerId)); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("No data about user with role " + userRole + " in account " + BaseTest.partnerId); + } + String userdData = ""; + try { + userdData = rs.getString("username") + ":" + rs.getString("password"); + } catch (SQLException e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("username/password can't be null"); + } + closeConnection(); + return userdData; + } + public static String getActivationToken(String username) { openConnection(); try { diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index ae27d08d9..6b13f4114 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -11,15 +11,6 @@ db_user=@DB_USER@ db_password=@DB_PASSWORD@ # Global Users Properties -administrator_user_username=@ADMINISTRATOR_USER_USERNAME@ -administrator_user_password=@ADMINISTRATOR_USER_PASSWORD@ - -operator_user_username=@OPERATOR_USER_USERNAME@ -operator_user_password=@OPERATOR_USER_PASSWORD@ - -manager_user_username=@MANAGER_USER_USERNAME@ -manager_user_password=@MANAGER_USER_PASSWORD@ - default_user_password=@DEFAULT_USER_PASSWORD@ # Ingest Users properties From 86ed3c90c3696bd03e295d333494cd4bc55d6921 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 2 May 2018 17:07:19 +0300 Subject: [PATCH 177/605] refactor ottUser tests --- .../ottUserTests/ActivateTests.java | 40 ++++++------------- .../ottUserTests/AnonymousLoginTests.java | 19 ++++----- .../ottUserTests/DeleteTests.java | 3 +- .../ottUserTests/GetEncryptedUserIdTests.java | 21 ++++------ .../servicesTests/ottUserTests/GetTests.java | 28 ++++++------- 5 files changed, 41 insertions(+), 70 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java index 9c218e521..ae67cb9de 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java @@ -1,10 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.UserState; import com.kaltura.client.services.OttUserService; -import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.DBUtils; import com.kaltura.client.types.OTTUser; @@ -15,41 +12,39 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.login; +import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class ActivateTests extends BaseTest { - private Client client; private OTTUser user; private Response ottUserResponse; @BeforeClass private void ottUser_activate_tests_setup() { - client = getClient(null); + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); - user = ottUserResponse.results; + // login user + user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); - login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); + // assert user is not activated + assertThat(user.getUserState()).isEqualTo(UserState.USER_NOT_ACTIVATED); } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/activate - activate") @Test private void activate() { + // get activation token String activationToken = DBUtils.getActivationToken(user.getUsername()); - ActivateOttUserBuilder activateOttUserBuilder = OttUserService.activate(partnerId, user.getUsername(), activationToken); -// activateOttUserBuilder.setKs(""); -// activateOttUserBuilder.setUserId(1); - - ottUserResponse = executor.executeSync(activateOttUserBuilder); -// ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, user.getUsername(), activationToken)); + // activate user + ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, user.getUsername(), activationToken)); + // assert user activated assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); } @@ -58,15 +53,6 @@ private void activate() { @Description("ottUser/action/activate - activate twice with the same token") @Test private void activate_with_sa() { - String activationToken = DBUtils.getActivationToken(user.getUsername()); - - - ottUserResponse = OttUserServiceImpl.activate(client, partnerId, user.getUsername(), activationToken); - assertThat(ottUserResponse.error).isNull(); - assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); - - + // TODO: 5/2/2018 implement test } - - } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 51e7d50ef..0ce6eb813 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -1,30 +1,24 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginSession; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.anonymousLogin; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -public class AnonymousLoginTests extends BaseTest { - private Client client; +public class AnonymousLoginTests extends BaseTest { - @BeforeClass - private void ottUser_anonymousLogin_tests_setup() { - client = getClient(null); - } + private Response loginSessionResponse; @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() - private void anonymousLogin() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, partnerId, null); + private void anonymousLoginTest() { + loginSessionResponse = executor.executeSync(anonymousLogin(partnerId)); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); @@ -33,7 +27,8 @@ private void anonymousLogin() { @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") @Test() private void anonymousLogin_with_wrong_partnerId() { - Response loginSessionResponse = OttUserServiceImpl.anonymousLogin(client, partnerId + 1, null); + int fakePartnerId = 1; + loginSessionResponse = executor.executeSync(anonymousLogin(fakePartnerId)); assertThat(loginSessionResponse.results).isNull(); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 05c08ce5c..24d90eb26 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -26,7 +26,6 @@ public class DeleteTests extends BaseTest { private Household household; private Response booleanResponse; - private Response ottUserResponse; private DeleteOttUserBuilder deleteOttUserBuilder; @BeforeClass @@ -55,7 +54,7 @@ private void delete() { // try to get user and assert error GetOttUserBuilder getOttUserBuilder = OttUserService.get(); getOttUserBuilder.setKs(getAdministratorKs()); - ottUserResponse = executor.executeSync(getOttUserBuilder); + Response ottUserResponse = executor.executeSync(getOttUserBuilder); assertThat(ottUserResponse.results).isNull(); assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java index 2189efbee..21ced1986 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java @@ -1,7 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.StringValue; @@ -10,30 +8,27 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class GetEncryptedUserIdTests extends BaseTest { - private Client client; private OTTUser user; - private Response stringValueResponse; - @BeforeClass private void ottUser_getEncryptedUserId_tests_setup() { - client = getClient(null); - Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); - user = ottUserResponse.results; + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; } @Description("ottUser/action/getEncryptedUserId - getEncryptedUserId") @Test - private void getEncryptedUserId() { - client.setKs(getAdministratorKs()); - client.setUserId(Integer.parseInt(user.getId())); - stringValueResponse = OttUserServiceImpl.getEncryptedUserId(client); + private void getEncryptedUserIdTest() { + GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = getEncryptedUserId(); + getEncryptedUserIdOttUserBuilder.setKs(getAdministratorKs()); + getEncryptedUserIdOttUserBuilder.setUserId(Integer.valueOf(user.getId())); + Response stringValueResponse = executor.executeSync(getEncryptedUserIdOttUserBuilder); assertThat(stringValueResponse.error).isNull(); assertThat(stringValueResponse.results.getValue()).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index c82fbcc32..41394914f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -1,7 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -10,35 +8,33 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class GetTests extends BaseTest { - private Client client; private OTTUser user; - private Response loginResponse; - private Response ottUserResponse; @BeforeClass - private void ottUser_login_tests_setup() { - client = getClient(null); - ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); - user = ottUserResponse.results; + private void ottUser_get_tests_setup() { + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - loginResponse = login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); + // login user + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); user = loginResponse.results.getUser(); - client.setKs(loginResponse.results.getLoginSession().getKs()); } - // get tests + // get test @Description("ottUser/action/get - get") @Test - private void get() { - ottUserResponse = OttUserServiceImpl.get(client); + private void getTest() { + GetOttUserBuilder getOttUserBuilder = get(); + get().setKs(loginResponse.results.getLoginSession().getKs()); + Response ottUserResponse = executor.executeSync(getOttUserBuilder); + assertThat(loginResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); } From 98f74bde4b411479867b26fb5d175dcfe581b35c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 3 May 2018 09:55:37 +0300 Subject: [PATCH 178/605] Fluent setters in builder --- .../test/tests/servicesTests/ottUserTests/DeleteTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 24d90eb26..93b33f06b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -67,7 +67,9 @@ private void delete_master_user() { HouseholdUser masterUser = getMasterUserFromHousehold(household); // try to delete master user and assert error - deleteOttUserBuilder = OttUserService.delete(); + deleteOttUserBuilder = OttUserService.delete() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); deleteOttUserBuilder.setKs(getAdministratorKs()); deleteOttUserBuilder.setUserId(Integer.valueOf(masterUser.getUserId())); booleanResponse = executor.executeSync(deleteOttUserBuilder); From 01f61a1fa41e5d890bc7b1410c36965edaf93e02 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 3 May 2018 09:56:47 +0300 Subject: [PATCH 179/605] Fluent setters in builder --- .../utils/request/BaseRequestBuilder.java | 26 +++++++------- .../client/utils/request/RequestBuilder.java | 34 +++++++++---------- .../utils/request/RequestBuilderData.java | 31 +++++++++++------ .../entitlementTests/GrantTests.java | 2 +- 4 files changed, 51 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java b/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java index 745137476..8a5355f31 100644 --- a/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java +++ b/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java @@ -19,9 +19,9 @@ /** * Created by tehilarozin on 14/08/2016. */ -public abstract class BaseRequestBuilder extends RequestBuilderData implements RequestElement { +public abstract class BaseRequestBuilder extends RequestBuilderData implements RequestElement { - protected Class type; + protected Class type; protected String url; protected Files files = null; protected HashMap headers; @@ -30,9 +30,9 @@ public abstract class BaseRequestBuilder extends RequestBuilderData implement /** * callback for the parsed response. */ - protected OnCompletion> onCompletion; + protected OnCompletion> onCompletion; - protected BaseRequestBuilder(Class type) { + protected BaseRequestBuilder(Class type) { super(); this.type = type; } @@ -63,7 +63,7 @@ public void setParams(Map objParams) { params.putAll(objParams); // !! null params should be checked - should not appear in request body or be presented as empty string. } - public BaseRequestBuilder setFile(String key, FileHolder value) { + public BaseRequestBuilder setFile(String key, FileHolder value) { if (files != null) { files.add(key, value); } @@ -142,33 +142,33 @@ private void prepareUrl(String endPoint) { } } - public RequestElement build(final Client client) { + public RequestElement build(final Client client) { return build(client, false); } @SuppressWarnings("unchecked") @Override - final public Response parseResponse(ResponseElement response) { - T result = null; + final public Response parseResponse(ResponseElement response) { + ReturnedType result = null; APIException error = null; if (!response.isSuccess()) { error = generateErrorResponse(response); } else { try { - result = (T) parse(response.getResponse()); + result = (ReturnedType) parse(response.getResponse()); } catch (APIException e) { error = e; } } - return new Response(result, error); + return new Response(result, error); } @Override - public void onComplete(Response response) { + public void onComplete(Response response) { if(onCompletion != null) { - onCompletion.onComplete((Response) response); + onCompletion.onComplete((Response) response); } } @@ -185,7 +185,7 @@ protected APIException generateErrorResponse(ResponseElement response) { return exception; } - public RequestElement build(final Client client, boolean addSignature) { + public RequestElement build(final Client client, boolean addSignature) { connectionConfig = client != null ? client.getConnectionConfiguration() : Configuration.getDefaults(); prepareParams(client, addSignature); diff --git a/src/main/java/com/kaltura/client/utils/request/RequestBuilder.java b/src/main/java/com/kaltura/client/utils/request/RequestBuilder.java index 2f47fd75e..09c24f21c 100644 --- a/src/main/java/com/kaltura/client/utils/request/RequestBuilder.java +++ b/src/main/java/com/kaltura/client/utils/request/RequestBuilder.java @@ -1,29 +1,29 @@ package com.kaltura.client.utils.request; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Proxy; - import com.kaltura.client.Params; import com.kaltura.client.types.APIException; -import com.kaltura.client.types.ObjectBase; import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.ObjectBase; import com.kaltura.client.utils.response.OnCompletion; import com.kaltura.client.utils.response.base.Response; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Proxy; + /** * Created by tehilarozin on 14/08/2016. */ -public abstract class RequestBuilder extends BaseRequestBuilder { +public abstract class RequestBuilder extends BaseRequestBuilder { protected String id; protected String service; protected String action; - public RequestBuilder(Class type, String service, String action) { + public RequestBuilder(Class type, String service, String action) { super(type); this.service = service; this.action = action; @@ -129,7 +129,7 @@ static protected I getTokenizer(Class intrface, String prefix) { } @SuppressWarnings("unchecked") - public TK getTokenizer() throws APIException { + public TokenizerType getTokenizer() throws APIException { if(id == null) { throw new APIException(APIException.FailureStep.OnRequest, "Request is not part of multi-request"); } @@ -142,10 +142,10 @@ public TK getTokenizer() throws APIException { interfaces[i] = parentInterfaces[i]; } interfaces[parentInterfaces.length] = annotation.value(); - return (TK) Proxy.newProxyInstance(type.getClassLoader(), interfaces, new Tokenizer(id + ":result")); + return (TokenizerType) Proxy.newProxyInstance(type.getClassLoader(), interfaces, new Tokenizer(id + ":result")); } else { - return (TK) ("{" + id + ":result}"); + return (TokenizerType) ("{" + id + ":result}"); } } @@ -180,15 +180,15 @@ protected String getUrlTail() { } @SuppressWarnings("unchecked") - protected S link(String destKey, String requestId, String sourceKey) { + protected SelfType link(String destKey, String requestId, String sourceKey) { params.link(destKey, requestId, sourceKey); - return (S)this; + return (SelfType)this; } @SuppressWarnings("unchecked") - protected S setId(String id) { + protected SelfType setId(String id) { this.id = id; - return (S)this; + return (SelfType)this; } protected String getId() { @@ -196,9 +196,9 @@ protected String getId() { } @SuppressWarnings("unchecked") - public S setCompletion(OnCompletion> onCompletion) { + public SelfType setCompletion(OnCompletion> onCompletion) { this.onCompletion = onCompletion; - return (S)this; + return (SelfType)this; } @Override diff --git a/src/main/java/com/kaltura/client/utils/request/RequestBuilderData.java b/src/main/java/com/kaltura/client/utils/request/RequestBuilderData.java index e2924fed9..843fd574b 100644 --- a/src/main/java/com/kaltura/client/utils/request/RequestBuilderData.java +++ b/src/main/java/com/kaltura/client/utils/request/RequestBuilderData.java @@ -37,7 +37,7 @@ * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. */ -public abstract class RequestBuilderData { +public abstract class RequestBuilderData { protected Params params = new Params(); @@ -47,64 +47,73 @@ protected RequestBuilderData() { /** * @param clientTag Client tag */ - public void setClientTag(String clientTag){ + public SelfType setClientTag(String clientTag){ params.add("clientTag", clientTag); + return (SelfType) this; } /** * @param apiVersion API Version */ - public void setApiVersion(String apiVersion){ + public SelfType setApiVersion(String apiVersion){ params.add("apiVersion", apiVersion); + return (SelfType) this; } /** * @param partnerId Impersonated partner id */ - public void setPartnerId(Integer partnerId){ + public SelfType setPartnerId(Integer partnerId){ params.add("partnerId", partnerId); + return (SelfType) this; } /** * @param userId Impersonated user id */ - public void setUserId(Integer userId){ + public SelfType setUserId(Integer userId){ params.add("userId", userId); + return (SelfType) this; } /** * @param language Content language */ - public void setLanguage(String language){ + public SelfType setLanguage(String language){ params.add("language", language); + return (SelfType) this; } /** * @param currency Content currency */ - public void setCurrency(String currency){ + public SelfType setCurrency(String currency){ params.add("currency", currency); + return (SelfType) this; } /** * @param ks Kaltura API session */ - public void setKs(String ks){ + public SelfType setKs(String ks){ params.add("ks", ks); - } + return (SelfType) this; + } /** * @param sessionId Kaltura API session */ - public void setSessionId(String sessionId){ + public SelfType setSessionId(String sessionId){ params.add("ks", sessionId); + return (SelfType) this; } /** * @param responseProfile Response profile - this attribute will be automatically unset after every API call */ - public void setResponseProfile(BaseResponseProfile responseProfile){ + public SelfType setResponseProfile(BaseResponseProfile responseProfile){ params.add("responseProfile", responseProfile); + return (SelfType) this; } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index ec6ae413e..d3fd9c375 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -76,7 +76,7 @@ private void grant_subscription_with_history() { client.setUserId(null); BillingTransaction billingTransaction; - TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); + TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); From 9a0009411ede68c8fcac4a9e2bc2a6839514b2d7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 3 May 2018 11:47:35 +0300 Subject: [PATCH 180/605] Discount modules have been removed from test.properties --- .../com/kaltura/client/test/Properties.java | 5 -- .../kaltura/client/test/utils/DBUtils.java | 34 ++++++++++ .../client/test/utils/IngestUtils.java | 64 ++++++++++++------- src/test/resources/test.template.properties | 4 -- 4 files changed, 75 insertions(+), 32 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 7e35ddd1d..baa2f66e7 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -51,11 +51,6 @@ public class Properties { // product codes public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; - // discount modules - public static final String FIFTY_PERCENTS_ILS_DISCOUNT_NAME = "fifty_percents_ils_discount_name"; - public static final String HUNDRED_PERCENTS_UKP_DISCOUNT_NAME = "hundred_percents_ukp_discount_name"; - - public static String getProperty(String propertyKey) { if (resourceBundle == null) { resourceBundle = ResourceBundle.getBundle("test"); diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 79d1a43f1..f3e146725 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -26,6 +26,13 @@ public class DBUtils extends BaseUtils { "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; + private static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + + "where lc.code3='%S'\n" + // CURRENCY + "and dc.discount_percent=%d\n" + // percent amount + "and dc.group_id=%d\n" + // group + "and dc.[status]=1 and dc.is_active=1"; //TODO - change existing methods to work with the new convertToJSON method @@ -87,6 +94,33 @@ public static JSONArray convertToJSON(String query) throws Exception { } + public static String getDiscountByPercentAndCurrency(String currency, int percent) { + openConnection(); + try { + rs = stam.executeQuery(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, BaseTest.partnerId)); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("No data about discount with currency " + currency + "and percent " + percent + " in account " + BaseTest.partnerId); + } + String code = ""; + try { + code = rs.getString("code"); + if ("".equals(code)) { + throw new SQLException(); + } + } catch (SQLException e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("code can't be null"); + } + closeConnection(); + return code; + } + public static String getUserDataByRole(String userRole) { openConnection(); try { diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 2836185fc..fde2d9e0e 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -3,7 +3,8 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.AssetService.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; @@ -79,6 +80,7 @@ public class IngestUtils extends BaseUtils { private static boolean PP_DEFAULT_IS_RENEWABLE_VALUE = false; private static int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; + // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project public static Response> ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, Optional programDuration, Optional programDurationPeriodName, @@ -182,16 +184,22 @@ public static Response> ingestEPG(String epgChannelName, Opt int delayBetweenRetriesInSeconds = 3; int maxTimeExpectingValidResponseInSeconds = 60; await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(assetFilter, programCountValue*seasonCountValue)); + .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue*seasonCountValue)); - Response> ingestedProgrammes = AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null); + ListAssetBuilder list = AssetService.list(assetFilter, null); + list.setKs(getAnonymousKs()); + Response> ingestedProgrammes = executor.executeSync(list); // TODO: complete Asset.json at least for programs return ingestedProgrammes; } - private static Callable isDataReturned(SearchAssetFilter assetFilter, int totalCount) { - return () -> (AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).error == null && - AssetServiceImpl.list(getClient(getAnonymousKs()), assetFilter, null).results.getTotalCount() == totalCount); + private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { + return () -> { + ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null); + listAssetBuilder.setKs(ks); + return executor.executeSync(listAssetBuilder).error == null && + executor.executeSync(listAssetBuilder).results.getTotalCount() == totalCount; + }; } private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { @@ -358,7 +366,9 @@ public static Subscription ingestMPP(Optional action, Optional m String descriptionValue = description.orElse(MPP_DEFAULT_DESCRIPTION_VALUE); String startDateValue = startDate.orElse(MPP_DEFAULT_START_DATE_VALUE); String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); - String internalDiscountValue = internalDiscount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); + String defaultCurrencyOfDiscount4IngestMpp = "GBP"; + int defaultPercentageOfDiscount4IngestMpp = 100; + String internalDiscountValue = internalDiscount.orElse(DBUtils.getDiscountByPercentAndCurrency(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); String productCodeValue = productCode.orElse(""); boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); @@ -509,7 +519,9 @@ public static PricePlan ingestPP(Optional action, Optional ppCod int maxViewsValue = maxViews.orElse(PP_DEFAULT_MAX_VIEWS_VALUE); String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT)); String currencyValue = currency.orElse(CURRENCY_EUR); - String discountValue = discount.orElse(getProperty(HUNDRED_PERCENTS_UKP_DISCOUNT_NAME)); + String defaultCurrencyOfDiscount4IngestMpp = "GBP"; + int defaultPercentageOfDiscount4IngestMpp = 100; + String discountValue = discount.orElse(DBUtils.getDiscountByPercentAndCurrency(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); @@ -622,15 +634,17 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; String descriptionValue = description.orElse("My ingest PPV"); - String discountValue = discount.orElseGet(() -> getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME)); - double priceValue = price.orElseGet(() -> Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); + String defaultCurrencyOfDiscount4IngestPpv = "ILS"; + int defaultPercentageOfDiscount4IngestPpv = 50; + String discountValue = discount.orElse(DBUtils.getDiscountByPercentAndCurrency(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); + double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); String currencyValue = currency.orElse(CURRENCY_EUR); - String usageModuleValue = usageModule.orElseGet(() -> getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); + String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; - String productCodeValue = productCode.orElseGet(() -> getProperty(DEFAULT_PRODUCT_CODE)); - String firstFileTypeValue = firstFileType.orElseGet(() -> getProperty(WEB_FILE_TYPE)); - String secondFileTypeValue = secondFileType.orElseGet(() -> getProperty(MOBILE_FILE_TYPE)); + String productCodeValue = productCode.orElse(getProperty(DEFAULT_PRODUCT_CODE)); + String firstFileTypeValue = firstFileType.orElse(getProperty(WEB_FILE_TYPE)); + String secondFileTypeValue = secondFileType.orElse(getProperty(MOBILE_FILE_TYPE)); String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headerMap = new HashMap<>(); @@ -808,21 +822,24 @@ public static MediaAsset ingestVOD(Optional action, Optional cog int delayBetweenRetriesInSeconds = 3; int maxTimeExpectingValidResponseInSeconds = 60; - await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(id, actionValue)); - Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); + await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), id, actionValue)); + GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA); + getAssetBuilder.setKs(getAnonymousKs()); if (!INGEST_ACTION_DELETE.equals(actionValue)) { - mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + mediaAsset.setMediaFiles(executor.executeSync(getAssetBuilder).results.getMediaFiles()); } // TODO: 4/15/2018 add log for ingest and index failures return mediaAsset; } - private static Callable isDataReturned(String mediaId, String action) { + private static Callable isDataReturned(String ks, String mediaId, String action) { + GetAssetBuilder getAssetBuilder = AssetService.get(mediaId, AssetReferenceType.MEDIA); + getAssetBuilder.setKs(ks); if (INGEST_ACTION_DELETE.equals(action)) { - return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error != null; + return () -> (executor.executeSync(getAssetBuilder).error != null); } else { - return () -> AssetServiceImpl.get(getClient(getAnonymousKs()), mediaId, AssetReferenceType.MEDIA).error == null; + return () -> (executor.executeSync(getAssetBuilder).error == null); } } @@ -965,9 +982,10 @@ public static MediaAsset ingestBasicVOD(Optional name, String mediaType) //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); - await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(INGEST_ACTION_INSERT, id)); - Response mediaAssetDetails = AssetServiceImpl.get(getClient(getAnonymousKs()), id, AssetReferenceType.MEDIA); - mediaAsset.setMediaFiles(mediaAssetDetails.results.getMediaFiles()); + await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), INGEST_ACTION_INSERT, id)); + GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA); + getAssetBuilder.setKs(getAnonymousKs()); + mediaAsset.setMediaFiles(executor.executeSync(getAssetBuilder).results.getMediaFiles()); // TODO: 4/15/2018 add log for ingest and index failures return mediaAsset; diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index 6b13f4114..597b29e24 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -24,10 +24,6 @@ ingest_business_module_user_password=@INGEST_BUSINESS_MODULE_USER_PASSWORD@ web_file_type=@WEB_FILE_TYPE@ mobile_file_type=@MOBILE_FILE_TYPE@ -# Discount Modules -fifty_percents_ils_discount_name=@FIFTY_PERCENTS_ILS_DISCOUNT_NAME@ -hundred_percents_ukp_discount_name=@HUNDRED_PERCENTS_UKP_DISCOUNT_NAME@ - # Channels default_channel=@DEFAULT_CHANNEL@ From 94a8b66934ad6fd94337f3a921287cb2a8bcdeb3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 3 May 2018 12:00:44 +0300 Subject: [PATCH 181/605] added usage of fluent setters for builders --- .../productPriceTests/ListTests.java | 8 +++---- .../client/test/utils/IngestUtils.java | 21 +++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 57223ec24..027168c2e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -82,9 +82,7 @@ public void listSubscription() { public void listSubscriptionWithCurrencyTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); - productPriceList.setCurrency(CURRENCY_EUR); - productPriceResponse = executor.executeSync(productPriceList); + productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(CURRENCY_EUR)); // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); @@ -169,8 +167,8 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); filter.setFileIdIn(String.valueOf(getSharedWebMediaFile().getId())); filter.setIsLowest(false); - ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); - productPriceListBeforePurchase.setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null)); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter) + .setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null)); productPriceResponse = executor.executeSync(productPriceListBeforePurchase); // should be 2 ss one item is subscription an another is media file assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(2); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index fde2d9e0e..b724a6dcc 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -186,17 +186,15 @@ public static Response> ingestEPG(String epgChannelName, Opt await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue*seasonCountValue)); - ListAssetBuilder list = AssetService.list(assetFilter, null); - list.setKs(getAnonymousKs()); - Response> ingestedProgrammes = executor.executeSync(list); + Response> ingestedProgrammes = executor.executeSync( + AssetService.list(assetFilter, null).setKs(getAnonymousKs())); // TODO: complete Asset.json at least for programs return ingestedProgrammes; } private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { return () -> { - ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null); - listAssetBuilder.setKs(ks); + ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null).setKs(ks); return executor.executeSync(listAssetBuilder).error == null && executor.executeSync(listAssetBuilder).results.getTotalCount() == totalCount; }; @@ -823,10 +821,9 @@ public static MediaAsset ingestVOD(Optional action, Optional cog int delayBetweenRetriesInSeconds = 3; int maxTimeExpectingValidResponseInSeconds = 60; await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), id, actionValue)); - GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA); - getAssetBuilder.setKs(getAnonymousKs()); if (!INGEST_ACTION_DELETE.equals(actionValue)) { - mediaAsset.setMediaFiles(executor.executeSync(getAssetBuilder).results.getMediaFiles()); + mediaAsset.setMediaFiles(executor.executeSync( + AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); } // TODO: 4/15/2018 add log for ingest and index failures @@ -834,8 +831,7 @@ public static MediaAsset ingestVOD(Optional action, Optional cog } private static Callable isDataReturned(String ks, String mediaId, String action) { - GetAssetBuilder getAssetBuilder = AssetService.get(mediaId, AssetReferenceType.MEDIA); - getAssetBuilder.setKs(ks); + GetAssetBuilder getAssetBuilder = AssetService.get(mediaId, AssetReferenceType.MEDIA).setKs(ks); if (INGEST_ACTION_DELETE.equals(action)) { return () -> (executor.executeSync(getAssetBuilder).error != null); } else { @@ -983,9 +979,8 @@ public static MediaAsset ingestBasicVOD(Optional name, String mediaType) //mediaAsset.setEndDate(endDate); await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), INGEST_ACTION_INSERT, id)); - GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA); - getAssetBuilder.setKs(getAnonymousKs()); - mediaAsset.setMediaFiles(executor.executeSync(getAssetBuilder).results.getMediaFiles()); + mediaAsset.setMediaFiles(executor.executeSync( + AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); // TODO: 4/15/2018 add log for ingest and index failures return mediaAsset; From 745bbf8da375bf138162e84ad2f0aeacc0a45209 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 3 May 2018 12:13:22 +0300 Subject: [PATCH 182/605] refacor ottUser listTests --- .../servicesTests/ottUserTests/ListTests.java | 77 ++++++++++++------- .../ottUserTests/UpdateTests.java | 3 +- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index 5e22783aa..0ea514aa9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -1,19 +1,20 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.List; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.list; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUserFromHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; import static com.kaltura.client.test.utils.OttUserUtils.getUserById; @@ -21,80 +22,104 @@ public class ListTests extends BaseTest { - private Client client; private Household household; private Response> householdUserListResponse; private int numberOfUsersInHousehold = 4; + private int numberOfDevicesInHousehold = 1; + @BeforeClass private void ottUser_list_tests_setup() { - client = getClient(null); - household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, 1, false); + household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/list - list from master ks") @Test private void list_from_master_ks() { + // get master user from household HouseholdUser masterUser = getMasterUserFromHousehold(household); - Response loginResponse = login(client, partnerId, getUserById(Integer.parseInt(masterUser.getUserId())).getUsername(), - defaultUserPassword, null, null); + // login master user + String username = getUserById(Integer.parseInt(masterUser.getUserId())).getUsername(); + LoginOttUserBuilder loginOttUserBuilder = login(partnerId, username, defaultUserPassword); + Response loginResponse = executor.executeSync(loginOttUserBuilder); - client.setKs(loginResponse.results.getLoginSession().getKs()); - householdUserListResponse = list(client, null); + // list household users + ListOttUserBuilder listOttUserBuilder = list() + .setKs(loginResponse.results.getLoginSession().getKs()); + householdUserListResponse = executor.executeSync(listOttUserBuilder); List users = householdUserListResponse.results.getObjects(); - assertThat(loginResponse.error).isNull(); + // assert users list size + assertThat(householdUserListResponse.error).isNull(); assertThat(users.size()).isEqualTo(numberOfUsersInHousehold + 1); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/list - get list with filter using idIn") @Test private void list_with_filter_idIn() { + // get users from household List householdUsers = getUsersListFromHouseHold(household); - OTTUserFilter filter = new OTTUserFilter(); - String idIn = householdUsers.get(0).getUserId() + "," + householdUsers.get(1).getUserId(); - filter.setIdIn(idIn); + // set user filter + OTTUserFilter ottUserFilter = new OTTUserFilter(); + String idIn = getConcatenatedString(householdUsers.get(0).getUserId(), householdUsers.get(1).getUserId()); + ottUserFilter.setIdIn(idIn); - client.setKs(getAdministratorKs()); - householdUserListResponse = list(client, filter); + // list household users + ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) + .setKs(getAdministratorKs()); + householdUserListResponse = executor.executeSync(listOttUserBuilder); List users = householdUserListResponse.results.getObjects(); + // assert users list size assertThat(householdUserListResponse.error).isNull(); assertThat(users.size()).isEqualTo(2); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/list - get list with filter using usernameEqual") @Test private void list_withd_filter_usernameEqual() { + // get users from household List householdUsers = getUsersListFromHouseHold(household); - OTTUserFilter filter = new OTTUserFilter(); + // set user filter + OTTUserFilter ottUserFilter = new OTTUserFilter(); String usernameEqual = getUserById(Integer.valueOf(householdUsers.get(0).getUserId())).getUsername(); + ottUserFilter.setUsernameEqual(usernameEqual); - filter.setUsernameEqual(usernameEqual); - - client.setKs(getAdministratorKs()); - householdUserListResponse = list(client, filter); + // list household users + ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) + .setKs(getAdministratorKs()); + householdUserListResponse = executor.executeSync(listOttUserBuilder); List users = householdUserListResponse.results.getObjects(); + // assert users list size assertThat(householdUserListResponse.error).isNull(); assertThat(users.size()).isEqualTo(1); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/list - get list with not valid filter") @Test private void list_with_not_valid_filter() { + // get users from household List householdUsers = getUsersListFromHouseHold(household); - OTTUserFilter filter = new OTTUserFilter(); - filter.setIdIn(householdUsers.get(0).getUserId()); - filter.setUsernameEqual(getUserById(Integer.valueOf(householdUsers.get(1).getUserId())).getUsername()); + // set user filter + OTTUserFilter ottUserFilter = new OTTUserFilter(); + ottUserFilter.setIdIn(householdUsers.get(0).getUserId()); + ottUserFilter.setUsernameEqual(getUserById(Integer.valueOf(householdUsers.get(1).getUserId())).getUsername()); - client.setKs(getAdministratorKs()); - householdUserListResponse = list(client, filter); + // list household users + ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) + .setKs(getAdministratorKs()); + householdUserListResponse = executor.executeSync(listOttUserBuilder); + // assert error 500038 is return assertThat(householdUserListResponse.results).isNull(); assertThat(householdUserListResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500038).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index 7d1ef3e5c..30b053ddc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -12,7 +11,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -28,6 +26,7 @@ public class UpdateTests extends BaseTest { @BeforeClass private void ottUser_update_tests_setup() { client = getClient(null); + // register user ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); user = ottUserResponse.results; originalUserEmail = user.getEmail(); From 7b5b9c3a30f0d47ad709b7fe3ae6d316a8718ce4 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 3 May 2018 12:47:33 +0300 Subject: [PATCH 183/605] add severity annotation to ottUser tests --- .../ottUserTests/AddRoleTests.java | 46 +++++++------------ .../ottUserTests/AnonymousLoginTests.java | 4 ++ .../ottUserTests/DeleteTests.java | 5 ++ .../ottUserTests/GetEncryptedUserIdTests.java | 3 ++ .../servicesTests/ottUserTests/GetTests.java | 4 +- .../ottUserTests/LoginTests.java | 19 ++++---- .../ottUserTests/LoginWithPinTests.java | 5 ++ .../ottUserTests/LogoutTests.java | 3 ++ .../ottUserTests/RegisterTests.java | 4 +- .../ResendActivationTokenTests.java | 3 ++ .../ottUserTests/ResetPasswordTests.java | 3 ++ .../ottUserTests/UpdateDynamicDataTests.java | 3 ++ .../ottUserTests/UpdateLoginDataTests.java | 4 ++ .../ottUserTests/UpdateTests.java | 5 ++ .../client/test/utils/SessionUtils.java | 2 - 15 files changed, 72 insertions(+), 41 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java index b34bfc0c8..35b08a0ae 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java @@ -1,54 +1,42 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.OTTUser; -import com.kaltura.client.types.UserRole; -import com.kaltura.client.types.UserRoleFilter; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.assertj.core.api.Assertions; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.List; - +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class AddRoleTests extends BaseTest { + private OTTUser user; @BeforeClass private void ottUser_addRole_tests_setup() { - user = generateOttUser(); - - // OttUser/action/register - OttUserService.RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, user, defaultUserPassword); - registerOttUserBuilder.setKs(null); - Response ottUserResponse = executor.executeSync(registerOttUserBuilder); - user = ottUserResponse.results; + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/addRole - addRole") @Test(enabled = false) // TODO: 3/27/2018 finish and fix test - private void addRole() { - // set client - client.setKs(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getId())); - - OttUserServiceImpl.addRole(client, 3); - - UserRoleFilter filter = new UserRoleFilter(); - filter.setIdIn(user.getId()); - - client.setUserId(null); - Response> userRoleListResponse = UserRoleServiceImpl.list(client, filter); - List userRoles = userRoleListResponse.results.getObjects(); + private void addRoleTest() { + int roleId = 3; - for (UserRole userRole : userRoles) { - System.out.println(userRole.getId().toString()); - } + // add role + AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(roleId) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + Response booleanResponse = executor.executeSync(addRoleOttUserBuilder); + Assertions.assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + // TODO: 3/27/2018 finish and fix test } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java index 0ce6eb813..f5577338d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java @@ -4,6 +4,8 @@ import com.kaltura.client.types.LoginSession; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; import static com.kaltura.client.services.OttUserService.anonymousLogin; @@ -15,6 +17,7 @@ public class AnonymousLoginTests extends BaseTest { private Response loginSessionResponse; + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() private void anonymousLoginTest() { @@ -24,6 +27,7 @@ private void anonymousLoginTest() { assertThat(loginSessionResponse.results.getKs()).isNotNull(); } + @Severity(SeverityLevel.MINOR) @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") @Test() private void anonymousLogin_with_wrong_partnerId() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 93b33f06b..9c0161d14 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -9,6 +9,8 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -35,6 +37,7 @@ private void ottUser_delete_tests_setup() { household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/delete - delete") @Test private void delete() { @@ -60,6 +63,7 @@ private void delete() { assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/delete - delete master user: error 2031") @Test(enabled = true) private void delete_master_user() { @@ -78,6 +82,7 @@ private void delete_master_user() { assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2031).getCode()); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/delete - delete default user: error 2030") @Test(enabled = true) private void delete_default_user() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java index 21ced1986..c7d637403 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java @@ -5,6 +5,8 @@ import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,6 +24,7 @@ private void ottUser_getEncryptedUserId_tests_setup() { user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/getEncryptedUserId - getEncryptedUserId") @Test private void getEncryptedUserIdTest() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 41394914f..10c4e9070 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -5,6 +5,8 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -27,7 +29,7 @@ private void ottUser_get_tests_setup() { user = loginResponse.results.getUser(); } - // get test + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/get - get") @Test private void getTest() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 821f89a01..274c98d95 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -1,35 +1,35 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; + +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class LoginTests extends BaseTest { - private Client client; private OTTUser user; private Response loginResponse; @BeforeClass private void ottUser_login_tests_setup() { - client = getClient(null); - Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); - user = ottUserResponse.results; + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; } -// @Issue("BEO-4933") + @Severity(SeverityLevel.CRITICAL) @Test(description = "ottUser/action/login - login") private void login() { loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); @@ -39,6 +39,7 @@ private void login() { assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/login - login with wrong password - error 1011") @Test private void login_with_wrong_password() { @@ -48,6 +49,7 @@ private void login_with_wrong_password() { assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/login - login with wrong username - error 1011") @Test private void login_with_wrong_username() { @@ -57,6 +59,7 @@ private void login_with_wrong_username() { assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/login - login with wrong partnerId - error 500006") @Test() private void login_with_wrong_partnerId() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java index bf8716ca7..0d1c9d22d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -9,6 +9,8 @@ import com.kaltura.client.types.UserLoginPin; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -37,6 +39,7 @@ private void ottUser_login_tests_setup() { adminClient.setUserId(Integer.parseInt(user.getId())); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/loginWithPin - loginWithPin with secret") @Test private void loginWithPin_with_secret() throws InterruptedException { @@ -50,6 +53,7 @@ private void loginWithPin_with_secret() throws InterruptedException { assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/loginWithPin - loginWithPin with wrong secret - error 2008") @Test private void loginWithPin_with_wrong_secret() { @@ -62,6 +66,7 @@ private void loginWithPin_with_wrong_secret() { assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2008).getCode()); } + @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") @Test(groups = "slow") private void loginWithPin_with_expired_pinCode() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java index de33506bd..ed91d4695 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java @@ -8,6 +8,8 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -33,6 +35,7 @@ private void ottUser_logout_tests_setup() { user = ottUserResponse.results; } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/logout - logout") @Test private void logout() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java index e87d26375..561e9c160 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java @@ -6,6 +6,8 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -25,7 +27,7 @@ private void ottUser_login_tests_setup() { user = generateOttUser(); } - // login tests + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/register - register") @Test private void register() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java index 847de62f1..8176bfd56 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -6,6 +6,8 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -28,6 +30,7 @@ private void ottUser_resendActivationToken_tests_setup() { login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resendActivationToken - resendActivationToken") @Test(enabled = false) private void resendActivationToken() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java index e29f0b6c4..59fd47c69 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java @@ -7,6 +7,8 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -28,6 +30,7 @@ private void ottUser_resetPassword_tests_setup() { user = ottUserResponse.results; } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resetPassword - resetPassword") @Test(enabled = false) private void resetPassword() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java index c42d4785b..dc19cc269 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java @@ -8,6 +8,8 @@ import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -27,6 +29,7 @@ private void ottUser_updateDynamicData_tests_setup() { user = ottUserResponse.results; } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateDynamicData - updateDynamicData") @Test private void updateDynamicData() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index dd9ad0d34..83bee9b9b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -7,6 +7,8 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; @@ -22,6 +24,7 @@ public class UpdateLoginDataTests extends BaseTest { private Response ottUserResponse; + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateLoginData - updateLoginData") @Test private void updateLoginData() { @@ -49,6 +52,7 @@ private void updateLoginData() { assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateLoginData - updateLoginData with administratorKs") @Test private void updateLoginData_with_administratorKs() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index 30b053ddc..8b5345d10 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -2,11 +2,14 @@ import com.kaltura.client.Client; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.Entitlement; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Issue; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -32,6 +35,7 @@ private void ottUser_update_tests_setup() { originalUserEmail = user.getEmail(); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update") @Test private void update() { @@ -59,6 +63,7 @@ private void update() { assertThat(user.getEmail()).isEqualTo(originalUserEmail); } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update with administratorKs") @Issue("BEO-4919") @Test(enabled = true) diff --git a/src/test/java/com/kaltura/client/test/utils/SessionUtils.java b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java index 90f74d1fe..cb10b1a59 100644 --- a/src/test/java/com/kaltura/client/test/utils/SessionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java @@ -1,12 +1,10 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.SessionServiceImpl; import com.kaltura.client.types.Session; import com.kaltura.client.utils.response.base.Response; import static com.kaltura.client.test.tests.BaseTest.getAdministratorKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; public class SessionUtils extends BaseUtils { From 2157f2b7d430c3f545adc89ff108a19a6c6d77a9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 3 May 2018 12:47:59 +0300 Subject: [PATCH 184/605] Refactored sessionUtils class --- .../com/kaltura/client/test/utils/SessionUtils.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/SessionUtils.java b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java index 90f74d1fe..92c175268 100644 --- a/src/test/java/com/kaltura/client/test/utils/SessionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SessionUtils.java @@ -1,20 +1,21 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.SessionServiceImpl; +import com.kaltura.client.services.SessionService; import com.kaltura.client.types.Session; import com.kaltura.client.utils.response.base.Response; +import static com.kaltura.client.test.tests.BaseTest.executor; import static com.kaltura.client.test.tests.BaseTest.getAdministratorKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; public class SessionUtils extends BaseUtils { // Return user id according to the ks provided public static String getUserIdByKs(String ks) { - Client client = getClient(getAdministratorKs()); - Response getSessionResponse = SessionServiceImpl.get(client,ks); + SessionService.GetSessionBuilder getSessionBuilder = SessionService.get(ks); + getSessionBuilder.setKs(getAdministratorKs()); + Response getSessionResponse = executor.executeSync(getSessionBuilder); + return getSessionResponse.results.getUserId(); } } From f5758e163cdc59d2e8e2a71fd6597d01ff773439 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 3 May 2018 14:00:41 +0300 Subject: [PATCH 185/605] Refactored AssetUtils class --- .../com/kaltura/client/test/utils/AssetUtils.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index d96e21902..d0b40b0ab 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -1,8 +1,7 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.test.servicesImpl.AssetServiceImpl; +import com.kaltura.client.services.AssetService; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -10,8 +9,9 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.services.AssetService.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; -import static com.kaltura.client.test.tests.BaseTest.getClient; +import static com.kaltura.client.test.tests.BaseTest.executor; public class AssetUtils extends BaseUtils { @@ -41,10 +41,13 @@ public static ChannelFilter getChannelFilter(int idEqual, @Nullable String ksql, } public static List getAssetFileIds(String assetId) { - Client client = getClient(getSharedMasterUserKs()); AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); - Response assetResponse = AssetServiceImpl.get(client, assetId, assetReferenceType); + + GetAssetBuilder getAssetBuilder = AssetService.get(assetId,assetReferenceType); + getAssetBuilder.setKs(getSharedMasterUserKs()); + Response assetResponse = executor.executeSync(getAssetBuilder); + List mediafiles = assetResponse.results.getMediaFiles(); List fileIdsList = new ArrayList<>(); From f6ac639d0e662fa4c876d3ae2ec0da222331e353 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 3 May 2018 14:09:05 +0300 Subject: [PATCH 186/605] Updated AssetHistoryActionCleanLists class --- .../AssetHistoryActionCleanLists.java | 26 ++++++++++++------- .../client/test/utils/AssetHistoryUtils.java | 14 +++++----- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index 5c6868da2..65dfbb24d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -29,6 +29,7 @@ public class AssetHistoryActionCleanLists extends BaseTest { private int numbOfDevices = 1; private int numOfUsers = 1; + @BeforeClass private void add_tests_before_class() { @@ -39,11 +40,12 @@ private void add_tests_before_class() { private void cleanHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); @@ -73,11 +75,12 @@ private void cleanHistory() { private void cleanSpecifcAssetHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId1), null, WatchStatus.ALL, null); @@ -104,11 +107,12 @@ private void cleanSpecifcAssetHistory() { private void cleanSpecifcAssetTypeHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(EPISODE_MEDIA_TYPE_ID)); @@ -136,11 +140,12 @@ private void cleanSpecifcAssetTypeHistory() { private void cleanAssetsAccordingToWatchStatusDone() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); @@ -167,11 +172,12 @@ private void cleanAssetsAccordingToWatchStatusDone() { private void cleanAssetsAccordingToWatchStatusProgress() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java index d218cd5ce..2a15cf5cf 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java @@ -1,10 +1,9 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; -import com.kaltura.client.test.servicesImpl.BookmarkServiceImpl; +import com.kaltura.client.services.BookmarkService; import com.kaltura.client.types.AssetHistoryFilter; import com.kaltura.client.types.Bookmark; import com.kaltura.client.types.MediaAsset; @@ -12,7 +11,7 @@ import javax.annotation.Nullable; import java.util.Optional; -import static com.kaltura.client.test.tests.BaseTest.getClient; +import static com.kaltura.client.test.tests.BaseTest.executor; public class AssetHistoryUtils extends BaseUtils { @@ -28,17 +27,20 @@ public static AssetHistoryFilter getAssetHistoryFilter(@Nullable String assetIdI } // Ingest asset, bookmark it and return the asset id - public static Long ingestAssetAndPerformBookmark(Client client, String mediaType, int position, BookmarkActionType bookmarkActionType) { + public static Long ingestAssetAndPerformBookmark(String ks, String mediaType, int position, BookmarkActionType bookmarkActionType) { // Ingest asset MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); Long assetId = mediaAsset.getId(); int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + // Movie asset bookmark AssetType assetType = AssetType.MEDIA; Bookmark bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, assetType, bookmarkActionType); - //bookmark/action/add - Movie asset - BookmarkServiceImpl.add(client, bookmark); + + BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + addBookmarkBuilder.setKs(ks); + executor.executeSync(addBookmarkBuilder); return assetId; } From 010c00d02a00d1afd5e7d952a686dc84152fb632 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 3 May 2018 14:11:27 +0300 Subject: [PATCH 187/605] uPDATED AssetHistoryListTests class --- .../AssetHistoryListTests.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index d4cd64997..96493d98a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -38,11 +38,12 @@ private void add_tests_before_class() { private void vodAssetHistory() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); @@ -85,12 +86,13 @@ private void vodAssetHistory() { private void vodAssetHistoryFilteredByAssetId() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - Long assetId3 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId3 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId2), null, WatchStatus.ALL, null); @@ -124,11 +126,13 @@ private void vodAssetHistoryFilteredByAssetId() { private void vodAssetHistoryFilteredByAssetType() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + // Ingest and bookmark first asset (movie in first play) - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(MOVIE_MEDIA_TYPE_ID)); @@ -153,11 +157,13 @@ private void vodAssetHistoryFilteredByAssetType() { private void vodAssetHistoryFilteredByAssetProgress() { Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + // Ingest and bookmark first asset (movie in first play) - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(client, EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); From 3d8996b1d0c1876593e56ed8a8676eb4b31d8673 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 3 May 2018 14:32:03 +0300 Subject: [PATCH 188/605] refactor ottuser tests --- .../utils/request/BaseRequestBuilder.java | 2 +- .../utils/request/MultiRequestBuilder.java | 2 +- .../ottUserTests/LoginTests.java | 28 ++++++++++++++----- .../ottUserTests/RegisterTests.java | 10 ++----- .../ResendActivationTokenTests.java | 21 ++++++-------- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java b/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java index 8a5355f31..fa10c1119 100644 --- a/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java +++ b/src/main/java/com/kaltura/client/utils/request/BaseRequestBuilder.java @@ -63,7 +63,7 @@ public void setParams(Map objParams) { params.putAll(objParams); // !! null params should be checked - should not appear in request body or be presented as empty string. } - public BaseRequestBuilder setFile(String key, FileHolder value) { + public BaseRequestBuilder setFile(String key, FileHolder value) { if (files != null) { files.add(key, value); } diff --git a/src/main/java/com/kaltura/client/utils/request/MultiRequestBuilder.java b/src/main/java/com/kaltura/client/utils/request/MultiRequestBuilder.java index d1be4b4a8..93b17c346 100644 --- a/src/main/java/com/kaltura/client/utils/request/MultiRequestBuilder.java +++ b/src/main/java/com/kaltura/client/utils/request/MultiRequestBuilder.java @@ -16,7 +16,7 @@ import java.util.List; -public class MultiRequestBuilder extends BaseRequestBuilder> { +public class MultiRequestBuilder extends BaseRequestBuilder, MultiRequestBuilder> { private static final String TAG = "MultiRequestBuilder"; /** diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 274c98d95..02d3fb139 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -12,7 +11,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.OttUserService.login; +import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -31,9 +31,11 @@ private void ottUser_login_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ottUser/action/login - login") - private void login() { - loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); + private void loginTest() { + // login user + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + // assertions assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); @@ -43,8 +45,12 @@ private void login() { @Description("ottUser/action/login - login with wrong password - error 1011") @Test private void login_with_wrong_password() { - loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword + "1", null, null); + String fakePassword = "fake"; + // login user + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), fakePassword)); + + // assertions assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); } @@ -53,8 +59,12 @@ private void login_with_wrong_password() { @Description("ottUser/action/login - login with wrong username - error 1011") @Test private void login_with_wrong_username() { - loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername() + "1", defaultUserPassword, null, null); + String fakeUsername = user.getUsername() + "1"; + + // login user + loginResponse = executor.executeSync(login(partnerId, fakeUsername, defaultUserPassword)); + // assertions assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); } @@ -63,8 +73,12 @@ private void login_with_wrong_username() { @Description("ottUser/action/login - login with wrong partnerId - error 500006") @Test() private void login_with_wrong_partnerId() { - loginResponse = OttUserServiceImpl.login(client, partnerId + 1, user.getUsername(), defaultUserPassword, null, null); + int fakePartnerId = partnerId + 1; + + // login user + loginResponse = executor.executeSync(login( fakePartnerId, user.getUsername(), defaultUserPassword)); + // assertions assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java index 561e9c160..6c5f4fb37 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java @@ -1,7 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -11,27 +9,25 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class RegisterTests extends BaseTest { - private Client client; private OTTUser user; - private Response ottUserResponse; @BeforeClass private void ottUser_login_tests_setup() { - client = getClient(null); user = generateOttUser(); } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/register - register") @Test - private void register() { - ottUserResponse = OttUserServiceImpl.register(client, partnerId, user, defaultUserPassword); + private void registerTest() { + ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUsername()).isEqualTo(user.getUsername()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java index 8176bfd56..f5159135d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java @@ -1,7 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -11,33 +9,32 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class ResendActivationTokenTests extends BaseTest { - private Client client; private OTTUser user; @BeforeClass private void ottUser_resendActivationToken_tests_setup() { - client = getClient(null); - user = generateOttUser(); + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - register(client, partnerId, user, defaultUserPassword); - login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); + // login user + user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resendActivationToken - resendActivationToken") @Test(enabled = false) - private void resendActivationToken() { - Response booleanResponse = OttUserServiceImpl.resendActivationToken(client, partnerId, user.getUsername()); + private void resendActivationTokenTest() { + Response booleanResponse = executor.executeSync(resendActivationToken(partnerId, user.getUsername())); + assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); - // TODO: 4/1/2018 can't be completely tests until we verify emails + // TODO: 4/1/2018 can't be completely tested until we verify emails } } From 5496f6ee7d2bc456fca47d3a15ab8a1b59fb9bae Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 3 May 2018 14:44:23 +0300 Subject: [PATCH 189/605] refactor ottuser tests --- .../ottUserTests/LoginTests.java | 1 - .../ottUserTests/LogoutTests.java | 26 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java index 02d3fb139..32a4e36ab 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java @@ -20,7 +20,6 @@ public class LoginTests extends BaseTest { private OTTUser user; - private Response loginResponse; @BeforeClass diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java index ed91d4695..3c66f3062 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.LoginResponse; @@ -13,14 +12,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.login; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class LogoutTests extends BaseTest { - private Client client; private OTTUser user; private Response loginResponse; @@ -29,9 +26,8 @@ public class LogoutTests extends BaseTest { @BeforeClass private void ottUser_logout_tests_setup() { - client = getClient(null); - - Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + // register user + Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); user = ottUserResponse.results; } @@ -39,14 +35,20 @@ private void ottUser_logout_tests_setup() { @Description("ottUser/action/logout - logout") @Test private void logout() { - loginResponse = login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); - client.setKs(loginResponse.results.getLoginSession().getKs()); + // login user + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + String userKs = loginResponse.results.getLoginSession().getKs(); + + // logout user + LogoutOttUserBuilder logoutOttUserBuilder = OttUserService.logout().setKs(userKs); + booleanResponse = executor.executeSync(logoutOttUserBuilder); - booleanResponse = OttUserServiceImpl.logout(client); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); - Response ottUserResponse = OttUserServiceImpl.get(client); + // assert can't get user after logout + GetOttUserBuilder getOttUserBuilder = OttUserService.get().setKs(userKs); + Response ottUserResponse = executor.executeSync(getOttUserBuilder); assertThat(ottUserResponse.results).isNull(); assertThat(ottUserResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500016).getCode()); } From 71bda2e834c7b52416ba7ca33033d46cb3e4f120 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 3 May 2018 15:04:24 +0300 Subject: [PATCH 190/605] Updated GrantTests.java --- .../entitlementTests/GrantTests.java | 187 ++++++++++-------- 1 file changed, 109 insertions(+), 78 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index d3fd9c375..f00ad7cbe 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -1,11 +1,14 @@ package com.kaltura.client.test.tests.servicesTests.entitlementTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.EntityReferenceBy; import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionHistoryOrderBy; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.test.servicesImpl.*; +import com.kaltura.client.services.*; +import com.kaltura.client.services.EntitlementService.*; +import com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; +import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; +import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.HouseholdUtils; @@ -15,7 +18,6 @@ import io.qameta.allure.Issue; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -42,8 +44,6 @@ private void grant_test_before_class() { @Test(description = "entitlement/action/grant - grant subscription with history = true") private void grant_subscription_with_history() { - Client client = getClient(getAdministratorKs()); - // set household Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); @@ -51,19 +51,21 @@ private void grant_subscription_with_history() { // grant subscription - history = true - client.setUserId(Integer.valueOf(user.getUserId())); - Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, true, null); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(subscriptionId, TransactionType.SUBSCRIPTION, true, 0) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); - // verify other user from the household entitled to granted subscription - client.setUserId(Integer.valueOf(masterUser.getUserId())); - ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.subscriptionIdIn(String.valueOf(subscriptionId)); - Response> productPriceListResponse = ProductPriceServiceImpl.list(client, productPriceFilter); + ProductPriceService.ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter) + .setUserId(Integer.valueOf(masterUser.getUserId())) + .setKs(getAdministratorKs()); + Response> productPriceListResponse = executor.executeSync(listProductPriceBuilder); ProductPrice productPrice = productPriceListResponse.results.getObjects().get(0); assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); @@ -72,15 +74,15 @@ private void grant_subscription_with_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); - client.setUserId(null); - BillingTransaction billingTransaction; TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + TransactionHistoryService.ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -90,7 +92,10 @@ private void grant_subscription_with_history() { // check transaction return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -98,52 +103,56 @@ private void grant_subscription_with_history() { //delete household for cleanup - HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); + //HouseholdService.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); + DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); } @Test(description = "entitlement/action/grant - grant subscription with history = false") private void grant_subscription_without_history() { - Client client = getClient(getAdministratorKs()); - // set household Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); // grant subscription - history = true - client.setUserId(Integer.valueOf(user.getUserId())); - Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(subscriptionId, TransactionType.SUBSCRIPTION, false, 0) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); - // check transaction not return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); - client.setUserId(null); - TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + TransactionHistoryService.ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); - // check transaction not return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); //delete household for cleanup - HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); + DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); } @Test(description = "entitlement/action/grant - grant ppv with history = true") private void grant_ppv_with_history() { - Client client = getClient(getAdministratorKs()); - // set household Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); @@ -151,19 +160,22 @@ private void grant_ppv_with_history() { // grant subscription - history = true - client.setUserId(Integer.valueOf(user.getUserId())); - Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); // verify other user from the household entitled to granted subscription - client.setUserId(Integer.valueOf(masterUser.getUserId())); - ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.fileIdIn(String.valueOf(contentId)); - Response> productPriceListResponse = ProductPriceServiceImpl.list(client, productPriceFilter); + ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter) + .setUserId(Integer.valueOf(masterUser.getUserId())) + .setKs(getAdministratorKs()); + Response> productPriceListResponse = executor.executeSync(listProductPriceBuilder); ProductPrice productPrice = productPriceListResponse.results.getObjects().get(0); assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); @@ -172,15 +184,15 @@ private void grant_ppv_with_history() { // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); - client.setUserId(null); - BillingTransaction billingTransaction; TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -190,7 +202,10 @@ private void grant_ppv_with_history() { // check transaction return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -198,13 +213,13 @@ private void grant_ppv_with_history() { //delete household for cleanup - HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); + DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); } @Test(description = "entitlement/action/grant - grant ppv with history = false") private void grant_ppv_without_history() { - Client client = getClient(getAdministratorKs()); - // set household Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); @@ -212,22 +227,24 @@ private void grant_ppv_without_history() { // grant subscription - history = true - client.setUserId(Integer.valueOf(user.getUserId())); - Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); // check transaction return in transactionHistory by user - client.setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); - client.setUserId(null); - BillingTransaction billingTransaction; TransactionHistoryFilter transactionHistoryfilter = new TransactionHistoryFilter(); transactionHistoryfilter.orderBy(TransactionHistoryOrderBy.CREATE_DATE_ASC.getValue()); transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -237,7 +254,10 @@ private void grant_ppv_without_history() { // check transaction return in transactionHistory by household transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); - billingTransactionListResponse = TransactionHistoryServiceImpl.list(client, transactionHistoryfilter, null); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) + .setUserId(null); + billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); billingTransaction = billingTransactionListResponse.results.getObjects().get(0); @@ -245,7 +265,9 @@ private void grant_ppv_without_history() { //delete household for cleanup - HouseholdServiceImpl.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); + DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); } @Test(description = "entitlement/action/grant - grant ppv with wrong id - error 6001") @@ -256,9 +278,11 @@ private void grant_ppv_with_wrong_id() { HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); // grant ppv with wrong id - Client client = getClient(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - Response booleanResponse = EntitlementServiceImpl.grant(client, productId, TransactionType.PPV, true, contentId); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(productId, TransactionType.PPV, true, contentId) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); + // assert error 6001 is return assertThat(booleanResponse.results).isEqualTo(null); @@ -270,15 +294,17 @@ private void grant_purchased_ppv() { // get user form test shared household HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); - // set client - Client client = getClient(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - // grant ppv - first time - EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + executor.executeSync(grantEntitlementBuilder); // grant ppv - second time - Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, true, contentId); + grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 3021 is return assertThat(booleanResponse.results).isEqualTo(null); @@ -290,15 +316,17 @@ private void grant_purchased_subscription() { // get user form test shared household HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); - // set client - Client client = getClient(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getUserId())); - // grant subscription - first time - EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(subscriptionId, TransactionType.SUBSCRIPTION, false, 0) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + executor.executeSync(grantEntitlementBuilder); // grant subscription - second time - Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + grantEntitlementBuilder = EntitlementService.grant(subscriptionId, TransactionType.SUBSCRIPTION, false, 0) + .setUserId(Integer.valueOf(user.getUserId())) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 3024 is return assertThat(booleanResponse.results).isEqualTo(null); @@ -320,16 +348,16 @@ private void grant_ppv_with_missing_contentId() { @Test(description = "entitlement/action/grant - user not in domain - error 1005") private void grant_ppv_user_not_in_domain() { // get user form test shared household - Client client = getClient(null); - Response ottUserResponse = OttUserServiceImpl.register(client, partnerId, OttUserUtils.generateOttUser(), defaultUserPassword); + OttUserService.RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, OttUserUtils.generateOttUser(), defaultUserPassword); + Response ottUserResponse = executor.executeSync(registerOttUserBuilder); OTTUser user = ottUserResponse.results; - // set client with user not from household - client.setKs(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getId())); - + // set user not from household + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, false, contentId) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); // grant subscription - Response booleanResponse = EntitlementServiceImpl.grant(client, ppvId, TransactionType.PPV, false, contentId); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 1005 is return assertThat(booleanResponse.results).isEqualTo(null); @@ -344,12 +372,15 @@ private void grant_ppv_user_suspend() { HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); // suspend household - Client client = getClient(getAdministratorKs()); - client.setUserId(Integer.valueOf(masterUser.getUserId())); - HouseholdServiceImpl.suspend(client, null); + HouseholdService.suspend(0) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); // grant subscription to suspend user - Response booleanResponse = EntitlementServiceImpl.grant(client, subscriptionId, TransactionType.SUBSCRIPTION, false, null); + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(subscriptionId, TransactionType.SUBSCRIPTION, false, 0) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 2001 is return assertThat(booleanResponse.results).isEqualTo(null); From 3eb8738653fdd15bd1f87d3cc8cbe43a2ad7e6d9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 3 May 2018 16:27:29 +0300 Subject: [PATCH 191/605] refactor ottUser tests --- .../ottUserTests/LoginWithPinTests.java | 50 ++++++++++++------- .../ottUserTests/ResetPasswordTests.java | 23 ++++----- .../ottUserTests/UpdateDynamicDataTests.java | 24 ++++----- .../ottUserTests/UpdateLoginDataTests.java | 2 - .../ottUserTests/UpdateTests.java | 38 ++++++-------- 5 files changed, 69 insertions(+), 68 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java index 0d1c9d22d..bf2f0baf2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java @@ -1,8 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; -import com.kaltura.client.test.servicesImpl.UserLoginPinServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -14,14 +11,15 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.UserLoginPinService.AddUserLoginPinBuilder; +import static com.kaltura.client.services.UserLoginPinService.add; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class LoginWithPinTests extends BaseTest { - private Client emptyClient, adminClient; private OTTUser user; private Response loginResponse; @@ -31,23 +29,27 @@ public class LoginWithPinTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { - emptyClient = getClient(null); - Response ottUserResponse = register(emptyClient, partnerId, generateOttUser(), defaultUserPassword); + // register user + Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); user = ottUserResponse.results; - - adminClient = getClient(getAdministratorKs()); - adminClient.setUserId(Integer.parseInt(user.getId())); } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/loginWithPin - loginWithPin with secret") @Test private void loginWithPin_with_secret() throws InterruptedException { - userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); + // add pin + AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); + // login with pin String pin = userLoginPinResponse.results.getPinCode(); - loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, partnerId, pin, null, SECRET); + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, SECRET); + loginResponse = executor.executeSync(loginWithPinOttUserBuilder); + // assert assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession()).isNotNull(); assertThat(loginResponse.results.getUser().getUsername()).isEqualTo(user.getUsername()); @@ -57,11 +59,19 @@ private void loginWithPin_with_secret() throws InterruptedException { @Description("ottUser/action/loginWithPin - loginWithPin with wrong secret - error 2008") @Test private void loginWithPin_with_wrong_secret() { - userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); - + // add pin + AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); + + // login with pin and wrong secret + String wrongSecret = SECRET + 1; String pin = userLoginPinResponse.results.getPinCode(); - loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, partnerId, pin, null, SECRET + 1); + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, wrongSecret); + loginResponse = executor.executeSync(loginWithPinOttUserBuilder); + // assert error 2008 is return assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2008).getCode()); } @@ -70,12 +80,18 @@ private void loginWithPin_with_wrong_secret() { @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") @Test(groups = "slow") private void loginWithPin_with_expired_pinCode() { - userLoginPinResponse = UserLoginPinServiceImpl.add(adminClient, SECRET); + // add pin + AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); + // login with expired pin String pin = userLoginPinResponse.results.getPinCode(); // sleep for 1.5 minutes try { Thread.sleep(120000); } catch (InterruptedException e) { e.printStackTrace(); } - loginResponse = OttUserServiceImpl.loginWithPin(emptyClient, partnerId, pin, null, SECRET); + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, SECRET); + loginResponse = executor.executeSync(loginWithPinOttUserBuilder); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2004).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java index 59fd47c69..8a23ae50a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java @@ -1,9 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -12,36 +9,34 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class ResetPasswordTests extends BaseTest { - private Client client; private OTTUser user; - private Response booleanResponse; - @BeforeClass private void ottUser_resetPassword_tests_setup() { - client = getClient(null); - Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + // register user + Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); user = ottUserResponse.results; } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resetPassword - resetPassword") @Test(enabled = false) - private void resetPassword() { - client.setKs(getAdministratorKs()); - booleanResponse = OttUserServiceImpl.resetPassword(client, partnerId, user.getUsername()); + private void resetPasswordTest() { + // reset user password + ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = resetPassword(partnerId, user.getUsername()) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(resetPasswordOttUserBuilder); + // assert success assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); - client = getClient(null); - Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); // TODO: 4/1/2018 finsih the test after bug BEO-4884 will be fixed } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java index dc19cc269..67063a3aa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java @@ -1,7 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.OTTUserDynamicData; @@ -13,37 +11,39 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class UpdateDynamicDataTests extends BaseTest { - private Client client; private OTTUser user; @BeforeClass private void ottUser_updateDynamicData_tests_setup() { - client = getClient(null); - Response ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + // register user + Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); user = ottUserResponse.results; } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateDynamicData - updateDynamicData") @Test - private void updateDynamicData() { - // set client - client.setKs(getAdministratorKs()); - client.setUserId(Integer.valueOf(user.getId())); - + private void updateDynamicDataTest() { + // set dynamic data String keyString = "key1"; String valueString = "value1"; StringValue value = new StringValue(); value.setValue(valueString); - Response ottUserDynamicDataResponse = OttUserServiceImpl.updateDynamicData(client, keyString, value); + // update user dynamic data + UpdateDynamicDataOttUserBuilder updateDynamicDataOttUserBuilder = updateDynamicData(keyString, value) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + Response ottUserDynamicDataResponse = executor.executeSync(updateDynamicDataOttUserBuilder); + + // assert new dynamic data assertThat(ottUserDynamicDataResponse.error).isNull(); assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo(keyString); assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo(valueString); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index 83bee9b9b..bc2c1cc09 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.Client; -import com.kaltura.client.test.servicesImpl.OttUserServiceImpl; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -11,7 +10,6 @@ import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; -import static com.kaltura.client.test.servicesImpl.OttUserServiceImpl.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java index 8b5345d10..2c87ab74f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java @@ -1,8 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.Entitlement; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -14,13 +12,13 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class UpdateTests extends BaseTest { - private Client client; private OTTUser user; private String originalUserEmail; @@ -28,9 +26,8 @@ public class UpdateTests extends BaseTest { @BeforeClass private void ottUser_update_tests_setup() { - client = getClient(null); // register user - ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); user = ottUserResponse.results; originalUserEmail = user.getEmail(); } @@ -38,25 +35,24 @@ private void ottUser_update_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update") @Test - private void update() { - // get self ks - Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); - client.setKs(loginResponse.results.getLoginSession().getKs()); + private void updateTest() { + // login user + Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + String userKs = loginResponse.results.getLoginSession().getKs(); - // update + // update user info String newUserInfo = "abc"; - user.setFirstName(newUserInfo); user.setLastName(newUserInfo); - ottUserResponse = OttUserServiceImpl.update(client, user, null); + ottUserResponse = executor.executeSync(update(user).setKs(userKs)); assertThat(ottUserResponse.error).isNull(); // get user after update - ottUserResponse = OttUserServiceImpl.get(client); + ottUserResponse = executor.executeSync(get().setKs(userKs)); user = ottUserResponse.results; - // assert + // assert user new info assertThat(ottUserResponse.error).isNull(); assertThat(user.getFirstName()).isEqualTo(newUserInfo); assertThat(user.getLastName()).isEqualTo(newUserInfo); @@ -69,24 +65,20 @@ private void update() { @Test(enabled = true) private void update_with_administratorKs() { - // update + // update user info String newUserInfo = "def"; - user.setFirstName(newUserInfo); user.setLastName(newUserInfo); // user.setAffiliateCode(null); - client.setKs(getAdministratorKs()); - ottUserResponse = OttUserServiceImpl.update(client, user, user.getId()); - + ottUserResponse = executor.executeSync(update(user).setKs(getAdministratorKs())); assertThat(ottUserResponse.error).isNull(); // get user after update - client.setUserId(Integer.valueOf(user.getId())); - ottUserResponse = OttUserServiceImpl.get(client); + ottUserResponse = executor.executeSync(get().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); user = ottUserResponse.results; - // assert + // assert user new info assertThat(ottUserResponse.error).isNull(); assertThat(user.getFirstName()).isEqualTo(newUserInfo); assertThat(user.getLastName()).isEqualTo(newUserInfo); @@ -95,6 +87,6 @@ private void update_with_administratorKs() { @AfterClass private void ottUser_update_tests_tearDown() { - OttUserServiceImpl.delete(client); + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } } From d5712fbfe477908b6fe0116f090358537e6072d8 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 3 May 2018 16:30:23 +0300 Subject: [PATCH 192/605] Remove client from ListTest class --- .../test/tests/featuresTests/productPriceTests/ListTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java index 3b273c08d..4211b5d5b 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java @@ -10,7 +10,6 @@ public class ListTests extends BaseTest { @BeforeClass public void beforeClass() { - client = getClient(getOperatorKs()); /*Ppv ppv = IngestUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, From 54964a1ecb27be698bef6ae66fa4cb3d1ea8e782 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 3 May 2018 16:53:42 +0300 Subject: [PATCH 193/605] Refactored UpdateLoginDataTests class --- .../ottUserTests/UpdateLoginDataTests.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index bc2c1cc09..55d76caad 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.Client; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -10,42 +11,46 @@ import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.OttUserService.login; +import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; -import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class UpdateLoginDataTests extends BaseTest { - private Client client; - private Response booleanResponse; private Response ottUserResponse; + private OTTUser user; @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateLoginData - updateLoginData") @Test private void updateLoginData() { - client = getClient(null); - ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); OTTUser user = ottUserResponse.results; + Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword, null, null)); + String userKs = loginResponse.results.getLoginSession().getKs(); - Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); - client.setKs(loginResponse.results.getLoginSession().getKs()); - - booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), defaultUserPassword, defaultUserPassword + 1); + UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(user.getUsername(), defaultUserPassword, defaultUserPassword + 1); + updateLoginDataOttUserBuilder.setKs(userKs); + Response booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password - loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); + + + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword, null, null)); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password - loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword + 1, null, null); + + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword + 1, null, null)); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } @@ -54,24 +59,27 @@ private void updateLoginData() { @Description("ottUser/action/updateLoginData - updateLoginData with administratorKs") @Test private void updateLoginData_with_administratorKs() { - client = getClient(getAdministratorKs()); - ottUserResponse = register(client, partnerId, generateOttUser(), defaultUserPassword); + + ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); OTTUser user = ottUserResponse.results; - booleanResponse = OttUserServiceImpl.updateLoginData(client, user.getUsername(), defaultUserPassword, defaultUserPassword + 1); + UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(user.getUsername(), defaultUserPassword, defaultUserPassword + 1); + updateLoginDataOttUserBuilder.setKs(getAdministratorKs()); + booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password - client = getClient(null); - Response loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword, null, null); + + Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword, null, null)); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password - loginResponse = OttUserServiceImpl.login(client, partnerId, user.getUsername(), defaultUserPassword + 1, null, null); + + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword + 1, null, null)); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } From c40bb5bfc504fb8d9c35682933cd080324728cb8 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 6 May 2018 07:03:37 +0300 Subject: [PATCH 194/605] fixed problems with shared non-master user --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 64b4e6538..4d8e4897a 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -202,7 +202,8 @@ public static Household getSharedHousehold() { if (user.getIsMaster() != null && user.getIsMaster()) { sharedMasterUser = user; } - if (user.getIsMaster() == null && user.getIsDefault() == null) { + // TODO: ask Alon if we have cases when commented part should be there? What tests related to that logic? + if (user.getIsMaster() == null/* && user.getIsDefault() == null*/) { sharedUser = user; } } From ad201c4914326e6d007a1030971b836fca2138ef Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 6 May 2018 10:53:36 +0300 Subject: [PATCH 195/605] Fixed problems with using client.set... --- .../appTokenTests/AppTokenStartSessionTests.java | 8 -------- .../com/kaltura/client/test/utils/HouseholdUtils.java | 5 ----- 2 files changed, 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index e71e22793..7c1aac4b5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -28,7 +28,6 @@ public class AppTokenStartSessionTests extends BaseTest { private String udid1 = "1234567890"; private String udid2 = "9876543210"; private AppToken appToken = new AppToken(); - public static Client client; private String sessionPrivileges = "key1:value1,key2:value2"; private Long expiryDate; private String anonymousKs; @@ -44,7 +43,6 @@ private void add_tests_before_class() { Response loginSessionResponse = executor.executeSync(anonymousLoginOttUserBuilder); anonymousKs = loginSessionResponse.results.getKs(); - client.setKs(null); expiryDate = BaseUtils.getTimeInEpoch(1); } @@ -61,8 +59,6 @@ private void startSessionSha1() { addAppTokenBuilder.setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); - client.setKs(anonymousKs); - // Generate new token hash String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); @@ -102,14 +98,10 @@ private void startSessionSha256() { appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); // Invoke AppToken/action/add - client.setKs(getOperatorKs()); - AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); addAppTokenBuilder.setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); - client.setKs(anonymousKs); - // Generate new token hash String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 3d5d9665c..6f8fce07d 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -1,16 +1,13 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.Client; import com.kaltura.client.Logger; import com.kaltura.client.services.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; - import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Random; - import static com.kaltura.client.services.HouseholdDeviceService.*; import static com.kaltura.client.services.HouseholdPaymentGatewayService.*; import static com.kaltura.client.services.HouseholdUserService.*; @@ -99,8 +96,6 @@ public static Household createHouseHold(int numberOfUsersInHoushold, int numberO if (isPreparePG) { // TODO: there should be added logic with getting and using default PG currently it all hardcoded - client.setKs(getOperatorKs()); - client.setUserId(Integer.valueOf(masterUser.getId())); //HouseholdPaymentGateway/action/setChargeId SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.setChargeID("0110151474255957105", "1234"); From ba6c949ef682d8abe920c4b4315e731afa0e89ad Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 6 May 2018 11:55:45 +0300 Subject: [PATCH 196/605] refactor some tests --- .../AssetHistoryActionCleanLists.java | 74 ++++++++++--------- .../AssetHistoryListTests.java | 32 ++++---- .../appTokenTests/AppTokenAddTests.java | 49 ++++++------ .../appTokenTests/AppTokenDeleteTests.java | 25 +++---- .../appTokenTests/AppTokenGetTests.java | 34 ++++----- .../AppTokenStartSessionTests.java | 70 +++++++----------- .../AssetCommentAddTests.java | 42 ++++++----- .../AssetCommentListTests.java | 29 ++++---- .../entitlementTests/GrantTests.java | 12 +-- .../ottUserTests/DeleteTests.java | 2 +- .../servicesTests/ottUserTests/ListTests.java | 2 +- .../productPriceTests/ListTests.java | 4 +- .../sessionTests/SessionGetTests.java | 2 +- .../sessionTests/SessionRevokeTests.java | 2 +- .../sessionTests/SessionSwitchUserTests.java | 4 +- 15 files changed, 187 insertions(+), 196 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index 65dfbb24d..eda434237 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -5,7 +5,6 @@ import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.AssetHistory; import com.kaltura.client.types.AssetHistoryFilter; import com.kaltura.client.types.Household; @@ -15,22 +14,26 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; +import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.Properties.EPISODE_MEDIA_TYPE_ID; +import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.services.AssetHistoryService.*; - public class AssetHistoryActionCleanLists extends BaseTest { - private int position1 = 10; - private int position2 = 20; - private int numbOfDevices = 1; - private int numOfUsers = 1; + private final int position1 = 10; + private final int position2 = 20; + private final int numbOfDevices = 1; + private final int numOfUsers = 1; @BeforeClass + // TODO: 5/3/2018 change before method name private void add_tests_before_class() { } @@ -39,8 +42,9 @@ private void add_tests_before_class() { @Test private void cleanHistory() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -50,21 +54,20 @@ private void cleanHistory() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); //assetHistory/action/list - both assets should returned - - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) + .setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); //assetHistory/action/clean - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - no object returned - listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); + listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) + .setKs(masterUserKs); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); @@ -74,8 +77,9 @@ private void cleanHistory() { @Test private void cleanSpecifcAssetHistory() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -85,9 +89,8 @@ private void cleanSpecifcAssetHistory() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId1), null, WatchStatus.ALL, null); //assetHistory/action/clean - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) @@ -95,7 +98,7 @@ private void cleanSpecifcAssetHistory() { // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + listAssetHistoryBuilder.setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -106,8 +109,9 @@ private void cleanSpecifcAssetHistory() { @Test private void cleanSpecifcAssetTypeHistory() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -119,7 +123,7 @@ private void cleanSpecifcAssetTypeHistory() { //assetHistory/action/clean - only episode type (asset id 2) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) @@ -128,7 +132,7 @@ private void cleanSpecifcAssetTypeHistory() { // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + listAssetHistoryBuilder.setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -139,8 +143,9 @@ private void cleanSpecifcAssetTypeHistory() { @Test private void cleanAssetsAccordingToWatchStatusDone() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -152,7 +157,7 @@ private void cleanAssetsAccordingToWatchStatusDone() { //assetHistory/action/clean - only asset that were finished (asset 2) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); @@ -160,7 +165,7 @@ private void cleanAssetsAccordingToWatchStatusDone() { // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + listAssetHistoryBuilder.setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -171,8 +176,9 @@ private void cleanAssetsAccordingToWatchStatusDone() { @Test private void cleanAssetsAccordingToWatchStatusProgress() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); @@ -182,17 +188,15 @@ private void cleanAssetsAccordingToWatchStatusProgress() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); //assetHistory/action/clean - only asset that in progress (asset 1) - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + listAssetHistoryBuilder.setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 96493d98a..6f89b644a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -1,28 +1,32 @@ package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.*; -import com.kaltura.client.types.*; +import com.kaltura.client.test.utils.AssetHistoryUtils; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.types.AssetHistory; +import com.kaltura.client.types.AssetHistoryFilter; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; +import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; +import static com.kaltura.client.test.Properties.getProperty; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.services.AssetHistoryService.*; - public class AssetHistoryListTests extends BaseTest { - private Client client; - private AssetType assetType = AssetType.MEDIA; + private int position1 = 10; private int position2 = 20; int numbOfDevices = 1; @@ -37,7 +41,7 @@ private void add_tests_before_class() { @Test private void vodAssetHistory() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset @@ -60,7 +64,7 @@ private void vodAssetHistory() { // Assertions for first object returned assertThat(assetHistoryObject1.getAssetId()).isEqualTo(assetId2); - assertThat(assetHistoryObject1.getAssetType()).isEqualTo(assetType); + assertThat(assetHistoryObject1.getAssetType()).isEqualTo(AssetType.MEDIA); assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); @@ -70,7 +74,7 @@ private void vodAssetHistory() { // Assertions for second object returned assertThat(assetHistoryObject2.getAssetId()).isEqualTo(assetId1); - assertThat(assetHistoryObject2.getAssetType()).isEqualTo(assetType); + assertThat(assetHistoryObject2.getAssetType()).isEqualTo(AssetType.MEDIA); assertThat(assetHistoryObject2.getPosition()).isEqualTo(position1); // Assert total count = 2 (two bookmarks) @@ -85,7 +89,7 @@ private void vodAssetHistory() { @Test private void vodAssetHistoryFilteredByAssetId() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset @@ -125,7 +129,7 @@ private void vodAssetHistoryFilteredByAssetId() { @Test private void vodAssetHistoryFilteredByAssetType() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); @@ -156,7 +160,7 @@ private void vodAssetHistoryFilteredByAssetType() { @Test private void vodAssetHistoryFilteredByAssetProgress() { - Household household = HouseholdUtils.createHouseHold(numOfUsers, numbOfDevices, false); + Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 7dfa495f6..e66c4ba9a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.appTokenTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.tests.BaseTest; @@ -12,32 +11,31 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.AppTokenService.AddAppTokenBuilder; +import static com.kaltura.client.services.AppTokenService.GetAppTokenBuilder; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.services.AppTokenService.*; public class AppTokenAddTests extends BaseTest { - private AppTokenHashType hashType; private String sessionUserId; - private AppToken appToken = new AppToken(); - public static Client client; + private AppToken appToken; private String sessionPrivileges; + // TODO: 5/3/2018 Add comments! @BeforeClass private void add_tests_before_class() { - hashType = AppTokenHashType.SHA1; sessionUserId = getSharedUser().getUserId(); - appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); + appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA1, null, null); } @Description("appToken/action/add") @Test private void addAppToken() { - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); // Verify no error returned @@ -45,21 +43,21 @@ private void addAppToken() { assertThat(appTokenResponse.results.getExpiry()).isNull(); assertThat(appTokenResponse.results.getId()).isNotEmpty(); assertThat(appTokenResponse.results.getSessionDuration()).isGreaterThan(0); - assertThat(appTokenResponse.results.getHashType()).isEqualTo(this.hashType); + assertThat(appTokenResponse.results.getHashType()).isEqualTo(AppTokenHashType.SHA1); assertThat(appTokenResponse.results.getToken()).isNotEmpty(); - assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(this.sessionUserId); + assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(sessionUserId); assertThat(appTokenResponse.results.getPartnerId()).isEqualTo(partnerId); - assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(String.valueOf(this.sessionUserId)); + assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(String.valueOf(sessionUserId)); } @Description("appToken/action/add - without hash type") @Test private void addAppTokenWithDefaultHashType() { appToken = AppTokenUtils.addAppToken(sessionUserId, null, null, null); + // Invoke AppToken/action/add - with no hash type (will return the default hash type) - - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); // Verify that hashType = SHA256 @@ -72,8 +70,8 @@ private void addAppTokenWithPrivileges() { sessionPrivileges = "key1:value1,key2:value2"; appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, null); - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); assertThat(appTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); @@ -85,8 +83,8 @@ private void addAppTokenWithExpiryDate() { Long expiryDate = BaseUtils.getTimeInEpoch(1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getOperatorKs()); Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); @@ -100,9 +98,8 @@ private void addAppTokenWithExpiryDate() { e.printStackTrace(); } - - GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponse.results.getId()); - getAppTokenBuilder.setKs(getOperatorKs()); + GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponse.results.getId()) + .setKs(getOperatorKs()); Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); @@ -118,8 +115,8 @@ private void addAppTokenWithNoExpiryDate() { //int cbExpiryDateValue = 2592000; appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, expiryDate); - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getSharedMasterUserKs()); + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getSharedMasterUserKs()); Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(BaseUtils.getTimeInEpoch(0))); @@ -130,8 +127,8 @@ private void addAppTokenWithNoExpiryDate() { private void addAppTokenWithoutSpecificUserId() { appToken = AppTokenUtils.addAppToken(null, null, sessionPrivileges, null); - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getOperatorKs()); Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); assertThat(addAppTokenResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java index f81c40dff..7e32acfc8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java @@ -16,48 +16,43 @@ import static org.assertj.core.api.Assertions.assertThat; public class AppTokenDeleteTests extends BaseTest { - - private AppTokenHashType hashType; + private String sessionUserId; - private AppToken appToken = new AppToken(); + private AppToken appToken; @BeforeClass private void add_tests_before_class() { sessionUserId = getSharedUser().getUserId(); - hashType = AppTokenHashType.SHA1; - appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, null, null); + appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA1, null, null); } @Description("appToken/action/delete") @Test + // TODO: 5/3/2018 not clear test name! private void addAppToken() { // Add token - - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken).setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); assertThat(appTokenResponse.error).isNull(); assertThat(appTokenResponse.results.getExpiry()).isNull(); // Delete token - - DeleteAppTokenBuilder deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()); - deleteAppTokenBuilder.setKs(getOperatorKs()); + DeleteAppTokenBuilder deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()).setKs(getOperatorKs()); Response deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); assertThat(deleteTokenResponse.results).isTrue(); // Try to delete token using invalid token id - - deleteAppTokenBuilder = AppTokenService.delete("1234"); + String invalidTokenId = "1234"; + deleteAppTokenBuilder = AppTokenService.delete(invalidTokenId).setKs(getOperatorKs()); deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); + // TODO: 5/3/2018 split two scenarios into separate tests assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); // Try to delete token again - exception returned - - deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()); + deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()).setKs(getOperatorKs()); deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index ff67572f4..37256f284 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.appTokenTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.tests.BaseTest; @@ -19,41 +18,37 @@ public class AppTokenGetTests extends BaseTest { private String sessionUserId; - private String sessionPrivileges = "key1:value1,key2:value2"; - private AppTokenHashType hashType; - public static Client client; private Long expiryDate; - private int offSetInMinutes = 1; - private int sessionDuration = 86400; private AppToken appToken; + + private final int offSetInMinutes = 1; + private final int sessionDuration = 86400; + private final String sessionPrivileges = "key1:value1,key2:value2"; @BeforeClass private void get_tests_before_class() { - hashType = AppTokenHashType.SHA1; - sessionUserId = getSharedUser().getUserId(); - + sessionUserId = getSharedUser().getUserId(); expiryDate = BaseUtils.getTimeInEpoch(offSetInMinutes); } @Description("AppToken/action/get") @Test - private void getAppToken() { - appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA1, sessionPrivileges, Math.toIntExact(expiryDate)); - AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getOperatorKs()); Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); - AppTokenService.GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponse.results.getId()); - getAppTokenBuilder.setKs(getOperatorKs()); + AppTokenService.GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponse.results.getId()) + .setKs(getOperatorKs()); Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); assertThat(getAppTokenResponse.results.getId()).isEqualTo(addAppTokenResponse.results.getId()); assertThat(getAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); assertThat(getAppTokenResponse.results.getPartnerId()).isEqualTo(partnerId); assertThat(getAppTokenResponse.results.getSessionDuration()).isEqualTo(sessionDuration); - assertThat(getAppTokenResponse.results.getHashType()).isEqualTo(hashType); + assertThat(getAppTokenResponse.results.getHashType()).isEqualTo(AppTokenHashType.SHA1); assertThat(getAppTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); assertThat(getAppTokenResponse.results.getToken()).isEqualTo(addAppTokenResponse.results.getToken()); assertThat(getAppTokenResponse.results.getSessionUserId()).isEqualTo(sessionUserId); @@ -61,10 +56,11 @@ private void getAppToken() { @Description("AppToken/action/get") @Test + // TODO: 5/3/2018 use underscore in test method names and edit the description private void getAppTokenWithInvalidId() { - - AppTokenService.GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get("1234"); - getAppTokenBuilder.setKs(getOperatorKs()); + String invalidId = "1234"; + AppTokenService.GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(invalidId) + .setKs(getOperatorKs()); Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index e71e22793..1954c34e4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -1,9 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.appTokenTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AppTokenHashType; import com.kaltura.client.services.AppTokenService; -import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.test.utils.BaseUtils; @@ -12,48 +10,43 @@ import com.kaltura.client.types.SessionInfo; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; +import static com.kaltura.client.services.AppTokenService.StartSessionAppTokenBuilder; +import static com.kaltura.client.services.OttUserService.AnonymousLoginOttUserBuilder; +import static com.kaltura.client.services.OttUserService.anonymousLogin; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.services.AppTokenService.*; public class AppTokenStartSessionTests extends BaseTest { - private AppTokenHashType hashType; //TODO - remove hardcoded values private String sessionUserId = "1577578"; private String udid1 = "1234567890"; private String udid2 = "9876543210"; - private AppToken appToken = new AppToken(); - public static Client client; private String sessionPrivileges = "key1:value1,key2:value2"; + + private AppToken appToken; private Long expiryDate; private String anonymousKs; @BeforeClass private void add_tests_before_class() { - // Invoke ottUser/action/anonymousLogin to receive LoginSession object (and anonymous KS) - - AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = OttUserService.anonymousLogin(partnerId, udid1); - anonymousLoginOttUserBuilder.setKs(null); + AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = anonymousLogin(partnerId, udid1); Response loginSessionResponse = executor.executeSync(anonymousLoginOttUserBuilder); - anonymousKs = loginSessionResponse.results.getKs(); - client.setKs(null); expiryDate = BaseUtils.getTimeInEpoch(1); } @Description("appToken/action/startSession - SHA1") @Test private void startSessionSha1() { - hashType = AppTokenHashType.SHA1; // Build appToken object - appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA1, sessionPrivileges, Math.toIntExact(expiryDate)); // Invoke AppToken/action/add @@ -64,7 +57,7 @@ private void startSessionSha1() { client.setKs(anonymousKs); // Generate new token hash - String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + String tokenHash = AppTokenUtils.getTokenHash(AppTokenHashType.SHA1, anonymousKs, appTokenResponse.results.getToken()); // Invoke AppToken/action/startSession - with udid1 @@ -97,27 +90,21 @@ private void startSessionSha1() { @Description("appToken/action/startSession - SHA256") @Test private void startSessionSha256() { - hashType = AppTokenHashType.SHA256; // Build appToken object - appToken = AppTokenUtils.addAppToken(sessionUserId, hashType, sessionPrivileges, Math.toIntExact(expiryDate)); + appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA256, sessionPrivileges, Math.toIntExact(expiryDate)); // Invoke AppToken/action/add - client.setKs(getOperatorKs()); - - AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getOperatorKs()); + AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); - client.setKs(anonymousKs); - // Generate new token hash - String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + String tokenHash = AppTokenUtils.getTokenHash(AppTokenHashType.SHA256, anonymousKs, appTokenResponse.results.getToken()); // // Invoke AppToken/action/startSession - with udid1 - StartSessionAppTokenBuilder startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, - Math.toIntExact(expiryDate), udid1); - startSessionAppTokenBuilder.setKs(anonymousKs); + Math.toIntExact(expiryDate), udid1) + .setKs(anonymousKs); Response sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); @@ -129,10 +116,9 @@ private void startSessionSha256() { assertThat(sessionInfoResponse.results.getCreateDate()).isNotZero(); // Invoke AppToken/action/startSession - with udid2 - startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, - Math.toIntExact(expiryDate), udid2); - startSessionAppTokenBuilder.setKs(anonymousKs); + Math.toIntExact(expiryDate), udid2) + .setKs(anonymousKs); sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); @@ -140,24 +126,24 @@ private void startSessionSha256() { // TODO - Add session/action/get request with ks received from startSession API } - @Description("appToken/action/startSession - token id with default expiry date (according to the value in group_203 CB document" + - "OPEN BEO-4980") + @Issue("BEO-4980") + @Description("appToken/action/startSession - token id with default expiry date (according to the value in group_203 CB document") @Test private void startSessionDefaultExpiryDate() { + // TODO: 5/3/2018 add comments! int expiryDate = 0; - getSharedHousehold(); - hashType = AppTokenHashType.SHA1; - appToken = AppTokenUtils.addAppToken(null, hashType, null, expiryDate); + + appToken = AppTokenUtils.addAppToken(null, AppTokenHashType.SHA1, null, expiryDate); - AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken); - addAppTokenBuilder.setKs(getSharedMasterUserKs()); + AppTokenService.AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) + .setKs(getSharedMasterUserKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); - String tokenHash = AppTokenUtils.getTokenHash(hashType, anonymousKs, appTokenResponse.results.getToken()); + String tokenHash = AppTokenUtils.getTokenHash(AppTokenHashType.SHA1, anonymousKs, appTokenResponse.results.getToken()); StartSessionAppTokenBuilder startSessionAppTokenBuilder = AppTokenService.startSession(appTokenResponse.results.getId(), tokenHash, null, - Math.toIntExact(expiryDate), udid1); - startSessionAppTokenBuilder.setKs(anonymousKs); + Math.toIntExact(expiryDate), udid1) + .setKs(anonymousKs); Response sessionInfoResponse = executor.executeSync(startSessionAppTokenBuilder); assertThat(sessionInfoResponse.results.getKs()).isNotEmpty(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index be6222db6..d5171614f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -16,35 +15,42 @@ import java.util.Optional; -import static com.kaltura.client.services.AssetCommentService.*; +import static com.kaltura.client.services.AssetCommentService.AddAssetCommentBuilder; +import static com.kaltura.client.services.AssetCommentService.ListAssetCommentBuilder; +import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class AssetCommentAddTests extends BaseTest { - private String writer = "Shmulik"; - private Long createDate = 0L; - private String header = "header"; - private String subHeader = "subHeader"; - private String text = "A lot of text"; + private final String writer = "Shmulik"; + private final Long createDate = 0L; + private final String header = "header"; + private final String subHeader = "subHeader"; + private final String text = "A lot of text"; + private Household household; + private String householdMasterUserKs; @BeforeClass private void add_tests_before_class() { - household = HouseholdUtils.createHouseHold(1, 1, false); + int numOfUsers = 1; + int numOfDevices = 1; + household = createHousehold(numOfUsers, numOfDevices, false); + householdMasterUserKs = getHouseholdMasterUserKs(household,null); } @Description("AssetComment/action/add - vod asset") @Test private void addCommentForVod() { - - Long assetId = BaseTest.getSharedMediaAsset().getId(); + Long assetId = getSharedMediaAsset().getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); // AssetComment/action/add - AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment); - addAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment) + .setKs(getHouseholdMasterUserKs(household,null)); Response assetCommentResponse = executor.executeSync(addAssetCommentBuilder); //Assertions for AssetComment/action/add @@ -63,8 +69,8 @@ private void addCommentForVod() { AssetCommentOrderBy.CREATE_DATE_DESC); //AssetComment/action/list - ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null); - listAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null) + .setKs(householdMasterUserKs); Response> assetCommentListResponse = executor.executeSync(listAssetCommentBuilder); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); @@ -93,8 +99,8 @@ private void addCommentForEPGProgram() { AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(epgProgramId), AssetType.EPG, writer, text, createDate, subHeader, header); // AssetComment/action/add - AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment); - addAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment) + .setKs(householdMasterUserKs); Response assetCommentResponse = executor.executeSync(addAssetCommentBuilder); //Assertions for AssetComment/action/add @@ -107,8 +113,8 @@ private void addCommentForEPGProgram() { AssetCommentOrderBy.CREATE_DATE_DESC); //AssetComment/action/list - ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null); - listAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null) + .setKs(householdMasterUserKs); Response> assetCommentListResponse = executor.executeSync(listAssetCommentBuilder); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index 217242656..434d103e0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -1,12 +1,10 @@ package com.kaltura.client.test.tests.servicesTests.assetCommentTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetCommentOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.services.AssetCommentService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; @@ -19,23 +17,28 @@ import java.util.Optional; -import static com.kaltura.client.services.AssetCommentService.*; +import static com.kaltura.client.services.AssetCommentService.ListAssetCommentBuilder; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; public class AssetCommentListTests extends BaseTest { - private Client client; - Household household; + private Household household; + private String householdMasterUserKs; @BeforeClass + // TODO: 5/3/2018 edit before method name private void add_tests_before_class() { - household = HouseholdUtils.createHouseHold(1, 1, false); + int numOfUsers = 1; + int numOfDevices = 1; + household = createHousehold(numOfUsers, numOfDevices, false); + householdMasterUserKs = getHouseholdMasterUserKs(household, null); } @Description("AssetComment/action/list - check order by functionality") @Test - private void checkCommentsOrder() { String writer = "Shmulik"; @@ -52,13 +55,13 @@ private void checkCommentsOrder() { // AssetComment/action/add - first comment - AssetCommentService.AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment); - addAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + AssetCommentService.AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment) + .setKs(householdMasterUserKs); Response assetComment1Response = executor.executeSync(addAssetCommentBuilder); // AssetComment/action/add - second comment comment - AssetCommentService.AddAssetCommentBuilder addAssetCommentBuilder2 = AssetCommentService.add(assetComment); - addAssetCommentBuilder2.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + AssetCommentService.AddAssetCommentBuilder addAssetCommentBuilder2 = AssetCommentService.add(assetComment) + .setKs(householdMasterUserKs); Response assetComment2Response = executor.executeSync(addAssetCommentBuilder2); //Initialize assetCommentFilter object @@ -67,8 +70,8 @@ private void checkCommentsOrder() { //AssetComment/action/list - return both comments - ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter,null); - listAssetCommentBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter, null) + .setKs(householdMasterUserKs); Response> assetCommentListResponse = executor.executeSync(listAssetCommentBuilder); AssetComment assetCommentObjectResponse = assetCommentListResponse.results.getObjects().get(0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index f00ad7cbe..eabcfc017 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -39,13 +39,13 @@ public class GrantTests extends BaseTest { @BeforeClass private void grant_test_before_class() { contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); - testSharedHousehold = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } @Test(description = "entitlement/action/grant - grant subscription with history = true") private void grant_subscription_with_history() { // set household - Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -112,7 +112,7 @@ private void grant_subscription_with_history() { @Test(description = "entitlement/action/grant - grant subscription with history = false") private void grant_subscription_without_history() { // set household - Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -154,7 +154,7 @@ private void grant_subscription_without_history() { @Test(description = "entitlement/action/grant - grant ppv with history = true") private void grant_ppv_with_history() { // set household - Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -221,7 +221,7 @@ private void grant_ppv_with_history() { @Test(description = "entitlement/action/grant - grant ppv with history = false") private void grant_ppv_without_history() { // set household - Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); @@ -368,7 +368,7 @@ private void grant_ppv_user_not_in_domain() { private void grant_ppv_user_suspend() { // set household - Household household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); // suspend household diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 9c0161d14..91ed1036a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -34,7 +34,7 @@ public class DeleteTests extends BaseTest { private void ottUser_delete_tests_setup() { int numberOfDevicesInHousehold = 0; int numberOfUsersInHousehold = 2; - household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index 0ea514aa9..d2abd9ab9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -30,7 +30,7 @@ public class ListTests extends BaseTest { @BeforeClass private void ottUser_list_tests_setup() { - household = HouseholdUtils.createHouseHold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 027168c2e..548426fcf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -58,7 +58,7 @@ public void beforeClass() { int numberOfUsers = 2; int numberOfDevices = 1; - household = HouseholdUtils.createHouseHold(numberOfUsers, numberOfDevices, true); + household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); } @@ -160,7 +160,7 @@ public void ppvTest() { public void productPriceSubscriptionAndPpvBeforePurchaseTest() { int numberOfUsers = 1; int numberOfDevices = 1; - Household household = HouseholdUtils.createHouseHold(numberOfUsers, numberOfDevices, true); + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); ProductPriceFilter filter = new ProductPriceFilter(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index 38c4cfc11..bbe983a3d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -30,7 +30,7 @@ private void get_tests_before_class() { @Description("session/action/get - master user") @Test private void getMasterUserSession() { - Household household = HouseholdUtils.createHouseHold(2, 1, false); + Household household = HouseholdUtils.createHousehold(2, 1, false); HouseholdUser user = HouseholdUtils.getMasterUserFromHousehold(household); String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String session = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), udid); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java index 5609583b0..81f400ed7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java @@ -30,7 +30,7 @@ private void revoke_tests_before_class() { @Description("/session/action/revoke - 2 different kss") @Test private void RevokeKs() { - Household household = HouseholdUtils.createHouseHold(2, 2, false); + Household household = HouseholdUtils.createHousehold(2, 2, false); String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); String masterUserKs2 = HouseholdUtils.getHouseholdMasterUserKs(household, udid); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index 95c6ec1ab..ca2894cf4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -34,7 +34,7 @@ private void switchUser_tests_before_class() { @Test private void SwitchUser() { - Household household = HouseholdUtils.createHouseHold(2, 1, false); + Household household = HouseholdUtils.createHousehold(2, 1, false); String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); String secondUserId = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0).getUserId(); @@ -85,7 +85,7 @@ private void SwitchUser() { @Description("/session/action/switchUser - user switch to himself") @Test private void SwitchUserToHimself() { - Household household = HouseholdUtils.createHouseHold(2, 1, false); + Household household = HouseholdUtils.createHousehold(2, 1, false); String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); From fda91696091dc1d8d471959535bb8b9e4c893561 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 6 May 2018 12:00:40 +0300 Subject: [PATCH 197/605] rename createHousehold method name --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 4 ++-- .../java/com/kaltura/client/test/utils/HouseholdUtils.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 4d8e4897a..c98c167a6 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -18,7 +18,7 @@ import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.utils.HouseholdUtils.createHouseHold; +import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; import static com.kaltura.client.test.utils.OttUserUtils.getUserById; import static org.awaitility.Awaitility.setDefaultTimeout; @@ -196,7 +196,7 @@ public static Household getSharedHousehold() { int numOfDevices = 2; if (sharedHousehold == null) { - sharedHousehold = createHouseHold(numOfUsers, numOfDevices, true); + sharedHousehold = createHousehold(numOfUsers, numOfDevices, true); List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); for (HouseholdUser user : sharedHouseholdUsers) { if (user.getIsMaster() != null && user.getIsMaster()) { diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 6f8fce07d..99ef04565 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -20,7 +20,7 @@ public class HouseholdUtils extends BaseUtils { // create household - public static Household createHouseHold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold, boolean isPreparePG) { + public static Household createHousehold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold, boolean isPreparePG) { // create and register From 449b8e7e6fe5258f68a77a8f3677a641592d9c44 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 6 May 2018 12:28:24 +0300 Subject: [PATCH 198/605] remvoe getClient method comment from BaseTest --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c98c167a6..036cc7817 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -93,13 +93,6 @@ public void base_test_before_suite() { defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } - -/* public static Client getClient(String ks) { - Client client = new Client(config); - client.setKs(ks); - return client; - }*/ - // getters for shared params public static String getAdministratorKs() { if (administratorKs == null) { From 2b7ec660e78309ff07dcce61ad8dddf82434eec5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 6 May 2018 14:23:32 +0300 Subject: [PATCH 199/605] fixed problems with Operator and Administrator ks --- .../productPriceTests/ListTests.java | 18 +++++----- .../kaltura/client/test/utils/DBUtils.java | 33 ++++++++++++++++++- .../client/test/utils/PurchaseUtils.java | 8 ++--- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java index 027168c2e..f5222e7f7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java @@ -59,7 +59,7 @@ public void beforeClass() { int numberOfUsers = 2; int numberOfDevices = 1; household = HouseholdUtils.createHouseHold(numberOfUsers, numberOfDevices, true); - classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + classMasterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); } @Severity(SeverityLevel.NORMAL) @@ -82,7 +82,7 @@ public void listSubscription() { public void listSubscriptionWithCurrencyTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(CURRENCY_EUR)); + productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(CURRENCY_EUR).setKs(getOperatorKs())); // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); @@ -96,7 +96,7 @@ public void listSubscriptionWithCurrencyTest() { public void listWithoutRequiredFields() { ProductPriceFilter filter = new ProductPriceFilter(); ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); - productPriceResponse = executor.executeSync(productPriceList); + productPriceResponse = executor.executeSync(productPriceList.setKs(getOperatorKs())); int errorCode = 500056; assertThat(productPriceResponse.results).isNull(); @@ -112,7 +112,7 @@ public void ppvTest() { // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementPpvsFilter, null); - entitlementResponse = executor.executeSync(entitlementListBeforePurchase); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); @@ -121,17 +121,17 @@ public void ppvTest() { ppFilter.setFileIdIn(String.valueOf(webMediaFileId)); ppFilter.setIsLowest(false); ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - PurchaseUtils.purchasePpv(Optional.empty(), Optional.of(webMediaFileId), null); + PurchaseUtils.purchasePpv(classMasterUserKs, Optional.empty(), Optional.of(webMediaFileId), null); ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); @@ -140,7 +140,7 @@ public void ppvTest() { assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); ListProductPriceBuilder productPriceListAfterPurchase = ProductPriceService.list(ppFilter); - productPriceResponse = executor.executeSync(productPriceListAfterPurchase); + productPriceResponse = executor.executeSync(productPriceListAfterPurchase.setKs(classMasterUserKs)); // only 1 item mention in filter assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); @@ -148,7 +148,7 @@ public void ppvTest() { ppFilter.setFileIdIn(String.valueOf(mobileMediaFileId)); ListProductPriceBuilder productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceService.list(ppFilter); - productPriceResponse = executor.executeSync(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia); + productPriceResponse = executor.executeSync(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.setKs(classMasterUserKs)); assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index f3e146725..5e2564293 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -21,6 +21,9 @@ public class DBUtils extends BaseUtils { //selects private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + private static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + + "from [Users].[dbo].[groups_parameters]\n" + + "where group_id=%d"; private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + "from [Users].[dbo].[users] u with(nolock)\n" + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + @@ -121,10 +124,38 @@ public static String getDiscountByPercentAndCurrency(String currency, int percen return code; } + public static boolean isActivationOfUsersNeeded() { + openConnection(); + try { + rs = stam.executeQuery(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId)); + } catch (SQLException e) { + e.printStackTrace(); + } + try { + rs.next(); + } catch (SQLException e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("No data about activation users in account " + BaseTest.partnerId); + } + int result =-1; + try { + result = rs.getInt("IS_ACTIVATION_NEEDED"); + } catch (SQLException e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("IS_ACTIVATION_NEEDED can't be null"); + } + closeConnection(); + return result == 1; + } + public static String getUserDataByRole(String userRole) { + String sqlQuery = USER_BY_ROLE_SELECT; + if (isActivationOfUsersNeeded()) { + sqlQuery += " and u.activate_status=1"; + } openConnection(); try { - rs = stam.executeQuery(String.format(USER_BY_ROLE_SELECT, userRole, BaseTest.partnerId)); + rs = stam.executeQuery(String.format(sqlQuery, userRole, BaseTest.partnerId)); } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index ec2c08d49..a54addd5f 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -26,7 +26,7 @@ public class PurchaseUtils { private static Response assetResponse; // TODO: 14/MAR/2018 add return - public static void purchasePpv(Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { + public static void purchasePpv(String ks, Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { purchasePpvDetailsMap = new HashMap<>(); int paymentGatewayId = 0; @@ -35,7 +35,7 @@ public static void purchasePpv(Optional mediaId, Optional file internalFileId = fileId.get(); } else { GetAssetBuilder mediaAsset = AssetService.get(String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); - assetResponse = executor.executeSync(mediaAsset); + assetResponse = executor.executeSync(mediaAsset.setKs(ks)); internalFileId = assetResponse.results.getMediaFiles().get(0).getId(); } @@ -45,7 +45,7 @@ public static void purchasePpv(Optional mediaId, Optional file filter.setIsLowest(false); ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(ks)); double price = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); String ppvModuleId = ((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvModuleId(); @@ -63,7 +63,7 @@ public static void purchasePpv(Optional mediaId, Optional file purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); PurchaseTransactionBuilder transactionBuilder = TransactionService.purchase(purchase); - executor.executeSync(transactionBuilder); + executor.executeSync(transactionBuilder.setKs(ks)); // TODO: complete the purchase ppv test purchasePpvDetailsMap.put("price", String.valueOf(price)); From a7b00a1529a7e80c3e0abe0c4d658869b6a02389 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 6 May 2018 15:40:31 +0300 Subject: [PATCH 200/605] fix some ottUser tests --- .../AssetHistoryListTests.java | 7 +-- .../ottUserTests/DeleteTests.java | 33 ++++++------- .../ottUserTests/UpdateLoginDataTests.java | 49 +++++++++---------- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 6f89b644a..613901499 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.AssetHistory; import com.kaltura.client.types.AssetHistoryFilter; @@ -23,6 +22,8 @@ import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { @@ -70,7 +71,7 @@ private void vodAssetHistory() { // Verify that flag is set to false (user hasn't finish watching the asset) assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); - assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); + assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(getTimeInEpoch(0)); // Assertions for second object returned assertThat(assetHistoryObject2.getAssetId()).isEqualTo(assetId1); @@ -108,7 +109,7 @@ private void vodAssetHistoryFilteredByAssetId() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); - String concatenatedString = BaseUtils.getConcatenatedString(String.valueOf(assetId2), String.valueOf(assetId3)); + String concatenatedString = getConcatenatedString(String.valueOf(assetId2), String.valueOf(assetId3)); //assetHistory/action/list - filter by asset 2 and asset 3 ids assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java index 91ed1036a..f03405ecd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java @@ -42,21 +42,22 @@ private void ottUser_delete_tests_setup() { @Test private void delete() { // register user - RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword); - registerOttUserBuilder.setKs(getAdministratorKs()); + RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword) + .setKs(getAdministratorKs()); OTTUser user = executor.executeSync(registerOttUserBuilder).results; // delete user and assert success - deleteOttUserBuilder = OttUserService.delete(); - deleteOttUserBuilder.setKs(getAdministratorKs()); - deleteOttUserBuilder.setUserId(Integer.valueOf(user.getId())); - + deleteOttUserBuilder = OttUserService.delete() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); boolean result = executor.executeSync(deleteOttUserBuilder).results; + assertThat(result).isTrue(); // try to get user and assert error - GetOttUserBuilder getOttUserBuilder = OttUserService.get(); - getOttUserBuilder.setKs(getAdministratorKs()); + GetOttUserBuilder getOttUserBuilder = OttUserService.get() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); Response ottUserResponse = executor.executeSync(getOttUserBuilder); assertThat(ottUserResponse.results).isNull(); @@ -72,10 +73,8 @@ private void delete_master_user() { // try to delete master user and assert error deleteOttUserBuilder = OttUserService.delete() - .setKs(getAdministratorKs()) - .setUserId(Integer.valueOf(masterUser.getUserId())); - deleteOttUserBuilder.setKs(getAdministratorKs()); - deleteOttUserBuilder.setUserId(Integer.valueOf(masterUser.getUserId())); + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); booleanResponse = executor.executeSync(deleteOttUserBuilder); assertThat(booleanResponse.results).isNull(); @@ -90,9 +89,9 @@ private void delete_default_user() { HouseholdUser defaultUser = getDefaultUserFromHousehold(household); // try to delete default user and assert error - deleteOttUserBuilder = OttUserService.delete(); - deleteOttUserBuilder.setKs(getAdministratorKs()); - deleteOttUserBuilder.setUserId(Integer.valueOf(defaultUser.getUserId())); + deleteOttUserBuilder = OttUserService.delete() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(defaultUser.getUserId())); booleanResponse = executor.executeSync(deleteOttUserBuilder); assertThat(booleanResponse.results).isNull(); @@ -101,8 +100,8 @@ private void delete_default_user() { @AfterClass private void ottUser_delete_tests_tearDown() { - DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())); - deleteHouseholdBuilder.setKs(getAdministratorKs()); + DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); executor.executeSync(deleteHouseholdBuilder); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java index 55d76caad..518071c90 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java @@ -1,7 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; -import com.kaltura.client.Client; -import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -12,45 +10,43 @@ import org.testng.annotations.Test; import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.services.OttUserService.login; -import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class UpdateLoginDataTests extends BaseTest { - private Response booleanResponse; - private Response ottUserResponse; - private OTTUser user; - + private Response loginResponse; @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateLoginData - updateLoginData") @Test - private void updateLoginData() { + private void updateLoginDataTest() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); - OTTUser user = ottUserResponse.results; - Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword, null, null)); + // login user + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); String userKs = loginResponse.results.getLoginSession().getKs(); - UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(user.getUsername(), defaultUserPassword, defaultUserPassword + 1); - updateLoginDataOttUserBuilder.setKs(userKs); + // update user login data + String userNewPassword = defaultUserPassword + 1; + UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = updateLoginData(user.getUsername(), defaultUserPassword, userNewPassword) + .setKs(userKs); Response booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); - - loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword, null, null)); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), userNewPassword)); - loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword + 1, null, null)); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } @@ -59,27 +55,30 @@ private void updateLoginData() { @Description("ottUser/action/updateLoginData - updateLoginData with administratorKs") @Test private void updateLoginData_with_administratorKs() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + // login user + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); - ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); - OTTUser user = ottUserResponse.results; - - UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(user.getUsername(), defaultUserPassword, defaultUserPassword + 1); - updateLoginDataOttUserBuilder.setKs(getAdministratorKs()); - booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); + // update usser login data + String userNewPassword = defaultUserPassword + 2; + UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = updateLoginData(user.getUsername(), defaultUserPassword, userNewPassword) + .setKs(getAdministratorKs()); + Response booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); // try login with old password + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); - Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword, null, null)); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); // try login with new password + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), userNewPassword)); - loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword + 1, null, null)); assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); } From ec3b25e3bf4e6ccae30f4e375b763d0326b1c635 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 6 May 2018 16:15:10 +0300 Subject: [PATCH 201/605] fix createHousehold util --- .../servicesTests/ottUserTests/GetTests.java | 5 +- .../client/test/utils/HouseholdUtils.java | 86 ++++++++----------- 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java index 10c4e9070..db59a7a36 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java @@ -33,8 +33,9 @@ private void ottUser_get_tests_setup() { @Description("ottUser/action/get - get") @Test private void getTest() { - GetOttUserBuilder getOttUserBuilder = get(); - get().setKs(loginResponse.results.getLoginSession().getKs()); + // get user + GetOttUserBuilder getOttUserBuilder = get() + .setKs(loginResponse.results.getLoginSession().getKs()); Response ottUserResponse = executor.executeSync(getOttUserBuilder); assertThat(loginResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 99ef04565..2598c3ce4 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -4,10 +4,12 @@ import com.kaltura.client.services.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; + import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Random; + import static com.kaltura.client.services.HouseholdDeviceService.*; import static com.kaltura.client.services.HouseholdPaymentGatewayService.*; import static com.kaltura.client.services.HouseholdUserService.*; @@ -22,54 +24,44 @@ public class HouseholdUtils extends BaseUtils { // create household public static Household createHousehold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold, boolean isPreparePG) { - // create and register - - RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, generateOttUser(), defaultUserPassword); - registerOttUserBuilder.setKs(null); - Response masterUserResponse = executor.executeSync(registerOttUserBuilder); - - OTTUser masterUser = masterUserResponse.results; + // register master user + RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword); + OTTUser masterUser = executor.executeSync(registerOttUserBuilder).results; // login master user - - LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, masterUser.getUsername(), defaultUserPassword, null, null); - loginOttUserBuilder.setKs(null); + LoginOttUserBuilder loginOttUserBuilder = login(partnerId, masterUser.getUsername(), defaultUserPassword, null, null); Response loginResponse = executor.executeSync(loginOttUserBuilder); - masterUser = loginResponse.results.getUser(); + String masterUserKs = loginResponse.results.getLoginSession().getKs(); - // create and add household + // add household Household household = new Household(); household.setName(masterUser.getFirstName() + "s Domain"); household.setDescription(masterUser.getLastName() + " Description"); - AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household); - addHouseholdBuilder.setKs(loginResponse.results.getLoginSession().getKs()); - Response householdResponse = executor.executeSync(addHouseholdBuilder); + AddHouseholdBuilder addHouseholdBuilder = HouseholdService.add(household) + .setKs(masterUserKs); + household = executor.executeSync(addHouseholdBuilder).results; - household = householdResponse.results; - - // create, register and add non-master user to household + // add additional users to household for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { + // register additional user + registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword); + OTTUser additionalUser = executor.executeSync(registerOttUserBuilder).results; - registerOttUserBuilder = OttUserService.register(partnerId, generateOttUser(), defaultUserPassword); - registerOttUserBuilder.setKs(null); - Response additionalUserResponse = executor.executeSync(registerOttUserBuilder); - - OTTUser additionalUser = additionalUserResponse.results; HouseholdUser householdUser = new HouseholdUser(); householdUser.setUserId(additionalUser.getId()); householdUser.setIsMaster(false); - // HouseholdUser/action/add - add user to household - - AddHouseholdUserBuilder addHouseholdUserBuilder = HouseholdUserService.add(householdUser); - addHouseholdBuilder.setKs(loginResponse.results.getLoginSession().getKs()); + // add additional user to household + AddHouseholdUserBuilder addHouseholdUserBuilder = add(householdUser) + .setKs(masterUserKs); executor.executeSync(addHouseholdUserBuilder); } - // create, add and save household device + // add household devices for (int i = 0; i < numberOfDevicesInHousehold; i++) { + // create household device long uniqueString = System.currentTimeMillis(); HouseholdDevice householdDevice = new HouseholdDevice(); householdDevice.setUdid(String.valueOf(uniqueString)); @@ -77,30 +69,26 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO householdDevice.setBrandId(r.nextInt(30 - 1) + 1); householdDevice.setName(String.valueOf(uniqueString) + "device"); - - AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice); - addHouseholdDeviceBuilder.setKs(loginResponse.results.getLoginSession().getKs()); + // add device to household + AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice) + .setKs(masterUserKs); executor.executeSync(addHouseholdDeviceBuilder); - } - // login as Master with udid - if (numberOfDevicesInHousehold > 0) { - List householdDevices = getDevicesListFromHouseHold(household); - - loginOttUserBuilder = OttUserService.login(partnerId, masterUser.getUsername(), defaultUserPassword, null, householdDevices.get(0).getUdid()); - loginOttUserBuilder.setKs(null); - executor.executeSync(loginOttUserBuilder); - - } +// // login as Master with udid +// if (numberOfDevicesInHousehold > 0) { +// List householdDevices = getDevicesListFromHouseHold(household); +// +// loginOttUserBuilder = login(partnerId, masterUser.getUsername(), defaultUserPassword, null, householdDevices.get(0).getUdid()); +// executor.executeSync(loginOttUserBuilder); +// } if (isPreparePG) { // TODO: there should be added logic with getting and using default PG currently it all hardcoded - //HouseholdPaymentGateway/action/setChargeId - SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.setChargeID("0110151474255957105", "1234"); - setChargeIDHouseholdPaymentGatewayBuilder.setKs(getOperatorKs()); - setChargeIDHouseholdPaymentGatewayBuilder.setUserId(Integer.valueOf(masterUser.getId())); + SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.setChargeID("0110151474255957105", "1234") + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getId())); executor.executeSync(setChargeIDHouseholdPaymentGatewayBuilder); } @@ -114,8 +102,8 @@ public static List getDevicesListFromHouseHold(Household househ filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); //HouseholdDevice/action/list - ListHouseholdDeviceBuilder listHouseholdDeviceBuilder = HouseholdDeviceService.list(filter); - listHouseholdDeviceBuilder.setKs(getAdministratorKs()); + ListHouseholdDeviceBuilder listHouseholdDeviceBuilder = HouseholdDeviceService.list(filter) + .setKs(getAdministratorKs()); Response> devicesResponse = executor.executeSync(listHouseholdDeviceBuilder); return devicesResponse.results.getObjects(); @@ -126,8 +114,8 @@ public static List getUsersListFromHouseHold(Household household) HouseholdUserFilter filter = new HouseholdUserFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); - ListHouseholdUserBuilder listHouseholdUserBuilder = HouseholdUserService.list(filter); - listHouseholdUserBuilder.setKs(getAdministratorKs()); + ListHouseholdUserBuilder listHouseholdUserBuilder = list(filter) + .setKs(getAdministratorKs()); Response> usersResponse = executor.executeSync(listHouseholdUserBuilder); return usersResponse.results.getObjects(); From c7426df3118585879748e3172a16913cae75a85e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 7 May 2018 12:19:01 +0300 Subject: [PATCH 202/605] updated removed MPP in entitlemet/action/grant --- .../test/tests/servicesTests/entitlementTests/GrantTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java index eabcfc017..a4a7047c7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java @@ -24,7 +24,7 @@ public class GrantTests extends BaseTest { // TODO: 4/12/2018 remove hardcoded subscription Id - private final int subscriptionId = 369426; + private final int subscriptionId = 327699; private final int ppvId = 30297; private final int assetId = 607368; From e713a46a9d188a963dbf6b054f517c853858f660 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 7 May 2018 12:35:36 +0300 Subject: [PATCH 203/605] fix some test in AssetHistoryListTests --- .../test/TestAPIOkRequestsExecutor.java | 2 +- .../AssetHistoryListTests.java | 125 ++++++++++-------- .../client/test/utils/HouseholdUtils.java | 2 +- 3 files changed, 70 insertions(+), 59 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 46a020c1f..1c112932d 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -42,7 +42,7 @@ public static TestAPIOkRequestsExecutor getExecutor() { protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, RequestElement action) { ResponseElement responseElement = super.onGotResponse(okhttpResponse, action); // logger.debug("response body:\n" + responseElement.getResponse()); // was found in base class -// logger.debug("response headers:\n" + response.headers()); +// logger.debug("response headers:\n" + okhttpResponse.headers()); if (responseElement.isSuccess()) { Response response = action.parseResponse(responseElement); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 613901499..22b1fc46c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -3,61 +3,56 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; -import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.AssetHistory; import com.kaltura.client.types.AssetHistoryFilter; import com.kaltura.client.types.Household; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; -import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; +import java.util.ArrayList; +import java.util.List; + +import static com.kaltura.client.services.AssetHistoryService.*; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { - private int position1 = 10; - private int position2 = 20; - int numbOfDevices = 1; - int numOfUsers = 1; - - @BeforeClass - private void add_tests_before_class() { + private final int position1 = 10; + private final int position2 = 20; + private final int numbOfDevices = 1; + private final int numOfUsers = 1; - } @Description("/AssetHistory/action/list - with no filter") @Test private void vodAssetHistory() { - - Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String masterUserKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); //assetHistory/action/list - both assets should returned - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) + .setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); - // First object AssetHistory assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); // Second object @@ -81,57 +76,69 @@ private void vodAssetHistory() { // Assert total count = 2 (two bookmarks) assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); - executor.executeSync(cleanAssetHistoryBuilder); + // clean + clean_asset_history(assetHistoryFilter, household); } @Description("/AssetHistory/action/list -filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { - Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String masterUserKs = getHouseholdMasterUserKs(household, null); + List assetIds = new ArrayList<>(); + int numOfBookmarks = 3; + for (int i = 0; i < numOfBookmarks; i++) { + long assetId = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + assetIds.add(assetId); + } // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); +/* + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - Long assetId3 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); + Long assetId3 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); +*/ - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId2), null, WatchStatus.ALL, null); + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetIds.get(1)), null, WatchStatus.ALL, null); //assetHistory/action/list - filter by asset 2 id - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) + .setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetIds.get(1)); - String concatenatedString = getConcatenatedString(String.valueOf(assetId2), String.valueOf(assetId3)); + String concatenatedString = getConcatenatedString(String.valueOf(assetIds.get(1)), String.valueOf(assetIds.get(2))); //assetHistory/action/list - filter by asset 2 and asset 3 ids - assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, - null, WatchStatus.ALL, null); + assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, null, WatchStatus.ALL, null); - listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + listAssetHistoryBuilder = list(assetHistoryFilter, null) + .setKs(masterUserKs); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId3); - assertThat(assetHistoryListResponse.results.getObjects().get(1).getAssetId()).isEqualTo(assetId2); + List assetHistoryList = assetHistoryListResponse.results.getObjects(); + assertThat(assetHistoryList); - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); - executor.executeSync(cleanAssetHistoryBuilder); + List assetHistoryIdsList = new ArrayList<>(); + for (AssetHistory assetHistory : assetHistoryList) { + assetHistoryIdsList.add(assetHistory.getAssetId()); + } + assertThat(assetHistoryIdsList).containsOnly(assetIds.get(1), assetIds.get(2)); + + // clean + clean_asset_history(assetHistoryFilter, household); } @Description("/AssetHistory/action/list -filtered by movie type id") @Test private void vodAssetHistoryFilteredByAssetType() { - Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String userKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset (movie in first play) @@ -144,16 +151,15 @@ private void vodAssetHistoryFilteredByAssetType() { //assetHistory/action/list - filter by in progress assets only - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null); + listAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); - executor.executeSync(cleanAssetHistoryBuilder); + // clean + clean_asset_history(assetHistoryFilter, household); } @@ -161,8 +167,8 @@ private void vodAssetHistoryFilteredByAssetType() { @Test private void vodAssetHistoryFilteredByAssetProgress() { - Household household = HouseholdUtils.createHousehold(numOfUsers, numbOfDevices, false); - String userKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + Household household = createHousehold(numOfUsers, numbOfDevices, false); + String userKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset (movie in first play) @@ -174,8 +180,8 @@ private void vodAssetHistoryFilteredByAssetProgress() { //assetHistory/action/list - filter by in progress assets only - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); - listAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household,null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null); + listAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -185,17 +191,22 @@ private void vodAssetHistoryFilteredByAssetProgress() { //assetHistory/action/list - filter by finished assets only - listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter,null); + listAssetHistoryBuilder = list(assetHistoryFilter, null); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(HouseholdUtils.getHouseholdMasterUserKs(household, null)); + // clean + clean_asset_history(assetHistoryFilter, household); + } + + + private void clean_asset_history(AssetHistoryFilter assetHistoryFilter, Household household) { + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); + cleanAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); executor.executeSync(cleanAssetHistoryBuilder); } //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] - } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 2598c3ce4..3cf44785f 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -44,7 +44,7 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO household = executor.executeSync(addHouseholdBuilder).results; // add additional users to household - for (int i = 0; i < numberOfUsersInHoushold - 1; i++) { + for (int i = 0; i < numberOfUsersInHoushold; i++) { // register additional user registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword); OTTUser additionalUser = executor.executeSync(registerOttUserBuilder).results; From 796c9bccc76b907af3987375272c0e8434884d0c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 7 May 2018 12:51:39 +0300 Subject: [PATCH 204/605] no message --- .../AssetHistoryTests/AssetHistoryListTests.java | 8 +------- .../test/tests/servicesTests/ottUserTests/ListTests.java | 2 +- .../com/kaltura/client/test/utils/HouseholdUtils.java | 8 -------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 22b1fc46c..4d172a71f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -93,14 +93,8 @@ private void vodAssetHistoryFilteredByAssetId() { long assetId = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); assetIds.add(assetId); } - // Ingest and bookmark first asset -/* - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - Long assetId3 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); -*/ + // Ingest and bookmark first asset AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetIds.get(1)), null, WatchStatus.ALL, null); //assetHistory/action/list - filter by asset 2 id diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java index d2abd9ab9..1c6861ed1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java @@ -53,7 +53,7 @@ private void list_from_master_ks() { // assert users list size assertThat(householdUserListResponse.error).isNull(); - assertThat(users.size()).isEqualTo(numberOfUsersInHousehold + 1); + assertThat(users.size()).isEqualTo(numberOfUsersInHousehold + 2); } @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 3cf44785f..090e24e7e 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -75,14 +75,6 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO executor.executeSync(addHouseholdDeviceBuilder); } -// // login as Master with udid -// if (numberOfDevicesInHousehold > 0) { -// List householdDevices = getDevicesListFromHouseHold(household); -// -// loginOttUserBuilder = login(partnerId, masterUser.getUsername(), defaultUserPassword, null, householdDevices.get(0).getUdid()); -// executor.executeSync(loginOttUserBuilder); -// } - if (isPreparePG) { // TODO: there should be added logic with getting and using default PG currently it all hardcoded //HouseholdPaymentGateway/action/setChargeId From f3fb54107b25bb631188be37f35a65a074af5551 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 7 May 2018 12:57:55 +0300 Subject: [PATCH 205/605] no message --- .../AssetHistoryListTests.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 4d172a71f..a773696e2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -132,21 +132,20 @@ private void vodAssetHistoryFilteredByAssetId() { private void vodAssetHistoryFilteredByAssetType() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String masterUserKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset (movie in first play) - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(MOVIE_MEDIA_TYPE_ID)); //assetHistory/action/list - filter by in progress assets only - - ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) + .setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -162,20 +161,18 @@ private void vodAssetHistoryFilteredByAssetType() { private void vodAssetHistoryFilteredByAssetProgress() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); - + String masterUserKs = getHouseholdMasterUserKs(household, null); // Ingest and bookmark first asset (movie in first play) - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); + Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); //assetHistory/action/list - filter by in progress assets only - - ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) + .setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -184,8 +181,8 @@ private void vodAssetHistoryFilteredByAssetProgress() { assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); //assetHistory/action/list - filter by finished assets only - - listAssetHistoryBuilder = list(assetHistoryFilter, null); + listAssetHistoryBuilder = list(assetHistoryFilter, null) + .setKs(masterUserKs); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); From 82e9b06afa58ab475b6e495ab6e6b056a5943880 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 7 May 2018 15:05:36 +0300 Subject: [PATCH 206/605] fixed ingest util --- src/test/java/com/kaltura/client/test/utils/IngestUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index b724a6dcc..5f07eca1b 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -978,7 +978,7 @@ public static MediaAsset ingestBasicVOD(Optional name, String mediaType) //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); - await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), INGEST_ACTION_INSERT, id)); + await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), id, INGEST_ACTION_INSERT)); mediaAsset.setMediaFiles(executor.executeSync( AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); From 0e42922c640205d6b366d70bf7ce1be5f6c173e3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 7 May 2018 15:14:10 +0300 Subject: [PATCH 207/605] Refactoring AssetHistroy tests --- .../AssetHistoryActionCleanLists.java | 117 +++++++++++----- .../AssetHistoryListTests.java | 130 ++++++++++++------ .../client/test/utils/AssetHistoryUtils.java | 32 ++--- 3 files changed, 182 insertions(+), 97 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index eda434237..a247f3ada 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -1,21 +1,26 @@ package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; +import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; -import com.kaltura.client.types.AssetHistory; -import com.kaltura.client.types.AssetHistoryFilter; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BookmarkUtils; +import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Optional; + +import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; +import static com.kaltura.client.services.BookmarkService.add; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.EPISODE_MEDIA_TYPE_ID; @@ -31,11 +36,26 @@ public class AssetHistoryActionCleanLists extends BaseTest { private final int numbOfDevices = 1; private final int numOfUsers = 1; + private MediaAsset movie; + private int movieFileId; + private MediaAsset movie2; + private int movie2FileId; + private MediaAsset episode; + private int episodeFileId; + @BeforeClass // TODO: 5/3/2018 change before method name - private void add_tests_before_class() { - + private void clean_tests_before_class() { + // Ingest first movie asset + movie = IngestUtils.ingestBasicVOD(Optional.of("movieForBookmark"), MOVIE_MEDIA_TYPE); + movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); + // Ingest second movie asset + movie2 = IngestUtils.ingestBasicVOD(Optional.of("movie2ForBookmark"), MOVIE_MEDIA_TYPE); + movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); + // Ingest episode asset + episode = IngestUtils.ingestBasicVOD(Optional.of("EpisodeForBookmark"), EPISODE_MEDIA_TYPE); + episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } @Description("/assetHistory/action/clean - no filtering") @@ -44,12 +64,16 @@ private void cleanHistory() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); - String userKs = getHouseholdMasterUserKs(household, null); - // Ingest and bookmark first asset - AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset - AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + // Bookmark second asset + bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); @@ -67,7 +91,7 @@ private void cleanHistory() { // assetHistory/action/list - after clean - no object returned listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) - .setKs(masterUserKs); + .setKs(masterUserKs); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); @@ -79,14 +103,18 @@ private void cleanSpecifcAssetHistory() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); - String userKs = getHouseholdMasterUserKs(household, null); - // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetId1), null, WatchStatus.ALL, null); + // Bookmark second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movie.getId()), null, WatchStatus.ALL, null); //assetHistory/action/clean CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); @@ -102,7 +130,7 @@ private void cleanSpecifcAssetHistory() { Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); } @Description("/assetHistory/action/clean - filtered by asset type") @@ -111,12 +139,16 @@ private void cleanSpecifcAssetTypeHistory() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); - String userKs = getHouseholdMasterUserKs(household, null); - // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + // Bookmark second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(EPISODE_MEDIA_TYPE_ID)); @@ -136,21 +168,25 @@ private void cleanSpecifcAssetTypeHistory() { Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); } - @Description("/assetHistory/action/clean - filtered by asset progress") + @Description("/assetHistory/action/clean - filtered by asset finished") @Test private void cleanAssetsAccordingToWatchStatusDone() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); - String userKs = getHouseholdMasterUserKs(household, null); - // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + // Bookmark second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); @@ -169,10 +205,10 @@ private void cleanAssetsAccordingToWatchStatusDone() { Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); } - @Description("/assetHistory/action/clean - filtered by asset progress") + @Description("/assetHistory/action/clean - filtered by asset in progress") @Test private void cleanAssetsAccordingToWatchStatusProgress() { @@ -180,10 +216,15 @@ private void cleanAssetsAccordingToWatchStatusProgress() { String masterUserKs = getHouseholdMasterUserKs(household, null); String userKs = getHouseholdMasterUserKs(household, null); - // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, position2, BookmarkActionType.FINISH); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + // Bookmark second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); @@ -200,6 +241,6 @@ private void cleanAssetsAccordingToWatchStatusProgress() { Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 4d172a71f..16700a2a8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -3,20 +3,24 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.services.BookmarkService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; -import com.kaltura.client.types.AssetHistory; -import com.kaltura.client.types.AssetHistoryFilter; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BookmarkUtils; +import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import static com.kaltura.client.services.AssetHistoryService.*; +import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; @@ -33,19 +37,46 @@ public class AssetHistoryListTests extends BaseTest { private final int position2 = 20; private final int numbOfDevices = 1; private final int numOfUsers = 1; + private MediaAsset movie; + private int movieFileId; + private MediaAsset movie2; + private int movie2FileId; + private MediaAsset episode; + private int episodeFileId; + + @BeforeClass + private void list_tests_before_class() { + // Ingest first movie asset + movie = IngestUtils.ingestBasicVOD(Optional.of("movieForBookmark"), MOVIE_MEDIA_TYPE); + movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); + // Ingest second movie asset + movie2 = IngestUtils.ingestBasicVOD(Optional.of("movie2ForBookmark"), MOVIE_MEDIA_TYPE); + movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); + // Ingest episode asset + episode = IngestUtils.ingestBasicVOD(Optional.of("EpisodeForBookmark"), EPISODE_MEDIA_TYPE); + episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); + } @Description("/AssetHistory/action/list - with no filter") @Test private void vodAssetHistory() { + + // Create HH with one user and one device Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); - // Ingest and bookmark first asset - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position2, BookmarkActionType.FIRST_PLAY); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + // Bookmark second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + // Build AssetHistoryFilter object AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); //assetHistory/action/list - both assets should returned @@ -59,7 +90,7 @@ private void vodAssetHistory() { AssetHistory assetHistoryObject2 = assetHistoryListResponse.results.getObjects().get(1); // Assertions for first object returned - assertThat(assetHistoryObject1.getAssetId()).isEqualTo(assetId2); + assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movie2.getId()); assertThat(assetHistoryObject1.getAssetType()).isEqualTo(AssetType.MEDIA); assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); @@ -69,17 +100,16 @@ private void vodAssetHistory() { assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(getTimeInEpoch(0)); // Assertions for second object returned - assertThat(assetHistoryObject2.getAssetId()).isEqualTo(assetId1); + assertThat(assetHistoryObject2.getAssetId()).isEqualTo(movie.getId()); assertThat(assetHistoryObject2.getAssetType()).isEqualTo(AssetType.MEDIA); assertThat(assetHistoryObject2.getPosition()).isEqualTo(position1); // Assert total count = 2 (two bookmarks) assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); - - // clean - clean_asset_history(assetHistoryFilter, household); } + + @Description("/AssetHistory/action/list -filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { @@ -87,15 +117,24 @@ private void vodAssetHistoryFilteredByAssetId() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); - List assetIds = new ArrayList<>(); - int numOfBookmarks = 3; - for (int i = 0; i < numOfBookmarks; i++) { - long assetId = AssetHistoryUtils.ingestAssetAndPerformBookmark(masterUserKs, MOVIE_MEDIA_TYPE, position1, BookmarkActionType.FIRST_PLAY); - assetIds.add(assetId); - } + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + // Bookmark Second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + // Bookmark third asset + bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + executor.executeSync(addBookmarkBuilder); + + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movie2.getId()), + null, WatchStatus.ALL, null); - // Ingest and bookmark first asset - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(assetIds.get(1)), null, WatchStatus.ALL, null); //assetHistory/action/list - filter by asset 2 id ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) @@ -103,9 +142,10 @@ private void vodAssetHistoryFilteredByAssetId() { Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetIds.get(1)); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); + + String concatenatedString = getConcatenatedString(String.valueOf(movie2.getId()), String.valueOf(episode.getId())); - String concatenatedString = getConcatenatedString(String.valueOf(assetIds.get(1)), String.valueOf(assetIds.get(2))); //assetHistory/action/list - filter by asset 2 and asset 3 ids assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, null, WatchStatus.ALL, null); @@ -121,12 +161,11 @@ private void vodAssetHistoryFilteredByAssetId() { for (AssetHistory assetHistory : assetHistoryList) { assetHistoryIdsList.add(assetHistory.getAssetId()); } - assertThat(assetHistoryIdsList).containsOnly(assetIds.get(1), assetIds.get(2)); - - // clean - clean_asset_history(assetHistoryFilter, household); + assertThat(assetHistoryIdsList).containsOnly(movie2.getId(), episode.getId()); } + + @Description("/AssetHistory/action/list -filtered by movie type id") @Test private void vodAssetHistoryFilteredByAssetType() { @@ -135,10 +174,16 @@ private void vodAssetHistoryFilteredByAssetType() { String userKs = getHouseholdMasterUserKs(household, null); - // Ingest and bookmark first asset (movie in first play) - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + executor.executeSync(addBookmarkBuilder); + + // Bookmark Second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark).setKs(userKs); + executor.executeSync(addBookmarkBuilder); + AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(MOVIE_MEDIA_TYPE_ID)); @@ -150,10 +195,7 @@ private void vodAssetHistoryFilteredByAssetType() { Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); - - // clean - clean_asset_history(assetHistoryFilter, household); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); } @@ -164,11 +206,16 @@ private void vodAssetHistoryFilteredByAssetProgress() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String userKs = getHouseholdMasterUserKs(household, null); + // Bookmark first asset + Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + executor.executeSync(addBookmarkBuilder); + - // Ingest and bookmark first asset (movie in first play) - Long assetId1 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, MOVIE_MEDIA_TYPE, 10, BookmarkActionType.FIRST_PLAY); - // Ingest and bookmark second asset (movie in finish action) - Long assetId2 = AssetHistoryUtils.ingestAssetAndPerformBookmark(userKs, EPISODE_MEDIA_TYPE, 100, BookmarkActionType.FINISH); + // Bookmark Second asset + bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); + addBookmarkBuilder = add(bookmark).setKs(userKs); + executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); @@ -179,7 +226,7 @@ private void vodAssetHistoryFilteredByAssetProgress() { Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId1); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); @@ -189,13 +236,12 @@ private void vodAssetHistoryFilteredByAssetProgress() { assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(assetId2); + assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); // clean clean_asset_history(assetHistoryFilter, household); } - private void clean_asset_history(AssetHistoryFilter assetHistoryFilter, Household household) { CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java index 2a15cf5cf..6b25f9376 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java @@ -27,21 +27,19 @@ public static AssetHistoryFilter getAssetHistoryFilter(@Nullable String assetIdI } // Ingest asset, bookmark it and return the asset id - public static Long ingestAssetAndPerformBookmark(String ks, String mediaType, int position, BookmarkActionType bookmarkActionType) { - // Ingest asset - MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); - Long assetId = mediaAsset.getId(); - int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); - - // Movie asset bookmark - AssetType assetType = AssetType.MEDIA; - Bookmark bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, assetType, bookmarkActionType); - - BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(ks); - executor.executeSync(addBookmarkBuilder); - - return assetId; - } +// public static Long ingestAssetAndPerformBookmark(String ks, String mediaType, int position, BookmarkActionType bookmarkActionType) { +// // Ingest asset +// MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), +// Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); +// Long assetId = mediaAsset.getId(); +// int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); +// +// // Movie asset bookmark +// Bookmark bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, bookmarkActionType); +// BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); +// addBookmarkBuilder.setKs(ks); +// executor.executeSync(addBookmarkBuilder); +// +// return assetId; +// } } From 32b4e346f65e1fe9d0e1c4f62132ec439d98627d Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 7 May 2018 15:39:29 +0300 Subject: [PATCH 208/605] rename test classes names --- ...Lists.java => AssetHistoryCleanTests.java} | 14 +--- .../AssetCommentListTests.java | 6 +- .../bookmarkTests/BookmarkAddTests.java | 84 ++++++------------- .../bookmarkTests/BookmarkListTests.java | 29 +++---- .../channelTests/ChannelAddTests.java | 31 ++----- .../channelTests/ChannelDeleteTests.java | 37 ++------ .../channelTests/ChannelGetTests.java | 13 +-- ...Tests.java => EntitlementCancelTests.java} | 3 +- ...tTests.java => EntitlementGrantTests.java} | 2 +- ...teTests.java => OttUserActivateTests.java} | 2 +- ...oleTests.java => OttUserAddRoleTests.java} | 2 +- ...s.java => OttUserAnonymousLoginTests.java} | 2 +- ...leteTests.java => OttUserDeleteTests.java} | 2 +- ...va => OttUserGetEncryptedUserIdTests.java} | 2 +- .../{GetTests.java => OttUserGetTests.java} | 2 +- .../{ListTests.java => OttUserListTests.java} | 0 ...LoginTests.java => OttUserLoginTests.java} | 4 +- ...sts.java => OttUserLoginWithPinTests.java} | 0 ...goutTests.java => OttUserLogoutTests.java} | 0 ...erTests.java => OttUserRegisterTests.java} | 0 ...=> OttUserResendActivationTokenTests.java} | 0 ...ts.java => OttUserResetPasswordTests.java} | 0 ...va => OttUserSetInitialPasswordTests.java} | 0 ...ava => OttUserUpdateDynamicDataTests.java} | 0 ....java => OttUserUpdateLoginDataTests.java} | 0 ...s.java => OttUserUpdatePasswordTests.java} | 0 ...dateTests.java => OttUserUpdateTests.java} | 0 ...tTests.java => ProductPriceListTests.java} | 0 .../sessionTests/SessionGetTests.java | 23 ++--- .../sessionTests/SessionRevokeTests.java | 28 ++----- .../sessionTests/SessionSwitchUserTests.java | 44 ++++------ 31 files changed, 100 insertions(+), 230 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/{AssetHistoryActionCleanLists.java => AssetHistoryCleanTests.java} (97%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/{CancelTests.java => EntitlementCancelTests.java} (83%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/{GrantTests.java => EntitlementGrantTests.java} (99%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{ActivateTests.java => OttUserActivateTests.java} (97%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{AddRoleTests.java => OttUserAddRoleTests.java} (96%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{AnonymousLoginTests.java => OttUserAnonymousLoginTests.java} (96%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{DeleteTests.java => OttUserDeleteTests.java} (98%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{GetEncryptedUserIdTests.java => OttUserGetEncryptedUserIdTests.java} (96%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{GetTests.java => OttUserGetTests.java} (97%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{ListTests.java => OttUserListTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{LoginTests.java => OttUserLoginTests.java} (98%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{LoginWithPinTests.java => OttUserLoginWithPinTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{LogoutTests.java => OttUserLogoutTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{RegisterTests.java => OttUserRegisterTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{ResendActivationTokenTests.java => OttUserResendActivationTokenTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{ResetPasswordTests.java => OttUserResetPasswordTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{SetInitialPasswordTests.java => OttUserSetInitialPasswordTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{UpdateDynamicDataTests.java => OttUserUpdateDynamicDataTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{UpdateLoginDataTests.java => OttUserUpdateLoginDataTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{UpdatePasswordTests.java => OttUserUpdatePasswordTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/{UpdateTests.java => OttUserUpdateTests.java} (100%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/{ListTests.java => ProductPriceListTests.java} (100%) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java similarity index 97% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java index eda434237..a9cdd618d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java @@ -11,7 +11,6 @@ import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; @@ -24,7 +23,7 @@ import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; import static org.assertj.core.api.Assertions.assertThat; -public class AssetHistoryActionCleanLists extends BaseTest { +public class AssetHistoryCleanTests extends BaseTest { private final int position1 = 10; private final int position2 = 20; @@ -32,16 +31,9 @@ public class AssetHistoryActionCleanLists extends BaseTest { private final int numOfUsers = 1; - @BeforeClass - // TODO: 5/3/2018 change before method name - private void add_tests_before_class() { - - } - @Description("/assetHistory/action/clean - no filtering") @Test private void cleanHistory() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); String userKs = getHouseholdMasterUserKs(household, null); @@ -164,8 +156,8 @@ private void cleanAssetsAccordingToWatchStatusDone() { // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(masterUserKs); + ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) + .setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index 434d103e0..ed7a7037c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -29,8 +29,7 @@ public class AssetCommentListTests extends BaseTest { private String householdMasterUserKs; @BeforeClass - // TODO: 5/3/2018 edit before method name - private void add_tests_before_class() { + private void asset_comment_listTests_before_class() { int numOfUsers = 1; int numOfDevices = 1; household = createHousehold(numOfUsers, numOfDevices, false); @@ -40,7 +39,6 @@ private void add_tests_before_class() { @Description("AssetComment/action/list - check order by functionality") @Test private void checkCommentsOrder() { - String writer = "Shmulik"; Long createDate = 0L; String header = "header"; @@ -54,7 +52,6 @@ private void checkCommentsOrder() { AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); // AssetComment/action/add - first comment - AssetCommentService.AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment) .setKs(householdMasterUserKs); Response assetComment1Response = executor.executeSync(addAssetCommentBuilder); @@ -69,7 +66,6 @@ private void checkCommentsOrder() { AssetCommentOrderBy.CREATE_DATE_DESC); //AssetComment/action/list - return both comments - ListAssetCommentBuilder listAssetCommentBuilder = AssetCommentService.list(assetCommentFilter, null) .setKs(householdMasterUserKs); Response> assetCommentListResponse = executor.executeSync(listAssetCommentBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 294466672..06bd04eaa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -24,18 +24,14 @@ public class BookmarkAddTests extends BaseTest { private long assetId; private int fileId; - private BookmarkActionType actionType; private int position; - private List assetList = new ArrayList<>(); - // instantiate Bookmark object - private Bookmark bookmark = new Bookmark(); - // instantiate BookmarkFilter object - private BookmarkFilter bookmarkFilter = new BookmarkFilter(); + private List assetList; + private Bookmark bookmark; + private BookmarkFilter bookmarkFilter; @BeforeClass - private void add_tests_before_class() { - - getSharedHousehold(); + private void bookmark_addTests_before_class() { + assetList = new ArrayList<>(); assetId = BaseTest.getSharedMediaAsset().getId(); fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); @@ -48,24 +44,18 @@ private void add_tests_before_class() { @Description("bookmark/action/add - first play") @Test private void firstPlayback() { - actionType = BookmarkActionType.FIRST_PLAY; position = 0; - bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); - // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); - // Verify no error returned assertThat(booleanResponse.error).isNull(); - // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); - listBookmarkBuilder.setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); @@ -87,30 +77,23 @@ private void firstPlayback() { // Verify total count = 1 assertThat(bookmarkListResponse.results.getTotalCount()).isEqualTo(1); - } @Description("bookmark/action/add - pause") @Test private void pausePlayback() { - // Set action type to "PAUSE" - actionType = BookmarkActionType.PAUSE; position = 30; - bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PAUSE); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); - // Verify response return true assertThat(booleanResponse.results.booleanValue()).isTrue(); - // Verify no error returned assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); - listBookmarkBuilder.setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); @@ -121,45 +104,39 @@ private void pausePlayback() { @Description("bookmark/action/add - 95% watching == finish watching") @Test private void watchingNinetyFive() { - actionType = BookmarkActionType.PLAY; position = 999; - bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PLAY); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); - // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); - // Verify no error returned assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); - listBookmarkBuilder.setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark3 = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = true assertThat(bookmark3.getFinishedWatching()).isTrue(); - } @Description("bookmark/action/add - back to start - position:0") @Test private void backToStart() { - actionType = BookmarkActionType.STOP; position = 0; - bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.STOP); - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); - listBookmarkBuilder.setKs(getSharedMasterUserKs()); + + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); + // Verify finishedWatching = false assertThat(bookmark.getFinishedWatching()).isFalse(); } @@ -167,46 +144,37 @@ private void backToStart() { @Description("bookmark/action/add - finish watching") @Test private void finishWatching() { - // Set action type to "FINISH" - actionType = BookmarkActionType.FINISH; position = 60; - bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, actionType); + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FINISH); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); - // Verify response return true + assertThat(booleanResponse.results.booleanValue()).isTrue(); - // Verify no error returned assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); - listBookmarkBuilder.setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = true assertThat(bookmark.getFinishedWatching()).isTrue(); - } - // Error validations - @Description("bookmark/action/add - empty asset id") @Test private void emptyAssetId() { bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); + assertThat(booleanResponse.results).isNull(); // Verify exception returned - code: 500003 ("Invalid Asset id") assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500003).getCode()); } - // TODO - Add test for EPG bookmark // TODO - Add test for recording bookmark } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index ba818af51..b9cf28cae 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -24,17 +24,13 @@ public class BookmarkListTests extends BaseTest { - private Long assetId; - private int fileId; - - - private Long assetId2; - private int fileId2; - - private List assetList = new ArrayList<>(); + private long assetId, assetId2; + private int fileId, fileId2; + private List assetList; @BeforeClass - private void list_tests_before_class() { + private void bookmark_listTtests_before_class() { + assetList = new ArrayList<>(); assetId = BaseTest.getSharedMediaAsset().getId(); List assetFileIds = AssetUtils.getAssetFileIds(String.valueOf(assetId)); @@ -49,13 +45,10 @@ private void list_tests_before_class() { @Description("bookmark/action/list - order by") @Test - private void BookmarkOrderBy() { - // Bookmark asset1 Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - addBookmarkBuilder.setKs(getSharedMasterUserKs()); + BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); @@ -63,14 +56,13 @@ private void BookmarkOrderBy() { // Bookmark asset2 Bookmark bookmark2 = BookmarkUtils.addBookmark(10, String.valueOf(assetId2), fileId2, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder2 = BookmarkService.add(bookmark2); - addBookmarkBuilder2.setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder2 = BookmarkService.add(bookmark2).setKs(getSharedMasterUserKs()); Response booleanResponse2 = executor.executeSync(addBookmarkBuilder2); assertThat(booleanResponse2.results.booleanValue()).isTrue(); + // set filter BookmarkFilter bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_DESC,AssetType.MEDIA, assetList); - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter); - listBookmarkBuilder.setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmarkObject = bookmarkListResponse.results.getObjects().get(0); @@ -81,8 +73,7 @@ private void BookmarkOrderBy() { assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId)); bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC,AssetType.MEDIA, assetList); - listBookmarkBuilder = BookmarkService.list(bookmarkFilter); - listBookmarkBuilder.setKs(getSharedMasterUserKs()); + listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); bookmarkListResponse = executor.executeSync(listBookmarkBuilder); bookmarkObject = bookmarkListResponse.results.getObjects().get(0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index d14d5cb9d..902b4b448 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -26,7 +26,7 @@ public class ChannelAddTests extends BaseTest { - private Channel channel = new Channel(); + private Channel channel; private String channelName; private String Description; private Boolean isActive = true; @@ -36,7 +36,7 @@ public class ChannelAddTests extends BaseTest { @BeforeClass - private void get_tests_before_class() { + private void channel_addTests_before_class() { channelName = "Channel_12345"; Description = "description of channel"; } @@ -48,14 +48,12 @@ private void addChannel() { channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel); - addChannelBuilder.setKs(getManagerKs()); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); assertThat(channelResponse.results.getName()).isEqualTo(channelName); } - // TODO @Description("channel/action/add - order by NAME_DESC") @Test private void checkOrderOfAssetsInChannel() { @@ -73,8 +71,7 @@ private void checkOrderOfAssetsInChannel() { channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel); - addChannelBuilder.setKs(getManagerKs()); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); assertThat(channelResponse.results.getName()).isEqualTo(channelName); @@ -84,8 +81,7 @@ private void checkOrderOfAssetsInChannel() { ChannelFilter channelFilter = AssetUtils.getChannelFilter(channelId, null, null, null); //asset/action/list - ListAssetBuilder listAssetBuilder = AssetService.list(channelFilter); - listAssetBuilder.setKs(getManagerKs()); + ListAssetBuilder listAssetBuilder = AssetService.list(channelFilter).setKs(getManagerKs()); Response> listResponse = executor.executeSync(listAssetBuilder); assertThat(listResponse.results.getTotalCount()).isEqualTo(2); @@ -93,13 +89,10 @@ private void checkOrderOfAssetsInChannel() { assertThat(listResponse.results.getObjects().get(0).getId()).isEqualTo(movieAsset.getId()); // Cleanup - channel/action/delete - DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId); - deleteChannelBuilder.setKs(getManagerKs()); + DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId).setKs(getManagerKs()); executor.executeSync(deleteChannelBuilder); - } - @Description("channel/action/add - with invalid asset type") @Test private void addChannelWithInvalidAssetType() { @@ -108,9 +101,7 @@ private void addChannelWithInvalidAssetType() { channel = ChannelUtils.addChannel(channelName, Description, isActive, null, AssetOrderBy.LIKES_DESC, assetTypes, null); //channel/action/add - - AddChannelBuilder addChannelBuilder = ChannelService.add(channel); - addChannelBuilder.setKs(getManagerKs()); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); // KalturaAPIException","code":"4020","message":"KSQL Channel media type 666 does not belong to group" @@ -123,9 +114,7 @@ private void addChannelWithNoName() { channel = ChannelUtils.addChannel(null, Description, isActive, null, AssetOrderBy.LIKES_DESC, null, null); //channel/action/add - - AddChannelBuilder addChannelBuilder = ChannelService.add(channel); - addChannelBuilder.setKs(getManagerKs()); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); // KalturaAPIException","code":"5005","message":"KSQL Channel must have a name" @@ -139,9 +128,7 @@ private void addChannelWithSyntaxErrorInFilterExpression() { channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); //channel/action/add - - AddChannelBuilder addChannelBuilder = ChannelService.add(channel); - addChannelBuilder.setKs(getManagerKs()); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); // KalturaAPIException","code":"4004","message":"Invalid expression structure" diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 12543b98e..09c44c565 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.channelTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; @@ -8,58 +7,40 @@ import com.kaltura.client.types.Channel; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.ChannelService.*; +import static com.kaltura.client.services.ChannelService.GetChannelBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class ChannelDeleteTests extends BaseTest { - private Channel channel = new Channel(); - private String channelName; - private String Description; - private Boolean isActive; - private String filterExpression; + private Channel channel; private int channelId; - - @BeforeClass - private void get_tests_before_class() { - channelName = "Channel_12345"; - Description = "description of channel"; - isActive = true; - filterExpression = "name ~ 'movie'"; - } + private final String channelName = "Channel_12345"; + private final String Description = "description of channel"; + private final String filterExpression = "name ~ 'movie'"; @Description("channel/action/delete") @Test private void DeleteChannel() { + channel = ChannelUtils.addChannel(channelName, Description, true, filterExpression, AssetOrderBy.LIKES_DESC, null, null); - channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); - - // channel/action/add // channel/action/add - - ChannelService.AddChannelBuilder addChannelBuilder = ChannelService.add(channel); - addChannelBuilder.setKs(getManagerKs()); + ChannelService.AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); channelId = Math.toIntExact(channelResponse.results.getId()); // channel/action/delete - - ChannelService.DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId); - deleteChannelBuilder.setKs(getManagerKs()); + ChannelService.DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId).setKs(getManagerKs()); Response deleteResponse = executor.executeSync(deleteChannelBuilder); assertThat(deleteResponse.results.booleanValue()).isTrue(); // channel/action/get - verify channel wasn't found - - GetChannelBuilder getChannelBuilder = ChannelService.get(channelId); - getChannelBuilder.setKs(getManagerKs()); + GetChannelBuilder getChannelBuilder = ChannelService.get(channelId).setKs(getManagerKs()); Response getResponse = executor.executeSync(getChannelBuilder); assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java index f8cbc9d3c..8e21973aa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java @@ -3,22 +3,17 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.Channel; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class ChannelGetTests extends BaseTest { - private Channel channel = new Channel(); - private String channelName = "Channel_12345"; - private String Description = "description of channel"; - private Boolean isActive = true; + private Channel channel; private String filterExpression; -public class ChannelActionGet extends BaseTest { + private final String channelName = "Channel_12345"; + private final String Description = "description of channel"; - @BeforeClass - private void get_tests_before_class() { - } +public class ChannelActionGet extends BaseTest { @Description @Test diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/CancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java similarity index 83% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/CancelTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 6b8bf4c0e..e31fd01b2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/CancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -3,11 +3,10 @@ import com.kaltura.client.test.tests.BaseTest; import org.testng.annotations.Test; -public class CancelTests extends BaseTest { +public class EntitlementCancelTests extends BaseTest { @Test(description = "entitlement/action/cancel") private void cancel() { // EntitlementServiceImpl - } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java similarity index 99% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index a4a7047c7..bad5ee703 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/GrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -21,7 +21,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -public class GrantTests extends BaseTest { +public class EntitlementGrantTests extends BaseTest { // TODO: 4/12/2018 remove hardcoded subscription Id private final int subscriptionId = 327699; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java similarity index 97% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java index ae67cb9de..66eecb199 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java @@ -17,7 +17,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class ActivateTests extends BaseTest { +public class OttUserActivateTests extends BaseTest { private OTTUser user; private Response ottUserResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java similarity index 96% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java index 35b08a0ae..b42fed22b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java @@ -13,7 +13,7 @@ import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; -public class AddRoleTests extends BaseTest { +public class OttUserAddRoleTests extends BaseTest { private OTTUser user; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java similarity index 96% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java index f5577338d..043729a05 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/AnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java @@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class AnonymousLoginTests extends BaseTest { +public class OttUserAnonymousLoginTests extends BaseTest { private Response loginSessionResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java index f03405ecd..a0fd24092 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/DeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java @@ -23,7 +23,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class DeleteTests extends BaseTest { +public class OttUserDeleteTests extends BaseTest { private Household household; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java similarity index 96% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java index c7d637403..4d69281c1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java @@ -14,7 +14,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class GetEncryptedUserIdTests extends BaseTest { +public class OttUserGetEncryptedUserIdTests extends BaseTest { private OTTUser user; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java similarity index 97% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java index db59a7a36..6a3a42903 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/GetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java @@ -14,7 +14,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class GetTests extends BaseTest { +public class OttUserGetTests extends BaseTest { private OTTUser user; private Response loginResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ListTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java index 32a4e36ab..f9201662c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java @@ -55,7 +55,7 @@ private void login_with_wrong_password() { } @Severity(SeverityLevel.NORMAL) - @Description("ottUser/action/login - login with wrong username - error 1011") + @Description("ottUser/action/login - login with wrong username - error 2000") @Test private void login_with_wrong_username() { String fakeUsername = user.getUsername() + "1"; @@ -65,7 +65,7 @@ private void login_with_wrong_username() { // assertions assertThat(loginResponse.results).isNull(); - assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LoginWithPinTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/LogoutTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/RegisterTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResendActivationTokenTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/ResetPasswordTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/SetInitialPasswordTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateDynamicDataTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateLoginDataTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdatePasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdatePasswordTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/UpdateTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ListTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index bbe983a3d..447a77bcc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; -import com.kaltura.client.Client; import com.kaltura.client.services.SessionService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; @@ -11,22 +10,14 @@ import com.kaltura.client.types.Session; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.SessionService.*; +import static com.kaltura.client.services.SessionService.GetSessionBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class SessionGetTests extends BaseTest { - private Client client; - - @BeforeClass - private void get_tests_before_class() { - - } - @Description("session/action/get - master user") @Test private void getMasterUserSession() { @@ -35,8 +26,7 @@ private void getMasterUserSession() { String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); String session = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), udid); - GetSessionBuilder getSessionBuilder = SessionService.get(session); - getSessionBuilder.setKs(getAdministratorKs()); + GetSessionBuilder getSessionBuilder = SessionService.get(session).setKs(getAdministratorKs()); Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); @@ -52,8 +42,7 @@ private void getMasterUserSession() { private void getAnonymousUserSession() { String session = BaseTest.getAnonymousKs(); - GetSessionBuilder getSessionBuilder = SessionService.get(session); - getSessionBuilder.setKs(getAdministratorKs()); + GetSessionBuilder getSessionBuilder = SessionService.get(session).setKs(getAdministratorKs()); Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); @@ -66,8 +55,7 @@ private void getAnonymousUserSession() { private void getOperatorUserSession() { String session = getOperatorKs(); - GetSessionBuilder getSessionBuilder = SessionService.get(session); - getSessionBuilder.setKs(getAdministratorKs()); + GetSessionBuilder getSessionBuilder = SessionService.get(session).setKs(getAdministratorKs()); Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.results.getKs()).isEqualTo(session); @@ -80,8 +68,7 @@ private void getOperatorUserSession() { private void getSessionWithInvalidSessionKs() { String session = getOperatorKs() + 1; - GetSessionBuilder getSessionBuilder = SessionService.get(session); - getSessionBuilder.setKs(getAdministratorKs()); + GetSessionBuilder getSessionBuilder = SessionService.get(session).setKs(getAdministratorKs()); Response getSessionResponse = executor.executeSync(getSessionBuilder); assertThat(getSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500015).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java index 81f400ed7..69d2e1014 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java @@ -1,32 +1,22 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; -import com.kaltura.client.Client; import com.kaltura.client.services.OttUserService; import com.kaltura.client.services.SessionService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; - import com.kaltura.client.types.Household; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.GetOttUserBuilder; +import static com.kaltura.client.services.SessionService.RevokeSessionBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.services.SessionService.*; -import static com.kaltura.client.services.OttUserService.*; public class SessionRevokeTests extends BaseTest { - public static Client client; - - @BeforeClass - private void revoke_tests_before_class() { - } - - @Description("/session/action/revoke - 2 different kss") @Test private void RevokeKs() { @@ -42,9 +32,7 @@ private void RevokeKs() { } // Revoke all sessions for specific user - - RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke(); - revokeSessionBuilder.setKs(masterUserKs); + RevokeSessionBuilder revokeSessionBuilder = SessionService.revoke().setKs(masterUserKs); Response booleanResponse = executor.executeSync(revokeSessionBuilder); assertThat(booleanResponse.results).isTrue(); @@ -56,17 +44,15 @@ private void RevokeKs() { } // Verify ks is expired - - GetOttUserBuilder getOttUserBuilder = OttUserService.get(); - getOttUserBuilder.setKs(masterUserKs); + GetOttUserBuilder getOttUserBuilder = OttUserService.get().setKs(masterUserKs); Response ottUserResponse = executor.executeSync(getOttUserBuilder); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); // Verify ks2 is expired - - GetOttUserBuilder getOttUserBuilder2 = OttUserService.get(); - getOttUserBuilder2.setKs(masterUserKs2); + GetOttUserBuilder getOttUserBuilder2 = OttUserService.get().setKs(masterUserKs2); Response ottUserResponse2 = executor.executeSync(getOttUserBuilder); + assertThat(ottUserResponse2.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index ca2894cf4..0a51e9dd3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -1,29 +1,31 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; -import com.kaltura.client.Client; import com.kaltura.client.enums.UserState; import com.kaltura.client.services.OttUserService; import com.kaltura.client.services.SessionService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.LoginSession; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.Session; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.GetOttUserBuilder; +import static com.kaltura.client.services.SessionService.GetSessionBuilder; +import static com.kaltura.client.services.SessionService.SwitchUserSessionBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.services.SessionService.*; -import static com.kaltura.client.services.OttUserService.*; public class SessionSwitchUserTests extends BaseTest { //TODO - replace hardcoded user id private String UserId = "1543798"; private String userKs; - public static Client client; @BeforeClass private void switchUser_tests_before_class() { @@ -40,9 +42,7 @@ private void SwitchUser() { String secondUserId = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0).getUserId(); // Invoke session/action/switchUser - second user replace master user in the session - - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(secondUserId); - switchUserSessionBuilder.setKs(masterUserKs); + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(secondUserId).setKs(masterUserKs); Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); // Verify new session ks returned @@ -52,19 +52,15 @@ private void SwitchUser() { ///----- After User was switched ------ // Invoke OttUser/action/get - with master user (expired) ks - - OttUserService.GetOttUserBuilder getOttUserBuilder = OttUserService.get(); - getOttUserBuilder.setKs(masterUserKs); + OttUserService.GetOttUserBuilder getOttUserBuilder = OttUserService.get().setKs(masterUserKs); Response ottUserResponse = executor.executeSync(getOttUserBuilder); // Verify master user ks is now expired (after the switch) assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); // Invoke OttUser/action/get with second user new ks - - GetOttUserBuilder getOttUserBuilder2 = OttUserService.get(); - getOttUserBuilder2.setKs(secondUserKs); - Response ottUserResponse2 = executor.executeSync(getOttUserBuilder); + GetOttUserBuilder getOttUserBuilder2 = OttUserService.get().setKs(secondUserKs); + Response ottUserResponse2 = executor.executeSync(getOttUserBuilder2); // Verify second user id return in the response assertThat(ottUserResponse2.results.getId()).isEqualTo(secondUserId); @@ -72,9 +68,7 @@ private void SwitchUser() { // Invoke session/action/get - - GetSessionBuilder getSessionBuilder = SessionService.get(secondUserKs); - getSessionBuilder.setKs(getAdministratorKs()); + GetSessionBuilder getSessionBuilder = SessionService.get(secondUserKs).setKs(getAdministratorKs()); Response getSessionResponse = executor.executeSync(getSessionBuilder); // Verify second user id returned in the response @@ -91,9 +85,7 @@ private void SwitchUserToHimself() { String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); // Invoke session/action/switchUser - Should return an error (user can't switched to himself - - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(masterUserId); - switchUserSessionBuilder.setKs(masterUserKs); + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(masterUserId).setKs(masterUserKs); Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); // Verify exception returned @@ -108,8 +100,7 @@ private void SwitchInactiveUser() { String inactiveUserId = "1543797"; String UserKs = OttUserUtils.getKs(Integer.valueOf(UserId), null); - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(inactiveUserId); - switchUserSessionBuilder.setKs(UserKs); + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(inactiveUserId).setKs(UserKs); Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2016).getCode()); @@ -126,8 +117,7 @@ private void switchToUserFromAnotherHousehold() { //TODO - replace hardcoded user id String userIdFromHousehold2 = "638731"; - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(userIdFromHousehold2); - switchUserSessionBuilder.setKs(Use1rKs); + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(userIdFromHousehold2).setKs(Use1rKs); Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); @@ -137,9 +127,7 @@ private void switchToUserFromAnotherHousehold() { @Description("/session/action/switchUser - No user id to switch provided") @Test private void switchToUserWithoutUserId() { - - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(null); - switchUserSessionBuilder.setKs(userKs); + SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(null).setKs(userKs); Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500053).getCode()); From 83943fb0313d61892805bea3f502c303dbd46212 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Mon, 7 May 2018 15:40:05 +0300 Subject: [PATCH 209/605] Fixed asset history tests --- .../AssetHistoryActionCleanLists.java | 13 ++++++------- .../AssetHistoryTests/AssetHistoryListTests.java | 13 ++----------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java index a247f3ada..1b914244a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryActionCleanLists.java @@ -152,7 +152,7 @@ private void cleanSpecifcAssetTypeHistory() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(EPISODE_MEDIA_TYPE_ID)); - //assetHistory/action/clean - only episode type (asset id 2) + //assetHistory/action/clean - only episode type (episode) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(masterUserKs); @@ -161,7 +161,7 @@ private void cleanSpecifcAssetTypeHistory() { // Update assetHistoryFilter object (assetIdIn = null) assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); - // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) + // assetHistory/action/list - after clean - only movie returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); listAssetHistoryBuilder.setKs(masterUserKs); @@ -190,7 +190,7 @@ private void cleanAssetsAccordingToWatchStatusDone() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); - //assetHistory/action/clean - only asset that were finished (asset 2) + //assetHistory/action/clean - only asset that were finished (episode) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(masterUserKs); @@ -198,7 +198,7 @@ private void cleanAssetsAccordingToWatchStatusDone() { assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); - // assetHistory/action/list - after clean - only asset id 1 returned (was not cleaned) + // assetHistory/action/list - after clean - only movie returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); listAssetHistoryBuilder.setKs(masterUserKs); @@ -214,7 +214,6 @@ private void cleanAssetsAccordingToWatchStatusProgress() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String masterUserKs = getHouseholdMasterUserKs(household, null); - String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -228,14 +227,14 @@ private void cleanAssetsAccordingToWatchStatusProgress() { AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); - //assetHistory/action/clean - only asset that in progress (asset 1) + //assetHistory/action/clean - only asset that in progress (movie) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); - // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) + // assetHistory/action/list - after clean - only episode returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); listAssetHistoryBuilder.setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 16700a2a8..5fb50d25d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -221,8 +221,7 @@ private void vodAssetHistoryFilteredByAssetProgress() { //assetHistory/action/list - filter by in progress assets only - ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); + ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null).setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -232,20 +231,12 @@ private void vodAssetHistoryFilteredByAssetProgress() { //assetHistory/action/list - filter by finished assets only - listAssetHistoryBuilder = list(assetHistoryFilter, null); + listAssetHistoryBuilder = list(assetHistoryFilter, null).setKs(userKs); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); - // clean - clean_asset_history(assetHistoryFilter, household); - } - - private void clean_asset_history(AssetHistoryFilter assetHistoryFilter, Household household) { - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); - executor.executeSync(cleanAssetHistoryBuilder); } //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] From 9245b66487fcdc14d13f71894e5afa0ccb58c5f7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 7 May 2018 15:41:18 +0300 Subject: [PATCH 210/605] fixed SwitchUserTest --- .../servicesTests/sessionTests/SessionSwitchUserTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index ca2894cf4..2cd9b72b4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -64,7 +64,7 @@ private void SwitchUser() { GetOttUserBuilder getOttUserBuilder2 = OttUserService.get(); getOttUserBuilder2.setKs(secondUserKs); - Response ottUserResponse2 = executor.executeSync(getOttUserBuilder); + Response ottUserResponse2 = executor.executeSync(getOttUserBuilder2); // Verify second user id return in the response assertThat(ottUserResponse2.results.getId()).isEqualTo(secondUserId); From 9c1dcf964579ec1265a211ab0abb8871f9b15d00 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 7 May 2018 15:50:47 +0300 Subject: [PATCH 211/605] change test classes names --- .../test/tests/servicesTests/ottUserTests/OttUserListTests.java | 2 +- .../tests/servicesTests/ottUserTests/OttUserLoginTests.java | 2 +- .../servicesTests/ottUserTests/OttUserLoginWithPinTests.java | 2 +- .../tests/servicesTests/ottUserTests/OttUserLogoutTests.java | 2 +- .../tests/servicesTests/ottUserTests/OttUserRegisterTests.java | 2 +- .../ottUserTests/OttUserResendActivationTokenTests.java | 2 +- .../servicesTests/ottUserTests/OttUserResetPasswordTests.java | 2 +- .../ottUserTests/OttUserSetInitialPasswordTests.java | 2 +- .../ottUserTests/OttUserUpdateDynamicDataTests.java | 2 +- .../servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java | 2 +- .../servicesTests/ottUserTests/OttUserUpdatePasswordTests.java | 2 +- .../tests/servicesTests/ottUserTests/OttUserUpdateTests.java | 2 +- .../servicesTests/productPriceTests/ProductPriceListTests.java | 2 +- src/test/resources/testng.xml | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java index 1c6861ed1..f7d42ae74 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java @@ -20,7 +20,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.getUserById; import static org.assertj.core.api.Assertions.assertThat; -public class ListTests extends BaseTest { +public class OttUserListTests extends BaseTest { private Household household; private Response> householdUserListResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java index f9201662c..e8b45b3b9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java @@ -17,7 +17,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class LoginTests extends BaseTest { +public class OttUserLoginTests extends BaseTest { private OTTUser user; private Response loginResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index bf2f0baf2..f369ced7e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -18,7 +18,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class LoginWithPinTests extends BaseTest { +public class OttUserLoginWithPinTests extends BaseTest { private OTTUser user; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java index 3c66f3062..1232a5119 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java @@ -16,7 +16,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class LogoutTests extends BaseTest { +public class OttUserLogoutTests extends BaseTest { private OTTUser user; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java index 6c5f4fb37..da78a03a9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java @@ -13,7 +13,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class RegisterTests extends BaseTest { +public class OttUserRegisterTests extends BaseTest { private OTTUser user; private Response ottUserResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java index f5159135d..de6ab0e59 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java @@ -13,7 +13,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class ResendActivationTokenTests extends BaseTest { +public class OttUserResendActivationTokenTests extends BaseTest { private OTTUser user; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java index 8a23ae50a..28946066c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java @@ -13,7 +13,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class ResetPasswordTests extends BaseTest { +public class OttUserResetPasswordTests extends BaseTest { private OTTUser user; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java index 82c075a04..6ded7d45d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java @@ -2,7 +2,7 @@ import com.kaltura.client.test.tests.BaseTest; -public class SetInitialPasswordTests extends BaseTest { +public class OttUserSetInitialPasswordTests extends BaseTest { // TODO: 4/1/2018 implemente tests } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java index 67063a3aa..99ab72756 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java @@ -15,7 +15,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class UpdateDynamicDataTests extends BaseTest { +public class OttUserUpdateDynamicDataTests extends BaseTest { private OTTUser user; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java index 518071c90..7803f4cc2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java @@ -14,7 +14,7 @@ import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; -public class UpdateLoginDataTests extends BaseTest { +public class OttUserUpdateLoginDataTests extends BaseTest { private Response loginResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java index a3ade05e3..709c47dcd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java @@ -2,6 +2,6 @@ import com.kaltura.client.test.tests.BaseTest; -public class UpdatePasswordTests extends BaseTest { +public class OttUserUpdatePasswordTests extends BaseTest { // TODO: 4/1/2018 implement tests } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index 2c87ab74f..26d321bf6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class UpdateTests extends BaseTest { +public class OttUserUpdateTests extends BaseTest { private OTTUser user; private String originalUserEmail; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index d2637e77e..811ff0885 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -23,7 +23,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; -public class ListTests extends BaseTest { +public class ProductPriceListTests extends BaseTest { private EntitlementFilter entitlementPpvsFilter; private EntitlementFilter entitlementSubsFilter; diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index c49991c68..a8f715a82 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -14,7 +14,7 @@ - + From ca1850b5e706a83d69c9affb266a79e0d5ed255d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 8 May 2018 11:14:19 +0300 Subject: [PATCH 212/605] Disabled tests having issues --- .../appTokenTests/AppTokenStartSessionTests.java | 2 +- .../servicesTests/entitlementTests/EntitlementGrantTests.java | 4 ++-- .../tests/servicesTests/ottUserTests/OttUserUpdateTests.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index e732aed69..fb68b20ac 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -127,7 +127,7 @@ private void startSessionSha256() { @Issue("BEO-4980") @Description("appToken/action/startSession - token id with default expiry date (according to the value in group_203 CB document") - @Test + @Test(enabled = false) private void startSessionDefaultExpiryDate() { // TODO: 5/3/2018 add comments! int expiryDate = 0; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index bad5ee703..8736a55ce 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -334,13 +334,13 @@ private void grant_purchased_subscription() { } @Issue("BEO-5022") - @Test(description = "entitlement/action/grant - error 3023") + @Test(description = "entitlement/action/grant - error 3023", enabled = false) private void grant_3023() { // TODO: 4/30/2018 implement test } @Issue("BEO-5022") - @Test(description = "entitlement/action/grant - grant ppv with missing content id - error 3018") + @Test(description = "entitlement/action/grant - grant ppv with missing content id - error 3018", enabled = false) private void grant_ppv_with_missing_contentId() { // TODO: 4/30/2018 implement test } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index 26d321bf6..ca3bacaea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -62,7 +62,7 @@ private void updateTest() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update with administratorKs") @Issue("BEO-4919") - @Test(enabled = true) + @Test(enabled = false) // TODO: find if it possible to exclude ftom build results failed tests having @Issue annotation private void update_with_administratorKs() { // update user info From 9351c2dbbdceb510107f0a83e904304452377fb9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 8 May 2018 11:26:02 +0300 Subject: [PATCH 213/605] fix some entitlementTests --- .../EntitlementGrantTests.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index bad5ee703..afb116255 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -4,10 +4,10 @@ import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionHistoryOrderBy; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.*; -import com.kaltura.client.services.EntitlementService.*; -import com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; -import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.EntitlementService.GrantEntitlementBuilder; +import com.kaltura.client.services.HouseholdService.*; +import com.kaltura.client.services.TransactionHistoryService; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; @@ -18,6 +18,12 @@ import io.qameta.allure.Issue; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + +import static com.kaltura.client.services.HouseholdService.*; +import static com.kaltura.client.services.OttUserService.RegisterOttUserBuilder; +import static com.kaltura.client.services.OttUserService.register; +import static com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; +import static com.kaltura.client.services.ProductPriceService.list; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -27,13 +33,13 @@ public class EntitlementGrantTests extends BaseTest { private final int subscriptionId = 327699; private final int ppvId = 30297; private final int assetId = 607368; + private int contentId; private final int numberOfUsersInHousehold = 2; private final int numberOfDevicesInHousehold = 1; - private Response> billingTransactionListResponse; - private int contentId; private Household testSharedHousehold; + private Response> billingTransactionListResponse; @BeforeClass @@ -62,7 +68,7 @@ private void grant_subscription_with_history() { ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.subscriptionIdIn(String.valueOf(subscriptionId)); - ProductPriceService.ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter) + ListProductPriceBuilder listProductPriceBuilder = list(productPriceFilter) .setUserId(Integer.valueOf(masterUser.getUserId())) .setKs(getAdministratorKs()); Response> productPriceListResponse = executor.executeSync(listProductPriceBuilder); @@ -104,7 +110,7 @@ private void grant_subscription_with_history() { //delete household for cleanup //HouseholdService.delete(getClient(getAdministratorKs()), Math.toIntExact(household.getId())); - DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) .setKs(getAdministratorKs()); executor.executeSync(deleteHouseholdBuilder); } @@ -146,7 +152,7 @@ private void grant_subscription_without_history() { //delete household for cleanup - DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) .setKs(getAdministratorKs()); executor.executeSync(deleteHouseholdBuilder); } @@ -158,13 +164,11 @@ private void grant_ppv_with_history() { HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); - // grant subscription - history = true GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) .setUserId(Integer.valueOf(user.getUserId())) .setKs(getAdministratorKs()); Response booleanResponse = executor.executeSync(grantEntitlementBuilder); - assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); @@ -172,7 +176,7 @@ private void grant_ppv_with_history() { ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.fileIdIn(String.valueOf(contentId)); - ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter) + ListProductPriceBuilder listProductPriceBuilder = list(productPriceFilter) .setUserId(Integer.valueOf(masterUser.getUserId())) .setKs(getAdministratorKs()); Response> productPriceListResponse = executor.executeSync(listProductPriceBuilder); @@ -213,7 +217,7 @@ private void grant_ppv_with_history() { //delete household for cleanup - DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) .setKs(getAdministratorKs()); executor.executeSync(deleteHouseholdBuilder); } @@ -265,7 +269,7 @@ private void grant_ppv_without_history() { //delete household for cleanup - DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) .setKs(getAdministratorKs()); executor.executeSync(deleteHouseholdBuilder); } @@ -348,7 +352,7 @@ private void grant_ppv_with_missing_contentId() { @Test(description = "entitlement/action/grant - user not in domain - error 1005") private void grant_ppv_user_not_in_domain() { // get user form test shared household - OttUserService.RegisterOttUserBuilder registerOttUserBuilder = OttUserService.register(partnerId, OttUserUtils.generateOttUser(), defaultUserPassword); + RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, OttUserUtils.generateOttUser(), defaultUserPassword); Response ottUserResponse = executor.executeSync(registerOttUserBuilder); OTTUser user = ottUserResponse.results; @@ -372,15 +376,17 @@ private void grant_ppv_user_suspend() { HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); // suspend household - HouseholdService.suspend(0) + SuspendHouseholdBuilder suspendHouseholdBuilder = suspend(0) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results.booleanValue()).isTrue(); // grant subscription to suspend user GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(subscriptionId, TransactionType.SUBSCRIPTION, false, 0) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(masterUser.getUserId())); - Response booleanResponse = executor.executeSync(grantEntitlementBuilder); + booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 2001 is return assertThat(booleanResponse.results).isEqualTo(null); From 3096a4173c5ba3e1c4768f26f3f2daf3133843b8 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 8 May 2018 16:25:52 +0300 Subject: [PATCH 214/605] change getActivationToken() to use getJsonArrayFromQueryResult() as example for Max --- .../AssetCommentAddTests.java | 1 - .../EntitlementGrantTests.java | 1 - .../ottUserTests/OttUserUpdateTests.java | 2 +- .../com/kaltura/client/test/utils/DBUtils.java | 18 ++++++++++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index d5171614f..0bb4e1988 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -89,7 +89,6 @@ private void addCommentForVod() { @Description("AssetComment/action/add - EPG program") @Test private void addCommentForEPGProgram() { - // Ingest EPG program Response> epgProgram = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index afb116255..954dad2b6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -61,7 +61,6 @@ private void grant_subscription_with_history() { .setUserId(Integer.valueOf(user.getUserId())) .setKs(getAdministratorKs()); Response booleanResponse = executor.executeSync(grantEntitlementBuilder); - assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); // verify other user from the household entitled to granted subscription diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index 26d321bf6..d60fd2f27 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -62,7 +62,7 @@ private void updateTest() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update with administratorKs") @Issue("BEO-4919") - @Test(enabled = true) + @Test(enabled = false) private void update_with_administratorKs() { // update user info diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 5e2564293..47060c55b 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -38,9 +38,8 @@ public class DBUtils extends BaseUtils { "and dc.[status]=1 and dc.is_active=1"; //TODO - change existing methods to work with the new convertToJSON method - // Return json array from DB - public static JSONArray convertToJSON(String query) throws Exception { + private static JSONArray getJsonArrayFromQueryResult(String query) throws Exception { openConnection(); JSONArray jsonArray = new JSONArray(); rs = stam.executeQuery(query); @@ -177,7 +176,7 @@ public static String getUserDataByRole(String userRole) { } public static String getActivationToken(String username) { - openConnection(); + /*openConnection(); try { rs = stam.executeQuery(String.format(ACTIVATION_TOKEN_SELECT, username)); } catch (SQLException e) { @@ -195,7 +194,18 @@ public static String getActivationToken(String username) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("activationToken can't be null"); } - closeConnection(); + closeConnection();*/ + + String activationToken = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ACTIVATION_TOKEN_SELECT, username)); + activationToken = jsonArray.getJSONObject(0).getString("activation_token"); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("activation_token can't be null"); + } + return activationToken; } From c64de5f86d554437bce573a155c897b8d6ddda88 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 9 May 2018 04:20:45 +0300 Subject: [PATCH 215/605] Updated subscription on common used from readyApi project --- .../servicesTests/entitlementTests/EntitlementGrantTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index e768c4fd2..fcc18fcb5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -30,7 +30,7 @@ public class EntitlementGrantTests extends BaseTest { // TODO: 4/12/2018 remove hardcoded subscription Id - private final int subscriptionId = 327699; + private final int subscriptionId = 41114; private final int ppvId = 30297; private final int assetId = 607368; private int contentId; From 46252e547d99c0be162847c5b690273f4d480cc1 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 9 May 2018 05:42:35 +0300 Subject: [PATCH 216/605] DBUtils updated to use getJsonArrayFromQueryResult method --- .../kaltura/client/test/utils/DBUtils.java | 77 +++---------------- 1 file changed, 12 insertions(+), 65 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 47060c55b..8fda6a1f8 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -97,53 +97,31 @@ private static JSONArray getJsonArrayFromQueryResult(String query) throws Except } public static String getDiscountByPercentAndCurrency(String currency, int percent) { - openConnection(); - try { - rs = stam.executeQuery(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, BaseTest.partnerId)); - } catch (SQLException e) { - e.printStackTrace(); - } - try { - rs.next(); - } catch (SQLException e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("No data about discount with currency " + currency + "and percent " + percent + " in account " + BaseTest.partnerId); - } String code = ""; try { - code = rs.getString("code"); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, BaseTest.partnerId)); + code = jsonArray.getJSONObject(0).getString("code"); if ("".equals(code)) { throw new SQLException(); } - } catch (SQLException e) { + } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("code can't be null"); } - closeConnection(); + return code; } public static boolean isActivationOfUsersNeeded() { - openConnection(); - try { - rs = stam.executeQuery(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId)); - } catch (SQLException e) { - e.printStackTrace(); - } - try { - rs.next(); - } catch (SQLException e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("No data about activation users in account " + BaseTest.partnerId); - } int result =-1; try { - result = rs.getInt("IS_ACTIVATION_NEEDED"); - } catch (SQLException e) { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId)); + result = jsonArray.getJSONObject(0).getInt("is_activation_needed"); + } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("IS_ACTIVATION_NEEDED can't be null"); } - closeConnection(); + return result == 1; } @@ -152,50 +130,19 @@ public static String getUserDataByRole(String userRole) { if (isActivationOfUsersNeeded()) { sqlQuery += " and u.activate_status=1"; } - openConnection(); - try { - rs = stam.executeQuery(String.format(sqlQuery, userRole, BaseTest.partnerId)); - } catch (SQLException e) { - e.printStackTrace(); - } - try { - rs.next(); - } catch (SQLException e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("No data about user with role " + userRole + " in account " + BaseTest.partnerId); - } String userdData = ""; try { - userdData = rs.getString("username") + ":" + rs.getString("password"); - } catch (SQLException e) { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, BaseTest.partnerId)); + userdData = jsonArray.getJSONObject(0).getString("username") + ":" + + jsonArray.getJSONObject(0).getString("password"); + } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("username/password can't be null"); } - closeConnection(); return userdData; } public static String getActivationToken(String username) { - /*openConnection(); - try { - rs = stam.executeQuery(String.format(ACTIVATION_TOKEN_SELECT, username)); - } catch (SQLException e) { - e.printStackTrace(); - } - try { - rs.next(); - } catch (SQLException e) { - e.printStackTrace(); - } - String activationToken = null; - try { - activationToken = rs.getString("ACTIVATION_TOKEN"); - } catch (SQLException e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("activationToken can't be null"); - } - closeConnection();*/ - String activationToken = null; try { From 2132f280411b2d1382dc9118b1a699e216c2d5ed Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 9 May 2018 07:42:07 +0300 Subject: [PATCH 217/605] removed ingest users/passwords from test.properties --- .../com/kaltura/client/test/Properties.java | 7 ---- .../kaltura/client/test/tests/BaseTest.java | 42 ++++++++++++++++++- .../kaltura/client/test/utils/DBUtils.java | 17 ++++++++ .../client/test/utils/IngestUtils.java | 18 ++++---- src/test/resources/test.template.properties | 7 ---- 5 files changed, 66 insertions(+), 25 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index baa2f66e7..733512d7c 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -31,13 +31,6 @@ public class Properties { public static final String MOVIE_MEDIA_TYPE_ID = "movie_media_type_id"; public static final String EPISODE_MEDIA_TYPE_ID = "episode_media_type_id"; - // ingest - public static final String INGEST_USER_USERNAME = "ingest_user_username"; - public static final String INGEST_USER_PASSWORD = "ingest_user_password"; - - public static final String INGEST_BUSINESS_MODULE_USER_USERNAME = "ingest_business_module_user_username"; - public static final String INGEST_BUSINESS_MODULE_USER_PASSWORD = "ingest_business_module_user_password"; - // channels public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 036cc7817..0b521d7e1 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -9,11 +9,9 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; - import java.util.List; import java.util.Optional; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; @@ -39,6 +37,10 @@ public class BaseTest { // shared ks's private static String administratorKs, operatorKs, managerKs, anonymousKs; + // shared ingest users data + private static String ingestAssetUserUsername, ingestAssetUserPassword, ingestBusinessModuleUserUsername, + ingestBusinessModuleUserPassword; + // shared VOD private static MediaAsset mediaAsset; @@ -93,6 +95,42 @@ public void base_test_before_suite() { defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } + public static String getIngestBusinessModuleUserName() { + if (ingestBusinessModuleUserUsername == null) { + String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId); + ingestBusinessModuleUserUsername = userInfo.split(":")[0]; + ingestBusinessModuleUserPassword = userInfo.split(":")[1]; + } + return ingestBusinessModuleUserUsername; + } + + public static String getIngestBusinessModuleUserPassword() { + if (ingestBusinessModuleUserPassword == null) { + String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId); + ingestBusinessModuleUserUsername = userInfo.split(":")[0]; + ingestBusinessModuleUserPassword = userInfo.split(":")[1]; + } + return ingestBusinessModuleUserPassword; + } + + public static String getIngestAssetUserName() { + if (ingestAssetUserUsername == null) { + String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId + 1); + ingestAssetUserUsername = userInfo.split(":")[0]; + ingestAssetUserPassword = userInfo.split(":")[1]; + } + return ingestAssetUserUsername; + } + + public static String getIngestAssetUserPassword() { + if (ingestAssetUserPassword == null) { + String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId + 1); + ingestAssetUserUsername = userInfo.split(":")[0]; + ingestAssetUserPassword = userInfo.split(":")[1]; + } + return ingestAssetUserPassword; + } + // getters for shared params public static String getAdministratorKs() { if (administratorKs == null) { diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 8fda6a1f8..73f324b6c 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -36,6 +36,9 @@ public class DBUtils extends BaseUtils { "and dc.discount_percent=%d\n" + // percent amount "and dc.group_id=%d\n" + // group "and dc.[status]=1 and dc.is_active=1"; + private static final String INGEST_BUSINESS_MODULE_DATA_SELECT = "select TOP (1) *\n" + + "from [Tvinci].[dbo].[groups_passwords]\n" + + "where [group_id]=%d order by UPDATE_DATE DESC"; //TODO - change existing methods to work with the new convertToJSON method // Return json array from DB @@ -96,6 +99,20 @@ private static JSONArray getJsonArrayFromQueryResult(String query) throws Except } + public static String getIngestBusinessModuleUserData(int accountId) { + String result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_BUSINESS_MODULE_DATA_SELECT, accountId)); + result = jsonArray.getJSONObject(0).getString("username") + ":" + + jsonArray.getJSONObject(0).getString("password"); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("data about ingest business module user can't be null"); + } + + return result; + } + public static String getDiscountByPercentAndCurrency(String currency, int percent) { String code = ""; try { diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 5f07eca1b..76b1e03f2 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -152,7 +152,7 @@ public static Response> ingestEPG(String epgChannelName, Opt " \n" + " " + " " + - " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " " + getIngestAssetUserName() + "" + getIngestAssetUserPassword() + "" + epgChannelIngestXml + "\n" + " \n" + " \n" + @@ -389,8 +389,8 @@ public static Subscription ingestMPP(Optional action, Optional m String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " " + getIngestBusinessModuleUserName() + "" + + getIngestBusinessModuleUserPassword() + "" + " action, Optional ppCod String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " " + getIngestBusinessModuleUserName() + "" + + getIngestBusinessModuleUserPassword() + "" + " action, Optional ppvCode, O String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_BUSINESS_MODULE_USER_USERNAME) + "" + - getProperty(INGEST_BUSINESS_MODULE_USER_PASSWORD) + "" + + " " + getIngestBusinessModuleUserName() + "" + + getIngestBusinessModuleUserPassword() + "" + " action, Optional cog String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " " + getIngestAssetUserName() + "" + getIngestAssetUserPassword() + "" + " \n" + @@ -957,7 +957,7 @@ public static MediaAsset ingestBasicVOD(Optional name, String mediaType) String reqBody = "\n" + " \n" + " \n" + - " " + getProperty(INGEST_USER_USERNAME) + "" + getProperty(INGEST_USER_PASSWORD) + "" + + " " + getIngestAssetUserName() + "" + getIngestAssetUserPassword() + "" + " \n" + diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index 597b29e24..b7c7bb4a1 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -13,13 +13,6 @@ db_password=@DB_PASSWORD@ # Global Users Properties default_user_password=@DEFAULT_USER_PASSWORD@ -# Ingest Users properties -ingest_user_username=@INGEST_USER_USERNAME@ -ingest_user_password=@INGEST_USER_PASSWORD@ - -ingest_business_module_user_username=@INGEST_BUSINESS_MODULE_USER_USERNAME@ -ingest_business_module_user_password=@INGEST_BUSINESS_MODULE_USER_PASSWORD@ - # File Types web_file_type=@WEB_FILE_TYPE@ mobile_file_type=@MOBILE_FILE_TYPE@ From ac0824bdf3c2739692d60f29db59152827fc28e3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 9 May 2018 09:57:18 +0300 Subject: [PATCH 218/605] updated names of methods and variable --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 8 ++++---- src/test/java/com/kaltura/client/test/utils/DBUtils.java | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 0b521d7e1..c559727d1 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -97,7 +97,7 @@ public void base_test_before_suite() { public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { - String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId); + String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId); ingestBusinessModuleUserUsername = userInfo.split(":")[0]; ingestBusinessModuleUserPassword = userInfo.split(":")[1]; } @@ -106,7 +106,7 @@ public static String getIngestBusinessModuleUserName() { public static String getIngestBusinessModuleUserPassword() { if (ingestBusinessModuleUserPassword == null) { - String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId); + String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId); ingestBusinessModuleUserUsername = userInfo.split(":")[0]; ingestBusinessModuleUserPassword = userInfo.split(":")[1]; } @@ -115,7 +115,7 @@ public static String getIngestBusinessModuleUserPassword() { public static String getIngestAssetUserName() { if (ingestAssetUserUsername == null) { - String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId + 1); + String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } @@ -124,7 +124,7 @@ public static String getIngestAssetUserName() { public static String getIngestAssetUserPassword() { if (ingestAssetUserPassword == null) { - String userInfo = DBUtils.getIngestBusinessModuleUserData(BaseTest.partnerId + 1); + String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 73f324b6c..6aa46f308 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -36,7 +36,7 @@ public class DBUtils extends BaseUtils { "and dc.discount_percent=%d\n" + // percent amount "and dc.group_id=%d\n" + // group "and dc.[status]=1 and dc.is_active=1"; - private static final String INGEST_BUSINESS_MODULE_DATA_SELECT = "select TOP (1) *\n" + + private static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; @@ -99,10 +99,10 @@ private static JSONArray getJsonArrayFromQueryResult(String query) throws Except } - public static String getIngestBusinessModuleUserData(int accountId) { + public static String getIngestItemUserData(int accountId) { String result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_BUSINESS_MODULE_DATA_SELECT, accountId)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_ITEMS_DATA_SELECT, accountId)); result = jsonArray.getJSONObject(0).getString("username") + ":" + jsonArray.getJSONObject(0).getString("password"); } catch (Exception e) { From 135f31f1750592522e618ec56f74b7b054142333 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 9 May 2018 16:21:02 +0300 Subject: [PATCH 219/605] added logging to generic errors --- pom.xml | 6 + .../test/TestAPIOkRequestsExecutor.java | 21 +++ .../kaltura/client/test/tests/BaseTest.java | 4 +- .../EntitlementGrantTests.java | 41 ++--- .../kaltura/client/test/utils/DBUtils.java | 143 ++++++++++-------- 5 files changed, 130 insertions(+), 85 deletions(-) diff --git a/pom.xml b/pom.xml index a2b2698fd..2fd750cf6 100644 --- a/pom.xml +++ b/pom.xml @@ -196,6 +196,12 @@ 2.9.5 + + com.google.guava + guava + 25.0-jre + + diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 1c112932d..54d5d0441 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -1,8 +1,10 @@ package com.kaltura.client.test; +import com.google.common.primitives.Ints; import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; +import com.kaltura.client.types.APIException; import com.kaltura.client.utils.request.RequestBuilder; import com.kaltura.client.utils.request.RequestElement; import com.kaltura.client.utils.response.base.ApiCompletion; @@ -12,6 +14,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.test.tests.BaseTest.client; +import static com.kaltura.client.utils.ErrorElement.*; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; @@ -85,6 +88,24 @@ public Response exec(RequestBuilder requestBuilder) { await().untilTrue(done); done.set(false); + APIException error = response.error; + if (error != null) { + int[] genericErrors = { + ConnectionError.getCode(), + BadRequestError.getCode(), + GeneralError.getCode(), + NotFound.getCode(), + LoadError.getCode(), + ServiceUnavailableError.getCode(), + SessionError.getCode() + }; + + int errorCode = Integer.parseInt(error.getCode()); + if (Ints.asList(genericErrors).contains(errorCode)) { + logger.error(error.getMessage() + " : " + error.getCode()); + } + } + return response; } } diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 0b521d7e1..9898b3fc9 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -23,6 +23,8 @@ public class BaseTest { + private final int DEFAULT_TIMEOUT_IN_SEC = 60; + public static Client client; public static Configuration config; public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); @@ -88,7 +90,7 @@ public void base_test_before_suite() { client = new Client(config); // set default awaitility timeout - setDefaultTimeout(30, TimeUnit.SECONDS); + setDefaultTimeout(DEFAULT_TIMEOUT_IN_SEC, TimeUnit.SECONDS); // set shared common params partnerId = Integer.parseInt(getProperty(PARTNER_ID)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index 4611bbde5..081b6188c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -85,8 +85,7 @@ private void grant_subscription_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); TransactionHistoryService.ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -98,8 +97,7 @@ private void grant_subscription_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -135,8 +133,7 @@ private void grant_subscription_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); TransactionHistoryService.ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); @@ -144,8 +141,7 @@ private void grant_subscription_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); @@ -193,8 +189,7 @@ private void grant_ppv_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -206,8 +201,7 @@ private void grant_ppv_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -228,13 +222,11 @@ private void grant_ppv_without_history() { HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); - // grant subscription - history = true GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) .setUserId(Integer.valueOf(user.getUserId())) .setKs(getAdministratorKs()); Response booleanResponse = executor.executeSync(grantEntitlementBuilder); - assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); @@ -245,8 +237,7 @@ private void grant_ppv_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -258,8 +249,7 @@ private void grant_ppv_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)) - .setUserId(null); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -288,7 +278,7 @@ private void grant_ppv_with_wrong_id() { // assert error 6001 is return - assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); } @@ -301,16 +291,17 @@ private void grant_purchased_ppv() { GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) .setUserId(Integer.valueOf(user.getUserId())) .setKs(getAdministratorKs()); - executor.executeSync(grantEntitlementBuilder); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); + assertThat(booleanResponse.error).isNull(); // grant ppv - second time grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) .setUserId(Integer.valueOf(user.getUserId())) .setKs(getAdministratorKs()); - Response booleanResponse = executor.executeSync(grantEntitlementBuilder); + booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 3021 is return - assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3021).getCode()); } @@ -332,7 +323,7 @@ private void grant_purchased_subscription() { Response booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 3024 is return - assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3024).getCode()); } @@ -363,7 +354,7 @@ private void grant_ppv_user_not_in_domain() { Response booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 1005 is return - assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1005).getCode()); } @@ -388,7 +379,7 @@ private void grant_ppv_user_suspend() { booleanResponse = executor.executeSync(grantEntitlementBuilder); // assert error 2001 is return - assertThat(booleanResponse.results).isEqualTo(null); + assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2001).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 73f324b6c..d2e418cec 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.utils; +import com.google.common.base.Strings; import com.kaltura.client.Logger; import com.kaltura.client.test.tests.BaseTest; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; @@ -18,6 +19,8 @@ public class DBUtils extends BaseUtils { private static Statement stam; private static ResultSet rs; + private static final String ERROR_MESSAGE = "No results found"; + //selects private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; @@ -40,69 +43,16 @@ public class DBUtils extends BaseUtils { "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; - //TODO - change existing methods to work with the new convertToJSON method - // Return json array from DB - private static JSONArray getJsonArrayFromQueryResult(String query) throws Exception { - openConnection(); - JSONArray jsonArray = new JSONArray(); - rs = stam.executeQuery(query); - ResultSetMetaData rsmd = rs.getMetaData(); - - if (rs != null && rs.isBeforeFirst()) { - while (rs.next()) { - int numColumns = rsmd.getColumnCount(); - JSONObject obj = new JSONObject(); - - for (int i = 1; i < numColumns + 1; i++) { - String column_name = rsmd.getColumnName(i).toLowerCase(); - - if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { - obj.put(column_name, rs.getArray(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { - obj.put(column_name, rs.getBoolean(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { - obj.put(column_name, rs.getBlob(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { - obj.put(column_name, rs.getDouble(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { - obj.put(column_name, rs.getFloat(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { - obj.put(column_name, rs.getNString(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { - obj.put(column_name, rs.getString(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { - obj.put(column_name, rs.getDate(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { - obj.put(column_name, rs.getTimestamp(column_name)); - } else { - obj.put(column_name, rs.getObject(column_name)); - } - } - jsonArray.put(obj); - } - closeConnection(); - return jsonArray; - - } else { - Logger.getLogger(DBUtils.class).error("No result found"); - closeConnection(); - return null; - } - } public static String getIngestBusinessModuleUserData(int accountId) { String result = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_BUSINESS_MODULE_DATA_SELECT, accountId)); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + } + result = jsonArray.getJSONObject(0).getString("username") + ":" + jsonArray.getJSONObject(0).getString("password"); } catch (Exception e) { @@ -117,6 +67,10 @@ public static String getDiscountByPercentAndCurrency(String currency, int percen String code = ""; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, BaseTest.partnerId)); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + } + code = jsonArray.getJSONObject(0).getString("code"); if ("".equals(code)) { throw new SQLException(); @@ -130,9 +84,13 @@ public static String getDiscountByPercentAndCurrency(String currency, int percen } public static boolean isActivationOfUsersNeeded() { - int result =-1; + int result = -1; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId)); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + } + result = jsonArray.getJSONObject(0).getInt("is_activation_needed"); } catch (Exception e) { e.printStackTrace(); @@ -150,12 +108,17 @@ public static String getUserDataByRole(String userRole) { String userdData = ""; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, BaseTest.partnerId)); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + } + userdData = jsonArray.getJSONObject(0).getString("username") + ":" + jsonArray.getJSONObject(0).getString("password"); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("username/password can't be null"); } + return userdData; } @@ -164,10 +127,13 @@ public static String getActivationToken(String username) { try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ACTIVATION_TOKEN_SELECT, username)); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + } + activationToken = jsonArray.getJSONObject(0).getString("activation_token"); } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("activation_token can't be null"); } return activationToken; @@ -196,6 +162,65 @@ public static int getEpgChannelId(String channelName) { return epgChannelId; } + //TODO - change existing methods to work with the new getJsonArrayFromQueryResult method + // Return json array from DB + private static JSONArray getJsonArrayFromQueryResult(String query) throws Exception { + openConnection(); + JSONArray jsonArray = new JSONArray(); + rs = stam.executeQuery(query); + ResultSetMetaData rsmd = rs.getMetaData(); + + if (rs != null && rs.isBeforeFirst()) { + while (rs.next()) { + int numColumns = rsmd.getColumnCount(); + JSONObject obj = new JSONObject(); + + for (int i = 1; i < numColumns + 1; i++) { + String column_name = rsmd.getColumnName(i).toLowerCase(); + + if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { + obj.put(column_name, rs.getArray(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { + obj.put(column_name, rs.getBoolean(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { + obj.put(column_name, rs.getBlob(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { + obj.put(column_name, rs.getDouble(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { + obj.put(column_name, rs.getFloat(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { + obj.put(column_name, rs.getNString(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { + obj.put(column_name, rs.getString(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { + obj.put(column_name, rs.getDate(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { + obj.put(column_name, rs.getTimestamp(column_name)); + } else { + obj.put(column_name, rs.getObject(column_name)); + } + } + jsonArray.put(obj); + } + closeConnection(); + return jsonArray; + + } else { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + closeConnection(); + return null; + } + + } + private static void openConnection() { dataSource = new SQLServerDataSource(); dataSource.setUser(getProperty(DB_USER)); From 74ad6ec3716feeeeaaf557e9b4e177c912a8c7bd Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 9 May 2018 16:25:13 +0300 Subject: [PATCH 220/605] no message --- src/test/java/com/kaltura/client/test/utils/DBUtils.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index c3e767c3b..053be2586 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -52,12 +52,10 @@ public static String getIngestItemUserData(int accountId) { if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } - result = jsonArray.getJSONObject(0).getString("username") + ":" + jsonArray.getJSONObject(0).getString("password"); } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("data about ingest business module user can't be null"); } return result; @@ -70,14 +68,12 @@ public static String getDiscountByPercentAndCurrency(String currency, int percen if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } - code = jsonArray.getJSONObject(0).getString("code"); if ("".equals(code)) { throw new SQLException(); } } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("code can't be null"); } return code; @@ -90,11 +86,9 @@ public static boolean isActivationOfUsersNeeded() { if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } - result = jsonArray.getJSONObject(0).getInt("is_activation_needed"); } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("IS_ACTIVATION_NEEDED can't be null"); } return result == 1; @@ -111,12 +105,10 @@ public static String getUserDataByRole(String userRole) { if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } - userdData = jsonArray.getJSONObject(0).getString("username") + ":" + jsonArray.getJSONObject(0).getString("password"); } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("username/password can't be null"); } return userdData; @@ -130,7 +122,6 @@ public static String getActivationToken(String username) { if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } - activationToken = jsonArray.getJSONObject(0).getString("activation_token"); } catch (Exception e) { e.printStackTrace(); From a4df520fbd9f24bf2cab997062fc07014d9d5e06 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 10 May 2018 09:59:14 +0300 Subject: [PATCH 221/605] Added draft of logic fixture data creation --- .../com/kaltura/client/test/Properties.java | 5 +++ .../kaltura/client/test/tests/BaseTest.java | 17 ++++++++ .../kaltura/client/test/utils/DBUtils.java | 40 ++++++++++++------- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 733512d7c..a61796fdb 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -36,6 +36,11 @@ public class Properties { // price codes public static final String PRICE_CODE_AMOUNT = "price_code_amount"; // 4.99 + //public static final String COMMON_PRICE_CODE_AMOUNT = "5"; // TODO: should we document it as requirement? + + //cycles + //public static final String CYCLE_1_DAY = "1440"; // in minutes + // usage modules public static final String DEFAULT_USAGE_MODULE_4_INGEST_PPV = "default_usage_module_4_ingest_ppv"; // module has 10 Minutes life cycles, 0 maximum views diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c559727d1..016bc00b0 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -15,6 +15,7 @@ import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; +//import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; @@ -51,6 +52,9 @@ public class BaseTest { // shared MPP private static Subscription fiveMinRenewableSubscription; + // shared ingested PP + //private static PricePlan sharedCommonPricePlan; + /*================================================================================ testing shared params list - used as a helper common params across tests @@ -95,6 +99,19 @@ public void base_test_before_suite() { defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } + /*public static PricePlan getSharedCommonPricePlan(){ + if (sharedCommonPricePlan == null) { + sharedCommonPricePlan = DBUtils.loadSharedPP(COMMON_PRICE_CODE_AMOUNT, "EUR"); + if (sharedCommonPricePlan == null) { + int fullDiscountPercent = 100; + sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), + Optional.of(CYCLE_1_DAY), Optional.of(CYCLE_1_DAY), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), + Optional.of("EUR"), Optional.of(DBUtils.getDiscount(0, fullDiscountPercent)), Optional.of(true), Optional.of(0)); + } + } + return sharedCommonPricePlan; + }*/ + public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId); diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 6aa46f308..19c6ab90f 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.PricePlan; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; @@ -39,6 +40,9 @@ public class DBUtils extends BaseUtils { private static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; + private static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; //TODO - change existing methods to work with the new convertToJSON method // Return json array from DB @@ -99,6 +103,22 @@ private static JSONArray getJsonArrayFromQueryResult(String query) throws Except } + //"and group_id=%d and internal_discount_id=%d and pricing_id=%d"; + /*public static PricePlan loadSharedPP(String priceAmount, String currency) { + Logger.getLogger(DBUtils.class).debug("loadSharedPP(): priceAmount = " + priceAmount + " currency = " + currency); + PricePlan pricePlan = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, BaseTest.partnerId, priceAmount, currency)); + result = jsonArray.getJSONObject(0).getString("code"); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("discount code can't be null"); + } + + + return pricePlan; + }*/ + public static String getIngestItemUserData(int accountId) { String result = null; try { @@ -174,25 +194,15 @@ public static String getActivationToken(String username) { } public static int getEpgChannelId(String channelName) { - openConnection(); + int epgChannelId =-1; try { - rs = stam.executeQuery(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName)); - } catch (SQLException e) { - e.printStackTrace(); - } - try { - rs.next(); - } catch (SQLException e) { - e.printStackTrace(); - } - int epgChannelId = -1; - try { - epgChannelId = rs.getInt("ID"); - } catch (SQLException e) { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName)); + epgChannelId = jsonArray.getJSONObject(0).getInt("id"); + } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("epgChannelId can't be null"); } - closeConnection(); + return epgChannelId; } From 9dbdd2f161e775df2184e18a547faedef4bd19d5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 10 May 2018 10:57:02 +0300 Subject: [PATCH 222/605] Removed unused method from assetHistory class --- .../client/test/utils/AssetHistoryUtils.java | 24 ------------------- .../client/test/utils/assetRulesUtils.java | 4 ++++ 2 files changed, 4 insertions(+), 24 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java diff --git a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java index 6b25f9376..ed08d2e0e 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java @@ -1,17 +1,9 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; -import com.kaltura.client.services.BookmarkService; import com.kaltura.client.types.AssetHistoryFilter; -import com.kaltura.client.types.Bookmark; -import com.kaltura.client.types.MediaAsset; - import javax.annotation.Nullable; -import java.util.Optional; -import static com.kaltura.client.test.tests.BaseTest.executor; public class AssetHistoryUtils extends BaseUtils { @@ -26,20 +18,4 @@ public static AssetHistoryFilter getAssetHistoryFilter(@Nullable String assetIdI } - // Ingest asset, bookmark it and return the asset id -// public static Long ingestAssetAndPerformBookmark(String ks, String mediaType, int position, BookmarkActionType bookmarkActionType) { -// // Ingest asset -// MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), -// Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(mediaType)), Optional.empty(), Optional.empty()); -// Long assetId = mediaAsset.getId(); -// int fileId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); -// -// // Movie asset bookmark -// Bookmark bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, bookmarkActionType); -// BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); -// addBookmarkBuilder.setKs(ks); -// executor.executeSync(addBookmarkBuilder); -// -// return assetId; -// } } diff --git a/src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java b/src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java new file mode 100644 index 000000000..8ca3e8654 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java @@ -0,0 +1,4 @@ +package com.kaltura.client.test.utils; + +public class assetRulesUtils { +} From 614665996fc90a9f077beee9f659ab81360c2767 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 10 May 2018 11:47:22 +0300 Subject: [PATCH 223/605] Updated list schema --- .../assetRuleTests/AssetRuleAddTests.groovy | 4 +++ .../assetRuleTests/AssetRuleDeleteTests.java | 4 +++ .../client/test/utils/AssetRuleUtils.java | 31 +++++++++++++++++++ .../client/test/utils/assetRulesUtils.java | 4 --- src/test/resources/schemas/ListResponse.json | 3 +- 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy new file mode 100644 index 000000000..76ec2757a --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy @@ -0,0 +1,4 @@ +package com.kaltura.client.test.tests.servicesTests.assetRuleTests + +class AssetRuleAddTests { +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java new file mode 100644 index 000000000..b3157d741 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java @@ -0,0 +1,4 @@ +package com.kaltura.client.test.tests.servicesTests.assetRuleTests; + +public class AssetRuleDeleteTests { +} diff --git a/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java new file mode 100644 index 000000000..b9de2b30d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java @@ -0,0 +1,31 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.services.AssetRuleService; +import com.kaltura.client.types.AssetRule; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; + +import static com.kaltura.client.services.AssetRuleService.*; +import static com.kaltura.client.test.tests.BaseTest.executor; + +public class assetRulesUtils extends BaseUtils { + + + + + + public void deleteAllGeoAssetRules() { + + + ListAssetRuleBuilder listAssetRuleBuilder = AssetRuleService.list(); + Response> d = executor.executeSync(listAssetRuleBuilder); + + for (int i = 0; i < listAssetRuleBuilder) { + + } + AddAssetRuleBuilder addAssetRuleBuilder = AssetRuleService.delete(); + } + + + +} diff --git a/src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java b/src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java deleted file mode 100644 index 8ca3e8654..000000000 --- a/src/test/java/com/kaltura/client/test/utils/assetRulesUtils.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.kaltura.client.test.utils; - -public class assetRulesUtils { -} diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index bfec96dc2..496354726 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -58,7 +58,8 @@ "KalturaProductPriceListResponse", "KalturaBookmarkListResponse", "KalturaAssetCommentListResponse", - "KalturaAssetHistoryListResponse" + "KalturaAssetHistoryListResponse", + "KalturaAssetRuleListResponse" ] } }, From 126c21bcfebcf126dda2f51868634fcd21a690fd Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 10 May 2018 11:47:37 +0300 Subject: [PATCH 224/605] Updated AssetRuleUtils --- .../client/test/utils/AssetRuleUtils.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java index b9de2b30d..d3cf28b87 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.utils; import com.kaltura.client.services.AssetRuleService; +import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.AssetRule; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; @@ -8,24 +9,16 @@ import static com.kaltura.client.services.AssetRuleService.*; import static com.kaltura.client.test.tests.BaseTest.executor; -public class assetRulesUtils extends BaseUtils { +public class AssetRuleUtils extends BaseUtils { - - - - public void deleteAllGeoAssetRules() { - - - ListAssetRuleBuilder listAssetRuleBuilder = AssetRuleService.list(); - Response> d = executor.executeSync(listAssetRuleBuilder); - - for (int i = 0; i < listAssetRuleBuilder) { - + // Delete all geo asset rules from DB (changed to status 2) + public static void deleteAllGeoAssetRules() { + ListAssetRuleBuilder listAssetRuleBuilder = AssetRuleService.list().setKs(BaseTest.getOperatorKs()); + Response> listAssetRule = executor.executeSync(listAssetRuleBuilder); + for (AssetRule rule : listAssetRule.results.getObjects()) { + DeleteAssetRuleBuilder deleteAssetRuleBuilder = AssetRuleService.delete(rule.getId()).setKs(BaseTest.getOperatorKs()); + executor.executeSync(deleteAssetRuleBuilder); } - AddAssetRuleBuilder addAssetRuleBuilder = AssetRuleService.delete(); } - - - } From 5370cb9396e925964f6100f1f7357d0f2db14d8e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 10 May 2018 11:48:39 +0300 Subject: [PATCH 225/605] Updated AssetRuleDeleteTests class --- .../assetRuleTests/AssetRuleAddTests.groovy | 4 ---- .../assetRuleTests/AssetRuleDeleteTests.java | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy deleted file mode 100644 index 76ec2757a..000000000 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleAddTests.groovy +++ /dev/null @@ -1,4 +0,0 @@ -package com.kaltura.client.test.tests.servicesTests.assetRuleTests - -class AssetRuleAddTests { -} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java index b3157d741..e8f57b8bf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java @@ -1,4 +1,17 @@ package com.kaltura.client.test.tests.servicesTests.assetRuleTests; -public class AssetRuleDeleteTests { +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetRuleUtils; +import io.qameta.allure.Description; +import org.testng.annotations.Test; + +public class AssetRuleDeleteTests extends BaseTest { + + + @Description("/assetrule/action/delete") + @Test + private void deleteAllGeoAssetRules() { + AssetRuleUtils.deleteAllGeoAssetRules(); + } + } From 8b6e2057ecf2315dd27b403a433a7af31042320a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Shmulik.Kummer" Date: Thu, 10 May 2018 11:49:38 +0300 Subject: [PATCH 226/605] Updated AssetRuleDeleteTests class --- .../servicesTests/assetRuleTests/AssetRuleDeleteTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java index e8f57b8bf..88e3982ac 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java @@ -8,7 +8,7 @@ public class AssetRuleDeleteTests extends BaseTest { - @Description("/assetrule/action/delete") + @Description("/assetrule/action/delete - currently used to run util only") @Test private void deleteAllGeoAssetRules() { AssetRuleUtils.deleteAllGeoAssetRules(); From 81e24ba906fdc8f198e14f6990c742dd17df61d5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Thu, 10 May 2018 15:00:45 +0300 Subject: [PATCH 227/605] /transactionHistory/action/list added --- .../transactionHistoryTests/ListTests.java | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java new file mode 100644 index 000000000..c40cd222b --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java @@ -0,0 +1,119 @@ +package com.kaltura.client.test.tests.servicesTests.transactionHistoryTests; + +import com.kaltura.client.enums.EntityReferenceBy; +import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; +import com.kaltura.client.services.TransactionHistoryService; +import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ListTests extends BaseTest{ + + private EntitlementFilter entitlementPpvFilter; + private TransactionHistoryFilter transactionHistoryFilter; + private Response> listEntitlementServiceResponse; + private Response> listBillingTransactionResponse; + private int numberOfDevicesInHousehold = 2; + private int numberOfUsersInHousehold = 2; + + @BeforeClass + public void beforeClass(){ + entitlementPpvFilter = new EntitlementFilter(); + entitlementPpvFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //Show entitlements per household + entitlementPpvFilter.setIsExpiredEqual(false); //Don't show expired assets + transactionHistoryFilter = new TransactionHistoryFilter(); + transactionHistoryFilter.setStartDateGreaterThanOrEqual((int)((System.currentTimeMillis()/1000)-86400)); //Start date from yesterday (86400 sec = 24 hours) + transactionHistoryFilter.setEndDateLessThanOrEqual((int)((System.currentTimeMillis()/1000)+86400)); //End date before tomorrow (86400 sec = 24 hours) + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionhistory/action/list - test ppv purchases is written correctly at transactionHistory") + public void purchase_ppv(){ + + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); + String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); //Login with master to first device + String userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); //Login with user to second device + + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //All transactions per household + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for household + assertThat(listBillingTransactionResponse.error).isNull(); + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); //No purchases were performed + + int assetFileId = getSharedWebMediaFile().getId(); + PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(assetFileId), null); //Purchase asset + String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get("ppvModuleId"); + String pricePpv = PurchaseUtils.purchasePpvDetailsMap.get("price"); + String currencyPpv = PurchaseUtils.purchasePpvDetailsMap.get("currency"); + + entitlementPpvFilter.setProductTypeEqual(TransactionType.PPV); //Show only PPV purchases + ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(entitlementPpvFilter).setKs(userKs); + listEntitlementServiceResponse = executor.executeSync(listEntitlementBuilder); //entitlement/action/list for household + List ppvEntitlementList = new ArrayList<>(); //Conversion from Entitlement to PpvEntitlement + for(Entitlement entitlement:listEntitlementServiceResponse.results.getObjects()){ + if(entitlement.getClass() == PpvEntitlement.class) { + ppvEntitlementList.add((PpvEntitlement) entitlement); + } + } + assertThat(listEntitlementServiceResponse.results.getTotalCount()).isEqualTo(1); //Verify that count of entitlements is 1 + assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(ppvModuleId); //Verify that PPV is correct + assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(assetFileId); //Verify that asset file is correct + + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); //All transactions per user + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); //Use non-master user ks + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for non-master user + assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); //Verify asset id is correct + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType().getValue()).isEqualTo(TransactionType.PPV.getValue()); //Verify transaction is for PPV + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); //Verify price amount + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); //Verify price currency + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType().getValue()).isEqualTo("FullPeriod"); //Verify entitlement period + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction().getValue()).isEqualTo("purchase"); //Verify that asset was purchased + + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //All transactions per household + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); //Use non-master user ks + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for household + assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); //Verify asset id is correct + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType().getValue()).isEqualTo(TransactionType.PPV.getValue()); //Verify transaction is for PPV + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); //Verify price amount + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); //Verify price currency + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType().getValue()).isEqualTo("FullPeriod"); //Verify entitlement period + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction().getValue()).isEqualTo("purchase"); //Verify that asset was purchased + + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //All transactions per household + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); //Use master user ks + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for household + assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); //Verify asset id is correct + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType().getValue()).isEqualTo(TransactionType.PPV.getValue()); //Verify transaction is for PPV + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); //Verify price amount + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); //Verify price currency + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType().getValue()).isEqualTo("FullPeriod"); //Verify entitlement period + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction().getValue()).isEqualTo("purchase"); //Verify that asset was purchased + + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); //All transactions per user + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); //Use master user ks + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for master user + assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); //No transactions were performed with master user + } +} From a2fc2cb0c96d43afeb085ba661f08f4a75c76f30 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 13 May 2018 08:51:53 +0300 Subject: [PATCH 228/605] no message --- .../ottUserTests/OttUserActivateTests.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java index 66eecb199..7ceece67f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java @@ -38,6 +38,15 @@ private void ottUser_activate_tests_setup() { @Description("ottUser/action/activate - activate") @Test private void activate() { + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // login user + user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); + + // assert user is not activated + assertThat(user.getUserState()).isEqualTo(UserState.USER_NOT_ACTIVATED); + // get activation token String activationToken = DBUtils.getActivationToken(user.getUsername()); @@ -52,7 +61,8 @@ private void activate() { @Severity(SeverityLevel.MINOR) @Description("ottUser/action/activate - activate twice with the same token") @Test - private void activate_with_sa() { + private void activate_with_same_token() { + // TODO: 5/2/2018 implement test } } From db9744849a5126f3d78ed6fcc8fc0d6e9282b6b1 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Sun, 13 May 2018 11:30:16 +0300 Subject: [PATCH 229/605] transactionHistory amends --- .../transactionHistoryTests/ListTests.java | 188 ++++++++++++------ 1 file changed, 125 insertions(+), 63 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java index c40cd222b..06fad0774 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.transactionHistoryTests; -import com.kaltura.client.enums.EntityReferenceBy; -import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.enums.*; import com.kaltura.client.services.EntitlementService; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; import com.kaltura.client.services.TransactionHistoryService; @@ -30,15 +29,26 @@ public class ListTests extends BaseTest{ private Response> listBillingTransactionResponse; private int numberOfDevicesInHousehold = 2; private int numberOfUsersInHousehold = 2; + public static final String PPV_MODULE_ID_KEY = "ppvModuleId"; + public static final String PPV_PRICE_AMOUNT = "price"; + public static final String PPV_PRICE_CURRENCY = "currency"; + //Epoch for transactionHistory filter (86400 sec = 24 hours) + public static final int yesterdayInEpoch = (int)((System.currentTimeMillis()/1000)-86400); + public static final int tomorrowInEpoch = (int)((System.currentTimeMillis()/1000)+86400); + @BeforeClass public void beforeClass(){ entitlementPpvFilter = new EntitlementFilter(); - entitlementPpvFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //Show entitlements per household - entitlementPpvFilter.setIsExpiredEqual(false); //Don't show expired assets + //Show entitlements per household + entitlementPpvFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + //Don't show expired assets + entitlementPpvFilter.setIsExpiredEqual(false); transactionHistoryFilter = new TransactionHistoryFilter(); - transactionHistoryFilter.setStartDateGreaterThanOrEqual((int)((System.currentTimeMillis()/1000)-86400)); //Start date from yesterday (86400 sec = 24 hours) - transactionHistoryFilter.setEndDateLessThanOrEqual((int)((System.currentTimeMillis()/1000)+86400)); //End date before tomorrow (86400 sec = 24 hours) + //Start date from yesterday + transactionHistoryFilter.setStartDateGreaterThanOrEqual(yesterdayInEpoch); + //End date before tomorrow + transactionHistoryFilter.setEndDateLessThanOrEqual(tomorrowInEpoch); } @Severity(SeverityLevel.BLOCKER) @@ -46,74 +56,126 @@ public void beforeClass(){ public void purchase_ppv(){ Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); - String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); //Login with master to first device - String userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); //Login with user to second device + //Login with master to first device + String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + //Login with user to second device + String userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //All transactions per household + //All transactions per household + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for household + //transactionHistory/action/list for household with master user ks + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); //No purchases were performed + //No purchases were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); int assetFileId = getSharedWebMediaFile().getId(); - PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(assetFileId), null); //Purchase asset - String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get("ppvModuleId"); - String pricePpv = PurchaseUtils.purchasePpvDetailsMap.get("price"); - String currencyPpv = PurchaseUtils.purchasePpvDetailsMap.get("currency"); + //Purchase asset + PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(assetFileId), null); + //Get PPV details (ID, Price, Currency) + String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get(PPV_MODULE_ID_KEY); + String pricePpv = PurchaseUtils.purchasePpvDetailsMap.get(PPV_PRICE_AMOUNT); + String currencyPpv = PurchaseUtils.purchasePpvDetailsMap.get(PPV_PRICE_CURRENCY); - entitlementPpvFilter.setProductTypeEqual(TransactionType.PPV); //Show only PPV purchases + //Show only PPV purchases + entitlementPpvFilter.setProductTypeEqual(TransactionType.PPV); ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(entitlementPpvFilter).setKs(userKs); - listEntitlementServiceResponse = executor.executeSync(listEntitlementBuilder); //entitlement/action/list for household - List ppvEntitlementList = new ArrayList<>(); //Conversion from Entitlement to PpvEntitlement + //entitlement/action/list + listEntitlementServiceResponse = executor.executeSync(listEntitlementBuilder); + //Conversion from Entitlement to PpvEntitlement object + List ppvEntitlementList = new ArrayList<>(); for(Entitlement entitlement:listEntitlementServiceResponse.results.getObjects()){ if(entitlement.getClass() == PpvEntitlement.class) { ppvEntitlementList.add((PpvEntitlement) entitlement); } } - assertThat(listEntitlementServiceResponse.results.getTotalCount()).isEqualTo(1); //Verify that count of entitlements is 1 - assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(ppvModuleId); //Verify that PPV is correct - assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(assetFileId); //Verify that asset file is correct - - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); //All transactions per user - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); //Use non-master user ks - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for non-master user - assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType().getValue()).isEqualTo(TransactionType.PPV.getValue()); //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType().getValue()).isEqualTo("FullPeriod"); //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction().getValue()).isEqualTo("purchase"); //Verify that asset was purchased - - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //All transactions per household - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); //Use non-master user ks - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for household - assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType().getValue()).isEqualTo(TransactionType.PPV.getValue()); //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType().getValue()).isEqualTo("FullPeriod"); //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction().getValue()).isEqualTo("purchase"); //Verify that asset was purchased - - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //All transactions per household - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); //Use master user ks - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for household - assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType().getValue()).isEqualTo(TransactionType.PPV.getValue()); //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType().getValue()).isEqualTo("FullPeriod"); //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction().getValue()).isEqualTo("purchase"); //Verify that asset was purchased - - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); //All transactions per user - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); //Use master user ks - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //transactionHistory/action/list for master user - assertThat(listBillingTransactionResponse.error).isNull(); //No errors appeared at response - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); //No transactions were performed with master user + //Verify that count of entitlements is 1 + assertThat(listEntitlementServiceResponse.results.getTotalCount()).isEqualTo(1); + //Verify that PPV is correct + assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(ppvModuleId); + //Verify that asset file is correct + assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(assetFileId); + + //All transactions per user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); + //Use non-master user ks + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); + //transactionHistory/action/list for non-master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + //Verify asset id is correct + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); + //Verify transaction is for PPV + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); + //Verify price amount + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); + //Verify price currency + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); + //Verify entitlement period + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + //Verify that asset was purchased + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); + + //All transactions per household + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + //Use non-master user ks + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); + //transactionHistory/action/list for non-master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + //Verify asset id is correct + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); + //Verify transaction is for PPV + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); + //Verify price amount + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); + //Verify price currency + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); + //Verify entitlement period + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + //Verify that asset was purchased + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); + + //All transactions per household + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + //Use master user ks + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); + //transactionHistory/action/list for master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + //Verify asset id is correct + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); + //Verify transaction is for PPV + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); + //Verify price amount + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); + //Verify price currency + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); + //Verify entitlement period + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + //Verify that asset was purchased + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); + + //All transactions per user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); + //Use master user ks + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); + //transactionHistory/action/list for master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //No transactions were performed with master user + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); } } From 01b198f4e58de34036227d187967ff0ff8b3de99 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 14 May 2018 08:51:30 +0300 Subject: [PATCH 230/605] Continue preparation of fixture --- .../com/kaltura/client/test/Properties.java | 4 +- .../kaltura/client/test/tests/BaseTest.java | 19 ++- .../kaltura/client/test/utils/DBUtils.java | 146 ++++++++++++++---- .../client/test/utils/IngestUtils.java | 6 +- 4 files changed, 127 insertions(+), 48 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index a61796fdb..9d3439cb1 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -36,10 +36,10 @@ public class Properties { // price codes public static final String PRICE_CODE_AMOUNT = "price_code_amount"; // 4.99 - //public static final String COMMON_PRICE_CODE_AMOUNT = "5"; // TODO: should we document it as requirement? + public static final String COMMON_PRICE_CODE_AMOUNT = "5"; // TODO: should we document it as requirement? //cycles - //public static final String CYCLE_1_DAY = "1440"; // in minutes + public static final String CYCLE_1_DAY = "1440"; // in minutes // usage modules diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 6757f3649..36499ca0b 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -15,7 +15,6 @@ import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; -//import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; @@ -55,7 +54,7 @@ public class BaseTest { private static Subscription fiveMinRenewableSubscription; // shared ingested PP - //private static PricePlan sharedCommonPricePlan; + private static PricePlan sharedCommonPricePlan; /*================================================================================ testing shared params list - used as a helper common params across tests @@ -101,18 +100,18 @@ public void base_test_before_suite() { defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } - /*public static PricePlan getSharedCommonPricePlan(){ + public static PricePlan getSharedCommonPricePlan(){ if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = DBUtils.loadSharedPP(COMMON_PRICE_CODE_AMOUNT, "EUR"); - if (sharedCommonPricePlan == null) { + sharedCommonPricePlan = DBUtils.loadPricePlan(COMMON_PRICE_CODE_AMOUNT, "EUR", 0.0, 100.0); + /*if (sharedCommonPricePlan == null) { int fullDiscountPercent = 100; sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.of(CYCLE_1_DAY), Optional.of(CYCLE_1_DAY), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), Optional.of("EUR"), Optional.of(DBUtils.getDiscount(0, fullDiscountPercent)), Optional.of(true), Optional.of(0)); - } + }*/ } return sharedCommonPricePlan; - }*/ + } public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { @@ -153,7 +152,7 @@ public static String getIngestAssetUserPassword() { // getters for shared params public static String getAdministratorKs() { if (administratorKs == null) { - String[] userInfo = DBUtils.getUserDataByRole("Administrator").split(":"); + String[] userInfo = DBUtils.getUserData("Administrator").split(":"); loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], null,null)); administratorKs = loginResponse.results.getLoginSession().getKs(); @@ -163,7 +162,7 @@ public static String getAdministratorKs() { public static String getOperatorKs() { if (operatorKs == null) { - String[] userInfo = DBUtils.getUserDataByRole("Operator").split(":"); + String[] userInfo = DBUtils.getUserData("Operator").split(":"); loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], null,null)); operatorKs = loginResponse.results.getLoginSession().getKs(); @@ -173,7 +172,7 @@ public static String getOperatorKs() { public static String getManagerKs() { if (managerKs == null) { - String[] userInfo = DBUtils.getUserDataByRole("Manager").split(":"); + String[] userInfo = DBUtils.getUserData("Manager").split(":"); loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], null,null)); managerKs = loginResponse.results.getLoginSession().getKs(); diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 185e01f5f..4f6654ca6 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -2,7 +2,12 @@ import com.google.common.base.Strings; import com.kaltura.client.Logger; +import com.kaltura.client.enums.BillingAction; +import com.kaltura.client.enums.BillingPriceType; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.DiscountModule; +import com.kaltura.client.types.Price; +import com.kaltura.client.types.PriceDetails; import com.kaltura.client.types.PricePlan; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; @@ -24,51 +29,121 @@ public class DBUtils extends BaseUtils { //selects private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; - private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; private static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + - "from [Users].[dbo].[groups_parameters]\n" + - "where group_id=%d"; - private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + - "from [Users].[dbo].[users] u with(nolock)\n" + - "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + - "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + - "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; - private static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + - "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + - "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + - "where lc.code3='%S'\n" + // CURRENCY - "and dc.discount_percent=%d\n" + // percent amount - "and dc.group_id=%d\n" + // group - "and dc.[status]=1 and dc.is_active=1"; + "from [Users].[dbo].[groups_parameters]\n" + + "where group_id=%d"; + private static final String DISCOUNT_BY_CURENCY_AND_PERCENT_SELECT = "select TOP (1) *\n" + + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + + "where lc.code3='%S'\n" + // CURRENCY + "and dc.discount_percent=%d\n" + // percent amount + "and dc.group_id=%d\n" + // group + "and dc.[status]=1 and dc.is_active=1"; + private static final String DISCOUNT_BY_PRICE_AND_PERCENT_SELECT = "select TOP (1) *\n" + + "from [Pricing].[dbo].[discount_codes]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d\n" + // group + "and price=%d\n" + // price amount + "and discount_percent=%d"; // percent amount + private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; private static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; + private static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + + "where pc.[status]=1 and pc.is_active=1\n" + + "and pc.group_id=%d and pc.price=%d and lc.CODE3='%S'"; private static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; + private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + + "from [Users].[dbo].[users] u with(nolock)\n" + + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + + "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; + + public static PriceDetails loadPriceCode(Double priceAmount, String currency) { + Logger.getLogger(DBUtils.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency); + PriceDetails result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_CODE_SELECT, BaseTest.partnerId, priceAmount, currency), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return result; + } + result = new PriceDetails(); + result.setName(jsonArray.getJSONObject(0).getString("code")); + result.setId(jsonArray.getJSONObject(0).getInt("id")); + Price price = new Price(); + price.setCurrency(currency); + price.setAmount(priceAmount); + result.setPrice(price); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("discount code can't be null"); + } + return result; + } + public static DiscountModule loadDiscount(Double discountPrice, Double discountPercent) { + Logger.getLogger(DBUtils.class).debug("loadDiscount(): discountPrice = " + discountPrice + " discountPercent = " + discountPercent); + DiscountModule result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, + BaseTest.partnerId, discountPrice, discountPrice), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return result; + } + result = new DiscountModule(); + result.setToken("id", jsonArray.getJSONObject(0).getString("id")); + result.setToken("name", jsonArray.getJSONObject(0).getString("code")); + result.setPercent(discountPercent); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("discount code can't be null"); + } + return result; + } - - //"and group_id=%d and internal_discount_id=%d and pricing_id=%d"; - /*public static PricePlan loadSharedPP(String priceAmount, String currency) { - Logger.getLogger(DBUtils.class).debug("loadSharedPP(): priceAmount = " + priceAmount + " currency = " + currency); + public static PricePlan loadPricePlan(Double priceAmount, String currency, Double discountPrice, Double discountPercent) { + Logger.getLogger(DBUtils.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency + + " discountPrice = " + discountPrice + " discountPercent = " + discountPercent); PricePlan pricePlan = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, BaseTest.partnerId, priceAmount, currency)); - result = jsonArray.getJSONObject(0).getString("code"); + PriceDetails priceCode = loadPriceCode(priceAmount, currency); + if (priceCode == null) { + return pricePlan; + } + DiscountModule discountModule = loadDiscount(discountPrice, discountPercent); + if (discountModule == null) { + return pricePlan; + } + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, BaseTest.partnerId, + Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return pricePlan; + } + //TODO: result = jsonArray.getJSONObject(0).getString("code"); + pricePlan = new PricePlan(); + pricePlan.setId(jsonArray.getJSONObject(0).getLong("id")); + pricePlan.setName(jsonArray.getJSONObject(0).getString("name")); + pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt("view_life_cycle_min")); + pricePlan.setIsRenewable("0".equals(jsonArray.getJSONObject(0).getString("is_renew"))); + + pricePlan.דקא } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("discount code can't be null"); + Logger.getLogger(DBUtils.class).error("price plan data can't be null"); } return pricePlan; - }*/ + } public static String getIngestItemUserData(int accountId) { + Logger.getLogger(DBUtils.class).debug("getIngestItemUserData(): accountId = " + accountId); String result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_ITEMS_DATA_SELECT, accountId)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_ITEMS_DATA_SELECT, accountId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } @@ -83,10 +158,11 @@ public static String getIngestItemUserData(int accountId) { return result; } - public static String getDiscountByPercentAndCurrency(String currency, int percent) { + public static String getDiscount(String currency, int percent) { + Logger.getLogger(DBUtils.class).debug("getDiscount(): currency = " + currency + " percent = " + percent); String code = ""; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, BaseTest.partnerId)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_CURENCY_AND_PERCENT_SELECT, currency, percent, BaseTest.partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } @@ -104,9 +180,10 @@ public static String getDiscountByPercentAndCurrency(String currency, int percen } public static boolean isActivationOfUsersNeeded() { + Logger.getLogger(DBUtils.class).debug("isActivationOfUsersNeeded()"); int result = -1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } @@ -120,14 +197,15 @@ public static boolean isActivationOfUsersNeeded() { return result == 1; } - public static String getUserDataByRole(String userRole) { + public static String getUserData(String userRole) { + Logger.getLogger(DBUtils.class).debug("getUserData(): userRole = " + userRole); String sqlQuery = USER_BY_ROLE_SELECT; if (isActivationOfUsersNeeded()) { sqlQuery += " and u.activate_status=1"; } String userdData = ""; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, BaseTest.partnerId)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, BaseTest.partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } @@ -143,10 +221,11 @@ public static String getUserDataByRole(String userRole) { } public static String getActivationToken(String username) { + Logger.getLogger(DBUtils.class).debug("getActivationToken(): username = " + username); String activationToken = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ACTIVATION_TOKEN_SELECT, username)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ACTIVATION_TOKEN_SELECT, username), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); } @@ -160,9 +239,10 @@ public static String getActivationToken(String username) { } public static int getEpgChannelId(String channelName) { + Logger.getLogger(DBUtils.class).debug("getEpgChannelId(): channelName = " + channelName); int epgChannelId =-1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName), false); epgChannelId = jsonArray.getJSONObject(0).getInt("id"); } catch (Exception e) { e.printStackTrace(); @@ -174,13 +254,13 @@ public static int getEpgChannelId(String channelName) { //TODO - change existing methods to work with the new getJsonArrayFromQueryResult method // Return json array from DB - private static JSONArray getJsonArrayFromQueryResult(String query) throws Exception { + private static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) throws Exception { openConnection(); JSONArray jsonArray = new JSONArray(); rs = stam.executeQuery(query); ResultSetMetaData rsmd = rs.getMetaData(); - if (rs != null && rs.isBeforeFirst()) { + if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { while (rs.next()) { int numColumns = rsmd.getColumnCount(); JSONObject obj = new JSONObject(); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 76b1e03f2..5be04db4e 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -366,7 +366,7 @@ public static Subscription ingestMPP(Optional action, Optional m String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); String defaultCurrencyOfDiscount4IngestMpp = "GBP"; int defaultPercentageOfDiscount4IngestMpp = 100; - String internalDiscountValue = internalDiscount.orElse(DBUtils.getDiscountByPercentAndCurrency(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); + String internalDiscountValue = internalDiscount.orElse(DBUtils.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); String productCodeValue = productCode.orElse(""); boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); @@ -519,7 +519,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String currencyValue = currency.orElse(CURRENCY_EUR); String defaultCurrencyOfDiscount4IngestMpp = "GBP"; int defaultPercentageOfDiscount4IngestMpp = 100; - String discountValue = discount.orElse(DBUtils.getDiscountByPercentAndCurrency(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); + String discountValue = discount.orElse(DBUtils.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); @@ -634,7 +634,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O String descriptionValue = description.orElse("My ingest PPV"); String defaultCurrencyOfDiscount4IngestPpv = "ILS"; int defaultPercentageOfDiscount4IngestPpv = 50; - String discountValue = discount.orElse(DBUtils.getDiscountByPercentAndCurrency(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); + String discountValue = discount.orElse(DBUtils.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); String currencyValue = currency.orElse(CURRENCY_EUR); String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); From 8251c77f95ffd52adf4bde68b253def473df8c14 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 14 May 2018 11:23:53 +0300 Subject: [PATCH 231/605] Completed getSharedCommonPricePlan() --- .../kaltura/client/test/tests/BaseTest.java | 14 ++++++---- .../kaltura/client/test/utils/DBUtils.java | 28 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 36499ca0b..22acae440 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -15,6 +15,7 @@ import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; @@ -101,14 +102,17 @@ public void base_test_before_suite() { } public static PricePlan getSharedCommonPricePlan(){ + String defaultCurrency = "EUR"; + double defaultDiscountPrice = 0.0; + double defaultDiscountPercentValue = 100.0; if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = DBUtils.loadPricePlan(COMMON_PRICE_CODE_AMOUNT, "EUR", 0.0, 100.0); - /*if (sharedCommonPricePlan == null) { - int fullDiscountPercent = 100; + sharedCommonPricePlan = DBUtils.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), defaultCurrency, defaultDiscountPrice, defaultDiscountPercentValue); + if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.of(CYCLE_1_DAY), Optional.of(CYCLE_1_DAY), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), - Optional.of("EUR"), Optional.of(DBUtils.getDiscount(0, fullDiscountPercent)), Optional.of(true), Optional.of(0)); - }*/ + Optional.of(defaultCurrency), Optional.of(DBUtils.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), + Optional.of(true), Optional.of(0)); + } } return sharedCommonPricePlan; } diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 4f6654ca6..3dbea0a54 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -2,8 +2,6 @@ import com.google.common.base.Strings; import com.kaltura.client.Logger; -import com.kaltura.client.enums.BillingAction; -import com.kaltura.client.enums.BillingPriceType; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.DiscountModule; import com.kaltura.client.types.Price; @@ -13,9 +11,7 @@ import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; import org.json.JSONObject; - import java.sql.*; - import static com.kaltura.client.test.Properties.*; public class DBUtils extends BaseUtils { @@ -29,9 +25,11 @@ public class DBUtils extends BaseUtils { //selects private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + private static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + "from [Users].[dbo].[groups_parameters]\n" + "where group_id=%d"; + private static final String DISCOUNT_BY_CURENCY_AND_PERCENT_SELECT = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + @@ -39,23 +37,29 @@ public class DBUtils extends BaseUtils { "and dc.discount_percent=%d\n" + // percent amount "and dc.group_id=%d\n" + // group "and dc.[status]=1 and dc.is_active=1"; + private static final String DISCOUNT_BY_PRICE_AND_PERCENT_SELECT = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d\n" + // group "and price=%d\n" + // price amount "and discount_percent=%d"; // percent amount + private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + private static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; + private static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + "where pc.[status]=1 and pc.is_active=1\n" + "and pc.group_id=%d and pc.price=%d and lc.CODE3='%S'"; + private static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; + private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + "from [Users].[dbo].[users] u with(nolock)\n" + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + @@ -107,35 +111,40 @@ public static DiscountModule loadDiscount(Double discountPrice, Double discountP public static PricePlan loadPricePlan(Double priceAmount, String currency, Double discountPrice, Double discountPercent) { Logger.getLogger(DBUtils.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency + " discountPrice = " + discountPrice + " discountPercent = " + discountPercent); + PricePlan pricePlan = null; + try { PriceDetails priceCode = loadPriceCode(priceAmount, currency); if (priceCode == null) { return pricePlan; } + DiscountModule discountModule = loadDiscount(discountPrice, discountPercent); if (discountModule == null) { return pricePlan; } + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, BaseTest.partnerId, Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return pricePlan; } - //TODO: result = jsonArray.getJSONObject(0).getString("code"); + pricePlan = new PricePlan(); pricePlan.setId(jsonArray.getJSONObject(0).getLong("id")); pricePlan.setName(jsonArray.getJSONObject(0).getString("name")); pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt("view_life_cycle_min")); + pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt("full_life_cycle_min")); + pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt("max_views_number")); + pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get("id").toString())); + pricePlan.setPriceDetailsId(priceCode.getId().longValue()); pricePlan.setIsRenewable("0".equals(jsonArray.getJSONObject(0).getString("is_renew"))); - - pricePlan.דקא + pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt("num_of_rec_period")); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("price plan data can't be null"); } - - return pricePlan; } @@ -252,7 +261,6 @@ public static int getEpgChannelId(String channelName) { return epgChannelId; } - //TODO - change existing methods to work with the new getJsonArrayFromQueryResult method // Return json array from DB private static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) throws Exception { openConnection(); From 44b3ef1af0fe49711aca7760994053f24cc980cb Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 14 May 2018 12:59:53 +0300 Subject: [PATCH 232/605] added OttUserAddRoleTests and OttUserActivateTests --- .../test/TestAPIOkRequestsExecutor.java | 6 +- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../ottUserTests/OttUserActivateTests.java | 79 +++++++++++++++- .../ottUserTests/OttUserAddRoleTests.java | 94 ++++++++++++++++--- .../kaltura/client/test/utils/DBUtils.java | 47 +++++++--- src/test/resources/schemas/ListResponse.json | 6 +- src/test/resources/schemas/UserRole.json | 24 +++++ 7 files changed, 225 insertions(+), 33 deletions(-) create mode 100644 src/test/resources/schemas/UserRole.json diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 54d5d0441..61005af4c 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -13,6 +13,7 @@ import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.test.tests.BaseTest.LOG_HEADERS; import static com.kaltura.client.test.tests.BaseTest.client; import static com.kaltura.client.utils.ErrorElement.*; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; @@ -45,7 +46,10 @@ public static TestAPIOkRequestsExecutor getExecutor() { protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, RequestElement action) { ResponseElement responseElement = super.onGotResponse(okhttpResponse, action); // logger.debug("response body:\n" + responseElement.getResponse()); // was found in base class -// logger.debug("response headers:\n" + okhttpResponse.headers()); + + if (LOG_HEADERS) { + logger.debug("response headers:\n" + okhttpResponse.headers()); + } if (responseElement.isSuccess()) { Response response = action.parseResponse(responseElement); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index ea3ea0dba..69ab9cf50 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -24,11 +24,11 @@ public class BaseTest { private final int DEFAULT_TIMEOUT_IN_SEC = 60; + public static final boolean LOG_HEADERS = true; public static Client client; public static Configuration config; public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); - private static Response loginResponse; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java index 7ceece67f..cc0b2e4b9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java @@ -14,6 +14,7 @@ import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.services.OttUserService.register; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -59,10 +60,82 @@ private void activate() { } @Severity(SeverityLevel.MINOR) - @Description("ottUser/action/activate - activate twice with the same token") + @Description("ottUser/action/activate - activate twice with the same token - error 2000") @Test - private void activate_with_same_token() { + private void activate_twice_with_same_token() { + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // login user + user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); + + // assert user is not activated + assertThat(user.getUserState()).isEqualTo(UserState.USER_NOT_ACTIVATED); + + // get activation token + String activationToken = DBUtils.getActivationToken(user.getUsername()); + + // activate user - first time + ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, user.getUsername(), activationToken)); + + // assert user activated + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); + + // activate user - second time + ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, user.getUsername(), activationToken)); + + // assert error return + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); + } + + @Severity(SeverityLevel.MINOR) + @Description("ottUser/action/activate - invalid user name - error 2000") + @Test + private void activate_with_invalid_username() { + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // login user + user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); + + // assert user is not activated + assertThat(user.getUserState()).isEqualTo(UserState.USER_NOT_ACTIVATED); + + // get activation token + String activationToken = DBUtils.getActivationToken(user.getUsername()); + + // activate user - with invalid user name + String invalidUserName = user.getUsername() + 1; + ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, invalidUserName, activationToken)); + + // assert error return + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); + } + + @Severity(SeverityLevel.MINOR) + @Description("ottUser/action/activate - invalid activationToken - error 2000") + @Test + private void activate_with_invalid_activationToken() { + // register user + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // login user + user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); + + // assert user is not activated + assertThat(user.getUserState()).isEqualTo(UserState.USER_NOT_ACTIVATED); + + // get activation token + String invalidActivationToken = "1"; + + // activate user - with invalid user name + ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, user.getUsername(), invalidActivationToken)); - // TODO: 5/2/2018 implement test + // assert error return + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java index b42fed22b..ed335936b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java @@ -1,42 +1,108 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.UserRoleService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.UserRole; +import com.kaltura.client.types.UserRoleFilter; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.assertj.core.api.Assertions; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.UserRoleService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static com.kaltura.client.test.utils.OttUserUtils.getKs; +import static org.assertj.core.api.Assertions.assertThat; public class OttUserAddRoleTests extends BaseTest { - private OTTUser user; - - @BeforeClass - private void ottUser_addRole_tests_setup() { - // register user - user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/addRole - addRole") + @Issue("BEO-5081") @Test(enabled = false) - // TODO: 3/27/2018 finish and fix test private void addRoleTest() { - int roleId = 3; + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // generate new role + UserRole userRole = generateUserRole(); // add role - AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(roleId) + AddUserRoleBuilder addUserRoleBuilder = add(userRole) + .setKs(getAdministratorKs()); + executor.executeSync(addUserRoleBuilder); + + // add role to user + AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(userRole.getId()) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(user.getId())); Response booleanResponse = executor.executeSync(addRoleOttUserBuilder); - Assertions.assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + + // get user roles + UserRoleFilter filter = new UserRoleFilter(); + filter.setCurrentUserRoleIdsContains(true); + + int userId = Integer.parseInt(user.getId()); + ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(filter) + .setKs(getKs(userId, null)); + List userRoles = executor.executeSync(listUserRoleBuilder).results.getObjects(); + + // assert new added role is return + List userRolesIds = new ArrayList<>(); + for (UserRole ur : userRoles) { + userRolesIds.add(ur.getId()); + } + + assertThat(userRolesIds).contains(userRole.getId()); + + // cleanup - delete role + // TODO: 5/14/2018 finish test after when reletead bug will be fixed + } + + @Severity(SeverityLevel.NORMAL) + @Description("ottUser/action/addRole - addRole with invalid roleId - error ") + @Issue("BEO-5083") + @Test(enabled = false) + private void addRole_with_invalid_roleId() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // generate new role +// UserRole userRole = generateUserRole(); + + // add not existing role to user + int invalidRoleId = -2; + AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(invalidRoleId) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + Response booleanResponse = executor.executeSync(addRoleOttUserBuilder); + + assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); + + // cleanup - delete role + // TODO: 5/14/2018 finish test after when reletead bug will be fixed + } + + private UserRole generateUserRole() { + Random r = new Random(); + int low = 9000; + int max = 10000; + long roleId = r.nextInt(max - low) + low; + + UserRole userRole = new UserRole(); + userRole.setId(roleId); + userRole.setName(String.valueOf(roleId)); - // TODO: 3/27/2018 finish and fix test + return userRole; } } diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 053be2586..edae1c774 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -25,24 +25,24 @@ public class DBUtils extends BaseUtils { private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; private static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + - "from [Users].[dbo].[groups_parameters]\n" + - "where group_id=%d"; + "from [Users].[dbo].[groups_parameters]\n" + + "where group_id=%d"; private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + - "from [Users].[dbo].[users] u with(nolock)\n" + - "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + - "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + - "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; + "from [Users].[dbo].[users] u with(nolock)\n" + + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + + "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; private static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + - "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + - "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + - "where lc.code3='%S'\n" + // CURRENCY - "and dc.discount_percent=%d\n" + // percent amount - "and dc.group_id=%d\n" + // group - "and dc.[status]=1 and dc.is_active=1"; + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + + "where lc.code3='%S'\n" + // CURRENCY + "and dc.discount_percent=%d\n" + // percent amount + "and dc.group_id=%d\n" + // group + "and dc.[status]=1 and dc.is_active=1"; private static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; - + private static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; public static String getIngestItemUserData(int accountId) { @@ -130,6 +130,27 @@ public static String getActivationToken(String username) { return activationToken; } +// public static List getUserRoles(String userId) { +// List userRoles = new ArrayList<>(); +// +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(USER_ROLES_SELECT, userId)); +// +// if (Strings.isNullOrEmpty(jsonArray.toString())) { +// Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); +// } +// +// for (int i = 0; i < jsonArray.length(); i++) { +// userRoles.add(jsonArray.getInt(i)); +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return userRoles; +// } + public static int getEpgChannelId(String channelName) { openConnection(); try { diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index bfec96dc2..d9fabe795 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -38,6 +38,9 @@ }, { "$ref": "HouseholdDevice.json#/definitions/HouseholdDevice" + }, + { + "$ref": "UserRole.json#/definitions/UserRole" } ] } @@ -58,7 +61,8 @@ "KalturaProductPriceListResponse", "KalturaBookmarkListResponse", "KalturaAssetCommentListResponse", - "KalturaAssetHistoryListResponse" + "KalturaAssetHistoryListResponse", + "KalturaUserRoleListResponse" ] } }, diff --git a/src/test/resources/schemas/UserRole.json b/src/test/resources/schemas/UserRole.json new file mode 100644 index 000000000..1d41dc593 --- /dev/null +++ b/src/test/resources/schemas/UserRole.json @@ -0,0 +1,24 @@ +{ + "$id": "UserRole", + "definitions": { + "UserRole": { + "type": "object", + "properties": { + "id": {"type": "integer", "minimum": 0}, + "name": {"type": "string"}, + "permissionNames": {"type": "string"}, + "excludedPermissionNames": {"type": "string"}, + "objectType": {"type": "string", "minLength": 0} + }, + "required": ["id", "objectType"] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/UserRole" + }, + "executionTime": {"type": "number"} + }, + "required": ["result", "executionTime"] +} From 2c314c6b329b8b396c3621960cf816c1e71471a8 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 14 May 2018 16:17:42 +0300 Subject: [PATCH 233/605] Added getSharedCommonSubscription() method --- .../com/kaltura/client/test/Properties.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 51 +++++++++++++++++- .../EntitlementGrantTests.java | 5 +- .../kaltura/client/test/utils/DBUtils.java | 54 ++++++++++++++----- 4 files changed, 96 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 9d3439cb1..f07de1288 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -39,7 +39,7 @@ public class Properties { public static final String COMMON_PRICE_CODE_AMOUNT = "5"; // TODO: should we document it as requirement? //cycles - public static final String CYCLE_1_DAY = "1440"; // in minutes + public static final int CYCLE_1_DAY = 1440; // in minutes // usage modules diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 22acae440..c754613a8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -9,7 +9,10 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; + +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.OttUserService.login; @@ -57,6 +60,17 @@ public class BaseTest { // shared ingested PP private static PricePlan sharedCommonPricePlan; + // shared ingested subscription + private static Subscription sharedCommonSubscription; + + // cycles map with values related view/full life cycles of price plans + private static Map cycles = new HashMap<>(); + { + // TODO: complete other values + cycles.put(1440, "1 Day"); + } + + /*================================================================================ testing shared params list - used as a helper common params across tests @@ -101,6 +115,16 @@ public void base_test_before_suite() { defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } + /** + * Regression requires existing of Price Plan with specific parameters. + * Price should be 5 Euros + * Discount percent should be equal 100% + * + * In case item is not found in DB it will be ingested. + * Can't work in case proper Discount and PriceCode aren't found in DB + * + * @return common shared Price Plan with mentioned parameters + */ public static PricePlan getSharedCommonPricePlan(){ String defaultCurrency = "EUR"; double defaultDiscountPrice = 0.0; @@ -109,7 +133,7 @@ public static PricePlan getSharedCommonPricePlan(){ sharedCommonPricePlan = DBUtils.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), defaultCurrency, defaultDiscountPrice, defaultDiscountPercentValue); if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), - Optional.of(CYCLE_1_DAY), Optional.of(CYCLE_1_DAY), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), + Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), Optional.of(defaultCurrency), Optional.of(DBUtils.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), Optional.of(true), Optional.of(0)); } @@ -117,6 +141,31 @@ public static PricePlan getSharedCommonPricePlan(){ return sharedCommonPricePlan; } + /** + * Regression requires existing of MPP with specific parameters. + * Price Plan should be as for method public static PricePlan getSharedCommonPricePlan() + * + * MPP shouldn't be renewed and with discount (internal items) 100% + * + * + * @return MPP with mentioned parameters + */ + public static Subscription getSharedCommonSubscription(){ + double defaultDiscountPercentValue = 100.0; + String defaultCurrency = "EUR"; + if (sharedCommonSubscription == null) { + sharedCommonSubscription = DBUtils.loadSharedCommonSubscription(getSharedCommonPricePlan()); + if (sharedCommonSubscription == null) { + sharedCommonSubscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(DBUtils.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), Optional.empty(), + Optional.of(false), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + } + } + return sharedCommonSubscription; + } + public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index 081b6188c..de959bb3e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -29,8 +29,8 @@ public class EntitlementGrantTests extends BaseTest { - // TODO: 4/12/2018 remove hardcoded subscription Id - private final int subscriptionId = 41114; + // TODO: 4/12/2018 remove hardcoded ppv Id + private static int subscriptionId; private final int ppvId = 30297; private final int assetId = 607368; private int contentId; @@ -46,6 +46,7 @@ public class EntitlementGrantTests extends BaseTest { private void grant_test_before_class() { contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + subscriptionId = Integer.valueOf(getSharedCommonSubscription().getId()); } @Test(description = "entitlement/action/grant - grant subscription with history = true") diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 3dbea0a54..24bb7f484 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -2,11 +2,9 @@ import com.google.common.base.Strings; import com.kaltura.client.Logger; +import com.kaltura.client.enums.SubscriptionDependencyType; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.DiscountModule; -import com.kaltura.client.types.Price; -import com.kaltura.client.types.PriceDetails; -import com.kaltura.client.types.PricePlan; +import com.kaltura.client.types.*; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; @@ -42,8 +40,8 @@ public class DBUtils extends BaseUtils { "from [Pricing].[dbo].[discount_codes]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d\n" + // group - "and price=%d\n" + // price amount - "and discount_percent=%d"; // percent amount + "and price=%f\n" + // price amount + "and discount_percent=%f"; // percent amount private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; @@ -54,12 +52,17 @@ public class DBUtils extends BaseUtils { private static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + "where pc.[status]=1 and pc.is_active=1\n" + - "and pc.group_id=%d and pc.price=%d and lc.CODE3='%S'"; + "and pc.group_id=%d and pc.price=%f and lc.CODE3='%S'"; private static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; + private static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d and usage_module_code=%d\n" + + "order by create_date"; + private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + "from [Users].[dbo].[users] u with(nolock)\n" + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + @@ -67,13 +70,14 @@ public class DBUtils extends BaseUtils { "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; public static PriceDetails loadPriceCode(Double priceAmount, String currency) { - Logger.getLogger(DBUtils.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency); + Logger.getLogger(DBUtils.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); PriceDetails result = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_CODE_SELECT, BaseTest.partnerId, priceAmount, currency), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } + result = new PriceDetails(); result.setName(jsonArray.getJSONObject(0).getString("code")); result.setId(jsonArray.getJSONObject(0).getInt("id")); @@ -93,12 +97,12 @@ public static DiscountModule loadDiscount(Double discountPrice, Double discountP DiscountModule result = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, - BaseTest.partnerId, discountPrice, discountPrice), true); + BaseTest.partnerId, discountPrice, discountPercent), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } result = new DiscountModule(); - result.setToken("id", jsonArray.getJSONObject(0).getString("id")); + result.setToken("id", String.valueOf(jsonArray.getJSONObject(0).getInt("id"))); result.setToken("name", jsonArray.getJSONObject(0).getString("code")); result.setPercent(discountPercent); } catch (Exception e) { @@ -139,8 +143,8 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt("max_views_number")); pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get("id").toString())); pricePlan.setPriceDetailsId(priceCode.getId().longValue()); - pricePlan.setIsRenewable("0".equals(jsonArray.getJSONObject(0).getString("is_renew"))); - pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt("num_of_rec_period")); + pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt("is_renew")); + pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt("num_of_rec_periods")); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("price plan data can't be null"); @@ -148,6 +152,31 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl return pricePlan; } + public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { + Logger.getLogger(DBUtils.class).debug("loadSharedCommonSubscription(): pricePlan id = " + pricePlan.getId()); + + Subscription subscription = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_SELECT, BaseTest.partnerId, + pricePlan.getId()), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return subscription; + } + + subscription = new Subscription(); + subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt("id"))); + subscription.setName(jsonArray.getJSONObject(0).getString("name")); + subscription.setPricePlanIds(String.valueOf(pricePlan.getId())); + subscription.setIsRenewable(false); + subscription.setDependencyType(SubscriptionDependencyType.BASE); + // TODO: add more data in case it needed + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("subscription data can't be null"); + } + return subscription; + } + public static String getIngestItemUserData(int accountId) { Logger.getLogger(DBUtils.class).debug("getIngestItemUserData(): accountId = " + accountId); String result = null; @@ -309,6 +338,7 @@ private static JSONArray getJsonArrayFromQueryResult(String query, boolean isNul jsonArray.put(obj); } closeConnection(); + Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); return jsonArray; } else { From 7cd845c46916ea5a682087377e4416de984ef997 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 14 May 2018 17:58:27 +0300 Subject: [PATCH 234/605] add ottUser tests --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../ottUserTests/OttUserAddRoleTests.java | 10 +- .../OttUserAnonymousLoginTests.java | 12 +- .../ottUserTests/OttUserDeleteTests.java | 53 ++++++++- .../OttUserGetEncryptedUserIdTests.java | 25 +++- .../ottUserTests/OttUserGetTests.java | 35 +++++- .../ottUserTests/OttUserListTests.java | 63 ++++++++-- .../ottUserTests/OttUserLoginTests.java | 110 +++++++++++++++--- .../OttUserLoginWithPinTests.java | 42 ++++++- .../ottUserTests/OttUserRegisterTests.java | 6 +- .../OttUserResendActivationTokenTests.java | 5 +- .../OttUserResetPasswordTests.java | 5 +- .../OttUserUpdateDynamicDataTests.java | 5 +- .../OttUserUpdateLoginDataTests.java | 7 +- .../ottUserTests/OttUserUpdateTests.java | 7 +- .../client/test/utils/OttUserUtils.java | 1 + 16 files changed, 320 insertions(+), 68 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 69ab9cf50..dfabe49aa 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -24,7 +24,7 @@ public class BaseTest { private final int DEFAULT_TIMEOUT_IN_SEC = 60; - public static final boolean LOG_HEADERS = true; + public static final boolean LOG_HEADERS = false; public static Client client; public static Configuration config; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java index ed335936b..4cbb5ff66 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.services.UserRoleService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; @@ -29,7 +30,7 @@ public class OttUserAddRoleTests extends BaseTest { @Description("ottUser/action/addRole - addRole") @Issue("BEO-5081") @Test(enabled = false) - private void addRoleTest() { + private void addRole() { // register user OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; @@ -42,7 +43,7 @@ private void addRoleTest() { executor.executeSync(addUserRoleBuilder); // add role to user - AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(userRole.getId()) + AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(userRole.getId()) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(user.getId())); Response booleanResponse = executor.executeSync(addRoleOttUserBuilder); @@ -77,12 +78,9 @@ private void addRole_with_invalid_roleId() { // register user OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - // generate new role -// UserRole userRole = generateUserRole(); - // add not existing role to user int invalidRoleId = -2; - AddRoleOttUserBuilder addRoleOttUserBuilder = addRole(invalidRoleId) + AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(invalidRoleId) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(user.getId())); Response booleanResponse = executor.executeSync(addRoleOttUserBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java index a5b7098cf..c8304bf0a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginSession; import com.kaltura.client.utils.response.base.Response; @@ -8,7 +9,6 @@ import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.anonymousLogin; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -21,8 +21,8 @@ public class OttUserAnonymousLoginTests extends BaseTest { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() - private void anonymousLoginTest() { - loginSessionResponse = executor.executeSync(anonymousLogin(partnerId)); + private void anonymousLogin() { + loginSessionResponse = executor.executeSync(OttUserService.anonymousLogin(partnerId)); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); @@ -31,9 +31,9 @@ private void anonymousLoginTest() { @Severity(SeverityLevel.MINOR) @Description("ottUser/action/anonymousLogin - anonymousLogin with wrong partnerId - error 500006") @Test() - private void anonymousLogin_with_wrong_partnerId() { - int fakePartnerId = 1; - loginSessionResponse = executor.executeSync(anonymousLogin(fakePartnerId)); + private void anonymousLogin_with_invalod_partnerId() { + int invalidPartnerId = 1; + loginSessionResponse = executor.executeSync(OttUserService.anonymousLogin(invalidPartnerId)); assertThat(loginSessionResponse.results).isNull(); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java index a0fd24092..8808088cf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java @@ -15,6 +15,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; @@ -26,14 +27,14 @@ public class OttUserDeleteTests extends BaseTest { private Household household; - private Response booleanResponse; private DeleteOttUserBuilder deleteOttUserBuilder; + private final int numberOfDevicesInHousehold = 0; + private final int numberOfUsersInHousehold = 2; + @BeforeClass private void ottUser_delete_tests_setup() { - int numberOfDevicesInHousehold = 0; - int numberOfUsersInHousehold = 2; household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } @@ -66,7 +67,7 @@ private void delete() { @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/delete - delete master user: error 2031") - @Test(enabled = true) + @Test() private void delete_master_user() { // get household master user HouseholdUser masterUser = getMasterUserFromHousehold(household); @@ -83,7 +84,7 @@ private void delete_master_user() { @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/delete - delete default user: error 2030") - @Test(enabled = true) + @Test() private void delete_default_user() { // get household default user HouseholdUser defaultUser = getDefaultUserFromHousehold(household); @@ -98,6 +99,48 @@ private void delete_default_user() { assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2030).getCode()); } + @Severity(SeverityLevel.MINOR) + @Description("ottUser/action/delete - delete not exist user: error 500004") + @Test() + private void delete_not_exist_user() { + // delete not exist user and assert error + int invalidUserId = 1; + deleteOttUserBuilder = OttUserService.delete() + .setKs(getAdministratorKs()) + .setUserId(invalidUserId); + booleanResponse = executor.executeSync(deleteOttUserBuilder); + + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); + } + + @Severity(SeverityLevel.MINOR) + @Description("ottUser/action/delete - delete user with suspended household: error 1009") + @Test() + private void delete_user_with_suspended_household() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + + // get regular user + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + + // suspend household + SuspendHouseholdBuilder suspendHouseholdBuilder = suspend() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getUserId())); + booleanResponse = executor.executeSync(suspendHouseholdBuilder); + + // delete suspended user + deleteOttUserBuilder = OttUserService.delete() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getUserId())); + booleanResponse = executor.executeSync(deleteOttUserBuilder); + + // assert error + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1009).getCode()); + } + @AfterClass private void ottUser_delete_tests_tearDown() { DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java index 4d69281c1..58ebbad0e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.StringValue; @@ -12,6 +13,7 @@ import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static com.kaltura.client.test.utils.OttUserUtils.getKs; import static org.assertj.core.api.Assertions.assertThat; public class OttUserGetEncryptedUserIdTests extends BaseTest { @@ -25,12 +27,25 @@ private void ottUser_getEncryptedUserId_tests_setup() { } @Severity(SeverityLevel.CRITICAL) - @Description("ottUser/action/getEncryptedUserId - getEncryptedUserId") + @Description("ottUser/action/getEncryptedUserId - getEncryptedUserId with super user ks") @Test - private void getEncryptedUserIdTest() { - GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = getEncryptedUserId(); - getEncryptedUserIdOttUserBuilder.setKs(getAdministratorKs()); - getEncryptedUserIdOttUserBuilder.setUserId(Integer.valueOf(user.getId())); + private void getEncryptedUserId_with_superUserKs () { + GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = OttUserService.getEncryptedUserId() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + Response stringValueResponse = executor.executeSync(getEncryptedUserIdOttUserBuilder); + + assertThat(stringValueResponse.error).isNull(); + assertThat(stringValueResponse.results.getValue()).isNotNull(); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/getEncryptedUserId") + @Test + private void getEncryptedUserId() { + String userKs = getKs(Integer.parseInt(user.getId()), null); + GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = OttUserService.getEncryptedUserId() + .setKs(userKs); Response stringValueResponse = executor.executeSync(getEncryptedUserIdOttUserBuilder); assertThat(stringValueResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java index 6a3a42903..9795520b1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -11,6 +12,7 @@ import org.testng.annotations.Test; import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -32,13 +34,42 @@ private void ottUser_get_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/get - get") @Test - private void getTest() { + private void get() { // get user - GetOttUserBuilder getOttUserBuilder = get() + GetOttUserBuilder getOttUserBuilder = OttUserService.get() .setKs(loginResponse.results.getLoginSession().getKs()); Response ottUserResponse = executor.executeSync(getOttUserBuilder); assertThat(loginResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); } + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/get - get with super user ks") + @Test + private void get_with_superUserKs() { + // get user + GetOttUserBuilder getOttUserBuilder = OttUserService.get() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId())); + Response ottUserResponse = executor.executeSync(getOttUserBuilder); + + assertThat(loginResponse.error).isNull(); + assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); + } + + @Severity(SeverityLevel.MINOR) + @Description("ottUser/action/get - get with invalid userId - error 500004") + @Test + private void get_with_invalid_userId() { + // get user + int invalidUserId = 1; + GetOttUserBuilder getOttUserBuilder = OttUserService.get() + .setKs(getAdministratorKs()) + .setUserId(invalidUserId); + Response ottUserResponse = executor.executeSync(getOttUserBuilder); + + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java index f7d42ae74..42c094dbc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java @@ -15,8 +15,8 @@ import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; -import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUserFromHousehold; -import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static com.kaltura.client.test.utils.OttUserUtils.getUserById; import static org.assertj.core.api.Assertions.assertThat; @@ -34,9 +34,9 @@ private void ottUser_list_tests_setup() { } @Severity(SeverityLevel.CRITICAL) - @Description("ottUser/action/list - list from master ks") + @Description("ottUser/action/list - list with master user ks") @Test - private void list_from_master_ks() { + private void list_with_masterUserKs() { // get master user from household HouseholdUser masterUser = getMasterUserFromHousehold(household); @@ -56,10 +56,33 @@ private void list_from_master_ks() { assertThat(users.size()).isEqualTo(numberOfUsersInHousehold + 2); } + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/list - list with regular user ks") + @Test + private void list_with_regularUserKs() { + // get master user from household + HouseholdUser user = getRegularUsersListFromHouseHold(household).get(0); + + // login regular user + String username = getUserById(Integer.parseInt(user.getUserId())).getUsername(); + LoginOttUserBuilder loginOttUserBuilder = login(partnerId, username, defaultUserPassword); + Response loginResponse = executor.executeSync(loginOttUserBuilder); + + // list household users + ListOttUserBuilder listOttUserBuilder = list() + .setKs(loginResponse.results.getLoginSession().getKs()); + householdUserListResponse = executor.executeSync(listOttUserBuilder); + List users = householdUserListResponse.results.getObjects(); + + // assert users list size + assertThat(householdUserListResponse.error).isNull(); + assertThat(users.size()).isEqualTo(numberOfUsersInHousehold + 2); + } + @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/list - get list with filter using idIn") @Test - private void list_with_filter_idIn() { + private void list_with_id_filter() { // get users from household List householdUsers = getUsersListFromHouseHold(household); @@ -82,7 +105,7 @@ private void list_with_filter_idIn() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/list - get list with filter using usernameEqual") @Test - private void list_withd_filter_usernameEqual() { + private void list_with_username_filter() { // get users from household List householdUsers = getUsersListFromHouseHold(household); @@ -103,13 +126,13 @@ private void list_withd_filter_usernameEqual() { } @Severity(SeverityLevel.NORMAL) - @Description("ottUser/action/list - get list with not valid filter") + @Description("ottUser/action/list - get list with invalid filter") @Test - private void list_with_not_valid_filter() { + private void list_with_invalid_filter() { // get users from household List householdUsers = getUsersListFromHouseHold(household); - // set user filter + // set invalid user filter OTTUserFilter ottUserFilter = new OTTUserFilter(); ottUserFilter.setIdIn(householdUsers.get(0).getUserId()); ottUserFilter.setUsernameEqual(getUserById(Integer.valueOf(householdUsers.get(1).getUserId())).getUsername()); @@ -123,4 +146,26 @@ private void list_with_not_valid_filter() { assertThat(householdUserListResponse.results).isNull(); assertThat(householdUserListResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500038).getCode()); } + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/list - get list with filter using usernameEqual") + @Test + private void list_with_externalId_filter() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // set user filter + OTTUserFilter ottUserFilter = new OTTUserFilter(); + ottUserFilter.setExternalIdEqual(user.getExternalId()); + + // list household users + ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) + .setKs(getAdministratorKs()); + householdUserListResponse = executor.executeSync(listOttUserBuilder); + List users = householdUserListResponse.results.getObjects(); + + // assert users list size + assertThat(householdUserListResponse.error).isNull(); + assertThat(users.size()).isEqualTo(1); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java index e8b45b3b9..14fd736b8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java @@ -1,7 +1,12 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.enums.UserState; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -11,10 +16,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.login; +import static com.kaltura.client.services.HouseholdService.SuspendHouseholdBuilder; +import static com.kaltura.client.services.HouseholdService.suspend; import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static com.kaltura.client.test.utils.OttUserUtils.getUserById; import static org.assertj.core.api.Assertions.assertThat; public class OttUserLoginTests extends BaseTest { @@ -30,9 +37,9 @@ private void ottUser_login_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ottUser/action/login - login") - private void loginTest() { + private void login() { // login user - loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + loginResponse = executor.executeSync(OttUserService.login(partnerId, user.getUsername(), defaultUserPassword)); // assertions assertThat(loginResponse.error).isNull(); @@ -41,13 +48,13 @@ private void loginTest() { } @Severity(SeverityLevel.NORMAL) - @Description("ottUser/action/login - login with wrong password - error 1011") + @Description("ottUser/action/login - login with invalid password - error 1011") @Test - private void login_with_wrong_password() { - String fakePassword = "fake"; + private void login_with_invalid_password() { + String invalidPassword = "invalid"; // login user - loginResponse = executor.executeSync(login(partnerId, user.getUsername(), fakePassword)); + loginResponse = executor.executeSync(OttUserService.login(partnerId, user.getUsername(), invalidPassword)); // assertions assertThat(loginResponse.results).isNull(); @@ -55,13 +62,13 @@ private void login_with_wrong_password() { } @Severity(SeverityLevel.NORMAL) - @Description("ottUser/action/login - login with wrong username - error 2000") + @Description("ottUser/action/login - login with invalid username - error 2000") @Test - private void login_with_wrong_username() { - String fakeUsername = user.getUsername() + "1"; + private void login_with_invalid_username() { + String invalidUsername = user.getUsername() + "1"; // login user - loginResponse = executor.executeSync(login(partnerId, fakeUsername, defaultUserPassword)); + loginResponse = executor.executeSync(OttUserService.login(partnerId, invalidUsername, defaultUserPassword)); // assertions assertThat(loginResponse.results).isNull(); @@ -69,16 +76,89 @@ private void login_with_wrong_username() { } @Severity(SeverityLevel.NORMAL) - @Description("ottUser/action/login - login with wrong partnerId - error 500006") + @Description("ottUser/action/login - login with invalid partnerId - error 500006") @Test() - private void login_with_wrong_partnerId() { - int fakePartnerId = partnerId + 1; + private void login_with_invalid_partnerId() { + int invalidPartnerId = partnerId + 1; // login user - loginResponse = executor.executeSync(login( fakePartnerId, user.getUsername(), defaultUserPassword)); + loginResponse = executor.executeSync(OttUserService.login(invalidPartnerId, user.getUsername(), defaultUserPassword)); // assertions assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500006).getCode()); } + + @Severity(SeverityLevel.NORMAL) + @Description("ottUser/action/login - login with suspended user - error ") + @Test() + private void login_with_suspended_user() { + // set household + int numberOfUsersInHousehold = 2; + int numberOfDevicesInHousehold = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + + // get regular user + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + + // suspend household + SuspendHouseholdBuilder suspendHouseholdBuilder = suspend() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getUserId())); + executor.executeSync(suspendHouseholdBuilder); + + // login user + String username = getUserById(Integer.parseInt(user.getUserId())).getUsername(); + loginResponse = executor.executeSync(OttUserService.login(partnerId, username, defaultUserPassword)); + + // assertions + assertThat(loginResponse.error).isNull(); + assertThat(loginResponse.results.getUser().getUserState().getValue()).isEqualTo(UserState.USER_NOT_ACTIVATED.getValue()); + } + + // TODO: 5/14/2018 ask Ira how to reproduce the below errors +// @Severity(SeverityLevel.NORMAL) +// @Description("ottUser/action/login - login with user twice - error ") +// @Test() +// private void login_with_user_twice() { +// // register user +// OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; +// +// // login user - first time +// executor.executeSync(OttUserService.login(partnerId, user.getUsername(), defaultUserPassword)); +// +// // login user - second time +// loginResponse = executor.executeSync(OttUserService.login(partnerId, user.getUsername(), defaultUserPassword)); +// +// // assertions +// assertThat(loginResponse.results).isNull(); +//// assertThat(loginResponse.error.getCode()).isEqualTo(UserState.USER_NOT_ACTIVATED.getValue()); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Description("ottUser/action/login - login with not registered device - error ") +// @Test() +// private void login_with_not_registered_devcie() { +// // set household +// int numberOfUsersInHousehold = 2; +// int numberOfDevicesInHousehold = 1; +// Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); +// +// // get regular user +// HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); +// +// // login user with invalid udid +// String username = getUserById(Integer.parseInt(user.getUserId())).getUsername(); +// String invalidDeviceId = "invalid_device_id"; +// loginResponse = executor.executeSync(OttUserService.login(partnerId, username, defaultUserPassword, null, invalidDeviceId)); +// +// // assertions +// assertThat(loginResponse.results).isNull(); +// } + + // UserAllreadyLoggedIn + // UserDoubleLogIn + // InsideLockTime + // DeviceNotRegistered - login with invalid registered + // UserNotMasterApproved - user in pending status } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index f369ced7e..430c603ee 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -30,14 +30,13 @@ public class OttUserLoginWithPinTests extends BaseTest { @BeforeClass private void ottUser_login_tests_setup() { // register user - Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); - user = ottUserResponse.results; + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/loginWithPin - loginWithPin with secret") @Test - private void loginWithPin_with_secret() throws InterruptedException { + private void loginWithPin_with_secret() { // add pin AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) .setKs(getAdministratorKs()) @@ -88,12 +87,47 @@ private void loginWithPin_with_expired_pinCode() { // login with expired pin String pin = userLoginPinResponse.results.getPinCode(); + // sleep for 1.5 minutes - try { Thread.sleep(120000); } catch (InterruptedException e) { e.printStackTrace(); } + try { + Thread.sleep(120000); + } catch (InterruptedException e) { + e.printStackTrace(); + } LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, SECRET); loginResponse = executor.executeSync(loginWithPinOttUserBuilder); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2004).getCode()); } + + @Severity(SeverityLevel.NORMAL) + @Description("ottUser/action/loginWithPin - loginWithPin with invalid pin") + @Test() + private void loginWithPin_with_invalid_pin() { + // login with invalid pin + String invalidPin = "invalidPin"; + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, invalidPin, null, SECRET); + loginResponse = executor.executeSync(loginWithPinOttUserBuilder); + + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2003).getCode()); + } + +// + +// +// +// +// +// +// +// +// +// +// +// + +// + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java index da78a03a9..61ee31a42 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -9,7 +10,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -26,8 +26,8 @@ private void ottUser_login_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/register - register") @Test - private void registerTest() { - ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); + private void register() { + ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results.getUsername()).isEqualTo(user.getUsername()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java index de6ab0e59..6cc5b7b38 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -29,8 +30,8 @@ private void ottUser_resendActivationToken_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resendActivationToken - resendActivationToken") @Test(enabled = false) - private void resendActivationTokenTest() { - Response booleanResponse = executor.executeSync(resendActivationToken(partnerId, user.getUsername())); + private void resendActivationToken() { + Response booleanResponse = executor.executeSync(OttUserService.resendActivationToken(partnerId, user.getUsername())); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java index 28946066c..ef2c2ecdf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; @@ -27,9 +28,9 @@ private void ottUser_resetPassword_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resetPassword - resetPassword") @Test(enabled = false) - private void resetPasswordTest() { + private void resetPassword() { // reset user password - ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = resetPassword(partnerId, user.getUsername()) + ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, user.getUsername()) .setKs(getAdministratorKs()); Response booleanResponse = executor.executeSync(resetPasswordOttUserBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java index 99ab72756..0f0bf74ac 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.OTTUserDynamicData; @@ -29,7 +30,7 @@ private void ottUser_updateDynamicData_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateDynamicData - updateDynamicData") @Test - private void updateDynamicDataTest() { + private void updateDynamicData() { // set dynamic data String keyString = "key1"; String valueString = "value1"; @@ -38,7 +39,7 @@ private void updateDynamicDataTest() { value.setValue(valueString); // update user dynamic data - UpdateDynamicDataOttUserBuilder updateDynamicDataOttUserBuilder = updateDynamicData(keyString, value) + UpdateDynamicDataOttUserBuilder updateDynamicDataOttUserBuilder = OttUserService.updateDynamicData(keyString, value) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(user.getId())); Response ottUserDynamicDataResponse = executor.executeSync(updateDynamicDataOttUserBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java index 7803f4cc2..8d8768dbc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -21,7 +22,7 @@ public class OttUserUpdateLoginDataTests extends BaseTest { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateLoginData - updateLoginData") @Test - private void updateLoginDataTest() { + private void updateLoginData() { // register user OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; @@ -31,7 +32,7 @@ private void updateLoginDataTest() { // update user login data String userNewPassword = defaultUserPassword + 1; - UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = updateLoginData(user.getUsername(), defaultUserPassword, userNewPassword) + UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(user.getUsername(), defaultUserPassword, userNewPassword) .setKs(userKs); Response booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); @@ -63,7 +64,7 @@ private void updateLoginData_with_administratorKs() { // update usser login data String userNewPassword = defaultUserPassword + 2; - UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = updateLoginData(user.getUsername(), defaultUserPassword, userNewPassword) + UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(user.getUsername(), defaultUserPassword, userNewPassword) .setKs(getAdministratorKs()); Response booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index ca3bacaea..f13b97702 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; @@ -35,7 +36,7 @@ private void ottUser_update_tests_setup() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update") @Test - private void updateTest() { + private void update() { // login user Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); String userKs = loginResponse.results.getLoginSession().getKs(); @@ -45,7 +46,7 @@ private void updateTest() { user.setFirstName(newUserInfo); user.setLastName(newUserInfo); - ottUserResponse = executor.executeSync(update(user).setKs(userKs)); + ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(userKs)); assertThat(ottUserResponse.error).isNull(); // get user after update @@ -71,7 +72,7 @@ private void update_with_administratorKs() { user.setLastName(newUserInfo); // user.setAffiliateCode(null); - ottUserResponse = executor.executeSync(update(user).setKs(getAdministratorKs())); + ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(getAdministratorKs())); assertThat(ottUserResponse.error).isNull(); // get user after update diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index bea516dab..4f5639f82 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -28,6 +28,7 @@ public static OTTUser generateOttUser() { user.setEmail(emailPrefix + stamp + emailDomain); user.setAddress(randomString + " fake address"); user.setCity(randomString + " fake city"); + user.setExternalId(stamp); Random r = new Random(); user.setCountryId(r.nextInt(30 - 1) + 1); From aab317799f890febddafd4da8c208bf3fd5db3e3 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 15 May 2018 10:16:09 +0300 Subject: [PATCH 235/605] no message --- .../ottUserTests/OttUserLoginWithPinTests.java | 11 ++++------- .../ottUserTests/OttUserLogoutTests.java | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index 430c603ee..21e30e9ea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -55,9 +55,9 @@ private void loginWithPin_with_secret() { } @Severity(SeverityLevel.NORMAL) - @Description("ottUser/action/loginWithPin - loginWithPin with wrong secret - error 2008") + @Description("ottUser/action/loginWithPin - loginWithPin with invalid secret - error 2008") @Test - private void loginWithPin_with_wrong_secret() { + private void loginWithPin_with_invalid_secret() { // add pin AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) .setKs(getAdministratorKs()) @@ -65,9 +65,9 @@ private void loginWithPin_with_wrong_secret() { userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); // login with pin and wrong secret - String wrongSecret = SECRET + 1; + String invalidSecret = SECRET + 1; String pin = userLoginPinResponse.results.getPinCode(); - LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, wrongSecret); + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, invalidSecret); loginResponse = executor.executeSync(loginWithPinOttUserBuilder); // assert error 2008 is return @@ -115,7 +115,6 @@ private void loginWithPin_with_invalid_pin() { } // - // // // @@ -127,7 +126,5 @@ private void loginWithPin_with_invalid_pin() { // // // - // - } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java index 1232a5119..854b05057 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java @@ -27,8 +27,7 @@ public class OttUserLogoutTests extends BaseTest { @BeforeClass private void ottUser_logout_tests_setup() { // register user - Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); - user = ottUserResponse.results; + user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; } @Severity(SeverityLevel.CRITICAL) From 0bebe4e28e9535aab06174f64db8d83779eeabf0 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 15 May 2018 17:25:24 +0300 Subject: [PATCH 236/605] add ottUser logout test --- .../ottUserTests/OttUserLogoutTests.java | 56 +++++++++++++++---- .../ottUserTests/OttUserRegisterTests.java | 8 ++- .../OttUserResetPasswordTests.java | 19 ++++--- 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java index 854b05057..c98ff89af 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java @@ -9,7 +9,6 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.OttUserService.*; @@ -18,22 +17,18 @@ public class OttUserLogoutTests extends BaseTest { - private OTTUser user; - private Response loginResponse; private Response booleanResponse; + private Response ottUserResponse; - @BeforeClass - private void ottUser_logout_tests_setup() { - // register user - user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - } - @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/logout - logout") @Test private void logout() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + // login user loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); String userKs = loginResponse.results.getLoginSession().getKs(); @@ -47,9 +42,50 @@ private void logout() { // assert can't get user after logout GetOttUserBuilder getOttUserBuilder = OttUserService.get().setKs(userKs); - Response ottUserResponse = executor.executeSync(getOttUserBuilder); + ottUserResponse = executor.executeSync(getOttUserBuilder); + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500016).getCode()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/logout - logout") + @Test + private void logout_from_specific_platform() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // login user without device + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + String userWithoutDeviceKs = loginResponse.results.getLoginSession().getKs(); + + // login user with device + String udid = "123456"; + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword, null, udid)); + String userWithDeviceKs = loginResponse.results.getLoginSession().getKs(); + + user = loginResponse.results.getUser(); + + // logout user using device ks + LogoutOttUserBuilder logoutOttUserBuilder = OttUserService.logout().setKs(userWithDeviceKs); + booleanResponse = executor.executeSync(logoutOttUserBuilder); + + assertThat(booleanResponse.error).isNull(); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert can't 'get' user using device ks + GetOttUserBuilder getOttUserBuilder = OttUserService.get().setKs(userWithDeviceKs); + ottUserResponse = executor.executeSync(getOttUserBuilder); + assertThat(ottUserResponse.results).isNull(); assertThat(ottUserResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500016).getCode()); + + // assert can 'get' user using no-device ks + getOttUserBuilder = OttUserService.get().setKs(userWithoutDeviceKs); + ottUserResponse = executor.executeSync(getOttUserBuilder); + + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java index 61ee31a42..a9ea40266 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java @@ -30,9 +30,11 @@ private void register() { ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); assertThat(ottUserResponse.error).isNull(); - assertThat(ottUserResponse.results.getUsername()).isEqualTo(user.getUsername()); - // TODO: 3/28/2018 add relevant assertions + assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType", + "householdId", "dynamicData", "isHouseholdMaster", "suspensionState", "id", "params"); } - // TODO: 3/29/2018 add relevant scenarios + +// +// } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java index ef2c2ecdf..350082053 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java @@ -2,33 +2,30 @@ import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.OttUserService.ResetPasswordOttUserBuilder; +import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class OttUserResetPasswordTests extends BaseTest { - private OTTUser user; - - @BeforeClass - private void ottUser_resetPassword_tests_setup() { - // register user - Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); - user = ottUserResponse.results; - } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resetPassword - resetPassword") @Test(enabled = false) private void resetPassword() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + // reset user password ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, user.getUsername()) .setKs(getAdministratorKs()); @@ -38,6 +35,10 @@ private void resetPassword() { assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); + // login after reset password + Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + assertThat(loginResponse.results).isNull(); + // TODO: 4/1/2018 finsih the test after bug BEO-4884 will be fixed } } From ec0bf2a55f2a65fe5a1aee29893686f1851465dc Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 16 May 2018 13:38:19 +0300 Subject: [PATCH 237/605] added tests to ottUser service --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../ottUserTests/OttUserActivateTests.java | 10 +- .../ottUserTests/OttUserAddRoleTests.java | 6 ++ .../ottUserTests/OttUserDeleteTests.java | 4 +- .../OttUserGetEncryptedUserIdTests.java | 7 ++ .../ottUserTests/OttUserGetTests.java | 8 ++ .../ottUserTests/OttUserListTests.java | 14 ++- .../ottUserTests/OttUserLoginTests.java | 8 ++ .../OttUserLoginWithPinTests.java | 7 ++ .../ottUserTests/OttUserLogoutTests.java | 6 ++ .../ottUserTests/OttUserRegisterTests.java | 9 +- .../OttUserResendActivationTokenTests.java | 14 ++- .../OttUserResetPasswordTests.java | 41 ++++++-- .../OttUserSetInitialPasswordTests.java | 98 ++++++++++++++++++- .../OttUserUpdateDynamicDataTests.java | 19 ++-- .../OttUserUpdateLoginDataTests.java | 6 ++ .../OttUserUpdatePasswordTests.java | 41 +++++++- .../ottUserTests/OttUserUpdateTests.java | 3 +- .../client/test/utils/IngestUtils.java | 1 + .../test/utils/{ => dbUtils}/DBUtils.java | 25 ++++- 20 files changed, 289 insertions(+), 40 deletions(-) rename src/test/java/com/kaltura/client/test/utils/{ => dbUtils}/DBUtils.java (95%) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 748984228..e9b6124d9 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -4,7 +4,7 @@ import com.kaltura.client.Configuration; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.test.utils.DBUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java index cc0b2e4b9..92b529f53 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java @@ -3,15 +3,17 @@ import com.kaltura.client.enums.UserState; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.DBUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.delete; import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; @@ -138,4 +140,10 @@ private void activate_with_invalid_activationToken() { assertThat(ottUserResponse.results).isNull(); assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); } + + @AfterClass + private void activate_afterClass() { + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java index 4cbb5ff66..f264df0fb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java @@ -68,6 +68,9 @@ private void addRole() { // cleanup - delete role // TODO: 5/14/2018 finish test after when reletead bug will be fixed + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } @Severity(SeverityLevel.NORMAL) @@ -89,6 +92,9 @@ private void addRole_with_invalid_roleId() { // cleanup - delete role // TODO: 5/14/2018 finish test after when reletead bug will be fixed + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } private UserRole generateUserRole() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java index 8808088cf..79df95e27 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java @@ -43,9 +43,7 @@ private void ottUser_delete_tests_setup() { @Test private void delete() { // register user - RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword) - .setKs(getAdministratorKs()); - OTTUser user = executor.executeSync(registerOttUserBuilder).results; + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; // delete user and assert success deleteOttUserBuilder = OttUserService.delete() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java index 58ebbad0e..5fa00c874 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java @@ -8,6 +8,7 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -51,4 +52,10 @@ private void getEncryptedUserId() { assertThat(stringValueResponse.error).isNull(); assertThat(stringValueResponse.results.getValue()).isNotNull(); } + + @AfterClass + private void getEncryptedUserId_afterClass() { + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java index 9795520b1..8120158c3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetTests.java @@ -8,6 +8,7 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -72,4 +73,11 @@ private void get_with_invalid_userId() { assertThat(ottUserResponse.results).isNull(); assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500004).getCode()); } + + @AfterClass + private void get_afterClass() { + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java index 42c094dbc..c900b391c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; @@ -7,6 +8,7 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,8 +26,9 @@ public class OttUserListTests extends BaseTest { private Household household; private Response> householdUserListResponse; - private int numberOfUsersInHousehold = 4; - private int numberOfDevicesInHousehold = 1; + + private final int numberOfUsersInHousehold = 4; + private final int numberOfDevicesInHousehold = 1; @BeforeClass @@ -168,4 +171,11 @@ private void list_with_externalId_filter() { assertThat(householdUserListResponse.error).isNull(); assertThat(users.size()).isEqualTo(1); } + + @AfterClass + private void list_AfterClass() { + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = HouseholdService.delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java index 14fd736b8..c61e4c7f5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java @@ -13,11 +13,13 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.HouseholdService.SuspendHouseholdBuilder; import static com.kaltura.client.services.HouseholdService.suspend; +import static com.kaltura.client.services.OttUserService.delete; import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -161,4 +163,10 @@ private void login_with_suspended_user() { // InsideLockTime // DeviceNotRegistered - login with invalid registered // UserNotMasterApproved - user in pending status + + @AfterClass + private void login_afterClass() { + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index 21e30e9ea..b8ed7c1b4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -8,6 +8,7 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -127,4 +128,10 @@ private void loginWithPin_with_invalid_pin() { // // // + + @AfterClass + private void loginWithPin_afterClass() { + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java index c98ff89af..dee67882a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLogoutTests.java @@ -45,6 +45,9 @@ private void logout() { ottUserResponse = executor.executeSync(getOttUserBuilder); assertThat(ottUserResponse.results).isNull(); assertThat(ottUserResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500016).getCode()); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } @Severity(SeverityLevel.CRITICAL) @@ -85,6 +88,9 @@ private void logout_from_specific_platform() { assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType"); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java index a9ea40266..431bf7c0c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java @@ -10,6 +10,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.OttUserService.delete; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -32,9 +33,11 @@ private void register() { assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType", "householdId", "dynamicData", "isHouseholdMaster", "suspensionState", "id", "params"); - } + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } -// -// + // + // } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java index 6cc5b7b38..70d41cf0e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java @@ -20,22 +20,28 @@ public class OttUserResendActivationTokenTests extends BaseTest { @BeforeClass private void ottUser_resendActivationToken_tests_setup() { - // register user - user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; - // login user - user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resendActivationToken - resendActivationToken") @Test(enabled = false) private void resendActivationToken() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // login user + user = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)).results.getUser(); + + // resendActivationToken Response booleanResponse = executor.executeSync(OttUserService.resendActivationToken(partnerId, user.getUsername())); assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + // TODO: 4/1/2018 can't be completely tested until we verify emails } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java index 350082053..5838e408c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java @@ -2,17 +2,19 @@ import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; +import org.testng.util.Strings; -import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.services.OttUserService.ResetPasswordOttUserBuilder; +import static com.kaltura.client.services.OttUserService.delete; import static com.kaltura.client.services.OttUserService.register; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -21,24 +23,43 @@ public class OttUserResetPasswordTests extends BaseTest { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resetPassword - resetPassword") - @Test(enabled = false) + @Test() private void resetPassword() { // register user OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + // assert resetPassword token is null + String resetPasswordToken = DBUtils.getResetPasswordToken(user.getUsername()); + assertThat(resetPasswordToken).isNull(); + // reset user password - ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, user.getUsername()) - .setKs(getAdministratorKs()); + ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, user.getUsername()); Response booleanResponse = executor.executeSync(resetPasswordOttUserBuilder); - // assert success assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); - // login after reset password - Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); - assertThat(loginResponse.results).isNull(); + // assert resetPassword token is not null or empty + resetPasswordToken = DBUtils.getResetPasswordToken(user.getUsername()); + assertThat(Strings.isNotNullAndNotEmpty(resetPasswordToken)).isTrue(); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/resetPassword - resetPassword with invalid user - error 2000") + @Test() + private void resetPassword_with_invalid_user() { + // register user + String invalidUsername = "invalidUsername"; + + // reset user password with invalid user + ResetPasswordOttUserBuilder resetPasswordOttUserBuilder = OttUserService.resetPassword(partnerId, invalidUsername); + Response booleanResponse = executor.executeSync(resetPasswordOttUserBuilder); + + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); - // TODO: 4/1/2018 finsih the test after bug BEO-4884 will be fixed } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java index 6ded7d45d..baecf6906 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserSetInitialPasswordTests.java @@ -1,8 +1,104 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.types.LoginSession; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; public class OttUserSetInitialPasswordTests extends BaseTest { - // TODO: 4/1/2018 implemente tests + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/setInitialPassword") + @Test() + private void setInitialPassword() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // reset user password + executor.executeSync(resetPassword(partnerId, user.getUsername())); + + // get resetPassword token + String resetPasswordToken = DBUtils.getResetPasswordToken(user.getUsername()); + + // set initial password + String newPassword = "newPassword"; + SetInitialPasswordOttUserBuilder setInitialPasswordOttUserBuilder = OttUserService.setInitialPassword(partnerId, resetPasswordToken, newPassword); + Response ottUserResponse = executor.executeSync(setInitialPasswordOttUserBuilder); + + assertThat(ottUserResponse.results).isEqualToComparingOnlyGivenFields(user, "username", "email", + "address", "firstName", "lastName", "city", "externalId", "countryId"); + + // login with new password + LoginSession loginSession = executor.executeSync(login(partnerId, user.getUsername(), newPassword)).results.getLoginSession(); + assertThat(loginSession.getKs()).isNotNull(); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } + + @Severity(SeverityLevel.MINOR) + @Description("ottUser/action/setInitialPassword - invalid resetPassword token") + @Test() + private void setInitialPassword_with_invalid_resetPassword_token() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // reset user password + executor.executeSync(resetPassword(partnerId, user.getUsername())); + + // set initial password with invalid token + String newPassword = "newPassword"; + String invalidToken = "invalidToken"; + + SetInitialPasswordOttUserBuilder setInitialPasswordOttUserBuilder = OttUserService.setInitialPassword(partnerId, invalidToken, newPassword); + Response ottUserResponse = executor.executeSync(setInitialPasswordOttUserBuilder); + + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } + + @Severity(SeverityLevel.NORMAL) + @Description("ottUser/action/setInitialPassword - expired resetPassword token") + @Test() + private void setInitialPassword_with_expired_resetPassword_token() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // reset user password + executor.executeSync(resetPassword(partnerId, user.getUsername())); + + // get resetPassword token + String resetPasswordToken = DBUtils.getResetPasswordToken(user.getUsername()); + + // set initial password - first time + String newPassword = "newPassword"; + + SetInitialPasswordOttUserBuilder setInitialPasswordOttUserBuilder = OttUserService.setInitialPassword(partnerId, resetPasswordToken, newPassword); + executor.executeSync(setInitialPasswordOttUserBuilder); + + // set initial password - second time + Response ottUserResponse = executor.executeSync(setInitialPasswordOttUserBuilder); + + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2000).getCode()); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java index 0f0bf74ac..09e27dc3a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java @@ -9,28 +9,24 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.OttUserService.UpdateDynamicDataOttUserBuilder; +import static com.kaltura.client.services.OttUserService.delete; +import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class OttUserUpdateDynamicDataTests extends BaseTest { - private OTTUser user; - - @BeforeClass - private void ottUser_updateDynamicData_tests_setup() { - // register user - Response ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); - user = ottUserResponse.results; - } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/updateDynamicData - updateDynamicData") @Test private void updateDynamicData() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + // set dynamic data String keyString = "key1"; String valueString = "value1"; @@ -48,5 +44,8 @@ private void updateDynamicData() { assertThat(ottUserDynamicDataResponse.error).isNull(); assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo(keyString); assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo(valueString); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java index 8d8768dbc..ebd0a12d5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java @@ -50,6 +50,9 @@ private void updateLoginData() { assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } @Severity(SeverityLevel.CRITICAL) @@ -82,5 +85,8 @@ private void updateLoginData_with_administratorKs() { assertThat(loginResponse.error).isNull(); assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java index 709c47dcd..895988708 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdatePasswordTests.java @@ -1,7 +1,46 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.OTTUser; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static org.assertj.core.api.Assertions.assertThat; public class OttUserUpdatePasswordTests extends BaseTest { - // TODO: 4/1/2018 implement tests + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/updateLoginData - updateLoginData") + @Test + private void updatePassword() { + // register user + OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; + + // update password + String newPassword = "newPassword"; + UpdatePasswordOttUserBuilder updatePasswordOttUserBuilder = OttUserService.updatePassword(Integer.parseInt(user.getId()), newPassword); + updatePasswordOttUserBuilder.setKs(getAdministratorKs()); + executor.executeSync(updatePasswordOttUserBuilder); + + // login with old password + Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1011).getCode()); + + // login with new password + loginResponse = executor.executeSync(login(partnerId, user.getUsername(), newPassword)); + assertThat(loginResponse.error).isNull(); + assertThat(loginResponse.results.getLoginSession().getKs()).isNotNull(); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index f13b97702..4bdefd46a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -63,7 +63,7 @@ private void update() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update with administratorKs") @Issue("BEO-4919") - @Test(enabled = false) // TODO: find if it possible to exclude ftom build results failed tests having @Issue annotation + @Test(enabled = false) private void update_with_administratorKs() { // update user info @@ -88,6 +88,7 @@ private void update_with_administratorKs() { @AfterClass private void ottUser_update_tests_tearDown() { + // cleanup executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 5be04db4e..1a707142e 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -5,6 +5,7 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.AssetService.*; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java similarity index 95% rename from src/test/java/com/kaltura/client/test/utils/DBUtils.java rename to src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 4d69d4baa..f42806faa 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -1,15 +1,18 @@ -package com.kaltura.client.test.utils; +package com.kaltura.client.test.utils.dbUtils; import com.google.common.base.Strings; import com.kaltura.client.Logger; import com.kaltura.client.enums.SubscriptionDependencyType; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.*; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; import org.json.JSONObject; + import java.sql.*; + import static com.kaltura.client.test.Properties.*; public class DBUtils extends BaseUtils { @@ -24,6 +27,8 @@ public class DBUtils extends BaseUtils { //selects private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + private static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + private static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + "from [Users].[dbo].[groups_parameters]\n" + "where group_id=%d"; @@ -279,6 +284,20 @@ public static String getActivationToken(String username) { return activationToken; } + public static String getResetPasswordToken(String username) { + String resetPasswordToken = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(RESET_PASSWORD_TOKEN_SELECT, username), false); + resetPasswordToken = jsonArray.getJSONObject(0).getString("cp_token"); + } catch (Exception e) { + e.printStackTrace(); + } + + return resetPasswordToken; + } + + // public static List getUserRoles(String userId) { // List userRoles = new ArrayList<>(); // @@ -286,7 +305,7 @@ public static String getActivationToken(String username) { // JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(USER_ROLES_SELECT, userId)); // // if (Strings.isNullOrEmpty(jsonArray.toString())) { -// Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); +// Logger.getLogger(dbUtils.class).error(ERROR_MESSAGE); // } // // for (int i = 0; i < jsonArray.length(); i++) { @@ -302,7 +321,7 @@ public static String getActivationToken(String username) { public static int getEpgChannelId(String channelName) { Logger.getLogger(DBUtils.class).debug("getEpgChannelId(): channelName = " + channelName); - int epgChannelId =-1; + int epgChannelId = -1; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName), false); epgChannelId = jsonArray.getJSONObject(0).getInt("id"); From 76bdd2509e37c66ae920222a8ecbacead8cf8dd6 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 16 May 2018 18:25:22 +0300 Subject: [PATCH 238/605] Added logic for automation of Permissions Management --- .../four_eight/PermissionsManagement.java | 65 +++++++ .../kaltura/client/test/utils/DBUtils.java | 164 +++++++++++++++++- 2 files changed, 226 insertions(+), 3 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java new file mode 100644 index 000000000..1acaa17f3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java @@ -0,0 +1,65 @@ +package com.kaltura.client.test.tests.featuresTests.four_eight; + +import com.kaltura.client.test.utils.DBUtils; +import org.testng.annotations.Test; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import static org.assertj.core.api.Assertions.assertThat; + +/** + * + * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 + */ +public class PermissionsManagement { + // TODO: discuss where to save these values + String path2Util = "C:\\123\\222\\"; + String mainFile = "PermissionsDeployment.exe"; + + // TODO: change descriptions later + @Test(enabled = false, description = "execute stored procedures related insert data into permission management related tables") + private void insertDataIntoTables() { + String role = "MaxTest"; + long roleId = DBUtils.insertRole(role); + System.out.println("Role: " + roleId); // 468 + //DBUtils.deleteRoleAndItsPermissions(roleId); + long permissionId = DBUtils.insertPermission(role, 2, "partner*"); + System.out.println("Permission: " + permissionId); // 26 + System.out.println("PermissionRole: " + DBUtils.insertPermissionRole(roleId, permissionId, 0)); // 622 + String name = "Asset_List_Max"; + String service = "asset"; + String action = "list"; + String permissionItemObject = "permissionItemObject"; + String parameter = "parameter"; + long permissionItemId = DBUtils.insertPermissionItem(name, 1, service, action, permissionItemObject, parameter); + System.out.println("PermissionItem: " + permissionItemId); // 539 + long permissionPermissionItemId = DBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); + System.out.println("PermissionPermissionItem: " + permissionPermissionItemId);//1063 + } + + @Test(enabled = false, description = "execute console util without parameters") + private void checkRunningWithoutParameters() { + StringBuilder output = new StringBuilder(); + + ProcessBuilder pb = new ProcessBuilder(path2Util + mainFile); + pb.redirectErrorStream(true); + BufferedReader inStreamReader; + try { + Process process = pb.start(); + inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while((line = inStreamReader.readLine()) != null){ + output.append(line); + } + + assertThat(output.toString()).contains("Permissions deployment tool"); + assertThat(output.toString()).contains("Shortcut: e"); + assertThat(output.toString()).contains("Shortcut: i"); + } catch (IOException e) { + e.printStackTrace(); + } finally { + // return input stream back + inStreamReader = new BufferedReader(new InputStreamReader(System.in)); + } + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/DBUtils.java index 4d69d4baa..83d6ccb02 100644 --- a/src/test/java/com/kaltura/client/test/utils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/DBUtils.java @@ -18,6 +18,7 @@ public class DBUtils extends BaseUtils { private static Connection conn; private static Statement stam; private static ResultSet rs; + private static CallableStatement cStmt; private static final String ERROR_MESSAGE = "No results found"; @@ -185,7 +186,7 @@ public static String getIngestItemUserData(int accountId) { try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_ITEMS_DATA_SELECT, accountId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + return result; } result = jsonArray.getJSONObject(0).getString("username") + ":" + @@ -205,7 +206,7 @@ public static String getDiscount(String currency, int percent) { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, BaseTest.partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + return null; } code = jsonArray.getJSONObject(0).getString("code"); @@ -227,6 +228,7 @@ public static boolean isActivationOfUsersNeeded() { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + return false; } result = jsonArray.getJSONObject(0).getInt("is_activation_needed"); @@ -249,6 +251,7 @@ public static String getUserData(String userRole) { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, BaseTest.partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + return null; } userdData = jsonArray.getJSONObject(0).getString("username") + ":" + @@ -269,6 +272,7 @@ public static String getActivationToken(String username) { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ACTIVATION_TOKEN_SELECT, username), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + return null; } activationToken = jsonArray.getJSONObject(0).getString("activation_token"); @@ -287,6 +291,7 @@ public static String getActivationToken(String username) { // // if (Strings.isNullOrEmpty(jsonArray.toString())) { // Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); +// return userRoles; // } // // for (int i = 0; i < jsonArray.length(); i++) { @@ -305,6 +310,10 @@ public static int getEpgChannelId(String channelName) { int epgChannelId =-1; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName), false); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + return epgChannelId; + } epgChannelId = jsonArray.getJSONObject(0).getInt("id"); } catch (Exception e) { e.printStackTrace(); @@ -395,7 +404,9 @@ private static void openConnection() { private static void closeConnection() { try { - rs.close(); + if (rs != null) { + rs.close(); + } } catch (SQLException e) { e.printStackTrace(); } @@ -410,4 +421,151 @@ private static void closeConnection() { e.printStackTrace(); } } + + private static void prepareCall(String sql) throws SQLException { + openConnection(); + cStmt = conn.prepareCall(sql); + } + + /** + * Call Stored Procedure to create role + */ + public static int insertRole(String role) { + int result =-1; + try { + prepareCall("{call TVinci.dbo.__482V0__Insert_Role(?, ?)}"); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setString(2, role); + + rs = cStmt.executeQuery(); + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to delete role and its permissions + */ + public static void deleteRoleAndItsPermissions(int roleId) { + try { + prepareCall("{call TVinci.dbo.__482V0__Delete_RolePermission(?, ?)}"); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setInt(2, roleId); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } + + /** + * Call Stored Procedure to insert permissions + */ + public static int insertPermission(String name, int type, String usersGroup) { + int result =-1; + try { + prepareCall("{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setString(2, name); + cStmt.setInt(3, type); + cStmt.setString(4, usersGroup); + + rs = cStmt.executeQuery(); + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to insert permission role + */ + public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { + int result =-1; + try { + prepareCall("{call TVinci.dbo.__482V0__Insert_PermissionRole(?, ?, ?, ?)}"); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setLong(2, roleId); + cStmt.setLong(3, permissionId); + cStmt.setInt(4, isExcluded); + + rs = cStmt.executeQuery(); + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to insert permission item + */ + public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { + int result =-1; + try { + prepareCall("{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"); + cStmt.setString(1, name); + cStmt.setInt(2, type); + cStmt.setString(3, service); + cStmt.setString(4, action); + cStmt.setString(5, permissionItemObject); + cStmt.setString(6, parameter); + rs = cStmt.executeQuery(); + + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to insert permission permission item + */ + public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { + int result =-1; + try { + prepareCall("{call TVinci.dbo.__482V0__Insert_PermissionPermissionItem(?, ?, ?, ?)}"); + cStmt.setInt(1, 0);; // group_id == 0 + cStmt.setLong(2, permissionId); + cStmt.setLong(3, permissionItemId); + cStmt.setInt(4, isExcluded); + rs = cStmt.executeQuery(); + + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } } From 424a7fc75286856bc87e4c9111f5bd3b98241504 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 21 May 2018 13:25:15 +0300 Subject: [PATCH 239/605] updated comment --- .../tests/servicesTests/ottUserTests/OttUserActivateTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java index 92b529f53..02dfa31d9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserActivateTests.java @@ -133,7 +133,7 @@ private void activate_with_invalid_activationToken() { // get activation token String invalidActivationToken = "1"; - // activate user - with invalid user name + // activate user - with invalid activationToken ottUserResponse = executor.executeSync(OttUserService.activate(partnerId, user.getUsername(), invalidActivationToken)); // assert error return From 469c77286edd80a1fe90ad04a4f07b3a005fbe4c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 21 May 2018 14:45:43 +0300 Subject: [PATCH 240/605] Sensitive information about DB structure was moved into DBConstants.java file. --- .../four_eight/PermissionsManagement.java | 67 ++++++- .../test/utils/PermissionManagementUtils.java | 62 +++++++ .../test/utils/dbUtils/DBConstants.java | 84 +++++++++ .../client/test/utils/dbUtils/DBUtils.java | 165 +++++++++--------- 4 files changed, 285 insertions(+), 93 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java index d22c59e52..a74720d13 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java @@ -2,9 +2,13 @@ import com.kaltura.client.test.utils.dbUtils.DBUtils; import org.testng.annotations.Test; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; +import static com.kaltura.client.test.utils.PermissionManagementUtils.*; import static org.assertj.core.api.Assertions.assertThat; /** @@ -15,18 +19,34 @@ public class PermissionsManagement { // TODO: discuss where to save these values String path2Util = "C:\\123\\222\\"; String mainFile = "PermissionsDeployment.exe"; + String dataFilePath = path2Util + "333\\" + "exp1.txt"; + + @Test(description = "just for deletion") + public void deleteData() { + //long roleId = 477L; + long permissionId = 32L; + /*long permissionItemId = 544L; + long permissionPermissionItemId = 1068;*/ + + //DBUtils.deleteRoleAndItsPermissions((int)roleId); + DBUtils.deletePermission((int)permissionId); + /*DBUtils.deletePermissionItem((int)permissionItemId); + DBUtils.deletePermissionPermissionItem((int)permissionPermissionItemId);*/ + } // TODO: change descriptions later @Test(enabled = false, description = "execute stored procedures related insert data into permission management related tables") - private void insertDataIntoTables() { - String role = "MaxTest"; + public void insertDataIntoTables() { + String suffix = "00002"; + String role = "MaxTest" + suffix; long roleId = DBUtils.insertRole(role); System.out.println("Role: " + roleId); // 468 - //DBUtils.deleteRoleAndItsPermissions(roleId); + //DBUtils.deleteRoleAndItsPermissions((int)roleId); long permissionId = DBUtils.insertPermission(role, 2, "partner*"); System.out.println("Permission: " + permissionId); // 26 - System.out.println("PermissionRole: " + DBUtils.insertPermissionRole(roleId, permissionId, 0)); // 622 - String name = "Asset_List_Max"; + long permissionRoleId = DBUtils.insertPermissionRole(roleId, permissionId, 0); + System.out.println("PermissionRole: " + permissionRoleId); // 622 + String name = "Asset_List_Max" + suffix; String service = "asset"; String action = "list"; String permissionItemObject = "permissionItemObject"; @@ -35,6 +55,23 @@ private void insertDataIntoTables() { System.out.println("PermissionItem: " + permissionItemId); // 539 long permissionPermissionItemId = DBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); System.out.println("PermissionPermissionItem: " + permissionPermissionItemId);//1063 + + // generation of XML file with insertedData + try { + File file = new File(path2Util + "333\\" + "import_data.txt"); + PrintWriter writer = new PrintWriter(file); + writer.println(""); + writer.println(""); + printRole(writer, roleId, role); + printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); + printPermission(writer, permissionId, role, 2, "partner*"); + printPermissionItem(writer, permissionItemId, name, 1, service, action, permissionItemObject, parameter); + printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, name, role); + writer.println(""); + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } } @Test(enabled = false, description = "execute console util without parameters") @@ -62,4 +99,18 @@ private void checkRunningWithoutParameters() { inStreamReader = new BufferedReader(new InputStreamReader(System.in)); } } + + @Test(enabled = false) + public void readXMLFile() throws ParserConfigurationException, IOException, SAXException { + File file = new File(dataFilePath); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + Document document = documentBuilder.parse(file); + assertThat(document).isNotNull(); + String id = document.getElementsByTagName("role").item(1).getChildNodes().item(1).getTextContent(); + String name = document.getElementsByTagName("role").item(1).getChildNodes().item(3).getTextContent(); + System.out.println("role id = " + id); + System.out.println("role name = " + name); + System.out.println("# of roles: " + document.getElementsByTagName("role").getLength()); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java new file mode 100644 index 000000000..de8d3f619 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -0,0 +1,62 @@ +package com.kaltura.client.test.utils; + +import java.io.PrintWriter; + +public class PermissionManagementUtils extends BaseUtils { + + public static void printPermissionPermissionItem(PrintWriter writer, long id, long permissionId, long permissionItemId, + int isExcluded, String permissionItemName, String permissionName) { + writer.println(""); + writer.println("" + id + ""); + writer.println("" + permissionId + ""); + writer.println("" + permissionItemId + ""); + writer.println("" + isExcluded + ""); + writer.println("" + permissionItemName + ""); + writer.println("" + permissionName + ""); + writer.println(""); + } + + public static void printPermissionItem(PrintWriter writer, long id, String name, int type, String service, String action, + String object, String parameter) { + writer.println(""); + writer.println("" + id + ""); + writer.println("" + name + ""); + writer.println("" + type + ""); + writer.println("" + service + ""); + writer.println("" + action + ""); + writer.println("" + object + ""); + writer.println("" + parameter + ""); + writer.println(""); + } + + public static void printPermission(PrintWriter writer, long id, String name, int type, String usersGroup) { + writer.println(""); + writer.println("" + id + ""); + writer.println("" + name + ""); + writer.println("" + type + ""); + writer.println("" + usersGroup + ""); + writer.println(""); + } + + public static void printRolePermission(PrintWriter writer, long permissionRoleId, long roleId, long permissionId, + int isExcluded, String roleName, String permissionName) { + writer.println(""); + writer.println("" + permissionRoleId + ""); + writer.println("" + roleId + ""); + writer.println("" + permissionId + ""); + writer.println("" + isExcluded + ""); + writer.println("" + roleName + ""); + writer.println("" + permissionName + ""); + writer.println(""); + } + + public static void printRole(PrintWriter writer, Long roleId, String roleName) { + writer.println(""); + writer.println("" + roleId + ""); + writer.println("" + roleName + ""); + writer.println(""); + } + + +} + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java new file mode 100644 index 000000000..638c998c6 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -0,0 +1,84 @@ +package com.kaltura.client.test.utils.dbUtils; + +public class DBConstants { + + // fields: + public static final String ACTIVATION_TOKEN = "activation_token"; + public static final String CODE = "code"; + public static final String CP_TOKEN = "cp_token"; + public static final String FULL_LIFE_CYCLE_MINUTES = "full_life_cycle_min"; + public static final String ID = "id"; + public static final String IS_ACTIVATION_NEEDED = "is_activation_needed"; + public static final String IS_RENEWED = "is_renew"; + public static final String MAX_VIEWS_COUNT = "max_views_number"; + public static final String NAME = "name"; + public static final String NUMBER_OF_REC_PERIODS = "num_of_rec_periods"; + public static final String PASSWORD = "password"; + public static final String USERNAME = "username"; + public static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; + + //queries + public static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + + public static final String AND_ACTIVE_STATUS = " and u.activate_status=1"; + + public static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + + public static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + + "from [Users].[dbo].[groups_parameters]\n" + + "where group_id=%d"; + + public static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + + "where lc.code3='%S'\n" + // CURRENCY + "and dc.discount_percent=%d\n" + // percent amount + "and dc.group_id=%d\n" + // group + "and dc.[status]=1 and dc.is_active=1"; + + public static final String DISCOUNT_BY_PRICE_AND_PERCENT_SELECT = "select TOP (1) *\n" + + "from [Pricing].[dbo].[discount_codes]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d\n" + // group + "and price=%f\n" + // price amount + "and discount_percent=%f"; // percent amount + + public static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + + public static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + + "from [Tvinci].[dbo].[groups_passwords]\n" + + "where [group_id]=%d order by UPDATE_DATE DESC"; + + public static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + + "where pc.[status]=1 and pc.is_active=1\n" + + "and pc.group_id=%d and pc.price=%f and lc.CODE3='%S'"; + + public static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; + + public static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d and usage_module_code=%d\n" + + "order by create_date"; + + public static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + + "from [Users].[dbo].[users] u with(nolock)\n" + + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + + "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; + + public static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; + + // STORED PROCEDURES: + public static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; + public static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; + public static final String SP_INSERT_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionPermissionItem(?, ?, ?, ?)}"; + public static final String SP_INSERT_PERMISSION_ROLE = "{call TVinci.dbo.__482V0__Insert_PermissionRole(?, ?, ?, ?)}"; + public static final String SP_INSERT_ROLE = "{call TVinci.dbo.__482V0__Insert_Role(?, ?)}"; + public static final String SP_DELETE_PERMISSION = "{call TVinci.dbo.__482V0__Delete_Permission(?)}"; + public static final String SP_DELETE_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionItem(?)}"; + public static final String SP_DELETE_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionPermissionItem(?)}"; + public static final String SP_DELETE_ROLE_AND_ITS_PERMISSIONS = "{call TVinci.dbo.__482V0__Delete_RolePermission(?, ?)}"; +} diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 3f197d54b..c15c32ce6 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -10,10 +10,9 @@ import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; import org.json.JSONObject; - import java.sql.*; - import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; public class DBUtils extends BaseUtils { @@ -25,58 +24,6 @@ public class DBUtils extends BaseUtils { private static final String ERROR_MESSAGE = "No results found"; - //selects - private static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; - - private static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; - - private static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + - "from [Users].[dbo].[groups_parameters]\n" + - "where group_id=%d"; - - private static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + - "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + - "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + - "where lc.code3='%S'\n" + // CURRENCY - "and dc.discount_percent=%d\n" + // percent amount - "and dc.group_id=%d\n" + // group - "and dc.[status]=1 and dc.is_active=1"; - - private static final String DISCOUNT_BY_PRICE_AND_PERCENT_SELECT = "select TOP (1) *\n" + - "from [Pricing].[dbo].[discount_codes]\n" + - "where [status]=1 and is_active=1\n" + - "and group_id=%d\n" + // group - "and price=%f\n" + // price amount - "and discount_percent=%f"; // percent amount - - private static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; - - private static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + - "from [Tvinci].[dbo].[groups_passwords]\n" + - "where [group_id]=%d order by UPDATE_DATE DESC"; - - private static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + - "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + - "where pc.[status]=1 and pc.is_active=1\n" + - "and pc.group_id=%d and pc.price=%f and lc.CODE3='%S'"; - - private static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + - "where [status]=1 and is_active=1\n" + - "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; - - private static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + - "where [status]=1 and is_active=1\n" + - "and group_id=%d and usage_module_code=%d\n" + - "order by create_date"; - - private static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + - "from [Users].[dbo].[users] u with(nolock)\n" + - "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + - "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + - "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; - - private static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; - public static PriceDetails loadPriceCode(Double priceAmount, String currency) { Logger.getLogger(DBUtils.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); PriceDetails result = null; @@ -87,8 +34,8 @@ public static PriceDetails loadPriceCode(Double priceAmount, String currency) { } result = new PriceDetails(); - result.setName(jsonArray.getJSONObject(0).getString("code")); - result.setId(jsonArray.getJSONObject(0).getInt("id")); + result.setName(jsonArray.getJSONObject(0).getString(CODE)); + result.setId(jsonArray.getJSONObject(0).getInt(ID)); Price price = new Price(); price.setCurrency(currency); price.setAmount(priceAmount); @@ -110,8 +57,8 @@ public static DiscountModule loadDiscount(Double discountPrice, Double discountP return result; } result = new DiscountModule(); - result.setToken("id", String.valueOf(jsonArray.getJSONObject(0).getInt("id"))); - result.setToken("name", jsonArray.getJSONObject(0).getString("code")); + result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + result.setToken(NAME, jsonArray.getJSONObject(0).getString(CODE)); result.setPercent(discountPercent); } catch (Exception e) { e.printStackTrace(); @@ -144,15 +91,15 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl } pricePlan = new PricePlan(); - pricePlan.setId(jsonArray.getJSONObject(0).getLong("id")); - pricePlan.setName(jsonArray.getJSONObject(0).getString("name")); - pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt("view_life_cycle_min")); - pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt("full_life_cycle_min")); - pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt("max_views_number")); - pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get("id").toString())); + pricePlan.setId(jsonArray.getJSONObject(0).getLong(ID)); + pricePlan.setName(jsonArray.getJSONObject(0).getString(NAME)); + pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt(VIEW_LIFE_CYCLE_MINUTES)); + pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt(FULL_LIFE_CYCLE_MINUTES)); + pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt(MAX_VIEWS_COUNT)); + pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get(ID).toString())); pricePlan.setPriceDetailsId(priceCode.getId().longValue()); - pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt("is_renew")); - pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt("num_of_rec_periods")); + pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt(IS_RENEWED)); + pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt(NUMBER_OF_REC_PERIODS)); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("price plan data can't be null"); @@ -172,8 +119,8 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { } subscription = new Subscription(); - subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt("id"))); - subscription.setName(jsonArray.getJSONObject(0).getString("name")); + subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); subscription.setPricePlanIds(String.valueOf(pricePlan.getId())); subscription.setIsRenewable(false); subscription.setDependencyType(SubscriptionDependencyType.BASE); @@ -194,8 +141,8 @@ public static String getIngestItemUserData(int accountId) { return result; } - result = jsonArray.getJSONObject(0).getString("username") + ":" + - jsonArray.getJSONObject(0).getString("password"); + result = jsonArray.getJSONObject(0).getString(USERNAME) + ":" + + jsonArray.getJSONObject(0).getString(PASSWORD); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("data about ingest business module user can't be null"); @@ -214,13 +161,13 @@ public static String getDiscount(String currency, int percent) { return null; } - code = jsonArray.getJSONObject(0).getString("code"); + code = jsonArray.getJSONObject(0).getString(CODE); if ("".equals(code)) { throw new SQLException(); } } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("code can't be null"); + Logger.getLogger(DBUtils.class).error(CODE + " can't be null"); } return code; @@ -236,10 +183,10 @@ public static boolean isActivationOfUsersNeeded() { return false; } - result = jsonArray.getJSONObject(0).getInt("is_activation_needed"); + result = jsonArray.getJSONObject(0).getInt(IS_ACTIVATION_NEEDED); } catch (Exception e) { e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("IS_ACTIVATION_NEEDED can't be null"); + Logger.getLogger(DBUtils.class).error(IS_ACTIVATION_NEEDED + " can't be null"); } return result == 1; @@ -249,7 +196,7 @@ public static String getUserData(String userRole) { Logger.getLogger(DBUtils.class).debug("getUserData(): userRole = " + userRole); String sqlQuery = USER_BY_ROLE_SELECT; if (isActivationOfUsersNeeded()) { - sqlQuery += " and u.activate_status=1"; + sqlQuery += AND_ACTIVE_STATUS; } String userdData = ""; try { @@ -259,8 +206,8 @@ public static String getUserData(String userRole) { return null; } - userdData = jsonArray.getJSONObject(0).getString("username") + ":" + - jsonArray.getJSONObject(0).getString("password"); + userdData = jsonArray.getJSONObject(0).getString(USERNAME) + ":" + + jsonArray.getJSONObject(0).getString(PASSWORD); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("username/password can't be null"); @@ -280,7 +227,7 @@ public static String getActivationToken(String username) { return null; } - activationToken = jsonArray.getJSONObject(0).getString("activation_token"); + activationToken = jsonArray.getJSONObject(0).getString(ACTIVATION_TOKEN); } catch (Exception e) { e.printStackTrace(); } @@ -293,7 +240,7 @@ public static String getResetPasswordToken(String username) { try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(RESET_PASSWORD_TOKEN_SELECT, username), false); - resetPasswordToken = jsonArray.getJSONObject(0).getString("cp_token"); + resetPasswordToken = jsonArray.getJSONObject(0).getString(CP_TOKEN); } catch (Exception e) { e.printStackTrace(); } @@ -452,7 +399,7 @@ private static void prepareCall(String sql) throws SQLException { public static int insertRole(String role) { int result =-1; try { - prepareCall("{call TVinci.dbo.__482V0__Insert_Role(?, ?)}"); + prepareCall(SP_INSERT_ROLE); cStmt.setInt(1, 0); // group_id == 0 cStmt.setString(2, role); @@ -474,7 +421,7 @@ public static int insertRole(String role) { */ public static void deleteRoleAndItsPermissions(int roleId) { try { - prepareCall("{call TVinci.dbo.__482V0__Delete_RolePermission(?, ?)}"); + prepareCall(SP_DELETE_ROLE_AND_ITS_PERMISSIONS); cStmt.setInt(1, 0); // group_id == 0 cStmt.setInt(2, roleId); @@ -492,7 +439,7 @@ public static void deleteRoleAndItsPermissions(int roleId) { public static int insertPermission(String name, int type, String usersGroup) { int result =-1; try { - prepareCall("{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"); + prepareCall(SP_INSERT_PERMISSION); cStmt.setInt(1, 0); // group_id == 0 cStmt.setString(2, name); cStmt.setInt(3, type); @@ -511,13 +458,29 @@ public static int insertPermission(String name, int type, String usersGroup) { } } + /** + * Call Stored Procedure to delete permission + */ + public static void deletePermission(int id) { + try { + prepareCall(SP_DELETE_PERMISSION); + cStmt.setInt(1, id); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } + /** * Call Stored Procedure to insert permission role */ public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { int result =-1; try { - prepareCall("{call TVinci.dbo.__482V0__Insert_PermissionRole(?, ?, ?, ?)}"); + prepareCall(SP_INSERT_PERMISSION_ROLE); cStmt.setInt(1, 0); // group_id == 0 cStmt.setLong(2, roleId); cStmt.setLong(3, permissionId); @@ -542,7 +505,7 @@ public static int insertPermissionRole(long roleId, long permissionId, int isExc public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { int result =-1; try { - prepareCall("{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"); + prepareCall(SP_INSERT_PERMISSION_ITEM); cStmt.setString(1, name); cStmt.setInt(2, type); cStmt.setString(3, service); @@ -563,13 +526,29 @@ public static int insertPermissionItem(String name, int type, String service, St } } + /** + * Call Stored Procedure to delete permission item + */ + public static void deletePermissionItem(int id) { + try { + prepareCall(SP_DELETE_PERMISSION_ITEM); + cStmt.setInt(1, id); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } + /** * Call Stored Procedure to insert permission permission item */ public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { int result =-1; try { - prepareCall("{call TVinci.dbo.__482V0__Insert_PermissionPermissionItem(?, ?, ?, ?)}"); + prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); cStmt.setInt(1, 0);; // group_id == 0 cStmt.setLong(2, permissionId); cStmt.setLong(3, permissionItemId); @@ -587,4 +566,20 @@ public static int insertPermissionPermissionItem(long permissionId, long permiss return result; } } + + /** + * Call Stored Procedure to delete permission permission item + */ + public static void deletePermissionPermissionItem(int id) { + try { + prepareCall(SP_DELETE_PERMISSION_PERMISSION_ITEM); + cStmt.setInt(1, id); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } } From cb87ad6f255145f8237b641142ea6e37b2a958b5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 21 May 2018 15:50:16 +0300 Subject: [PATCH 241/605] logic related preparation of fixture for ingested items have been moved from DBUtils.java --- .../kaltura/client/test/tests/BaseTest.java | 17 +- .../client/test/utils/IngestUtils.java | 10 +- .../test/utils/dbUtils/DBConstants.java | 70 +++---- .../client/test/utils/dbUtils/DBUtils.java | 173 +---------------- .../test/utils/dbUtils/IngestFixtureData.java | 182 ++++++++++++++++++ 5 files changed, 233 insertions(+), 219 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index e9b6124d9..093911039 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -6,6 +6,7 @@ import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; @@ -130,11 +131,11 @@ public static PricePlan getSharedCommonPricePlan(){ double defaultDiscountPrice = 0.0; double defaultDiscountPercentValue = 100.0; if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = DBUtils.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), defaultCurrency, defaultDiscountPrice, defaultDiscountPercentValue); + sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), defaultCurrency, defaultDiscountPrice, defaultDiscountPercentValue); if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), - Optional.of(defaultCurrency), Optional.of(DBUtils.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), + Optional.of(defaultCurrency), Optional.of(IngestFixtureData.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), Optional.of(true), Optional.of(0)); } } @@ -154,11 +155,11 @@ public static Subscription getSharedCommonSubscription(){ double defaultDiscountPercentValue = 100.0; String defaultCurrency = "EUR"; if (sharedCommonSubscription == null) { - sharedCommonSubscription = DBUtils.loadSharedCommonSubscription(getSharedCommonPricePlan()); + sharedCommonSubscription = IngestFixtureData.loadSharedCommonSubscription(getSharedCommonPricePlan()); if (sharedCommonSubscription == null) { sharedCommonSubscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(DBUtils.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), Optional.empty(), + Optional.of(IngestFixtureData.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), Optional.empty(), Optional.of(false), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -168,7 +169,7 @@ public static Subscription getSharedCommonSubscription(){ public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { - String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId); + String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId); ingestBusinessModuleUserUsername = userInfo.split(":")[0]; ingestBusinessModuleUserPassword = userInfo.split(":")[1]; } @@ -177,7 +178,7 @@ public static String getIngestBusinessModuleUserName() { public static String getIngestBusinessModuleUserPassword() { if (ingestBusinessModuleUserPassword == null) { - String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId); + String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId); ingestBusinessModuleUserUsername = userInfo.split(":")[0]; ingestBusinessModuleUserPassword = userInfo.split(":")[1]; } @@ -186,7 +187,7 @@ public static String getIngestBusinessModuleUserPassword() { public static String getIngestAssetUserName() { if (ingestAssetUserUsername == null) { - String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId + 1); + String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } @@ -195,7 +196,7 @@ public static String getIngestAssetUserName() { public static String getIngestAssetUserPassword() { if (ingestAssetUserPassword == null) { - String userInfo = DBUtils.getIngestItemUserData(BaseTest.partnerId + 1); + String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 1a707142e..239a4d95a 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -5,7 +5,7 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.AssetService.*; -import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; @@ -168,7 +168,7 @@ public static Response> ingestEPG(String epgChannelName, Opt Logger.getLogger(IngestUtils.class).debug(reqBody); Logger.getLogger(IngestUtils.class).debug(resp.asString()); - int epgChannelId = DBUtils.getEpgChannelId(epgChannelName); + int epgChannelId = IngestFixtureData.getEpgChannelId(epgChannelName); // TODO: create method getting epoch value from String and pattern long epoch = 0L; try { @@ -367,7 +367,7 @@ public static Subscription ingestMPP(Optional action, Optional m String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); String defaultCurrencyOfDiscount4IngestMpp = "GBP"; int defaultPercentageOfDiscount4IngestMpp = 100; - String internalDiscountValue = internalDiscount.orElse(DBUtils.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); + String internalDiscountValue = internalDiscount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); String productCodeValue = productCode.orElse(""); boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); @@ -520,7 +520,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String currencyValue = currency.orElse(CURRENCY_EUR); String defaultCurrencyOfDiscount4IngestMpp = "GBP"; int defaultPercentageOfDiscount4IngestMpp = 100; - String discountValue = discount.orElse(DBUtils.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); + String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); @@ -635,7 +635,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O String descriptionValue = description.orElse("My ingest PPV"); String defaultCurrencyOfDiscount4IngestPpv = "ILS"; int defaultPercentageOfDiscount4IngestPpv = 50; - String discountValue = discount.orElse(DBUtils.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); + String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); String currencyValue = currency.orElse(CURRENCY_EUR); String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 638c998c6..4591188c6 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -3,32 +3,32 @@ public class DBConstants { // fields: - public static final String ACTIVATION_TOKEN = "activation_token"; - public static final String CODE = "code"; - public static final String CP_TOKEN = "cp_token"; - public static final String FULL_LIFE_CYCLE_MINUTES = "full_life_cycle_min"; - public static final String ID = "id"; - public static final String IS_ACTIVATION_NEEDED = "is_activation_needed"; - public static final String IS_RENEWED = "is_renew"; - public static final String MAX_VIEWS_COUNT = "max_views_number"; - public static final String NAME = "name"; - public static final String NUMBER_OF_REC_PERIODS = "num_of_rec_periods"; - public static final String PASSWORD = "password"; - public static final String USERNAME = "username"; - public static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; + static final String ACTIVATION_TOKEN = "activation_token"; + static final String CODE = "code"; + static final String CP_TOKEN = "cp_token"; + static final String FULL_LIFE_CYCLE_MINUTES = "full_life_cycle_min"; + static final String ID = "id"; + static final String IS_ACTIVATION_NEEDED = "is_activation_needed"; + static final String IS_RENEWED = "is_renew"; + static final String MAX_VIEWS_COUNT = "max_views_number"; + static final String NAME = "name"; + static final String NUMBER_OF_REC_PERIODS = "num_of_rec_periods"; + static final String PASSWORD = "password"; + static final String USERNAME = "username"; + static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; //queries - public static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; - public static final String AND_ACTIVE_STATUS = " and u.activate_status=1"; + static final String AND_ACTIVE_STATUS = " and u.activate_status=1"; - public static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; - public static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + + static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + "from [Users].[dbo].[groups_parameters]\n" + "where group_id=%d"; - public static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + + static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + "where lc.code3='%S'\n" + // CURRENCY @@ -36,49 +36,49 @@ public class DBConstants { "and dc.group_id=%d\n" + // group "and dc.[status]=1 and dc.is_active=1"; - public static final String DISCOUNT_BY_PRICE_AND_PERCENT_SELECT = "select TOP (1) *\n" + + static final String DISCOUNT_BY_PRICE_AND_PERCENT_SELECT = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d\n" + // group "and price=%f\n" + // price amount "and discount_percent=%f"; // percent amount - public static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; - public static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + + static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; - public static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + + static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + "where pc.[status]=1 and pc.is_active=1\n" + "and pc.group_id=%d and pc.price=%f and lc.CODE3='%S'"; - public static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + + static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; - public static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + + static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d and usage_module_code=%d\n" + "order by create_date"; - public static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + + static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + "from [Users].[dbo].[users] u with(nolock)\n" + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; - public static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; + static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; // STORED PROCEDURES: - public static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; - public static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; - public static final String SP_INSERT_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionPermissionItem(?, ?, ?, ?)}"; - public static final String SP_INSERT_PERMISSION_ROLE = "{call TVinci.dbo.__482V0__Insert_PermissionRole(?, ?, ?, ?)}"; - public static final String SP_INSERT_ROLE = "{call TVinci.dbo.__482V0__Insert_Role(?, ?)}"; - public static final String SP_DELETE_PERMISSION = "{call TVinci.dbo.__482V0__Delete_Permission(?)}"; - public static final String SP_DELETE_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionItem(?)}"; - public static final String SP_DELETE_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionPermissionItem(?)}"; - public static final String SP_DELETE_ROLE_AND_ITS_PERMISSIONS = "{call TVinci.dbo.__482V0__Delete_RolePermission(?, ?)}"; + static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; + static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; + static final String SP_INSERT_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionPermissionItem(?, ?, ?, ?)}"; + static final String SP_INSERT_PERMISSION_ROLE = "{call TVinci.dbo.__482V0__Insert_PermissionRole(?, ?, ?, ?)}"; + static final String SP_INSERT_ROLE = "{call TVinci.dbo.__482V0__Insert_Role(?, ?)}"; + static final String SP_DELETE_PERMISSION = "{call TVinci.dbo.__482V0__Delete_Permission(?)}"; + static final String SP_DELETE_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionItem(?)}"; + static final String SP_DELETE_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionPermissionItem(?)}"; + static final String SP_DELETE_ROLE_AND_ITS_PERMISSIONS = "{call TVinci.dbo.__482V0__Delete_RolePermission(?, ?)}"; } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index c15c32ce6..76e00203b 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -2,10 +2,8 @@ import com.google.common.base.Strings; import com.kaltura.client.Logger; -import com.kaltura.client.enums.SubscriptionDependencyType; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.types.*; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; @@ -22,156 +20,7 @@ public class DBUtils extends BaseUtils { private static ResultSet rs; private static CallableStatement cStmt; - private static final String ERROR_MESSAGE = "No results found"; - - public static PriceDetails loadPriceCode(Double priceAmount, String currency) { - Logger.getLogger(DBUtils.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); - PriceDetails result = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_CODE_SELECT, BaseTest.partnerId, priceAmount, currency), true); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; - } - - result = new PriceDetails(); - result.setName(jsonArray.getJSONObject(0).getString(CODE)); - result.setId(jsonArray.getJSONObject(0).getInt(ID)); - Price price = new Price(); - price.setCurrency(currency); - price.setAmount(priceAmount); - result.setPrice(price); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("discount code can't be null"); - } - return result; - } - - public static DiscountModule loadDiscount(Double discountPrice, Double discountPercent) { - Logger.getLogger(DBUtils.class).debug("loadDiscount(): discountPrice = " + discountPrice + " discountPercent = " + discountPercent); - DiscountModule result = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, - BaseTest.partnerId, discountPrice, discountPercent), true); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; - } - result = new DiscountModule(); - result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - result.setToken(NAME, jsonArray.getJSONObject(0).getString(CODE)); - result.setPercent(discountPercent); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("discount code can't be null"); - } - return result; - } - - public static PricePlan loadPricePlan(Double priceAmount, String currency, Double discountPrice, Double discountPercent) { - Logger.getLogger(DBUtils.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency + - " discountPrice = " + discountPrice + " discountPercent = " + discountPercent); - - PricePlan pricePlan = null; - - try { - PriceDetails priceCode = loadPriceCode(priceAmount, currency); - if (priceCode == null) { - return pricePlan; - } - - DiscountModule discountModule = loadDiscount(discountPrice, discountPercent); - if (discountModule == null) { - return pricePlan; - } - - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, BaseTest.partnerId, - Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()), true); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return pricePlan; - } - - pricePlan = new PricePlan(); - pricePlan.setId(jsonArray.getJSONObject(0).getLong(ID)); - pricePlan.setName(jsonArray.getJSONObject(0).getString(NAME)); - pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt(VIEW_LIFE_CYCLE_MINUTES)); - pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt(FULL_LIFE_CYCLE_MINUTES)); - pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt(MAX_VIEWS_COUNT)); - pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get(ID).toString())); - pricePlan.setPriceDetailsId(priceCode.getId().longValue()); - pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt(IS_RENEWED)); - pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt(NUMBER_OF_REC_PERIODS)); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("price plan data can't be null"); - } - return pricePlan; - } - - public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { - Logger.getLogger(DBUtils.class).debug("loadSharedCommonSubscription(): pricePlan id = " + pricePlan.getId()); - - Subscription subscription = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_SELECT, BaseTest.partnerId, - pricePlan.getId()), true); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return subscription; - } - - subscription = new Subscription(); - subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); - subscription.setPricePlanIds(String.valueOf(pricePlan.getId())); - subscription.setIsRenewable(false); - subscription.setDependencyType(SubscriptionDependencyType.BASE); - // TODO: add more data in case it needed - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("subscription data can't be null"); - } - return subscription; - } - - public static String getIngestItemUserData(int accountId) { - Logger.getLogger(DBUtils.class).debug("getIngestItemUserData(): accountId = " + accountId); - String result = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_ITEMS_DATA_SELECT, accountId), false); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; - } - - result = jsonArray.getJSONObject(0).getString(USERNAME) + ":" + - jsonArray.getJSONObject(0).getString(PASSWORD); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("data about ingest business module user can't be null"); - } - - return result; - } - - public static String getDiscount(String currency, int percent) { - Logger.getLogger(DBUtils.class).debug("getDiscount(): currency = " + currency + " percent = " + percent); - String code = ""; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, - percent, BaseTest.partnerId), false); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return null; - } - - code = jsonArray.getJSONObject(0).getString(CODE); - if ("".equals(code)) { - throw new SQLException(); - } - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error(CODE + " can't be null"); - } - - return code; - } + static final String ERROR_MESSAGE = "No results found"; public static boolean isActivationOfUsersNeeded() { Logger.getLogger(DBUtils.class).debug("isActivationOfUsersNeeded()"); @@ -271,26 +120,8 @@ public static String getResetPasswordToken(String username) { // return userRoles; // } - public static int getEpgChannelId(String channelName) { - Logger.getLogger(DBUtils.class).debug("getEpgChannelId(): channelName = " + channelName); - int epgChannelId = -1; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName), false); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); - return epgChannelId; - } - epgChannelId = jsonArray.getJSONObject(0).getInt("id"); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("epgChannelId can't be null"); - } - - return epgChannelId; - } - // Return json array from DB - private static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) throws Exception { + static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) throws Exception { openConnection(); JSONArray jsonArray = new JSONArray(); rs = stam.executeQuery(query); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java new file mode 100644 index 000000000..111d872b1 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -0,0 +1,182 @@ +package com.kaltura.client.test.utils.dbUtils; + +import com.google.common.base.Strings; +import com.kaltura.client.Logger; +import com.kaltura.client.enums.SubscriptionDependencyType; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.*; +import org.json.JSONArray; +import java.sql.SQLException; +import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; + +public class IngestFixtureData { + + public static PriceDetails loadPriceCode(Double priceAmount, String currency) { + Logger.getLogger(IngestFixtureData.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); + PriceDetails result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_CODE_SELECT, BaseTest.partnerId, priceAmount, currency), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return result; + } + + result = new PriceDetails(); + result.setName(jsonArray.getJSONObject(0).getString(CODE)); + result.setId(jsonArray.getJSONObject(0).getInt(ID)); + Price price = new Price(); + price.setCurrency(currency); + price.setAmount(priceAmount); + result.setPrice(price); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("discount code can't be null"); + } + return result; + } + + + public static DiscountModule loadDiscount(Double discountPrice, Double discountPercent) { + Logger.getLogger(IngestFixtureData.class).debug("loadDiscount(): discountPrice = " + discountPrice + " discountPercent = " + discountPercent); + DiscountModule result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, + BaseTest.partnerId, discountPrice, discountPercent), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return result; + } + result = new DiscountModule(); + result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + result.setToken(NAME, jsonArray.getJSONObject(0).getString(CODE)); + result.setPercent(discountPercent); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("discount code can't be null"); + } + return result; + } + + public static PricePlan loadPricePlan(Double priceAmount, String currency, Double discountPrice, Double discountPercent) { + Logger.getLogger(IngestFixtureData.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency + + " discountPrice = " + discountPrice + " discountPercent = " + discountPercent); + + PricePlan pricePlan = null; + + try { + PriceDetails priceCode = loadPriceCode(priceAmount, currency); + if (priceCode == null) { + return pricePlan; + } + + DiscountModule discountModule = loadDiscount(discountPrice, discountPercent); + if (discountModule == null) { + return pricePlan; + } + + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, BaseTest.partnerId, + Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return pricePlan; + } + + pricePlan = new PricePlan(); + pricePlan.setId(jsonArray.getJSONObject(0).getLong(ID)); + pricePlan.setName(jsonArray.getJSONObject(0).getString(NAME)); + pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt(VIEW_LIFE_CYCLE_MINUTES)); + pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt(FULL_LIFE_CYCLE_MINUTES)); + pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt(MAX_VIEWS_COUNT)); + pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get(ID).toString())); + pricePlan.setPriceDetailsId(priceCode.getId().longValue()); + pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt(IS_RENEWED)); + pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt(NUMBER_OF_REC_PERIODS)); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); + } + return pricePlan; + } + + public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { + Logger.getLogger(IngestFixtureData.class).debug("loadSharedCommonSubscription(): pricePlan id = " + pricePlan.getId()); + + Subscription subscription = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_SELECT, BaseTest.partnerId, + pricePlan.getId()), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return subscription; + } + + subscription = new Subscription(); + subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); + subscription.setPricePlanIds(String.valueOf(pricePlan.getId())); + subscription.setIsRenewable(false); + subscription.setDependencyType(SubscriptionDependencyType.BASE); + // TODO: add more data in case it needed + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("subscription data can't be null"); + } + return subscription; + } + + public static String getDiscount(String currency, int percent) { + Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): currency = " + currency + " percent = " + percent); + String code = ""; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, + percent, BaseTest.partnerId), false); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return null; + } + + code = jsonArray.getJSONObject(0).getString(CODE); + if ("".equals(code)) { + throw new SQLException(); + } + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error(CODE + " can't be null"); + } + + return code; + } + + public static int getEpgChannelId(String channelName) { + Logger.getLogger(IngestFixtureData.class).debug("getEpgChannelId(): channelName = " + channelName); + int epgChannelId = -1; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName), false); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + Logger.getLogger(IngestFixtureData.class).error(ERROR_MESSAGE); + return epgChannelId; + } + epgChannelId = jsonArray.getJSONObject(0).getInt("id"); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("epgChannelId can't be null"); + } + + return epgChannelId; + } + + public static String getIngestItemUserData(int accountId) { + Logger.getLogger(IngestFixtureData.class).debug("getIngestItemUserData(): accountId = " + accountId); + String result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_ITEMS_DATA_SELECT, accountId), false); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return result; + } + + result = jsonArray.getJSONObject(0).getString(USERNAME) + ":" + + jsonArray.getJSONObject(0).getString(PASSWORD); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("data about ingest business module user can't be null"); + } + + return result; + } +} From cbfc33992ef54ba9a07767e7bc4339371d672ca1 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 22 May 2018 08:50:28 +0300 Subject: [PATCH 242/605] Added new test ingest util to ingestUtils class --- .../AssetHistoryCleanTests.java | 6 +- .../AssetHistoryListTests.java | 6 +- .../channelTests/ChannelAddTests.java | 4 +- .../client/test/utils/IngestUtils.java | 236 ++++++++---------- 4 files changed, 116 insertions(+), 136 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java index eaf00a40e..e69e8cba6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java @@ -48,13 +48,13 @@ public class AssetHistoryCleanTests extends BaseTest { // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestBasicVOD(Optional.of("movieForBookmark"), MOVIE_MEDIA_TYPE); + movie = IngestUtils.ingestBasicVOD("movieForBookmark", MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestBasicVOD(Optional.of("movie2ForBookmark"), MOVIE_MEDIA_TYPE); + movie2 = IngestUtils.ingestBasicVOD("movie2ForBookmark", MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestBasicVOD(Optional.of("EpisodeForBookmark"), EPISODE_MEDIA_TYPE); + episode = IngestUtils.ingestBasicVOD("EpisodeForBookmark", EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index 5fb50d25d..fbdbf79a4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -47,13 +47,13 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestBasicVOD(Optional.of("movieForBookmark"), MOVIE_MEDIA_TYPE); + movie = IngestUtils.ingestBasicVOD("movieForBookmark", MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestBasicVOD(Optional.of("movie2ForBookmark"), MOVIE_MEDIA_TYPE); + movie2 = IngestUtils.ingestBasicVOD("movie2ForBookmark", MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestBasicVOD(Optional.of("EpisodeForBookmark"), EPISODE_MEDIA_TYPE); + episode = IngestUtils.ingestBasicVOD("EpisodeForBookmark", EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 902b4b448..6d205b6c1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -62,10 +62,10 @@ private void checkOrderOfAssetsInChannel() { String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); // Ingest first asset - MediaAsset movieAsset = IngestUtils.ingestBasicVOD(Optional.of(asset1Name), MOVIE_MEDIA_TYPE); + MediaAsset movieAsset = IngestUtils.ingestBasicVOD(asset1Name, MOVIE_MEDIA_TYPE); // Ingest second asset - MediaAsset episodeAsset = IngestUtils.ingestBasicVOD(Optional.of(asset2Name), MOVIE_MEDIA_TYPE); + MediaAsset episodeAsset = IngestUtils.ingestBasicVOD(asset2Name, MOVIE_MEDIA_TYPE); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 5be04db4e..8053e718a 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -8,11 +8,15 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; + +import java.awt.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; + import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; @@ -35,6 +39,7 @@ public class IngestUtils extends BaseUtils { public static final String EPG_DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; private static List durationPeriodNames = new ArrayList<>(); + static { durationPeriodNames.add(DURATION_PERIOD_DAYS); durationPeriodNames.add(DURATION_PERIOD_HOURS); @@ -130,7 +135,7 @@ public static Response> ingestEPG(String epgChannelName, Opt Date now = Calendar.getInstance().getTime(); while (seasonId <= seasonCountValue) { int idx = 1; - while(idx <= programCountValue) { + while (idx <= programCountValue) { endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); oneProgrammOutput = getProgrammeXML(idx, df2.format(startDate.getTime()), df2.format(endDate), epgChannelName, coguidValue, cridValue, "Program", df2.format(now), @@ -172,7 +177,7 @@ public static Response> ingestEPG(String epgChannelName, Opt long epoch = 0L; try { Date firstProgramStartDateAsDate = dateFormat.parse(firstProgramStartDateValue); - epoch = firstProgramStartDateAsDate.getTime()/1000; // 1000 milliseconds in 1 second + epoch = firstProgramStartDateAsDate.getTime() / 1000; // 1000 milliseconds in 1 second } catch (ParseException e) { e.printStackTrace(); } @@ -184,7 +189,7 @@ public static Response> ingestEPG(String epgChannelName, Opt int delayBetweenRetriesInSeconds = 3; int maxTimeExpectingValidResponseInSeconds = 60; await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue*seasonCountValue)); + .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue * seasonCountValue)); Response> ingestedProgrammes = executor.executeSync( AssetService.list(assetFilter, null).setKs(getAnonymousKs())); @@ -196,7 +201,7 @@ private static Callable isDataReturned(String ks, SearchAssetFilter ass return () -> { ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null).setKs(ks); return executor.executeSync(listAssetBuilder).error == null && - executor.executeSync(listAssetBuilder).results.getTotalCount() == totalCount; + executor.executeSync(listAssetBuilder).results.getTotalCount() == totalCount; }; } @@ -319,8 +324,8 @@ private static Date loadEndDate(Date startDate, int durationValue, String period /** * IMPORTANT: please delete inserted by that method items * - * @param action - can be "insert" or "delete" ("update" looks like broken) - * @param mppCode - should have value in case "action" is "delete" + * @param action - can be "insert" or "delete" ("update" looks like broken) + * @param mppCode - should have value in case "action" is "delete" * @param isActive * @param title * @param description @@ -339,14 +344,14 @@ private static Date loadEndDate(Date startDate, int durationValue, String period * @param couponGroup * @param productCodes * @return MPP data - * - * !!!Only created by that method MPP can be deleted!!! - * - * to delete existed MPP use corresponded action and value mpp.getName() as "mppCode" - * (where mpp is a variable that contains mpp data). - * - * - * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created by ingestPP method) + *

+ * !!!Only created by that method MPP can be deleted!!! + *

+ * to delete existed MPP use corresponded action and value mpp.getName() as "mppCode" + * (where mpp is a variable that contains mpp data). + *

+ *

+ * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created by ingestPP method) */ // ingest new MPP public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, @@ -445,39 +450,39 @@ private static String buildIngestMppXML(String action, String mppCode, boolean i String pricePlanCode2, String channel1, String channel2, String fileType1, String fileType2, String couponGroup, String productCodes) { return "\n" + - "\n" + - "\n" + - "\n" + - "" + title + "\n" + - "\n" + - "\n" + - "" + description + "" + - "\n" + - "" + startDate + "\n" + - "" + endDate + "\n" + - "" + internalDiscount + "\n" + - "\n" + - "" + productCode + "\n" + - "" + isRenewable + "\n" + - "\n" + - "" + gracePeriodMinute + "\n" + - "\n" + - "" + pricePlanCode1 + "\n" + - "" + pricePlanCode2 + "\n" + - "\n" + - "\n" + - "" + channel1 + "\n" + - "" + channel2 + "\n" + - "\n" + - "\n" + - "" + fileType1 + "\n" + - "" + fileType2 + "\n" + - "\n" + - "\n" + - "" + couponGroup + "\n" + - "" + productCodes + "\n" + - "\n" + - "\n" + + "\n" + + "\n" + + "\n" + + "" + title + "\n" + + "\n" + + "\n" + + "" + description + "" + + "\n" + + "" + startDate + "\n" + + "" + endDate + "\n" + + "" + internalDiscount + "\n" + + "\n" + + "" + productCode + "\n" + + "" + isRenewable + "\n" + + "\n" + + "" + gracePeriodMinute + "\n" + + "\n" + + "" + pricePlanCode1 + "\n" + + "" + pricePlanCode2 + "\n" + + "\n" + + "\n" + + "" + channel1 + "\n" + + "" + channel2 + "\n" + + "\n" + + "\n" + + "" + fileType1 + "\n" + + "" + fileType2 + "\n" + + "\n" + + "\n" + + "" + couponGroup + "\n" + + "" + productCodes + "\n" + + "\n" + + "\n" + "\n"; } @@ -486,8 +491,8 @@ private static String buildIngestMppXML(String action, String mppCode, boolean i /** * IMPORTANT: please delete inserted by that method items * - * @param action - can be "insert", "update" and "delete" - * @param ppCode - should have value in case "action" one of {"update" and "delete"} + * @param action - can be "insert", "update" and "delete" + * @param ppCode - should have value in case "action" one of {"update" and "delete"} * @param isActive * @param fullLifeCycle * @param viewLifeCycle @@ -498,10 +503,10 @@ private static String buildIngestMppXML(String action, String mppCode, boolean i * @param isRenewable * @param recurringPeriods * @return PricePlan data - * + *

* to update or delete existed price plan use corresponded action and value pricePlan.getName() as "ppCode" * (where pricePlan is a variable that contains price plan data) - * + *

* !!!Only created by that method PP can be deleted/updated!!! */ public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, @@ -582,28 +587,28 @@ private static String buildIngestPpXML(String action, String ppCode, boolean isA String discount, boolean isRenewable, int recurringPeriods) { String id = "reportIngestPricePlan" + action.substring(0, 1).toUpperCase() + action.substring(1); return "\n" + - "\n" + - "\n" + - "" + fullLifeCycle + "\n" + - "" + viewLifeCycle + "\n" + - "" + maxViews + "\n" + - "\n" + - "" + price + "\n" + - "" + currency + "\n" + - "\n" + - "" + discount + "\n" + - "" + isRenewable + "\n" + - "" + recurringPeriods + "\n" + - "\n" + - "\n" + + "\n" + + "\n" + + "" + fullLifeCycle + "\n" + + "" + viewLifeCycle + "\n" + + "" + maxViews + "\n" + + "\n" + + "" + price + "\n" + + "" + currency + "\n" + + "\n" + + "" + discount + "\n" + + "" + isRenewable + "\n" + + "" + recurringPeriods + "\n" + + "\n" + + "\n" + "\n"; } /** * IMPORTANT: please delete inserted by that method items * - * @param action - can be "insert", "update" and "delete" - * @param ppvCode - should have value in case "action" one of {"update" and "delete"} + * @param action - can be "insert", "update" and "delete" + * @param ppvCode - should have value in case "action" one of {"update" and "delete"} * @param isActive * @param description * @param discount @@ -616,11 +621,11 @@ private static String buildIngestPpXML(String action, String ppCode, boolean isA * @param firstFileType * @param secondFileType * @return PPV data - * - * to update or delete existed ppv use corresponded action and value ppv.getName() as "ppvCode" - * (where ppv is a variable that contains ppv data) - * - * !!!Only created by that method PPV can be deleted/update!!! + *

+ * to update or delete existed ppv use corresponded action and value ppv.getName() as "ppvCode" + * (where ppv is a variable that contains ppv data) + *

+ * !!!Only created by that method PPV can be deleted/update!!! */ // ingest new PPV public static Ppv ingestPPV(Optional action, Optional ppvCode, Optional isActive, Optional description, @@ -739,8 +744,8 @@ private static String buildIngestPpvXML(String action, String ppvCode, boolean i /** * IMPORTANT: please delete inserted by that method items * - * @param action - can be "insert", "update" and "delete" - * @param coguid - should have value in case "action" one of {"update" and "delete"} + * @param action - can be "insert", "update" and "delete" + * @param coguid - should have value in case "action" one of {"update" and "delete"} * @param isActive * @param name * @param thumbUrl @@ -752,12 +757,10 @@ private static String buildIngestPpvXML(String action, String ppvCode, boolean i * @param mediaType * @param ppvWebName * @param ppvMobileName - * @return - * - * to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" - * (where vod is a variable that contains VOD data) - * - * !!!Only created by that method VOD can be deleted/update!!! + * @return to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" + * (where vod is a variable that contains VOD data) + *

+ * !!!Only created by that method VOD can be deleted/update!!! */ // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project public static MediaAsset ingestVOD(Optional action, Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, @@ -767,7 +770,7 @@ public static MediaAsset ingestVOD(Optional action, Optional cog String coguidDatePattern = "yyMMddHHmmssSS"; String maxEndDateValue = "14/10/2099 17:00:00"; String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value - int defaultDayOffset =-1; + int defaultDayOffset = -1; String actionValue = action.orElse(INGEST_ACTION_INSERT); String coguidValue = coguid.orElse(getCurrentDataInFormat(coguidDatePattern)); @@ -937,52 +940,29 @@ private static String buildIngestVodXml(String action, String coguid, boolean is } // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestBasicVOD(Optional name, String mediaType) { - String coguidValue = getCurrentDataInFormat("yyMMddHHmmssSS"); - String nameValue = name.orElseGet(() -> MOVIE_MEDIA_TYPE + "_" + coguidValue); - String thumbUrlValue = INGEST_VOD_DEFAULT_THUMB; - String descriptionValue = "description of " + coguidValue; - String catalogStartDateValue = getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss"); - String catalogEndDateValue = "14/10/2099 17:00:00"; - String startDateValue = getOffsetDateInFormat(-1, "dd/MM/yyyy hh:mm:ss"); - String endDateValue = "14/10/2099 17:00:00"; - String mediaTypeValue = mediaType; - String ppvWebNameValue = "Shai_Regression_PPV"; - String ppvMobileNameValue = "Shai_Regression_PPV"; // TODO: update on any generated value - // TODO: check if ingest url is the same for all ingest actions - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headermap = new HashMap<>(); - headermap.put("Content-Type", "text/xml;charset=UTF-8"); - headermap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); - String reqBody = "\n" + - " \n" + - " \n" + - " " + getIngestAssetUserName() + "" + getIngestAssetUserPassword() + "" + - " \n" + - " \n" + - ""; - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headermap) - .body(reqBody) - .post(url); - //System.out.println("RESPONSE: " + resp.asString()); - String id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - - MediaAsset mediaAsset = new MediaAsset(); - mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id)); - mediaAsset.setDescription(descriptionValue); - //mediaAsset.setStartDate(startDate); - //mediaAsset.setEndDate(endDate); - - await().pollInterval(3, TimeUnit.SECONDS).atMost(45, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), id, INGEST_ACTION_INSERT)); - mediaAsset.setMediaFiles(executor.executeSync( - AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); - - // TODO: 4/15/2018 add log for ingest and index failures + public static MediaAsset ingestBasicVOD(String name, String mediaType) { + MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.of(name), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty()); return mediaAsset; } -} +}; + + +// public static ArrayList ingestBasicVODNew(int numOfAssets, String mediaType) { +// MediaAsset mediaAsset; +// ArrayList assetList = new ArrayList<>(); +// String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; +// int defaultDayOffset; +// String catalogStartDateValue; +// for (int i = 0; i < numOfAssets; i++) { +// defaultDayOffset = (-1 + - i) ; +// catalogStartDateValue = getOffsetDateInFormat(defaultDayOffset, startEndDatePattern); +// mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.of("Shmulik"), Optional.empty(), Optional.empty(), +// Optional.of(catalogStartDateValue), Optional.empty(), +// Optional.of(catalogStartDateValue), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty()); +// assetList.add(mediaAsset); +// } +// +// return assetList; +// } +//} From c7300df247ab0f0493e6de314ccfef6c830c12af Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 22 May 2018 09:17:15 +0300 Subject: [PATCH 243/605] ottUser tests - changes after Max review 1 --- .../OttUserAnonymousLoginTests.java | 3 +- .../ottUserTests/OttUserListTests.java | 8 ++-- .../ottUserTests/OttUserRegisterTests.java | 46 ++++++++++++++++--- .../ottUserTests/OttUserUpdateTests.java | 1 - 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java index c8304bf0a..dc02b0f3e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAnonymousLoginTests.java @@ -22,7 +22,8 @@ public class OttUserAnonymousLoginTests extends BaseTest { @Description("ottUser/action/anonymousLogin - anonymousLogin") @Test() private void anonymousLogin() { - loginSessionResponse = executor.executeSync(OttUserService.anonymousLogin(partnerId)); + String udid = "1234"; + loginSessionResponse = executor.executeSync(OttUserService.anonymousLogin(partnerId, udid)); assertThat(loginSessionResponse.error).isNull(); assertThat(loginSessionResponse.results.getKs()).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java index c900b391c..f0007295b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java @@ -96,7 +96,7 @@ private void list_with_id_filter() { // list household users ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) - .setKs(getAdministratorKs()); + .setKs(getOperatorKs()); householdUserListResponse = executor.executeSync(listOttUserBuilder); List users = householdUserListResponse.results.getObjects(); @@ -119,7 +119,7 @@ private void list_with_username_filter() { // list household users ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) - .setKs(getAdministratorKs()); + .setKs(getOperatorKs()); householdUserListResponse = executor.executeSync(listOttUserBuilder); List users = householdUserListResponse.results.getObjects(); @@ -142,7 +142,7 @@ private void list_with_invalid_filter() { // list household users ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) - .setKs(getAdministratorKs()); + .setKs(getOperatorKs()); householdUserListResponse = executor.executeSync(listOttUserBuilder); // assert error 500038 is return @@ -163,7 +163,7 @@ private void list_with_externalId_filter() { // list household users ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) - .setKs(getAdministratorKs()); + .setKs(getOperatorKs()); householdUserListResponse = executor.executeSync(listOttUserBuilder); List users = householdUserListResponse.results.getObjects(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java index 431bf7c0c..8b589820f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java @@ -3,32 +3,45 @@ import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.HashMap; +import java.util.Map; + import static com.kaltura.client.services.OttUserService.delete; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class OttUserRegisterTests extends BaseTest { - private OTTUser user; private Response ottUserResponse; - @BeforeClass - private void ottUser_login_tests_setup() { - user = generateOttUser(); - } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/register - register") @Test private void register() { + // generate user + OTTUser user = generateOttUser(); + + // set dynamic date + Map dynamicData = new HashMap<>(); + String dynamicDataKey = "key"; + StringValue dynamicDataValue = new StringValue(); + dynamicDataValue.setValue("value"); + + dynamicData.put(dynamicDataKey, dynamicDataValue); + user.setDynamicData(dynamicData); + + // register ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); + user = ottUserResponse.results; assertThat(ottUserResponse.error).isNull(); assertThat(ottUserResponse.results).isEqualToIgnoringGivenFields(user, "userState", "userType", @@ -38,6 +51,27 @@ private void register() { executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } + @Severity(SeverityLevel.NORMAL) + @Description("ottUser/action/register - user exists - error 2014") + @Test + private void register_exists_user() { + // generate user + OTTUser user = generateOttUser(); + + // register - first time + ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); + user = ottUserResponse.results; + + // register - second time + ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); + + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2014).getCode()); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + } + // // } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index 4bdefd46a..bdbd9804b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -65,7 +65,6 @@ private void update() { @Issue("BEO-4919") @Test(enabled = false) private void update_with_administratorKs() { - // update user info String newUserInfo = "def"; user.setFirstName(newUserInfo); From ceb4ba1fc4a1b6aa09b7c9143b93c10023d01c27 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 22 May 2018 09:41:54 +0300 Subject: [PATCH 244/605] Updated ingestBasicVODNumOfTimes util --- .../AssetHistoryCleanTests.java | 6 +-- .../AssetHistoryListTests.java | 6 +-- .../channelTests/ChannelAddTests.java | 8 ++-- .../client/test/utils/IngestUtils.java | 37 +++++++------------ 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java index e69e8cba6..f22726c99 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java @@ -48,13 +48,13 @@ public class AssetHistoryCleanTests extends BaseTest { // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestBasicVOD("movieForBookmark", MOVIE_MEDIA_TYPE); + movie = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestBasicVOD("movie2ForBookmark", MOVIE_MEDIA_TYPE); + movie2 = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestBasicVOD("EpisodeForBookmark", EPISODE_MEDIA_TYPE); + episode = IngestUtils.ingestBasicVOD(EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java index fbdbf79a4..6be2ec045 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java @@ -47,13 +47,13 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestBasicVOD("movieForBookmark", MOVIE_MEDIA_TYPE); + movie = IngestUtils.ingestBasicVOD( MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestBasicVOD("movie2ForBookmark", MOVIE_MEDIA_TYPE); + movie2 = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestBasicVOD("EpisodeForBookmark", EPISODE_MEDIA_TYPE); + episode = IngestUtils.ingestBasicVOD(EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 6d205b6c1..b7edc5fb5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -58,14 +58,14 @@ private void addChannel() { @Test private void checkOrderOfAssetsInChannel() { - String asset1Name = "Movie_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); - String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); + //String asset1Name = "Movie_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); + //String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); // Ingest first asset - MediaAsset movieAsset = IngestUtils.ingestBasicVOD(asset1Name, MOVIE_MEDIA_TYPE); + MediaAsset movieAsset = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); // Ingest second asset - MediaAsset episodeAsset = IngestUtils.ingestBasicVOD(asset2Name, MOVIE_MEDIA_TYPE); + MediaAsset episodeAsset = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index e3dd2d80f..86f042003 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -941,29 +941,20 @@ private static String buildIngestVodXml(String action, String coguid, boolean is } // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestBasicVOD(String name, String mediaType) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.of(name), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + public static MediaAsset ingestBasicVOD(String mediaType) { + MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty()); return mediaAsset; } -}; - - -// public static ArrayList ingestBasicVODNew(int numOfAssets, String mediaType) { -// MediaAsset mediaAsset; -// ArrayList assetList = new ArrayList<>(); -// String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; -// int defaultDayOffset; -// String catalogStartDateValue; -// for (int i = 0; i < numOfAssets; i++) { -// defaultDayOffset = (-1 + - i) ; -// catalogStartDateValue = getOffsetDateInFormat(defaultDayOffset, startEndDatePattern); -// mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.of("Shmulik"), Optional.empty(), Optional.empty(), -// Optional.of(catalogStartDateValue), Optional.empty(), -// Optional.of(catalogStartDateValue), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty()); -// assetList.add(mediaAsset); -// } -// -// return assetList; -// } -//} + + + public static ArrayList ingestBasicVODNumOfTimes(int numOfAssets, String mediaType) { + MediaAsset mediaAsset; + ArrayList assetList = new ArrayList<>(); + for (int i = 0; i < numOfAssets; i++) { + mediaAsset = ingestBasicVOD(mediaType); + assetList.add(mediaAsset); + } + return assetList; + } +} From bbbe8444d08b257032ec556ed999d3a5793ad302 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 22 May 2018 09:55:53 +0300 Subject: [PATCH 245/605] Updated deleteAllGeoAssetRules util to prevent nullpointerexception if total count = 0 --- .../com/kaltura/client/test/utils/AssetRuleUtils.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java index d3cf28b87..4d6efd4ac 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetRuleUtils.java @@ -16,9 +16,12 @@ public class AssetRuleUtils extends BaseUtils { public static void deleteAllGeoAssetRules() { ListAssetRuleBuilder listAssetRuleBuilder = AssetRuleService.list().setKs(BaseTest.getOperatorKs()); Response> listAssetRule = executor.executeSync(listAssetRuleBuilder); - for (AssetRule rule : listAssetRule.results.getObjects()) { - DeleteAssetRuleBuilder deleteAssetRuleBuilder = AssetRuleService.delete(rule.getId()).setKs(BaseTest.getOperatorKs()); - executor.executeSync(deleteAssetRuleBuilder); + if (listAssetRule.results.getTotalCount() > 0) { + for (AssetRule rule : listAssetRule.results.getObjects()) { + DeleteAssetRuleBuilder deleteAssetRuleBuilder = AssetRuleService.delete(rule.getId()).setKs(BaseTest.getOperatorKs()); + executor.executeSync(deleteAssetRuleBuilder); + } } + } } From fe75c21a024fb806cd58dba887bc6c32f14a94cb Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 22 May 2018 14:00:10 +0300 Subject: [PATCH 246/605] Added new class - "AssetGetTests" --- .../AssetTests/AssetGetTests.java | 47 +++++++++++++++++++ .../bookmarkTests/BookmarkListTests.java | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java new file mode 100644 index 000000000..63dc5afdd --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java @@ -0,0 +1,47 @@ +package com.kaltura.client.test.tests.servicesTests.AssetTests; + + +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.test.tests.BaseTest; + +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.types.Asset; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.AssetService.*; + +public class AssetGetTests extends BaseTest { + + private Long assetId; + private int fileId1; + private int fileId2; + + + @BeforeClass + private void bookmark_addTests_before_class() { + assetId = BaseTest.getSharedMediaAsset().getId(); + fileId1 = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + fileId2 = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(1); + } + + @Severity(SeverityLevel.NORMAL) + @Description("Asset/action/get - VOD") + @Test + + private void get() { + GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(assetId), AssetReferenceType.MEDIA) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response assetGetResponse = executor.executeSync(getAssetBuilder); + + assertThat(assetGetResponse.results.getId()).isEqualTo(assetId); + assertThat(assetGetResponse.results.getMediaFiles().get(0).getId()).isEqualTo(fileId1); + assertThat(assetGetResponse.results.getMediaFiles().get(1).getId()).isEqualTo(fileId2); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index b9cf28cae..4e0f4851e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -29,7 +29,7 @@ public class BookmarkListTests extends BaseTest { private List assetList; @BeforeClass - private void bookmark_listTtests_before_class() { + private void bookmark_listTests_before_class() { assetList = new ArrayList<>(); assetId = BaseTest.getSharedMediaAsset().getId(); From 10d7fe58f523b4f93d5991d1b19425c60301c547 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 22 May 2018 14:19:07 +0300 Subject: [PATCH 247/605] ottUser tests - changes after Max review 2 --- .../ottUserTests/OttUserRegisterTests.java | 13 +-- .../OttUserUpdateDynamicDataTests.java | 6 +- .../OttUserUpdateLoginDataTests.java | 2 +- .../ottUserTests/OttUserUpdateTests.java | 89 ++++++++++++++----- .../client/test/utils/OttUserUtils.java | 17 ++++ 5 files changed, 87 insertions(+), 40 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java index 8b589820f..2c002bcf2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java @@ -3,18 +3,15 @@ import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.OTTUser; -import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; -import java.util.HashMap; -import java.util.Map; - import static com.kaltura.client.services.OttUserService.delete; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.dynamicDataMapBuilder; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -31,13 +28,7 @@ private void register() { OTTUser user = generateOttUser(); // set dynamic date - Map dynamicData = new HashMap<>(); - String dynamicDataKey = "key"; - StringValue dynamicDataValue = new StringValue(); - dynamicDataValue.setValue("value"); - - dynamicData.put(dynamicDataKey, dynamicDataValue); - user.setDynamicData(dynamicData); + user.setDynamicData(dynamicDataMapBuilder("key", "value")); // register ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java index 09e27dc3a..5f638e4ea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java @@ -11,9 +11,7 @@ import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.UpdateDynamicDataOttUserBuilder; -import static com.kaltura.client.services.OttUserService.delete; -import static com.kaltura.client.services.OttUserService.register; +import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -36,7 +34,7 @@ private void updateDynamicData() { // update user dynamic data UpdateDynamicDataOttUserBuilder updateDynamicDataOttUserBuilder = OttUserService.updateDynamicData(keyString, value) - .setKs(getAdministratorKs()) + .setKs(getOperatorKs()) .setUserId(Integer.valueOf(user.getId())); Response ottUserDynamicDataResponse = executor.executeSync(updateDynamicDataOttUserBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java index ebd0a12d5..4b0a1d356 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateLoginDataTests.java @@ -33,7 +33,7 @@ private void updateLoginData() { // update user login data String userNewPassword = defaultUserPassword + 1; UpdateLoginDataOttUserBuilder updateLoginDataOttUserBuilder = OttUserService.updateLoginData(user.getUsername(), defaultUserPassword, userNewPassword) - .setKs(userKs); + .setKs(userKs); Response booleanResponse = executor.executeSync(updateLoginDataOttUserBuilder); assertThat(booleanResponse.error).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index bdbd9804b..022469422 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -9,85 +9,126 @@ import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.OttUserUtils.dynamicDataMapBuilder; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; public class OttUserUpdateTests extends BaseTest { - private OTTUser user; - private String originalUserEmail; - private Response ottUserResponse; - @BeforeClass - private void ottUser_update_tests_setup() { - // register user - ottUserResponse = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)); - user = ottUserResponse.results; - originalUserEmail = user.getEmail(); - } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update") - @Test + @Issue("BEO-5114") + @Test(enabled = false) private void update() { + // register user + OTTUser user = generateOttUser(); + user.setDynamicData(dynamicDataMapBuilder("key", "value")); + + ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); + user = ottUserResponse.results; + String originalUserEmail = user.getEmail(); + // login user Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); String userKs = loginResponse.results.getLoginSession().getKs(); // update user info - String newUserInfo = "abc"; + String newUserInfo = "newUserInfo"; user.setFirstName(newUserInfo); user.setLastName(newUserInfo); + user.setAddress(newUserInfo); ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(userKs)); assertThat(ottUserResponse.error).isNull(); // get user after update - ottUserResponse = executor.executeSync(get().setKs(userKs)); - user = ottUserResponse.results; + user = executor.executeSync(get().setKs(userKs)).results; // assert user new info assertThat(ottUserResponse.error).isNull(); assertThat(user.getFirstName()).isEqualTo(newUserInfo); assertThat(user.getLastName()).isEqualTo(newUserInfo); + assertThat(user.getAddress()).isEqualTo(newUserInfo); assertThat(user.getEmail()).isEqualTo(originalUserEmail); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update with administratorKs") - @Issue("BEO-4919") - @Test(enabled = false) + @Test(enabled = true) private void update_with_administratorKs() { + // register user + OTTUser user = generateOttUser(); + user.setDynamicData(dynamicDataMapBuilder("key", "value")); + + ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); + user = ottUserResponse.results; + String originalUserEmail = user.getEmail(); + // update user info - String newUserInfo = "def"; + String newUserInfo = "newUserInfo"; user.setFirstName(newUserInfo); user.setLastName(newUserInfo); -// user.setAffiliateCode(null); + user.setAddress(newUserInfo); - ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(getAdministratorKs())); + ottUserResponse = executor.executeSync(OttUserService.update(user) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId()))); assertThat(ottUserResponse.error).isNull(); // get user after update - ottUserResponse = executor.executeSync(get().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + ottUserResponse = executor.executeSync(get() + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId()))); user = ottUserResponse.results; // assert user new info assertThat(ottUserResponse.error).isNull(); assertThat(user.getFirstName()).isEqualTo(newUserInfo); assertThat(user.getLastName()).isEqualTo(newUserInfo); + assertThat(user.getAddress()).isEqualTo(newUserInfo); assertThat(user.getEmail()).isEqualTo(originalUserEmail); + + // cleanup + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } - @AfterClass - private void ottUser_update_tests_tearDown() { + @Severity(SeverityLevel.NORMAL) + @Description("ottUser/action/update - update user externalId - error ") + @Test(enabled = true) + private void update_user_externalId() { + // register user + OTTUser user = generateOttUser(); + user.setDynamicData(dynamicDataMapBuilder("key", "value")); + + ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); + user = ottUserResponse.results; + + // login user + Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); + String userKs = loginResponse.results.getLoginSession().getKs(); + + // update user externalId + String newExternalId = "newExternalId"; + user.setExternalId(newExternalId); + + ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(userKs)); + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500051).getCode()); + // cleanup executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } + + } diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 4f5639f82..632ac9431 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -3,9 +3,12 @@ import com.kaltura.client.services.OttUserService; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; +import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; import javax.annotation.Nullable; +import java.util.HashMap; +import java.util.Map; import java.util.Random; import static com.kaltura.client.services.OttUserService.*; @@ -57,4 +60,18 @@ public static String getKs(int userId, @Nullable String udid) { return loginResponse.results.getLoginSession().getKs(); } + + public static Map dynamicDataMapBuilder(String key, String value) { + Map dynamicData = new HashMap<>(); + + String sk = key; + StringValue sv = new StringValue(); + sv.setValue(value); + dynamicData.put(sk, sv); + + return dynamicData; + } + + + } From 63ff219db853e58197fbb210604fe817e47becdc Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 22 May 2018 18:15:33 +0300 Subject: [PATCH 248/605] Added more tests into PermissionsManagement.java --- .../four_eight/PermissionsManagement.java | 180 ++++++++++++------ .../kaltura/client/test/utils/BaseUtils.java | 33 +++- .../client/test/utils/IngestUtils.java | 3 - .../test/utils/PermissionManagementUtils.java | 58 +++++- 4 files changed, 206 insertions(+), 68 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java index a74720d13..abbb5f82f 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.featuresTests.four_eight; +import com.kaltura.client.test.utils.PermissionManagementUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import org.testng.annotations.Test; import org.w3c.dom.Document; @@ -8,6 +9,9 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.*; +import java.util.ArrayList; +import java.util.List; + import static com.kaltura.client.test.utils.PermissionManagementUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -17,11 +21,18 @@ */ public class PermissionsManagement { // TODO: discuss where to save these values + String path2Log = "C:\\log\\permissions\\permissions.log"; String path2Util = "C:\\123\\222\\"; + String path2EmptyFile = path2Util + "333\\" + "empty_file.txt"; String mainFile = "PermissionsDeployment.exe"; String dataFilePath = path2Util + "333\\" + "exp1.txt"; + String importOnly4TablesFilePath = path2Util + "333\\" + "importOnly4Tables.txt"; + + public static final String EXPORT_KEY = "e="; + public static final String IMPORT_KEY = "i="; + public static final String DELETE_KEY = "d="; - @Test(description = "just for deletion") + @Test(enabled = false, description = "just for deletion") public void deleteData() { //long roleId = 477L; long permissionId = 32L; @@ -34,72 +45,115 @@ public void deleteData() { DBUtils.deletePermissionPermissionItem((int)permissionPermissionItemId);*/ } - // TODO: change descriptions later - @Test(enabled = false, description = "execute stored procedures related insert data into permission management related tables") - public void insertDataIntoTables() { - String suffix = "00002"; - String role = "MaxTest" + suffix; - long roleId = DBUtils.insertRole(role); - System.out.println("Role: " + roleId); // 468 - //DBUtils.deleteRoleAndItsPermissions((int)roleId); - long permissionId = DBUtils.insertPermission(role, 2, "partner*"); - System.out.println("Permission: " + permissionId); // 26 - long permissionRoleId = DBUtils.insertPermissionRole(roleId, permissionId, 0); - System.out.println("PermissionRole: " + permissionRoleId); // 622 - String name = "Asset_List_Max" + suffix; - String service = "asset"; - String action = "list"; - String permissionItemObject = "permissionItemObject"; - String parameter = "parameter"; - long permissionItemId = DBUtils.insertPermissionItem(name, 1, service, action, permissionItemObject, parameter); - System.out.println("PermissionItem: " + permissionItemId); // 539 - long permissionPermissionItemId = DBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); - System.out.println("PermissionPermissionItem: " + permissionPermissionItemId);//1063 - - // generation of XML file with insertedData - try { - File file = new File(path2Util + "333\\" + "import_data.txt"); - PrintWriter writer = new PrintWriter(file); - writer.println(""); - writer.println(""); - printRole(writer, roleId, role); - printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); - printPermission(writer, permissionId, role, 2, "partner*"); - printPermissionItem(writer, permissionItemId, name, 1, service, action, permissionItemObject, parameter); - printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, name, role); - writer.println(""); - writer.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - @Test(enabled = false, description = "execute console util without parameters") private void checkRunningWithoutParameters() { - StringBuilder output = new StringBuilder(); - - ProcessBuilder pb = new ProcessBuilder(path2Util + mainFile); - pb.redirectErrorStream(true); - BufferedReader inStreamReader; - try { - Process process = pb.start(); - inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream())); - String line; - while((line = inStreamReader.readLine()) != null){ - output.append(line); - } - - assertThat(output.toString()).contains("Permissions deployment tool"); - assertThat(output.toString()).contains("Shortcut: e"); - assertThat(output.toString()).contains("Shortcut: i"); - } catch (IOException e) { - e.printStackTrace(); - } finally { - // return input stream back - inStreamReader = new BufferedReader(new InputStreamReader(System.in)); - } + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("Permissions deployment tool"); + assertThat(consoleOutput).contains("Shortcut: e"); + assertThat(consoleOutput).contains("Shortcut: i"); + } + + @Test(enabled = false, description = "execute console util to export without mentioned file") + private void checkRunningExportWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(EXPORT_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } + + @Test(enabled = false, description = "execute console util to import without mentioned file") + private void checkRunningImportWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } + + @Test(enabled = false, description = "execute console util to delete without mentioned file") + private void checkRunningDeleteWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } + + @Test(enabled = false, description = "execute console util to export data from DB into file") + private void checkRunningExport() { + // prepare data inserting them in DB using stored procedures + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.insertDataInAllTables(path2Util, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix); + + // export from DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(EXPORT_KEY + dataFilePath); + executeCommandsInColsole(commands); + + // checks that created file contains inserted data + String fileContent = getFileContent(dataFilePath); + assertThat(fileContent).contains("MaxTest" + suffix); + assertThat(fileContent).contains("Asset_List_Max" + suffix); + assertThat(fileContent).contains("permissionItemObject" + suffix); + assertThat(fileContent).contains("parameter" + suffix); + } + + @Test(enabled = false, description = "execute console util to import data into DB from file having only 4 tables instead of 5") + private void checkRunningImportFromFileNotHavingAllTables() { + // remove log file + deleteFile(path2Log); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + importOnly4TablesFilePath); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("Import failed: reading from XML resulted in empty data set or data set with less than 5 tables"); + } + + @Test(enabled = false, description = "execute console util to try import data into DB from empty file") + private void checkRunningImportFromEmptyFile() { + // remove log file + deleteFile(path2Log); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + path2EmptyFile); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); + } + + @Test(/*enabled = false,*/ description = "execute console util to try delete data from DB using empty file") + private void checkRunningDeleteUsingEmptyFile() { + // remove log file + deleteFile(path2Log); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + path2EmptyFile); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); } + // TODO: check how to use it @Test(enabled = false) public void readXMLFile() throws ParserConfigurationException, IOException, SAXException { File file = new File(dataFilePath); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 8cc0c182b..e63d54bdb 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -10,7 +10,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; +import java.io.*; import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -134,4 +134,35 @@ public static String getConcatenatedString(String... args) { } return String.join(",", assetIds); } + + public static String getFileContent(String filePath) { + String result = ""; + try { + StringBuilder sb = new StringBuilder(); + InputStream is = new FileInputStream(filePath); + BufferedReader buf = new BufferedReader(new InputStreamReader(is)); + + String line = buf.readLine(); + while(line != null){ + sb.append(line).append("\n"); + line = buf.readLine(); + } + + result = sb.toString(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + return result; + } + } + + public static void deleteFile(String filePath) { + File file = new File(filePath); + + if (file.delete()) { + Logger.getLogger(BaseUtils.class).debug("File deleted successfully: " + filePath); + } else { + Logger.getLogger(BaseUtils.class).error("Failed to delete the file: " + filePath); + } + } } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index e3dd2d80f..1f41ea898 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -9,15 +9,12 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; - -import java.awt.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index de8d3f619..889d52f20 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -1,6 +1,8 @@ package com.kaltura.client.test.utils; -import java.io.PrintWriter; +import com.kaltura.client.test.utils.dbUtils.DBUtils; +import java.io.*; +import java.util.List; public class PermissionManagementUtils extends BaseUtils { @@ -58,5 +60,59 @@ public static void printRole(PrintWriter writer, Long roleId, String roleName) { } + public static String executeCommandsInColsole(List commands) { + StringBuilder output = new StringBuilder(); + + ProcessBuilder pb = new ProcessBuilder(commands); + pb.redirectErrorStream(true); + BufferedReader inStreamReader; + try { + Process process = pb.start(); + inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while((line = inStreamReader.readLine()) != null){ + output.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + output.append(e.getMessage()); + } + + return output.toString(); + } + + public static void insertDataInAllTables(String path2Util, String role, String usersGroup, String permissionItemName, + String service, String action, String permissionItemObject, String parameter) { + long roleId = DBUtils.insertRole(role); + long permissionId = DBUtils.insertPermission(role, 2, usersGroup); + long permissionRoleId = DBUtils.insertPermissionRole(roleId, permissionId, 0); + + long permissionItemId = DBUtils.insertPermissionItem(permissionItemName, 1, service, action, permissionItemObject, parameter); + long permissionPermissionItemId = DBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); + + generateFileWithInsertedIntoDBData(path2Util, role, usersGroup, permissionItemName, service, action, + permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId); + } + + private static void generateFileWithInsertedIntoDBData(String path2Util, String role, String usersGroup, String permissionItemName, + String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, + long permissionRoleId, long permissionItemId, long permissionPermissionItemId) { + try { + // TODO: update file name as parameter + File file = new File(path2Util + "333\\" + "import_data.txt"); + PrintWriter writer = new PrintWriter(file); + writer.println(""); + writer.println(""); + printRole(writer, roleId, role); + printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); + printPermission(writer, permissionId, role, 2, usersGroup); + printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); + printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); + writer.println(""); + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } } From ad93df97dbf684793f724f1c32c0b41d5293df05 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 23 May 2018 10:13:27 +0300 Subject: [PATCH 249/605] Added more tests related PermissionManagement --- ...t.java => PermissionsManagementTests.java} | 103 +++++- .../test/utils/PermissionManagementUtils.java | 21 +- .../test/utils/dbUtils/DBConstants.java | 33 ++ .../client/test/utils/dbUtils/DBUtils.java | 198 +---------- .../dbUtils/PermissionsManagementDBUtils.java | 320 ++++++++++++++++++ 5 files changed, 453 insertions(+), 222 deletions(-) rename src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/{PermissionsManagement.java => PermissionsManagementTests.java} (56%) create mode 100644 src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagementTests.java similarity index 56% rename from src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java rename to src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagementTests.java index abbb5f82f..ad829a02e 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagement.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagementTests.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.tests.featuresTests.four_eight; import com.kaltura.client.test.utils.PermissionManagementUtils; -import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -11,21 +11,25 @@ import java.io.*; import java.util.ArrayList; import java.util.List; - import static com.kaltura.client.test.utils.PermissionManagementUtils.*; +import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BaseUtils.getFileContent; +import static com.kaltura.client.test.utils.BaseUtils.deleteFile; /** * * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 */ -public class PermissionsManagement { +public class PermissionsManagementTests { // TODO: discuss where to save these values String path2Log = "C:\\log\\permissions\\permissions.log"; String path2Util = "C:\\123\\222\\"; String path2EmptyFile = path2Util + "333\\" + "empty_file.txt"; String mainFile = "PermissionsDeployment.exe"; String dataFilePath = path2Util + "333\\" + "exp1.txt"; + String generatedDataFilePath = path2Util + "333\\" + "import.txt"; String importOnly4TablesFilePath = path2Util + "333\\" + "importOnly4Tables.txt"; public static final String EXPORT_KEY = "e="; @@ -39,14 +43,14 @@ public void deleteData() { /*long permissionItemId = 544L; long permissionPermissionItemId = 1068;*/ - //DBUtils.deleteRoleAndItsPermissions((int)roleId); - DBUtils.deletePermission((int)permissionId); - /*DBUtils.deletePermissionItem((int)permissionItemId); - DBUtils.deletePermissionPermissionItem((int)permissionPermissionItemId);*/ + //PermissionsManagementDBUtils.deleteRoleAndItsPermissions((int)roleId); + PermissionsManagementDBUtils.deletePermission((int)permissionId); + /*PermissionsManagementDBUtils.deletePermissionItem((int)permissionItemId); + PermissionsManagementDBUtils.deletePermissionPermissionItem((int)permissionPermissionItemId);*/ } @Test(enabled = false, description = "execute console util without parameters") - private void checkRunningWithoutParameters() { + public void runningWithoutParameters() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); String consoleOutput = executeCommandsInColsole(commands); @@ -57,7 +61,7 @@ private void checkRunningWithoutParameters() { } @Test(enabled = false, description = "execute console util to export without mentioned file") - private void checkRunningExportWithoutFile() { + public void runningExportWithoutFile() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); commands.add(EXPORT_KEY); @@ -67,7 +71,7 @@ private void checkRunningExportWithoutFile() { } @Test(enabled = false, description = "execute console util to import without mentioned file") - private void checkRunningImportWithoutFile() { + public void runningImportWithoutFile() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); commands.add(IMPORT_KEY); @@ -77,7 +81,7 @@ private void checkRunningImportWithoutFile() { } @Test(enabled = false, description = "execute console util to delete without mentioned file") - private void checkRunningDeleteWithoutFile() { + public void runningDeleteWithoutFile() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); commands.add(DELETE_KEY); @@ -87,10 +91,10 @@ private void checkRunningDeleteWithoutFile() { } @Test(enabled = false, description = "execute console util to export data from DB into file") - private void checkRunningExport() { + public void export() { // prepare data inserting them in DB using stored procedures String suffix = String.valueOf(getTimeInEpoch(0)); - PermissionManagementUtils.insertDataInAllTables(path2Util, "MaxTest" + suffix, "partner*", + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix); @@ -109,7 +113,7 @@ private void checkRunningExport() { } @Test(enabled = false, description = "execute console util to import data into DB from file having only 4 tables instead of 5") - private void checkRunningImportFromFileNotHavingAllTables() { + public void runningImportFromFileNotHavingAllTables() { // remove log file deleteFile(path2Log); @@ -124,7 +128,7 @@ private void checkRunningImportFromFileNotHavingAllTables() { } @Test(enabled = false, description = "execute console util to try import data into DB from empty file") - private void checkRunningImportFromEmptyFile() { + public void runningImportFromEmptyFile() { // remove log file deleteFile(path2Log); @@ -138,8 +142,8 @@ private void checkRunningImportFromEmptyFile() { assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); } - @Test(/*enabled = false,*/ description = "execute console util to try delete data from DB using empty file") - private void checkRunningDeleteUsingEmptyFile() { + @Test(enabled = false, description = "execute console util to try delete data from DB using empty file") + public void runningDeleteUsingEmptyFile() { // remove log file deleteFile(path2Log); @@ -153,6 +157,71 @@ private void checkRunningDeleteUsingEmptyFile() { assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); } + @Test(enabled = false, description = "execute console util to import data into DB from valid file") + public void importFromFile() { + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(1); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + + int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); + assertThat(idRolePermission).isEqualTo(1); + + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + + int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, + idPermissionItemHavingName, 0); + assertThat(rowsInPermissionsPermissions).isEqualTo(1); + } + + @Test(enabled = false, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") + public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { + // remove log file + deleteFile(path2Log); + + // insert data in DB + String suffix = String.valueOf(getTimeInEpoch(0)) + "inserted"; + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + // generate import file data + suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + path2EmptyFile); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("!!NOT EXISTS IN SOURCE!! Table : role Id : " + idRoleHavingName + " Name : " + "MaxTest" + suffix); + assertThat(fileContent).contains("Asset_List_Max" + suffix); + assertThat(fileContent).contains("permissionItemObject" + suffix); + assertThat(fileContent).contains("parameter" + suffix); + } + // TODO: check how to use it @Test(enabled = false) public void readXMLFile() throws ParserConfigurationException, IOException, SAXException { diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index 889d52f20..41b92c9d1 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -1,6 +1,6 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import java.io.*; import java.util.List; @@ -81,25 +81,24 @@ public static String executeCommandsInColsole(List commands) { return output.toString(); } - public static void insertDataInAllTables(String path2Util, String role, String usersGroup, String permissionItemName, + public static void insertDataInAllTables(String path2ResultFile, String role, String usersGroup, String permissionItemName, String service, String action, String permissionItemObject, String parameter) { - long roleId = DBUtils.insertRole(role); - long permissionId = DBUtils.insertPermission(role, 2, usersGroup); - long permissionRoleId = DBUtils.insertPermissionRole(roleId, permissionId, 0); + long roleId = PermissionsManagementDBUtils.insertRole(role); + long permissionId = PermissionsManagementDBUtils.insertPermission(role, 2, usersGroup); + long permissionRoleId = PermissionsManagementDBUtils.insertPermissionRole(roleId, permissionId, 0); - long permissionItemId = DBUtils.insertPermissionItem(permissionItemName, 1, service, action, permissionItemObject, parameter); - long permissionPermissionItemId = DBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); + long permissionItemId = PermissionsManagementDBUtils.insertPermissionItem(permissionItemName, 1, service, action, permissionItemObject, parameter); + long permissionPermissionItemId = PermissionsManagementDBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); - generateFileWithInsertedIntoDBData(path2Util, role, usersGroup, permissionItemName, service, action, + generateFileWithInsertedIntoDBData(path2ResultFile, role, usersGroup, permissionItemName, service, action, permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId); } - private static void generateFileWithInsertedIntoDBData(String path2Util, String role, String usersGroup, String permissionItemName, + public static void generateFileWithInsertedIntoDBData(String path2ResultFile, String role, String usersGroup, String permissionItemName, String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, long permissionRoleId, long permissionItemId, long permissionPermissionItemId) { try { - // TODO: update file name as parameter - File file = new File(path2Util + "333\\" + "import_data.txt"); + File file = new File(path2ResultFile); PrintWriter writer = new PrintWriter(file); writer.println(""); writer.println(""); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 4591188c6..e35c1ca02 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -14,6 +14,7 @@ public class DBConstants { static final String NAME = "name"; static final String NUMBER_OF_REC_PERIODS = "num_of_rec_periods"; static final String PASSWORD = "password"; + static final String ROW_COUNT = "row_count"; static final String USERNAME = "username"; static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; @@ -71,6 +72,38 @@ public class DBConstants { static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; + static final String COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT = "select count(*) as " + ROW_COUNT + "\n" + + "from [TVinci].[dbo].[roles]\n" + + "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + + static final String ID_BY_ROLE_NAME_IN_ROLES_SELECT = "select " + ID + "\n" + + "from [TVinci].[dbo].[roles]\n" + + "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + + static final String COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + + "from [TVinci].[dbo].[permissions]\n" + + "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + + static final String ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT = "select " + ID + "\n" + + "from [TVinci].[dbo].[permissions]\n" + + "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + + static final String COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + + "from [TVinci].[dbo].[roles_permissions]\n" + + "where role_id=%d and permission_id=%d and is_active=1 and [status]=1 and group_id=%d"; + + static final String COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + + "from [TVinci].[dbo].[permission_items]\n" + + "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + + static final String ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT = "select " + ID + "\n" + + "from [TVinci].[dbo].[permission_items]\n" + + "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + + static final String COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + + "from [TVinci].[dbo].[permissions_permission_items]\n" + + "where permission_id=%d and permission_item_id=%d and is_active=1 and [status]=1 and group_id=%d"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 76e00203b..0dc77f86c 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -17,8 +17,8 @@ public class DBUtils extends BaseUtils { private static SQLServerDataSource dataSource; private static Connection conn; private static Statement stam; - private static ResultSet rs; - private static CallableStatement cStmt; + static ResultSet rs; + static CallableStatement cStmt; static final String ERROR_MESSAGE = "No results found"; @@ -199,7 +199,7 @@ private static void openConnection() { } } - private static void closeConnection() { + static void closeConnection() { try { if (rs != null) { rs.close(); @@ -219,198 +219,8 @@ private static void closeConnection() { } } - private static void prepareCall(String sql) throws SQLException { + static void prepareCall(String sql) throws SQLException { openConnection(); cStmt = conn.prepareCall(sql); } - - /** - * Call Stored Procedure to create role - */ - public static int insertRole(String role) { - int result =-1; - try { - prepareCall(SP_INSERT_ROLE); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setString(2, role); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete role and its permissions - */ - public static void deleteRoleAndItsPermissions(int roleId) { - try { - prepareCall(SP_DELETE_ROLE_AND_ITS_PERMISSIONS); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setInt(2, roleId); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permissions - */ - public static int insertPermission(String name, int type, String usersGroup) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setString(2, name); - cStmt.setInt(3, type); - cStmt.setString(4, usersGroup); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission - */ - public static void deletePermission(int id) { - try { - prepareCall(SP_DELETE_PERMISSION); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permission role - */ - public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION_ROLE); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setLong(2, roleId); - cStmt.setLong(3, permissionId); - cStmt.setInt(4, isExcluded); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to insert permission item - */ - public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION_ITEM); - cStmt.setString(1, name); - cStmt.setInt(2, type); - cStmt.setString(3, service); - cStmt.setString(4, action); - cStmt.setString(5, permissionItemObject); - cStmt.setString(6, parameter); - rs = cStmt.executeQuery(); - - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission item - */ - public static void deletePermissionItem(int id) { - try { - prepareCall(SP_DELETE_PERMISSION_ITEM); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permission permission item - */ - public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); - cStmt.setInt(1, 0);; // group_id == 0 - cStmt.setLong(2, permissionId); - cStmt.setLong(3, permissionItemId); - cStmt.setInt(4, isExcluded); - rs = cStmt.executeQuery(); - - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission permission item - */ - public static void deletePermissionPermissionItem(int id) { - try { - prepareCall(SP_DELETE_PERMISSION_PERMISSION_ITEM); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java new file mode 100644 index 000000000..4c69dd407 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java @@ -0,0 +1,320 @@ +package com.kaltura.client.test.utils.dbUtils; + +import org.json.JSONArray; +import java.sql.*; +import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; + +public class PermissionsManagementDBUtils extends DBUtils { + + /** + * Call Stored Procedure to create role + */ + public static int insertRole(String role) { + int result =-1; + try { + prepareCall(SP_INSERT_ROLE); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setString(2, role); + + rs = cStmt.executeQuery(); + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to delete role and its permissions + */ + public static void deleteRoleAndItsPermissions(int roleId) { + try { + prepareCall(SP_DELETE_ROLE_AND_ITS_PERMISSIONS); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setInt(2, roleId); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } + + /** + * Call Stored Procedure to insert permissions + */ + public static int insertPermission(String name, int type, String usersGroup) { + int result =-1; + try { + prepareCall(SP_INSERT_PERMISSION); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setString(2, name); + cStmt.setInt(3, type); + cStmt.setString(4, usersGroup); + + rs = cStmt.executeQuery(); + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to delete permission + */ + public static void deletePermission(int id) { + try { + prepareCall(SP_DELETE_PERMISSION); + cStmt.setInt(1, id); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } + + /** + * Call Stored Procedure to insert permission role + */ + public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { + int result =-1; + try { + prepareCall(SP_INSERT_PERMISSION_ROLE); + cStmt.setInt(1, 0); // group_id == 0 + cStmt.setLong(2, roleId); + cStmt.setLong(3, permissionId); + cStmt.setInt(4, isExcluded); + + rs = cStmt.executeQuery(); + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to insert permission item + */ + public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { + int result =-1; + try { + prepareCall(SP_INSERT_PERMISSION_ITEM); + cStmt.setString(1, name); + cStmt.setInt(2, type); + cStmt.setString(3, service); + cStmt.setString(4, action); + cStmt.setString(5, permissionItemObject); + cStmt.setString(6, parameter); + rs = cStmt.executeQuery(); + + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to delete permission item + */ + public static void deletePermissionItem(int id) { + try { + prepareCall(SP_DELETE_PERMISSION_ITEM); + cStmt.setInt(1, id); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } + + /** + * Call Stored Procedure to insert permission permission item + */ + public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { + int result =-1; + try { + prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); + cStmt.setInt(1, 0);; // group_id == 0 + cStmt.setLong(2, permissionId); + cStmt.setLong(3, permissionItemId); + cStmt.setInt(4, isExcluded); + rs = cStmt.executeQuery(); + + String columnName = rs.getMetaData().getColumnName(1); + while (rs.next()) { + result = rs.getInt(columnName); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + return result; + } + } + + /** + * Call Stored Procedure to delete permission permission item + */ + public static void deletePermissionPermissionItem(int id) { + try { + prepareCall(SP_DELETE_PERMISSION_PERMISSION_ITEM); + cStmt.setInt(1, id); + + cStmt.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + closeConnection(); + } + } + + public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { + int count = 0; + try { + System.out.println(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, + name, groupId)); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { + int count =-1; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getCountRowsHavingRoleNameInPermissions(String name, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getIdRecordHavingRoleNameInPermissions(String name, int groupId) { + int count =-1; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permissionId, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT, + roleId, permissionId, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getCountRowsHavingNameInPermissionItems(String name, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getIdRecordHavingNameInPermissionItems(String name, int groupId) { + int count =-1; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getCountSpecificRowsFromPermissionsPermissionsItems(int permissionId, int permissionItemId, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT, + permissionId, permissionItemId, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } +} From 146b664181ac5ad01d36b95757a218ebf8d5222e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 23 May 2018 12:41:02 +0300 Subject: [PATCH 250/605] add EntitlementCancelTests --- .../AssetHistoryCleanTests.java | 4 +- .../AssetHistoryListTests.java | 4 +- .../EntitlementCancelTests.java | 107 +++++++++++++++++- .../EntitlementGrantTests.java | 2 +- .../kaltura/client/test/utils/AssetUtils.java | 10 +- .../client/test/utils/dbUtils/DBUtils.java | 8 +- .../test/utils/dbUtils/IngestFixtureData.java | 19 ++-- src/test/resources/WORK_PLAN.md | 97 ++++++++++++++++ 8 files changed, 226 insertions(+), 25 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/{AssetHistoryTests => assetHistoryTests}/AssetHistoryCleanTests.java (99%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/{AssetHistoryTests => assetHistoryTests}/AssetHistoryListTests.java (98%) create mode 100644 src/test/resources/WORK_PLAN.md diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java similarity index 99% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index e69e8cba6..ce4cb2bd2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -1,4 +1,4 @@ -package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; +package com.kaltura.client.test.tests.servicesTests.assetHistoryTests; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; @@ -15,8 +15,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index fbdbf79a4..006fc1cf8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -1,9 +1,8 @@ -package com.kaltura.client.test.tests.servicesTests.AssetHistoryTests; +package com.kaltura.client.test.tests.servicesTests.assetHistoryTests; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; -import com.kaltura.client.services.BookmarkService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; @@ -17,7 +16,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Optional; import static com.kaltura.client.services.AssetHistoryService.*; import static com.kaltura.client.services.BookmarkService.*; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index e31fd01b2..8ded1301d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -1,12 +1,113 @@ package com.kaltura.client.test.tests.servicesTests.entitlementTests; +import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.services.EntitlementService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Entitlement; +import com.kaltura.client.types.EntitlementFilter; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; + +import static com.kaltura.client.services.EntitlementService.*; +import static com.kaltura.client.services.HouseholdService.delete; +import static org.assertj.core.api.Assertions.assertThat; + public class EntitlementCancelTests extends BaseTest { - @Test(description = "entitlement/action/cancel") - private void cancel() { -// EntitlementServiceImpl + private int subscriptionId; + + private Household testSharedHousehold; + private HouseholdUser testSharedMasterUser; + + private final int numberOfUsersInHousehold = 2; + private final int numberOfDevicesInHousehold = 1; + + @BeforeClass + private void cancel_test_before_class() { + subscriptionId = Integer.valueOf(getSharedCommonSubscription().getId()); + + // set household + testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + testSharedMasterUser = HouseholdUtils.getMasterUserFromHousehold(testSharedHousehold); + } + + @Test(description = "entitlement/action/cancel - cancel subscription") + private void cancel_subscription() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + // grant subscription + GrantEntitlementBuilder grantEntitlementBuilder = grant(subscriptionId, TransactionType.SUBSCRIPTION, true, 0) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + executor.executeSync(grantEntitlementBuilder); + + // set entitlementFilter + EntitlementFilter filter = new EntitlementFilter(); + filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + + // assert entitlement list size == 1 + ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(filter) + .setKs(userKs); + List entitlementList = executor.executeSync(listEntitlementBuilder).results.getObjects(); + assertThat(entitlementList.size()).isEqualTo(1); + + // cancel subscription + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(subscriptionId, TransactionType.SUBSCRIPTION) + .setKs(userKs); + Response booleanResponse = executor.executeSync(cancelEntitlementBuilder); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert entitlement list size == 0 + listEntitlementBuilder = EntitlementService.list(filter) + .setKs(userKs); + entitlementList = executor.executeSync(listEntitlementBuilder).results.getObjects(); + assertThat(entitlementList.size()).isEqualTo(0); + + // delete household for cleanup + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); + } + + @Test(description = "entitlement/action/cancel - cancel invalid subscription - error 3000") + private void cancel_with_invalid_subscription() { + // cancel subscription + int invalidSubscriptionId = 1; + String userKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId()), null); + + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(invalidSubscriptionId, TransactionType.SUBSCRIPTION) + .setKs(userKs); + Response booleanResponse = executor.executeSync(cancelEntitlementBuilder); + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3000).getCode()); + } + + @Test(description = "entitlement/action/cancel - cancel played subscription - error 3005") + private void cancel_played_subscription() { +// // set household +// Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); +// HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); +// String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + // TODO: 5/23/2018 complete test + } + + @AfterClass + private void cancel_test_after_class() { + + // delete shared household for cleanup + executor.executeSync(delete(Math.toIntExact(testSharedHousehold.getId())).setKs(getAdministratorKs())); } + + + // TODO: 5/22/2018 add cancel ppv test with dynamic data } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index de959bb3e..6137d6b94 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -30,9 +30,9 @@ public class EntitlementGrantTests extends BaseTest { // TODO: 4/12/2018 remove hardcoded ppv Id - private static int subscriptionId; private final int ppvId = 30297; private final int assetId = 607368; + private int subscriptionId; private int contentId; private final int numberOfUsersInHousehold = 2; diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index d0b40b0ab..d3f80d107 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import static com.kaltura.client.services.AssetService.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; @@ -30,12 +31,13 @@ public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nul return searchAssetFilter; } - public static ChannelFilter getChannelFilter(int idEqual, @Nullable String ksql, @Nullable DynamicOrderBy dynamicOrderBy, @Nullable String orderBy) { + public static ChannelFilter getChannelFilter(int idEqual, Optional ksql, Optional dynamicOrderBy, Optional orderBy) { ChannelFilter channelFilter = new ChannelFilter(); channelFilter.setIdEqual(idEqual); - channelFilter.setKSql(ksql); - channelFilter.setDynamicOrderBy(dynamicOrderBy); - channelFilter.setOrderBy(orderBy); + + ksql.ifPresent(channelFilter::setKSql); + dynamicOrderBy.ifPresent(channelFilter::setDynamicOrderBy); + orderBy.ifPresent(channelFilter::setOrderBy); return channelFilter; } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 76e00203b..f76180ed3 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -2,14 +2,16 @@ import com.google.common.base.Strings; import com.kaltura.client.Logger; -import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; import org.json.JSONObject; + import java.sql.*; + import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; public class DBUtils extends BaseUtils { @@ -26,7 +28,7 @@ public static boolean isActivationOfUsersNeeded() { Logger.getLogger(DBUtils.class).debug("isActivationOfUsersNeeded()"); int result = -1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, BaseTest.partnerId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); return false; @@ -49,7 +51,7 @@ public static String getUserData(String userRole) { } String userdData = ""; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, BaseTest.partnerId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); return null; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 111d872b1..efb8eebd0 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -3,12 +3,15 @@ import com.google.common.base.Strings; import com.kaltura.client.Logger; import com.kaltura.client.enums.SubscriptionDependencyType; -import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.*; import org.json.JSONArray; + import java.sql.SQLException; + +import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.ERROR_MESSAGE; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getJsonArrayFromQueryResult; public class IngestFixtureData { @@ -16,7 +19,7 @@ public static PriceDetails loadPriceCode(Double priceAmount, String currency) { Logger.getLogger(IngestFixtureData.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); PriceDetails result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_CODE_SELECT, BaseTest.partnerId, priceAmount, currency), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_CODE_SELECT, partnerId, priceAmount, currency), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } @@ -41,7 +44,7 @@ public static DiscountModule loadDiscount(Double discountPrice, Double discountP DiscountModule result = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, - BaseTest.partnerId, discountPrice, discountPercent), true); + partnerId, discountPrice, discountPercent), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } @@ -73,7 +76,7 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl return pricePlan; } - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, BaseTest.partnerId, + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, partnerId, Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return pricePlan; @@ -101,7 +104,7 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { Subscription subscription = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_SELECT, BaseTest.partnerId, + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_SELECT, partnerId, pricePlan.getId()), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return subscription; @@ -126,7 +129,7 @@ public static String getDiscount(String currency, int percent) { String code = ""; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, - percent, BaseTest.partnerId), false); + percent, partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { return null; } @@ -147,7 +150,7 @@ public static int getEpgChannelId(String channelName) { Logger.getLogger(IngestFixtureData.class).debug("getEpgChannelId(): channelName = " + channelName); int epgChannelId = -1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, BaseTest.partnerId + 1, channelName), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, partnerId + 1, channelName), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(IngestFixtureData.class).error(ERROR_MESSAGE); return epgChannelId; diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md new file mode 100644 index 000000000..3c484ecfa --- /dev/null +++ b/src/test/resources/WORK_PLAN.md @@ -0,0 +1,97 @@ +# PHASE 1 +Migrate services tests from ReadyAPI + +### Services List: +| Service | Status | +|------------------------------|--------| +| announcement | | +| appToken | | +| asset | | +| assetComment | | +| assetFile | | +| assetHistory | | +| assetRule | | +| assetStatistics | | +| assetUserRule | | +| bookmark | | +| cDVRAdapterProfile | | +| cdnAdapterProfile | | +| cdnPartnerSettings | | +| channel | | +| collection | | +| compensation | | +| configurationGroup | | +| configurationGroupDevice | | +| configurationGroupTag | | +| configurations | | +| country | | +| coupon | | +| couponsGroup | | +| currency | | +| deviceBrand | | +| deviceFamily | | +| email | | +| engagement | | +| engagementAdapter | | +| entitlement | | +| exportTask | | +| externalChannelProfile | | +| favorite | | +| followTvSeries | | +| homeNetwork | | +| household | | +| householdDevice | | +| householdLimitations | | +| householdPaymentGateway | | +| householdPaymentMethod | | +| householdPremiumService | | +| householdQuota | | +| householdUser | | +| inboxMessage | | +| language | | +| licensedUrl | | +| messageTemplate | | +| meta | | +| notification | | +| notificationsPartnerSettings | | +| notificationsSettings | | +| ossAdapterProfile | | +| ottCategory | | +| ottUser | Done | +| parentalRule | | +| partnerConfiguration | | +| paymentGatewayProfile | | +| paymentMethodProfile | | +| personalFeed | | +| pin | | +| ppv | | +| priceDetails | | +| pricePlan | | +| productPrice | | +| purchaseSettings | | +| recommendationProfile | | +| recording | | +| region | | +| registrySettings | | +| reminder | | +| report | | +| searchHistory | | +| seriesRecording | | +| session | | +| social | | +| socialAction | | +| socialComment | | +| socialFriendActivity | | +| subscription | | +| subscriptionSet | | +| system | | +| timeShiftedTvPartnerSettings | | +| topic | | +| transaction | | +| transactionHistory | | +| unifiedPayment | | +| userAssetRule | | +| userAssetsListItem | | +| userInterest | | +| userLoginPin | | +| userRole | | From 0f011e4ee19854e06c227a6350e4d31144fb2926 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 23 May 2018 15:30:40 +0300 Subject: [PATCH 251/605] add householdGetTests --- .../AssetCommentAddTests.java | 5 +- .../householdTests/householdAddTests.java | 51 ++++++++++ .../householdTests/householdGetTests.java | 93 +++++++++++++++++++ .../licensedUrlTests/licensedUrlGetTests.java | 4 + .../client/test/utils/IngestUtils.java | 15 ++- src/test/resources/WORK_PLAN.md | 4 +- 6 files changed, 163 insertions(+), 9 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/licensedUrlGetTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 0bb4e1988..793ced13c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -13,6 +13,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; import java.util.Optional; import static com.kaltura.client.services.AssetCommentService.AddAssetCommentBuilder; @@ -90,9 +91,9 @@ private void addCommentForVod() { @Test private void addCommentForEPGProgram() { // Ingest EPG program - Response> epgProgram = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + List epgPrograms = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - Long epgProgramId = epgProgram.results.getObjects().get(0).getId(); + Long epgProgramId = epgPrograms.get(0).getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(epgProgramId), AssetType.EPG, writer, text, createDate, subHeader, header); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java new file mode 100644 index 000000000..12babcf2e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java @@ -0,0 +1,51 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import io.qameta.allure.Description; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.HouseholdService.add; +import static com.kaltura.client.services.HouseholdService.delete; + +public class householdAddTests extends BaseTest { + + private Household household; + private HouseholdUser masterUser; + + @BeforeClass + private void household_addTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 1; + int numberOfDevicesInHousehold = 1; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + } + + @Description("household/action/add - master user exists in other household") + @Test + private void add_with_exists_in_other_household_masterUser() { + // create household + Household household = new Household(); + household.setName(masterUser.getUserId() + " Domain"); + household.setDescription(masterUser.getUserId() + " Description"); + + // add household + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + executor.executeSync(add(household).setKs(masterUserKs)); + + // TODO: 5/23/2018 finsih test + + } + + @AfterClass + private void household_getTests_afterClass() { + // delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java new file mode 100644 index 000000000..bc1a5a190 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java @@ -0,0 +1,93 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.HouseholdService.*; +import static org.assertj.core.api.Assertions.assertThat; + +public class householdGetTests extends BaseTest { + + private Household household; + + @BeforeClass + private void household_getTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 2; + int numberOfDevicesInHousehold = 2; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + } + + @Description("household/action/get - with master user ks") + @Test + private void get_with_masterUser_ks() { + // get master user ks + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + // get household + GetHouseholdBuilder getHouseholdBuilder = get() + .setKs(masterUserKs); + Response householdResponse = executor.executeSync(getHouseholdBuilder); + + assertThat(householdResponse.error).isNull(); + assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); + } + + @Description("household/action/get - with regular user ks") + @Test + private void get_with_regularUser_ks() { + // get regular user ks + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + + // get household + GetHouseholdBuilder getHouseholdBuilder = get() + .setKs(userKs); + Response householdResponse = executor.executeSync(getHouseholdBuilder); + + assertThat(householdResponse.error).isNull(); + assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); + } + + @Description("household/action/get - with operator user ks") + @Test + private void get_with_operatorUser_ks() { + // get household + GetHouseholdBuilder getHouseholdBuilder = get(Math.toIntExact(household.getId())) + .setKs(getOperatorKs()); + Response householdResponse = executor.executeSync(getHouseholdBuilder); + + assertThat(householdResponse.error).isNull(); + assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); + } + + @Description("household/action/get - with invalid household id - error 1006") + @Test + private void get_with_invalid_householdId() { + int invalidHouseholdId = 1; + + // get household + GetHouseholdBuilder getHouseholdBuilder = get(invalidHouseholdId) + .setKs(getOperatorKs()); + Response householdResponse = executor.executeSync(getHouseholdBuilder); + + assertThat(householdResponse.results).isNull(); + assertThat(householdResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1006).getCode()); + } + + @AfterClass + private void household_getTests_afterClass() { + // delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/licensedUrlGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/licensedUrlGetTests.java new file mode 100644 index 000000000..2a369427d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/licensedUrlGetTests.java @@ -0,0 +1,4 @@ +package com.kaltura.client.test.tests.servicesTests.licensedUrlTests; + +public class licensedUrlGetTests { +} diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 1f41ea898..ed302011e 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -85,10 +85,10 @@ public class IngestUtils extends BaseUtils { // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project - public static Response> ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, - Optional programDuration, Optional programDurationPeriodName, - Optional isCridUnique4AllPrograms, Optional seasonCount, - Optional coguid, Optional crid, Optional seriesId) { + public static List ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, + Optional programDuration, Optional programDurationPeriodName, + Optional isCridUnique4AllPrograms, Optional seasonCount, + Optional coguid, Optional crid, Optional seriesId) { int programCountValue = programCount.orElse(EPG_DEFAULT_COUNT_OF_PROGRAMMES); if (programCountValue <= 0) { @@ -192,7 +192,12 @@ public static Response> ingestEPG(String epgChannelName, Opt Response> ingestedProgrammes = executor.executeSync( AssetService.list(assetFilter, null).setKs(getAnonymousKs())); // TODO: complete Asset.json at least for programs - return ingestedProgrammes; + List assets = ingestedProgrammes.results.getObjects(); + List programAssets = new ArrayList<>(); + for (Asset asset: assets) { + programAssets.add((ProgramAsset) asset); + } + return programAssets; } private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 3c484ecfa..82fde978a 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -39,7 +39,7 @@ Migrate services tests from ReadyAPI | favorite | | | followTvSeries | | | homeNetwork | | -| household | | +| household | Alon - in progress | | householdDevice | | | householdLimitations | | | householdPaymentGateway | | @@ -88,7 +88,7 @@ Migrate services tests from ReadyAPI | timeShiftedTvPartnerSettings | | | topic | | | transaction | | -| transactionHistory | | +| transactionHistory | Michael - in progress | | unifiedPayment | | | userAssetRule | | | userAssetsListItem | | From 90496bb6127189d0793616f27443b7e4f95bae4e Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 15:33:43 +0300 Subject: [PATCH 252/605] Added new util to DB utils - "getLinearAssetIdAndEpgChannelNameJsonArray()" --- .../client/test/utils/dbUtils/DBUtils.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 76e00203b..223fd88ed 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -8,7 +8,9 @@ import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; import org.json.JSONObject; + import java.sql.*; + import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; @@ -97,6 +99,20 @@ public static String getResetPasswordToken(String username) { return resetPasswordToken; } + // Get epg channel name and linear asset id json array + public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { + JSONArray jsonArray = null; + try { + jsonArray = getJsonArrayFromQueryResult(String.format(ASSET_ID_SELECT, Integer.valueOf(getProperty(PARTNER_ID)) + 1), false); + if (jsonArray == null || jsonArray.length() <= 0) { + Logger.getLogger("Response is empty"); + } + } catch (Exception e) { + e.printStackTrace(); + } + return jsonArray; + } + // public static List getUserRoles(String userId) { // List userRoles = new ArrayList<>(); @@ -228,7 +244,7 @@ private static void prepareCall(String sql) throws SQLException { * Call Stored Procedure to create role */ public static int insertRole(String role) { - int result =-1; + int result = -1; try { prepareCall(SP_INSERT_ROLE); cStmt.setInt(1, 0); // group_id == 0 @@ -268,7 +284,7 @@ public static void deleteRoleAndItsPermissions(int roleId) { * Call Stored Procedure to insert permissions */ public static int insertPermission(String name, int type, String usersGroup) { - int result =-1; + int result = -1; try { prepareCall(SP_INSERT_PERMISSION); cStmt.setInt(1, 0); // group_id == 0 @@ -309,7 +325,7 @@ public static void deletePermission(int id) { * Call Stored Procedure to insert permission role */ public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { - int result =-1; + int result = -1; try { prepareCall(SP_INSERT_PERMISSION_ROLE); cStmt.setInt(1, 0); // group_id == 0 @@ -334,7 +350,7 @@ public static int insertPermissionRole(long roleId, long permissionId, int isExc * Call Stored Procedure to insert permission item */ public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { - int result =-1; + int result = -1; try { prepareCall(SP_INSERT_PERMISSION_ITEM); cStmt.setString(1, name); @@ -377,10 +393,11 @@ public static void deletePermissionItem(int id) { * Call Stored Procedure to insert permission permission item */ public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { - int result =-1; + int result = -1; try { prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); - cStmt.setInt(1, 0);; // group_id == 0 + cStmt.setInt(1, 0); + ; // group_id == 0 cStmt.setLong(2, permissionId); cStmt.setLong(3, permissionItemId); cStmt.setInt(4, isExcluded); From a7689ff8c0dea167798016edba67a82e1a607b49 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 15:33:58 +0300 Subject: [PATCH 253/605] Added 2 addiotnal varaibles to DB constants --- .../com/kaltura/client/test/utils/dbUtils/DBConstants.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 4591188c6..49db6e656 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -16,6 +16,8 @@ public class DBConstants { static final String PASSWORD = "password"; static final String USERNAME = "username"; static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; + static final String MEDIA_ID = "media_id"; + static final String EPG_CHANNEL_NAME = "name"; //queries static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; @@ -71,6 +73,8 @@ public class DBConstants { static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; + static final String ASSET_ID_SELECT = "SELECT [media_id],[name] FROM [TVinci].[dbo].[epg_channels] WHERE group_id=%d and status=1 and DATALENGTH(media_id) > 0"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; From 651f97bd7fc39aa6806800992c8078b9862f2aac Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 15:34:36 +0300 Subject: [PATCH 254/605] Added new util to Assetutils --- .../kaltura/client/test/utils/AssetUtils.java | 19 ++++++++++++++++--- .../client/test/utils/IngestUtils.java | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index d0b40b0ab..a89717073 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -44,18 +44,31 @@ public static List getAssetFileIds(String assetId) { AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); - GetAssetBuilder getAssetBuilder = AssetService.get(assetId,assetReferenceType); + GetAssetBuilder getAssetBuilder = AssetService.get(assetId, assetReferenceType); getAssetBuilder.setKs(getSharedMasterUserKs()); Response assetResponse = executor.executeSync(getAssetBuilder); - List mediafiles = assetResponse.results.getMediaFiles(); + List mediaFiles = assetResponse.results.getMediaFiles(); List fileIdsList = new ArrayList<>(); - for (MediaFile mediaFile : mediafiles) { + for (MediaFile mediaFile : mediaFiles) { fileIdsList.add(mediaFile.getId()); } return fileIdsList; } + + public static List getAssetsByType(String typeIn) { + AssetFilter assetFilter = getSearchAssetFilter(null, null, typeIn, null, null, null,null); + FilterPager filterPager = new FilterPager(); + filterPager.setPageSize(20); + filterPager.setPageIndex(1); + ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter,filterPager) + .setKs(getSharedMasterUserKs()); + Response> assetResponse = executor.executeSync(listAssetBuilder); + + return assetResponse.results.getObjects(); + } + } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 86f042003..28db4c2a2 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -194,7 +194,7 @@ public static Response> ingestEPG(String epgChannelName, Opt Response> ingestedProgrammes = executor.executeSync( AssetService.list(assetFilter, null).setKs(getAnonymousKs())); - // TODO: complete Asset.json at least for programs + // TODO: complete Asset.json at least for programs+ return ingestedProgrammes; } From 6f6222b0c9c6759d2ded47503a9ff11f473b39bc Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 15:34:56 +0300 Subject: [PATCH 255/605] Updated AssetGetTests class --- .../AssetTests/AssetGetTests.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java index 63dc5afdd..fb59e67d5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java @@ -14,6 +14,9 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + +import static com.kaltura.client.enums.AssetReferenceType.EPG_INTERNAL; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; @@ -22,20 +25,22 @@ public class AssetGetTests extends BaseTest { private Long assetId; private int fileId1; private int fileId2; + Long epgProgram; @BeforeClass - private void bookmark_addTests_before_class() { + private void Asset_get_before_class() { assetId = BaseTest.getSharedMediaAsset().getId(); fileId1 = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); fileId2 = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(1); + epgProgram = BaseTest.getSharedEpgProgram().getId(); + } - @Severity(SeverityLevel.NORMAL) + @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/get - VOD") @Test - - private void get() { + private void getVodAsset() { GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(assetId), AssetReferenceType.MEDIA) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response assetGetResponse = executor.executeSync(getAssetBuilder); @@ -44,4 +49,29 @@ private void get() { assertThat(assetGetResponse.results.getMediaFiles().get(0).getId()).isEqualTo(fileId1); assertThat(assetGetResponse.results.getMediaFiles().get(1).getId()).isEqualTo(fileId2); } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/get - EPG") + @Test + private void getEpgProgram() { + GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(epgProgram), AssetReferenceType.EPG_INTERNAL) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response assetGetResponse = executor.executeSync(getAssetBuilder); + + assertThat(assetGetResponse.results.getId()).isEqualTo(assetId); + assertThat(assetGetResponse.results.getMediaFiles().get(0).getId()).isEqualTo(fileId1); + assertThat(assetGetResponse.results.getMediaFiles().get(1).getId()).isEqualTo(fileId2); + } + + @Severity(SeverityLevel.MINOR) + @Description("Asset/action/get - invalid asset id") + @Test + private void getWithInvalidAssetId() { + GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(assetId + "1"), AssetReferenceType.MEDIA) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response assetGetResponse = executor.executeSync(getAssetBuilder); + + // KalturaAPIException - code: 500007, message: "Asset not found" + assertThat(assetGetResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); + } } From 07e345894eaa176035510425b9429613bc58684a Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 15:35:12 +0300 Subject: [PATCH 256/605] Added EPG ingest util to base test --- .../kaltura/client/test/tests/BaseTest.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 093911039..7edf860b8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -16,6 +16,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; + import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; @@ -51,6 +52,12 @@ public class BaseTest { // shared VOD private static MediaAsset mediaAsset; + // TODO - dynamic + private static String epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); + + //Shared EPG program + private static Asset epgProgram; + // shared files private static MediaFile webMediaFile; private static MediaFile mobileMediaFile; @@ -66,6 +73,7 @@ public class BaseTest { // cycles map with values related view/full life cycles of price plans private static Map cycles = new HashMap<>(); + { // TODO: complete other values cycles.put(1440, "1 Day"); @@ -120,13 +128,13 @@ public void base_test_before_suite() { * Regression requires existing of Price Plan with specific parameters. * Price should be 5 Euros * Discount percent should be equal 100% - * + *

* In case item is not found in DB it will be ingested. * Can't work in case proper Discount and PriceCode aren't found in DB * * @return common shared Price Plan with mentioned parameters */ - public static PricePlan getSharedCommonPricePlan(){ + public static PricePlan getSharedCommonPricePlan() { String defaultCurrency = "EUR"; double defaultDiscountPrice = 0.0; double defaultDiscountPercentValue = 100.0; @@ -145,13 +153,12 @@ public static PricePlan getSharedCommonPricePlan(){ /** * Regression requires existing of MPP with specific parameters. * Price Plan should be as for method public static PricePlan getSharedCommonPricePlan() - * + *

* MPP shouldn't be renewed and with discount (internal items) 100% * - * * @return MPP with mentioned parameters */ - public static Subscription getSharedCommonSubscription(){ + public static Subscription getSharedCommonSubscription() { double defaultDiscountPercentValue = 100.0; String defaultCurrency = "EUR"; if (sharedCommonSubscription == null) { @@ -208,7 +215,7 @@ public static String getAdministratorKs() { if (administratorKs == null) { String[] userInfo = DBUtils.getUserData("Administrator").split(":"); loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], - null,null)); + null, null)); administratorKs = loginResponse.results.getLoginSession().getKs(); } return administratorKs; @@ -218,7 +225,7 @@ public static String getOperatorKs() { if (operatorKs == null) { String[] userInfo = DBUtils.getUserData("Operator").split(":"); loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], - null,null)); + null, null)); operatorKs = loginResponse.results.getLoginSession().getKs(); } return operatorKs; @@ -228,7 +235,7 @@ public static String getManagerKs() { if (managerKs == null) { String[] userInfo = DBUtils.getUserData("Manager").split(":"); loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], - null,null)); + null, null)); managerKs = loginResponse.results.getLoginSession().getKs(); } return managerKs; @@ -250,6 +257,15 @@ public static MediaAsset getSharedMediaAsset() { return mediaAsset; } + public static ProgramAsset getSharedEpgProgram() { + if (epgProgram == null) { + epgProgram = IngestUtils.ingestEPG(epgChannelName, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()).results.getObjects().get(0); + } + return (ProgramAsset) epgProgram; + } + + public static MediaFile getSharedWebMediaFile() { if (webMediaFile == null) { if (getProperty(WEB_FILE_TYPE).equals(getSharedMediaAsset().getMediaFiles().get(0).getType())) { @@ -312,11 +328,11 @@ public static Household getSharedHousehold() { } String sharedMasterUserName = getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(); - loginResponse = executor.executeSync(login(partnerId, sharedMasterUserName, defaultUserPassword,null,null)); + loginResponse = executor.executeSync(login(partnerId, sharedMasterUserName, defaultUserPassword, null, null)); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); String sharedUserName = getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(); - loginResponse = executor.executeSync(login(partnerId, sharedUserName, defaultUserPassword,null,null)); + loginResponse = executor.executeSync(login(partnerId, sharedUserName, defaultUserPassword, null, null)); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } return sharedHousehold; From 19a0c3a18f557eda8e903066a5c8be8f37c8ef6f Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 15:53:03 +0300 Subject: [PATCH 257/605] Added programAsset.json schema --- src/test/resources/schemas/ProgramAsset.json | 138 +++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 src/test/resources/schemas/ProgramAsset.json diff --git a/src/test/resources/schemas/ProgramAsset.json b/src/test/resources/schemas/ProgramAsset.json new file mode 100644 index 000000000..188be0f8b --- /dev/null +++ b/src/test/resources/schemas/ProgramAsset.json @@ -0,0 +1,138 @@ +{ + "$id": "ProgramAsset", + "type": "object", + "definitions": { + "ProgramAsset": { + "type": "object", + "properties": { + "epgChannelId": { + "type": "integer", + "minimum": 0 + }, + "epgId": { + "type": "string", + "minLength": 0 + }, + "relatedMediaId": { + "type": "integer", + "minimum": 0 + }, + "crid": { + "type": "string", + "minLength": 0 + }, + "linearAssetId": { + "type": "integer", + "minimum": 0 + }, + "id": { + "type": "integer", + "minimum": 0 + }, + "type": { + "type": "integer", + "minimum": 0 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "description": { + "type": "string", + "minLength": 0 + }, + "images": { + "type": "array" + }, + "metas": { + "type": "object", + "properties": { + "season_num": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "Series_ID": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "Episode number": { + "type": "object", + "properties": { + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + } + } + }, + "tags": { + "type": "object" + }, + "startDate": { + "type": "integer", + "minimum": 0 + }, + "endDate": { + "type": "integer", + "minimum": 0 + }, + "enableCdvr": { + "type": "boolean" + }, + "enableCatchUp": { + "type": "boolean" + }, + "enableStartOver": { + "type": "boolean" + }, + "enableTrickPlay": { + "type": "boolean" + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "epgChannelId", + "epgId", + "type", + "name", + "startDate", + "endDate" + ] + } + }, + "properties": { + "result": { + "ref":"#/definitions/ProgramAsset" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From 477e3d28683a1d962fbad7ccf0306feb3a32bbc2 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 16:18:44 +0300 Subject: [PATCH 258/605] Added new util to DB util - "getUnActiveAsset" --- .../kaltura/client/test/utils/dbUtils/DBUtils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index cfb980c9a..a06bfd5c3 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -113,6 +113,20 @@ public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { return jsonArray; } + // Get un active asset from DB (status = 2) + public static int getUnActiveAsset() { + int assetId = 0; + + try { + assetId = getJsonArrayFromQueryResult(String.format(UNACTIVE_ASSET_ID_SELECT, + Integer.valueOf(getProperty(PARTNER_ID)) + 1), false).getJSONObject(0).getInt("id"); + } catch (Exception e) { + e.printStackTrace(); + } + + return assetId; + } + // public static List getUserRoles(String userId) { // List userRoles = new ArrayList<>(); From 894e27ea98f74c8e6028c655f032bd2855cf88a9 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 16:19:11 +0300 Subject: [PATCH 259/605] Added constants to DBcontstants class - for getUnActiveAsset() util --- .../java/com/kaltura/client/test/utils/dbUtils/DBConstants.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 0ae2adf57..073619f8a 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -106,6 +106,8 @@ public class DBConstants { static final String ASSET_ID_SELECT = "SELECT [media_id],[name] FROM [TVinci].[dbo].[epg_channels] WHERE group_id=%d and status=1 and DATALENGTH(media_id) > 0"; + static final String UNACTIVE_ASSET_ID_SELECT = "SELECT top 1 [id] FROM [TVinci].[dbo].[media] where group_id = %d and status = 2"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; From 9beaf6a1a451e8cd7477fb6b7975a5bba096f684 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 23 May 2018 16:19:35 +0300 Subject: [PATCH 260/605] Work completed on class AssetGetTests --- .../AssetTests/AssetGetTests.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java index fb59e67d5..43f9f33c1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java @@ -6,6 +6,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.Asset; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -15,7 +16,6 @@ import org.testng.annotations.Test; -import static com.kaltura.client.enums.AssetReferenceType.EPG_INTERNAL; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; @@ -25,7 +25,7 @@ public class AssetGetTests extends BaseTest { private Long assetId; private int fileId1; private int fileId2; - Long epgProgram; + private Long epgProgram; @BeforeClass @@ -50,6 +50,7 @@ private void getVodAsset() { assertThat(assetGetResponse.results.getMediaFiles().get(1).getId()).isEqualTo(fileId2); } + @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/get - EPG") @Test @@ -58,9 +59,22 @@ private void getEpgProgram() { .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response assetGetResponse = executor.executeSync(getAssetBuilder); - assertThat(assetGetResponse.results.getId()).isEqualTo(assetId); - assertThat(assetGetResponse.results.getMediaFiles().get(0).getId()).isEqualTo(fileId1); - assertThat(assetGetResponse.results.getMediaFiles().get(1).getId()).isEqualTo(fileId2); + assertThat(assetGetResponse.results.getId()).isEqualTo(epgProgram); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/get - unactive vod") + @Test + private void getUnactiveVodAsset() { + + int unactiveAssetId = DBUtils.getUnActiveAsset(); + + GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(unactiveAssetId), AssetReferenceType.MEDIA) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response assetGetResponse = executor.executeSync(getAssetBuilder); + + // KalturaAPIException - code: 500007, message: "Asset not found" + assertThat(assetGetResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); } @Severity(SeverityLevel.MINOR) From fbdefd0ab54fcea321e764d55190aaa3d829caa4 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 23 May 2018 16:22:43 +0300 Subject: [PATCH 261/605] Added group for "Permission management" tests --- .../PermissionsManagementTests.java | 42 ++++++++++++------- src/test/resources/testng.xml | 1 + 2 files changed, 28 insertions(+), 15 deletions(-) rename src/test/java/com/kaltura/client/test/tests/featuresTests/{ => versions}/four_eight/PermissionsManagementTests.java (84%) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java similarity index 84% rename from src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagementTests.java rename to src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index ad829a02e..da152dc6b 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -1,7 +1,9 @@ -package com.kaltura.client.test.tests.featuresTests.four_eight; +package com.kaltura.client.test.tests.featuresTests.versions.four_eight; import com.kaltura.client.test.utils.PermissionManagementUtils; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -23,11 +25,11 @@ * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 */ public class PermissionsManagementTests { - // TODO: discuss where to save these values + + String mainFile = "PermissionsDeployment.exe"; String path2Log = "C:\\log\\permissions\\permissions.log"; String path2Util = "C:\\123\\222\\"; String path2EmptyFile = path2Util + "333\\" + "empty_file.txt"; - String mainFile = "PermissionsDeployment.exe"; String dataFilePath = path2Util + "333\\" + "exp1.txt"; String generatedDataFilePath = path2Util + "333\\" + "import.txt"; String importOnly4TablesFilePath = path2Util + "333\\" + "importOnly4Tables.txt"; @@ -36,7 +38,7 @@ public class PermissionsManagementTests { public static final String IMPORT_KEY = "i="; public static final String DELETE_KEY = "d="; - @Test(enabled = false, description = "just for deletion") + @Test(groups = {"Permission management"}, description = "just for deletion") public void deleteData() { //long roleId = 477L; long permissionId = 32L; @@ -49,7 +51,8 @@ public void deleteData() { PermissionsManagementDBUtils.deletePermissionPermissionItem((int)permissionPermissionItemId);*/ } - @Test(enabled = false, description = "execute console util without parameters") + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util without parameters") public void runningWithoutParameters() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); @@ -60,7 +63,8 @@ public void runningWithoutParameters() { assertThat(consoleOutput).contains("Shortcut: i"); } - @Test(enabled = false, description = "execute console util to export without mentioned file") + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") public void runningExportWithoutFile() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); @@ -70,7 +74,8 @@ public void runningExportWithoutFile() { assertThat(consoleOutput).contains("The system cannot find the file specified"); } - @Test(enabled = false, description = "execute console util to import without mentioned file") + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") public void runningImportWithoutFile() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); @@ -80,7 +85,8 @@ public void runningImportWithoutFile() { assertThat(consoleOutput).contains("The system cannot find the file specified"); } - @Test(enabled = false, description = "execute console util to delete without mentioned file") + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") public void runningDeleteWithoutFile() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); @@ -90,7 +96,8 @@ public void runningDeleteWithoutFile() { assertThat(consoleOutput).contains("The system cannot find the file specified"); } - @Test(enabled = false, description = "execute console util to export data from DB into file") + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") public void export() { // prepare data inserting them in DB using stored procedures String suffix = String.valueOf(getTimeInEpoch(0)); @@ -112,7 +119,8 @@ public void export() { assertThat(fileContent).contains("parameter" + suffix); } - @Test(enabled = false, description = "execute console util to import data into DB from file having only 4 tables instead of 5") + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from file having only 4 tables instead of 5") public void runningImportFromFileNotHavingAllTables() { // remove log file deleteFile(path2Log); @@ -127,7 +135,8 @@ public void runningImportFromFileNotHavingAllTables() { assertThat(fileContent).contains("Import failed: reading from XML resulted in empty data set or data set with less than 5 tables"); } - @Test(enabled = false, description = "execute console util to try import data into DB from empty file") + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to try import data into DB from empty file") public void runningImportFromEmptyFile() { // remove log file deleteFile(path2Log); @@ -142,7 +151,8 @@ public void runningImportFromEmptyFile() { assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); } - @Test(enabled = false, description = "execute console util to try delete data from DB using empty file") + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to try delete data from DB using empty file") public void runningDeleteUsingEmptyFile() { // remove log file deleteFile(path2Log); @@ -157,7 +167,8 @@ public void runningDeleteUsingEmptyFile() { assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); } - @Test(enabled = false, description = "execute console util to import data into DB from valid file") + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") public void importFromFile() { String suffix = String.valueOf(getTimeInEpoch(0)); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", @@ -191,7 +202,8 @@ public void importFromFile() { assertThat(rowsInPermissionsPermissions).isEqualTo(1); } - @Test(enabled = false, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"Permission management"}, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { // remove log file deleteFile(path2Log); @@ -223,7 +235,7 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { } // TODO: check how to use it - @Test(enabled = false) + @Test(enabled = false, groups = {"Permission management"}) public void readXMLFile() throws ParserConfigurationException, IOException, SAXException { File file = new File(dataFilePath); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index a8f715a82..0c943be1b 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -5,6 +5,7 @@ + From 104bda740613ab0ae9386aacf1274fe444253a5c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 23 May 2018 16:45:29 +0300 Subject: [PATCH 262/605] Added test checking removing from DB --- .../PermissionsManagementTests.java | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index da152dc6b..005358da0 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -233,7 +233,61 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { assertThat(fileContent).contains("permissionItemObject" + suffix); assertThat(fileContent).contains("parameter" + suffix); } - + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") + public void deleteFromDB() { + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(1); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + + int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); + assertThat(idRolePermission).isEqualTo(1); + + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + + int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, + idPermissionItemHavingName, 0); + assertThat(rowsInPermissionsPermissions).isEqualTo(1); + + // remove log file + deleteFile(path2Log); + + // delete from DB + commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // DB should be empty + rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(0); + + rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(0); + + rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); + } + // TODO: check how to use it @Test(enabled = false, groups = {"Permission management"}) public void readXMLFile() throws ParserConfigurationException, IOException, SAXException { From 6b57774f2b38a2f7e3724ad1516693d4b8d59dae Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 24 May 2018 09:07:57 +0300 Subject: [PATCH 263/605] add householdDeleteTests --- .../householdTests/householdAddTests.java | 14 ++++-- .../householdTests/householdDeleteTests.java | 50 +++++++++++++++++++ .../householdTests/householdGetTests.java | 6 +++ .../client/test/utils/IngestUtils.java | 8 +-- 4 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java index 12babcf2e..9b35b085a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java @@ -1,17 +1,22 @@ package com.kaltura.client.test.tests.servicesTests.householdTests; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.Household; import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.HouseholdService.add; import static com.kaltura.client.services.HouseholdService.delete; +import static org.assertj.core.api.Assertions.assertThat; public class householdAddTests extends BaseTest { @@ -27,7 +32,8 @@ private void household_addTests_beforeClass() { masterUser = HouseholdUtils.getMasterUserFromHousehold(household); } - @Description("household/action/add - master user exists in other household") + @Severity(SeverityLevel.NORMAL) + @Description("household/action/add - master user exists in other household - error 1018") @Test private void add_with_exists_in_other_household_masterUser() { // create household @@ -37,10 +43,10 @@ private void add_with_exists_in_other_household_masterUser() { // add household String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); - executor.executeSync(add(household).setKs(masterUserKs)); - - // TODO: 5/23/2018 finsih test + Response householdResponse = executor.executeSync(add(household).setKs(masterUserKs)); + assertThat(householdResponse.results).isNull(); + assertThat(householdResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1018).getCode()); } @AfterClass diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java new file mode 100644 index 000000000..0cbd4d6ed --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java @@ -0,0 +1,50 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.services.HouseholdService.get; +import static org.assertj.core.api.Assertions.assertThat; + +public class householdDeleteTests extends BaseTest { + + private Household household; + private HouseholdUser masterUser; + + @BeforeClass + private void household_deleteTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 1; + int numberOfDevicesInHousehold = 1; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + } + + @Severity(SeverityLevel.NORMAL) + @Description("household/action/delete - master user household delete") + @Test + private void delete_with_household_masterUser() { + // delete household + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + Response booleanResponse = executor.executeSync(delete().setKs(masterUserKs)); + + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // get household + Response householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + + assertThat(householdResponse.results).isNull(); + assertThat(householdResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1006).getCode()); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java index bc1a5a190..358572063 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java @@ -8,6 +8,8 @@ import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -27,6 +29,7 @@ private void household_getTests_beforeClass() { household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); } + @Severity(SeverityLevel.CRITICAL) @Description("household/action/get - with master user ks") @Test private void get_with_masterUser_ks() { @@ -43,6 +46,7 @@ private void get_with_masterUser_ks() { assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); } + @Severity(SeverityLevel.CRITICAL) @Description("household/action/get - with regular user ks") @Test private void get_with_regularUser_ks() { @@ -59,6 +63,7 @@ private void get_with_regularUser_ks() { assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); } + @Severity(SeverityLevel.CRITICAL) @Description("household/action/get - with operator user ks") @Test private void get_with_operatorUser_ks() { @@ -71,6 +76,7 @@ private void get_with_operatorUser_ks() { assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); } + @Severity(SeverityLevel.MINOR) @Description("household/action/get - with invalid household id - error 1006") @Test private void get_with_invalid_householdId() { diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index ed302011e..06279906d 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -192,12 +192,8 @@ public static List ingestEPG(String epgChannelName, Optional> ingestedProgrammes = executor.executeSync( AssetService.list(assetFilter, null).setKs(getAnonymousKs())); // TODO: complete Asset.json at least for programs - List assets = ingestedProgrammes.results.getObjects(); - List programAssets = new ArrayList<>(); - for (Asset asset: assets) { - programAssets.add((ProgramAsset) asset); - } - return programAssets; + + return (List) (Object) ingestedProgrammes.results.getObjects(); } private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { From 19f102777f09ed969222732efe8a40ff6eeb4c83 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 24 May 2018 09:26:45 +0300 Subject: [PATCH 264/605] Updated work plan --- .../servicesTests/AssetTests/AssetListTests.java | 4 ++++ src/test/resources/WORK_PLAN.md | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java new file mode 100644 index 000000000..bee5a3e2b --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -0,0 +1,4 @@ +package com.kaltura.client.test.tests.servicesTests.AssetTests; + +public class AssetListTests { +} diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 82fde978a..34c6bec69 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -5,19 +5,19 @@ Migrate services tests from ReadyAPI | Service | Status | |------------------------------|--------| | announcement | | -| appToken | | -| asset | | -| assetComment | | +| appToken | Done | +| asset | Shmulik - in progress | +| assetComment | Done | | assetFile | | -| assetHistory | | +| assetHistory | Done | | assetRule | | | assetStatistics | | | assetUserRule | | -| bookmark | | +| bookmark | Done | | cDVRAdapterProfile | | | cdnAdapterProfile | | | cdnPartnerSettings | | -| channel | | +| channel | Shmulik - in progress | | collection | | | compensation | | | configurationGroup | | @@ -77,7 +77,7 @@ Migrate services tests from ReadyAPI | report | | | searchHistory | | | seriesRecording | | -| session | | +| session | Done | | social | | | socialAction | | | socialComment | | From 2219f6f70e1560249b09a4ab3f2fbd4df8720e0e Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 24 May 2018 09:28:55 +0300 Subject: [PATCH 265/605] Updated class - "ChannelAddTests.java --- .../servicesTests/channelTests/ChannelAddTests.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index b7edc5fb5..d621d515c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.ChannelUtils; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; @@ -78,10 +77,11 @@ private void checkOrderOfAssetsInChannel() { int channelId = Math.toIntExact(channelResponse.results.getId()); - ChannelFilter channelFilter = AssetUtils.getChannelFilter(channelId, null, null, null); + ChannelFilter channelFilter = AssetUtils.getChannelFilter(channelId, Optional.empty(), Optional.empty(), Optional.empty()); //asset/action/list - ListAssetBuilder listAssetBuilder = AssetService.list(channelFilter).setKs(getManagerKs()); + ListAssetBuilder listAssetBuilder = AssetService.list(channelFilter) + .setKs(getManagerKs()); Response> listResponse = executor.executeSync(listAssetBuilder); assertThat(listResponse.results.getTotalCount()).isEqualTo(2); @@ -101,7 +101,8 @@ private void addChannelWithInvalidAssetType() { channel = ChannelUtils.addChannel(channelName, Description, isActive, null, AssetOrderBy.LIKES_DESC, assetTypes, null); //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel) + .setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); // KalturaAPIException","code":"4020","message":"KSQL Channel media type 666 does not belong to group" @@ -114,7 +115,8 @@ private void addChannelWithNoName() { channel = ChannelUtils.addChannel(null, Description, isActive, null, AssetOrderBy.LIKES_DESC, null, null); //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel) + .setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); // KalturaAPIException","code":"5005","message":"KSQL Channel must have a name" From ca8586f0100b74b22a1f64c3da84bc5444045c20 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 24 May 2018 10:45:43 +0300 Subject: [PATCH 266/605] Added processing of tags and metas for ingest VOD util --- .../kaltura/client/test/tests/BaseTest.java | 3 +- .../AssetCommentListTests.java | 3 +- .../client/test/utils/IngestUtils.java | 215 +++++++++++++----- 3 files changed, 162 insertions(+), 59 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 093911039..ac6c142f3 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -245,7 +245,8 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); } return mediaAsset; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index ed7a7037c..a530f0b7c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -46,7 +46,8 @@ private void checkCommentsOrder() { String text = "A lot of text"; Long assetId = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(MOVIE_MEDIA_TYPE)), Optional.empty(), Optional.empty()).getId(); + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(MOVIE_MEDIA_TYPE)), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()).getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index ed302011e..e1ecdf6e6 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -760,6 +760,10 @@ private static String buildIngestPpvXML(String action, String ppvCode, boolean i * @param mediaType * @param ppvWebName * @param ppvMobileName + * @param tags + * @param strings + * @param numbers + * @param dates * @return to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" * (where vod is a variable that contains VOD data) *

@@ -768,7 +772,9 @@ private static String buildIngestPpvXML(String action, String ppvCode, boolean i // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project public static MediaAsset ingestVOD(Optional action, Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, - Optional mediaType, Optional ppvWebName, Optional ppvMobileName) { + Optional mediaType, Optional ppvWebName, Optional ppvMobileName, + Optional>> tags, Optional> strings, + Optional> numbers, Optional> dates) { String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; String coguidDatePattern = "yyMMddHHmmssSS"; String maxEndDateValue = "14/10/2099 17:00:00"; @@ -787,6 +793,10 @@ public static MediaAsset ingestVOD(Optional action, Optional cog String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); String ppvMobileNameValue = ppvMobileName.orElse(ppvModuleName); + Map> tagsValue = tags.orElse(getDefaultTags()); + Map stringsValue = strings.orElse(getDefaultStrings()); + Map numbersValue = numbers.orElse(getDefaultNumbers()); + Map datesValue = dates.orElse(getDefaultDates()); // TODO: check if ingest url is the same for all ingest actions String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headerMap = new HashMap<>(); @@ -797,7 +807,7 @@ public static MediaAsset ingestVOD(Optional action, Optional cog " \n" + " " + getIngestAssetUserName() + "" + getIngestAssetUserPassword() + "" + " \n" + " \n" + ""; @@ -836,6 +846,56 @@ public static MediaAsset ingestVOD(Optional action, Optional cog return mediaAsset; } + // TODO: these values should be get in another way than now + private static Map> getDefaultTags() { + Map> tags = new HashMap<>(); + List tagValues = new ArrayList<>(); + tagValues.add("Costa Rica;Israel"); + tags.put("Country", tagValues); + tagValues = new ArrayList<>(); + tagValues.add("GIH"); + tagValues.add("ABC"); + tagValues.add("DEF"); + tags.put("Genre", tagValues); + tagValues = new ArrayList<>(); + tagValues.add("Shay_Series"); + tags.put("Series name", tagValues); + tagValues = new ArrayList<>(); + tagValues.add("KSQL channel_573349"); + tags.put("Free", tagValues); + tagValues = new ArrayList<>(); + tags.put("Parental Rating", tagValues); + /*tagValues = new ArrayList<>(); + tags.put("", tagValues);*/ + + return tags; + } + + // TODO: these values should be get in another way than now + private static Map getDefaultStrings() { + Map strings = new HashMap<>(); + strings.put("Synopsis", "syno pino sister"); + strings.put("meta_name", "meta_value"); + + return strings; + } + + // TODO: these values should be get in another way than now + private static Map getDefaultNumbers() { + Map doubles = new HashMap<>(); + doubles.put("Release year", 1900); + + return doubles; + } + + // TODO: these values should be get in another way than now + private static Map getDefaultDates() { + Map dates = new HashMap<>(); + dates.put("Life cycle start date", "23/03/2017 12:34:56"); + + return dates; + } + private static Callable isDataReturned(String ks, String mediaId, String action) { GetAssetBuilder getAssetBuilder = AssetService.get(mediaId, AssetReferenceType.MEDIA).setKs(ks); if (INGEST_ACTION_DELETE.equals(action)) { @@ -848,7 +908,8 @@ private static Callable isDataReturned(String ks, String mediaId, Strin private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, String startDate, String endDate, String mediaType, String ppvWebName, - String ppvMobileName) { + String ppvMobileName, Map> tags, + Map strings, Map numbers, Map dates) { return "\n" + " \n" + " \n" + @@ -879,59 +940,11 @@ private static String buildIngestVodXml(String action, String coguid, boolean is " \n" + " \n" + " \n" + - //" \n" + - //" \n" + - //" syno pino sister\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_double_meta_value}\n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_date_meta_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Costa Rica;Israel\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" GIH\n" + - //" \n" + - //" \n" + - //" ABC\n" + - //" \n" + - //" \n" + - //" DEF\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" Shay_Series\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_free_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_parental_value}\n" + - //" \n" + - //" \n" + - //" \n" + - //" \n" + - //" ${#TestCase#i_tag_value}\n" + - //" \n" + - //" \n" + - //" \n" + + generateStringsXml(strings) + + " \n" + + generateNumbersXml(numbers) + + generateDatesXml(dates) + + generateTagsXml(tags) + "\n" + " \n" + " \n" + " \n" + @@ -942,10 +955,98 @@ private static String buildIngestVodXml(String action, String coguid, boolean is ""; } + private static String generateNumbersXml(Map numbers) { + if (numbers.isEmpty()) { + return ""; + } + StringBuilder result = new StringBuilder(); + String key; + int value; + result.append(" \n"); + for(Map.Entry entry : numbers.entrySet()) { + key = entry.getKey(); + value = entry.getValue(); + result.append("" + value + "\n"); + } + result.append(" \n"); + + return result.toString(); + } + + private static String getMetaXml(String key, String value) { + StringBuilder sb = new StringBuilder(); + sb.append(" \n"); + sb.append(" " + value + "\n"); + sb.append(" \n"); + + return sb.toString(); + } + + private static String generateStringsXml(Map strings) { + if (strings.isEmpty()) { + return ""; + } + StringBuilder result = new StringBuilder(); + String key, value; + result.append(" \n"); + for(Map.Entry entry : strings.entrySet()) { + key = entry.getKey(); + value = entry.getValue(); + result.append(" \n"); + result.append(" " + value + "\n"); + result.append(" \n"); + //result.append(getMetaXml(key, value)); + } + result.append(" \n"); + + return result.toString(); + } + + private static String generateDatesXml(Map dates) { + if (dates.isEmpty()) { + return ""; + } + StringBuilder result = new StringBuilder(); + String key, value; + result.append(" \n"); + for(Map.Entry entry : dates.entrySet()) { + key = entry.getKey(); + value = entry.getValue(); + result.append("" + value + "\n"); + } + result.append(" \n"); + + return result.toString(); + } + + private static String generateTagsXml(Map> metas) { + if (metas.isEmpty()) { + return ""; + } + StringBuilder result = new StringBuilder(); + String key; + List values; + result.append(" \n"); + for(Map.Entry> entry : metas.entrySet()) { + key = entry.getKey(); + values = entry.getValue(); + result.append(" \n"); + for (String value: values) { + result.append(" \n"); + result.append(" " + value + "\n"); + result.append(" \n"); + } + result.append(" \n"); + } + result.append(" \n"); + + return result.toString(); + } + // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) public static MediaAsset ingestBasicVOD(String name, String mediaType) { MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.of(name), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty()); + Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); return mediaAsset; } }; From ecc8dd6f9dd03d919f2bd6bc9ed599fd936391fb Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 24 May 2018 13:59:38 +0300 Subject: [PATCH 267/605] Completed PermissionManagement task --- .../PermissionsManagementTests.java | 99 ++++++++++++++++++- .../test/utils/PermissionManagementUtils.java | 44 ++++++++- .../dbUtils/PermissionsManagementDBUtils.java | 8 +- src/test/resources/WORK_PLAN.md | 2 +- .../permission_management_data/empty_file.txt | 0 .../importOnly4Tables.txt | 30 ++++++ 6 files changed, 171 insertions(+), 12 deletions(-) create mode 100644 src/test/resources/permission_management_data/empty_file.txt create mode 100644 src/test/resources/permission_management_data/importOnly4Tables.txt diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 005358da0..579b80362 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -27,12 +28,26 @@ public class PermissionsManagementTests { String mainFile = "PermissionsDeployment.exe"; + // that file generated automatically String path2Log = "C:\\log\\permissions\\permissions.log"; String path2Util = "C:\\123\\222\\"; - String path2EmptyFile = path2Util + "333\\" + "empty_file.txt"; + + // these files are generated String dataFilePath = path2Util + "333\\" + "exp1.txt"; String generatedDataFilePath = path2Util + "333\\" + "import.txt"; - String importOnly4TablesFilePath = path2Util + "333\\" + "importOnly4Tables.txt"; + + // these files added into project + String importOnly4TablesFilePath; + String path2EmptyFile; + + @BeforeClass + public void setUp() { + ClassLoader classLoader = PermissionsManagementTests.class.getClassLoader(); + File file = new File(classLoader.getResource("permission_management_data/empty_file.txt").getFile()); + path2EmptyFile = file.getAbsolutePath(); + file = new File(classLoader.getResource("permission_management_data/importOnly4Tables.txt").getFile()); + importOnly4TablesFilePath = file.getAbsolutePath(); + } public static final String EXPORT_KEY = "e="; public static final String IMPORT_KEY = "i="; @@ -288,6 +303,86 @@ public void deleteFromDB() { assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); } + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") + public void importAlreadyExistedFromFile() { + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // retry import + executeCommandsInColsole(commands); + + // check data in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(1); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + + int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); + assertThat(idRolePermission).isEqualTo(1); + + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + + int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, + idPermissionItemHavingName, 0); + assertThat(rowsInPermissionsPermissions).isEqualTo(1); + } + + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") + public void runningDeleteUsingFileWithInvalidTags() { + // insert role in DB + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); + + // try delete + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data still in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + } + + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") + public void deleteOnlyFromOneTable() { + // insert role in DB + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + PermissionManagementUtils.generateFileForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); + + // delete + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data deleted from DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(0); + } + // TODO: check how to use it @Test(enabled = false, groups = {"Permission management"}) public void readXMLFile() throws ParserConfigurationException, IOException, SAXException { diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index 41b92c9d1..be97f5558 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -59,7 +59,6 @@ public static void printRole(PrintWriter writer, Long roleId, String roleName) { writer.println(""); } - public static String executeCommandsInColsole(List commands) { StringBuilder output = new StringBuilder(); @@ -100,14 +99,51 @@ public static void generateFileWithInsertedIntoDBData(String path2ResultFile, St try { File file = new File(path2ResultFile); PrintWriter writer = new PrintWriter(file); - writer.println(""); - writer.println(""); + printOpenTag(writer); printRole(writer, roleId, role); printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); printPermission(writer, permissionId, role, 2, usersGroup); printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); - writer.println(""); + printCloseTag(writer); + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + public static void generateFileWithInvalidTagForRole(String path2ResultFile, String roleName, int roleId) { + try { + File file = new File(path2ResultFile); + PrintWriter writer = new PrintWriter(file); + printOpenTag(writer); + writer.println(""); // this 1 here to make tag invalid + writer.println("" + roleId + ""); + writer.println("" + roleName + ""); + writer.println(""); // this 1 here to make tag invalid + printCloseTag(writer); + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + private static void printOpenTag(PrintWriter writer) { + writer.println(""); + writer.println(""); + } + + private static void printCloseTag(PrintWriter writer) { + writer.println(""); + } + + public static void generateFileForRole(String path2ResultFile, String roleName, long roleId) { + try { + File file = new File(path2ResultFile); + PrintWriter writer = new PrintWriter(file); + printOpenTag(writer); + printRole(writer, roleId, roleName); + printCloseTag(writer); writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java index 4c69dd407..b7dc87705 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java @@ -199,8 +199,6 @@ public static void deletePermissionPermissionItem(int id) { public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { int count = 0; try { - System.out.println(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, - name, groupId)); JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, name, groupId), true); if (!jsonArray.isNull(0)) { @@ -214,18 +212,18 @@ public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { } public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { - int count =-1; + int id =-1; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT, name, groupId), true); if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + id = jsonArray.getJSONObject(0).getInt(ID); } } catch (Exception e) { e.printStackTrace(); } - return count; + return id; } public static int getCountRowsHavingRoleNameInPermissions(String name, int groupId) { diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 82fde978a..2f6ef72d2 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -67,7 +67,7 @@ Migrate services tests from ReadyAPI | ppv | | | priceDetails | | | pricePlan | | -| productPrice | | +| productPrice | Max - in progress | | purchaseSettings | | | recommendationProfile | | | recording | | diff --git a/src/test/resources/permission_management_data/empty_file.txt b/src/test/resources/permission_management_data/empty_file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/src/test/resources/permission_management_data/importOnly4Tables.txt b/src/test/resources/permission_management_data/importOnly4Tables.txt new file mode 100644 index 000000000..fcd358f48 --- /dev/null +++ b/src/test/resources/permission_management_data/importOnly4Tables.txt @@ -0,0 +1,30 @@ + + + + 485 + MaxTest1526998432 + + + 637 + 485 + 33 + 0 + MaxTest1526998432 + MaxTest1526998432 + + + 33 + MaxTest1526998432 + 2 + partner* + + + 548 + Asset_List_Max1526998432 + 1 + asset + list + permissionItemObject1526998432 + parameter1526998432 + + From 0cb089ccdafe3724b8534f96f4220ac1592fe149 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 24 May 2018 14:27:13 +0300 Subject: [PATCH 268/605] Updated class AssetGetTests --- .../AssetTests/AssetGetTests.java | 3 +- .../AssetTests/AssetListTests.java | 77 ++++++++++++++++++- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java index 43f9f33c1..76d1cd958 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetGetTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.AssetTests; - import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; @@ -63,7 +62,7 @@ private void getEpgProgram() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/get - unactive vod") + @Description("Asset/action/get - un active vod") @Test private void getUnactiveVodAsset() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java index bee5a3e2b..72bc1f042 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -1,4 +1,79 @@ package com.kaltura.client.test.tests.servicesTests.AssetTests; -public class AssetListTests { +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.AssetFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +import java.util.Optional; + +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.services.AssetService.*; + +public class AssetListTests extends BaseTest { + + MediaAsset assetId; + String ksqlQuery; + + @BeforeClass + private void Asset_list_before_class() { + assetId = BaseTest.getSharedMediaAsset(); + ksqlQuery = "name = '" + assetId.getName() + "'"; + } + + // KalturaSearchAssetFilter + // ****************************************** + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - equal query") + @Test + private void listVodAssetsWithExactKsqlQuery() { + AssetFilter assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, + null,null); + ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter,null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + } + + // TODO - complete test after ingest util was updated + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - not like query") + @Test + private void listVodAssetsWithNotLikeKsqlQuery() { + + } + + // TODO - complete test after ingest util was updated + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - like query") + @Test + private void listVodAssetsWithLikeKsqlQuery() { + + } + + // TODO - complete test after ingest util was updated + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - start with query") + @Test + private void listVodAssetsWithStartWithKsqlQuery() { + + } + + + + } From 91fc2a32e8aeca4a29e9ef815af614886190e7ae Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 24 May 2018 15:04:18 +0300 Subject: [PATCH 269/605] Updated class AssetListsTests - added several tests --- .../AssetTests/AssetListTests.java | 68 +++++++++++++++---- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java index 72bc1f042..3c9f87ab3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.servicesTests.AssetTests; -import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; @@ -17,43 +16,78 @@ import org.testng.annotations.Test; -import java.util.Optional; - -import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; public class AssetListTests extends BaseTest { - MediaAsset assetId; - String ksqlQuery; + private MediaAsset asset; + private MediaAsset asset2; + private String ksqlQuery; + private AssetFilter assetFilter = null; + private ListAssetBuilder listAssetBuilder = null; @BeforeClass private void Asset_list_before_class() { - assetId = BaseTest.getSharedMediaAsset(); - ksqlQuery = "name = '" + assetId.getName() + "'"; + // Get asset from shared asset method + asset = BaseTest.getSharedMediaAsset(); + // Ingest asset2 + asset2 = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); + + ksqlQuery = "name = '" + asset.getName() + "'"; + } // KalturaSearchAssetFilter // ****************************************** @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - equal query") + @Description("Asset/action/list - VOD - name equal query") @Test private void listVodAssetsWithExactKsqlQuery() { - AssetFilter assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, + null,null); + listAssetBuilder = AssetService.list(assetFilter,null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - id equal query") + @Test + private void listVodAssetsWithExactKsqlQuery2() { + ksqlQuery = "media_id = '" + asset.getId() + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, + null,null); + listAssetBuilder = AssetService.list(assetFilter,null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - or query") + @Test + private void listVodAssetsWithOrQuery() { + ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, null,null); - ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter,null) + listAssetBuilder = AssetService.list(assetFilter,null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); } + // TODO - complete test after ingest util was updated @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - not like query") + @Description("Asset/action/list - VOD - not query") @Test - private void listVodAssetsWithNotLikeKsqlQuery() { + private void listVodAssetsWithNotKsqlQuery() { } @@ -62,7 +96,13 @@ private void listVodAssetsWithNotLikeKsqlQuery() { @Description("Asset/action/list - VOD - like query") @Test private void listVodAssetsWithLikeKsqlQuery() { - + ksqlQuery = "name ~ '" + asset.getName() + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, + null,null); + listAssetBuilder = AssetService.list(assetFilter,null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); } // TODO - complete test after ingest util was updated From 598d87a50d000a82441a3ea01bd7750ccf515bdc Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 27 May 2018 09:16:26 +0300 Subject: [PATCH 270/605] household subscription suspend tests --- .../kaltura/client/test/tests/BaseTest.java | 6 +- .../householdTests/householdDeleteTests.java | 37 ++++-- .../householdTests/householdSuspendTests.java | 119 ++++++++++++++++++ .../ottUserTests/OttUserListTests.java | 10 +- .../ottUserTests/OttUserLoginTests.java | 6 +- .../client/test/utils/OttUserUtils.java | 4 +- .../client/test/utils/SubscriptionUtils.java | 39 ++++++ 7 files changed, 196 insertions(+), 25 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java create mode 100644 src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 093911039..6556605b2 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -23,7 +23,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; -import static com.kaltura.client.test.utils.OttUserUtils.getUserById; +import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -311,11 +311,11 @@ public static Household getSharedHousehold() { } } - String sharedMasterUserName = getUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(); + String sharedMasterUserName = getOttUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(); loginResponse = executor.executeSync(login(partnerId, sharedMasterUserName, defaultUserPassword,null,null)); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); - String sharedUserName = getUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(); + String sharedUserName = getOttUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(); loginResponse = executor.executeSync(login(partnerId, sharedUserName, defaultUserPassword,null,null)); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java index 0cbd4d6ed..24166d964 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java @@ -10,7 +10,6 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.HouseholdService.delete; @@ -19,22 +18,18 @@ public class householdDeleteTests extends BaseTest { - private Household household; - private HouseholdUser masterUser; + private final int numberOfUsersInHousehold = 1; + private final int numberOfDevicesInHousehold = 1; - @BeforeClass - private void household_deleteTests_beforeClass() { - // set household - int numberOfUsersInHousehold = 1; - int numberOfDevicesInHousehold = 1; - household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - } - @Severity(SeverityLevel.NORMAL) + @Severity(SeverityLevel.CRITICAL) @Description("household/action/delete - master user household delete") @Test private void delete_with_household_masterUser() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + // delete household String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); Response booleanResponse = executor.executeSync(delete().setKs(masterUserKs)); @@ -47,4 +42,22 @@ private void delete_with_household_masterUser() { assertThat(householdResponse.results).isNull(); assertThat(householdResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1006).getCode()); } + + @Severity(SeverityLevel.MINOR) + @Description("household/action/delete - regular user household delete - error 500004") + @Test + private void delete_with_household_regularUser() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + + // delete household + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + Response booleanResponse = executor.executeSync(delete().setKs(userKs)); + + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500004).getCode()); + } + + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java new file mode 100644 index 000000000..5dab0bd62 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java @@ -0,0 +1,119 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.enums.HouseholdState; +import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.services.UserRoleService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.types.UserRole; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.HouseholdService.*; +import static com.kaltura.client.services.OttUserService.login; +import static org.assertj.core.api.Assertions.assertThat; + +public class householdSuspendTests extends BaseTest { + + private Household household; + private HouseholdUser masterUser; + + private enum Permissions { + PLAYBACK_SUBSCRIPTION, + PLAYBACK_PPV, + PURCHASE_SUBSCRIPTION, + PURCHASE_PPV, + RENEW_SUBSCRIPTION, + PURCHASE_SERVICE, + LOGIN, + CANCEL_SUBSCRIPTION, + DELETE_ALL_APP_TOKENS + } + + @BeforeClass + private void household_suspendTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 2; + int numberOfDevicesInHousehold = 1; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/suspend") + @Test + private void suspend() { + // suspend household + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + + assertThat(booleanResponse.error).isNull(); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // get household + Response householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + assertThat(householdResponse.results.getState().getValue()).isEqualTo(HouseholdState.SUSPENDED.getValue()); + } + + @Severity(SeverityLevel.MINOR) + @Description("household/action/suspend - with master user ks - error 500004") + @Test + private void suspend_with_masterUser_ks() { + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + // suspend household + Response booleanResponse = executor.executeSync(HouseholdService.suspend().setKs(masterUserKs)); + + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500004).getCode()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/suspend - login role - error 7013") + @Test + private void suspend_with_login_role() { + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.LOGIN.name()); + role.setName(Permissions.LOGIN.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // suspend login + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + + // login + String username = OttUserUtils.getOttUserById(Integer.parseInt(masterUser.getUserId())).getUsername(); + Response loginResponse = executor.executeSync(login(partnerId, username, defaultUserPassword)); + + assertThat(loginResponse.results).isNull(); + assertThat(loginResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } + + @AfterClass + private void household_suspendTests_afterClass() { + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java index f0007295b..f181cf2ff 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java @@ -19,7 +19,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; -import static com.kaltura.client.test.utils.OttUserUtils.getUserById; +import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; import static org.assertj.core.api.Assertions.assertThat; public class OttUserListTests extends BaseTest { @@ -44,7 +44,7 @@ private void list_with_masterUserKs() { HouseholdUser masterUser = getMasterUserFromHousehold(household); // login master user - String username = getUserById(Integer.parseInt(masterUser.getUserId())).getUsername(); + String username = getOttUserById(Integer.parseInt(masterUser.getUserId())).getUsername(); LoginOttUserBuilder loginOttUserBuilder = login(partnerId, username, defaultUserPassword); Response loginResponse = executor.executeSync(loginOttUserBuilder); @@ -67,7 +67,7 @@ private void list_with_regularUserKs() { HouseholdUser user = getRegularUsersListFromHouseHold(household).get(0); // login regular user - String username = getUserById(Integer.parseInt(user.getUserId())).getUsername(); + String username = getOttUserById(Integer.parseInt(user.getUserId())).getUsername(); LoginOttUserBuilder loginOttUserBuilder = login(partnerId, username, defaultUserPassword); Response loginResponse = executor.executeSync(loginOttUserBuilder); @@ -114,7 +114,7 @@ private void list_with_username_filter() { // set user filter OTTUserFilter ottUserFilter = new OTTUserFilter(); - String usernameEqual = getUserById(Integer.valueOf(householdUsers.get(0).getUserId())).getUsername(); + String usernameEqual = getOttUserById(Integer.valueOf(householdUsers.get(0).getUserId())).getUsername(); ottUserFilter.setUsernameEqual(usernameEqual); // list household users @@ -138,7 +138,7 @@ private void list_with_invalid_filter() { // set invalid user filter OTTUserFilter ottUserFilter = new OTTUserFilter(); ottUserFilter.setIdIn(householdUsers.get(0).getUserId()); - ottUserFilter.setUsernameEqual(getUserById(Integer.valueOf(householdUsers.get(1).getUserId())).getUsername()); + ottUserFilter.setUsernameEqual(getOttUserById(Integer.valueOf(householdUsers.get(1).getUserId())).getUsername()); // list household users ListOttUserBuilder listOttUserBuilder = list(ottUserFilter) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java index c61e4c7f5..6cf5810fa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java @@ -23,7 +23,7 @@ import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; -import static com.kaltura.client.test.utils.OttUserUtils.getUserById; +import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; import static org.assertj.core.api.Assertions.assertThat; public class OttUserLoginTests extends BaseTest { @@ -110,7 +110,7 @@ private void login_with_suspended_user() { executor.executeSync(suspendHouseholdBuilder); // login user - String username = getUserById(Integer.parseInt(user.getUserId())).getUsername(); + String username = getOttUserById(Integer.parseInt(user.getUserId())).getUsername(); loginResponse = executor.executeSync(OttUserService.login(partnerId, username, defaultUserPassword)); // assertions @@ -150,7 +150,7 @@ private void login_with_suspended_user() { // HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); // // // login user with invalid udid -// String username = getUserById(Integer.parseInt(user.getUserId())).getUsername(); +// String username = getOttUserById(Integer.parseInt(user.getUserId())).getUsername(); // String invalidDeviceId = "invalid_device_id"; // loginResponse = executor.executeSync(OttUserService.login(partnerId, username, defaultUserPassword, null, invalidDeviceId)); // diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 632ac9431..056be3cce 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -38,7 +38,7 @@ public static OTTUser generateOttUser() { return user; } - public static OTTUser getUserById(int userId) { + public static OTTUser getOttUserById(int userId) { // OttUser/action/get GetOttUserBuilder getOttUserBuilder = OttUserService.get(); @@ -50,7 +50,7 @@ public static OTTUser getUserById(int userId) { } public static String getKs(int userId, @Nullable String udid) { - OTTUser ottUser = getUserById(userId); + OTTUser ottUser = getOttUserById(userId); //OttUser/action/login LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, ottUser.getUsername(), defaultUserPassword, null, udid); diff --git a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java new file mode 100644 index 000000000..b0940d7d4 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java @@ -0,0 +1,39 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.BundleType; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.BundleFilter; +import com.kaltura.client.types.FilterPager; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; + +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; + +public class SubscriptionUtils extends BaseUtils { + + + public static List getAssetsListBySubscription(int subscriptionId, Optional numOfPages) { + Response> assetListResponse; + + // set filter + BundleFilter filter = new BundleFilter(); + filter.setBundleTypeEqual(BundleType.SUBSCRIPTION); + filter.setIdEqual(subscriptionId); + + if (numOfPages.isPresent()) { + FilterPager pager = new FilterPager(); + pager.setPageSize(numOfPages.get()); + pager.setPageIndex(1); + + assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter, pager).setKs(getOperatorKs())); + } else { + assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter).setKs(getOperatorKs())); + } + return assetListResponse.results.getObjects(); + } +} From c8194a92f553da57b5c476cdae817a011eba533a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 28 May 2018 10:00:44 +0300 Subject: [PATCH 271/605] suspend_with_purchase_subscription_role() --- .../EntitlementGrantTests.java | 19 ++++++++-- .../householdTests/householdSuspendTests.java | 37 +++++++++++++++++-- .../client/test/utils/PurchaseUtils.java | 33 +++++++++-------- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index 6137d6b94..d9d475dd1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -335,9 +335,22 @@ private void grant_3023() { } @Issue("BEO-5022") - @Test(description = "entitlement/action/grant - grant ppv with missing content id - error 3018", enabled = false) - private void grant_ppv_with_missing_contentId() { - // TODO: 4/30/2018 implement test + @Test(enabled = false, description = "entitlement/action/grant - grant ppv with invalid content id - error 3018") + private void grant_ppv_with_invalid_contentId() { + // get user form test shared household + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + + // grant ppv with invalid content id + int invalidContentId = 1; + GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, invalidContentId) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getUserId())); + Response booleanResponse = executor.executeSync(grantEntitlementBuilder); + assertThat(booleanResponse.error).isNull(); + + // assert error 3018 is return + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3018).getCode()); } @Test(description = "entitlement/action/grant - user not in domain - error 1005") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java index 5dab0bd62..683dfefe6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java @@ -7,10 +7,8 @@ import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.HouseholdUser; -import com.kaltura.client.types.LoginResponse; -import com.kaltura.client.types.UserRole; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; @@ -111,6 +109,37 @@ private void suspend_with_login_role() { executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); } + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/suspend - purchase_subscription role - error 7013") + @Test + private void suspend_with_purchase_subscription_role() { + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.PURCHASE_SUBSCRIPTION.name()); + role.setName(Permissions.PURCHASE_SUBSCRIPTION.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // suspend purchase_subscription + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + + // purchase_subscription + String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + Response transactionResponse = PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(BaseTest.getSharedCommonSubscription().getId())); + + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } + @AfterClass private void household_suspendTests_afterClass() { // cleanup - delete household diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index a54addd5f..994df81c5 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -26,16 +26,16 @@ public class PurchaseUtils { private static Response assetResponse; // TODO: 14/MAR/2018 add return - public static void purchasePpv(String ks, Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { + public static Response purchasePpv(String ks, Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { purchasePpvDetailsMap = new HashMap<>(); int paymentGatewayId = 0; - int internalFileId =-1; + int internalFileId = -1; if (fileId.isPresent()) { internalFileId = fileId.get(); } else { - GetAssetBuilder mediaAsset = AssetService.get(String.valueOf(mediaId.get()), AssetReferenceType.MEDIA); - assetResponse = executor.executeSync(mediaAsset.setKs(ks)); + GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(mediaId.get()), AssetReferenceType.MEDIA).setKs(ks); + assetResponse = executor.executeSync(getAssetBuilder); internalFileId = assetResponse.results.getMediaFiles().get(0).getId(); } @@ -44,8 +44,8 @@ public static void purchasePpv(String ks, Optional mediaId, Optional mediaId, Optional transactionResponse = executor.executeSync(transactionBuilder); // TODO: complete the purchase ppv test purchasePpvDetailsMap.put("price", String.valueOf(price)); purchasePpvDetailsMap.put("currency", currency); purchasePpvDetailsMap.put("ppvModuleId", ppvModuleId); purchasePpvDetailsMap.put("fileId", String.valueOf(internalFileId)); + + return transactionResponse; } - // TODO: 3/7/2018 add return - // private as not completed - private static void purchaseSubscription(int subscriptionId) { + public static Response purchaseSubscription(String ks, int subscriptionId) { purchaseSubscriptionDetailsMap = new HashMap<>(); int paymentGatewayId = 0; ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(String.valueOf(subscriptionId)); filter.setIsLowest(false); - ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + + ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(filter).setKs(ks); + productPriceResponse = executor.executeSync(listProductPriceBuilder); String currency = productPriceResponse.results.getObjects().get(0).getPrice().getCurrency(); double price = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); @@ -95,11 +96,13 @@ private static void purchaseSubscription(int subscriptionId) { purchase.setProductType(Optional.of(TransactionType.SUBSCRIPTION).get()); purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); - PurchaseTransactionBuilder transactionBuilder = TransactionService.purchase(purchase); - executor.executeSync(transactionBuilder); + PurchaseTransactionBuilder purchaseTransactionBuilder = TransactionService.purchase(purchase).setKs(ks); + Response transactionResponse = executor.executeSync(purchaseTransactionBuilder); // TODO: complete the purchase subscription test purchaseSubscriptionDetailsMap.put("price", String.valueOf(price)); purchaseSubscriptionDetailsMap.put("currency", currency); + + return transactionResponse; } } From f80a19f4c1bb5dd0516591a6e6ac55750c613cc1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 28 May 2018 10:13:16 +0300 Subject: [PATCH 272/605] sync --- pom.xml | 4 +- src/main/java/com/kaltura/client/Client.java | 4 +- .../client/enums/AssetUserRuleOrderBy.java | 69 +++++++ .../kaltura/client/enums/RuleActionType.java | 3 +- .../com/kaltura/client/enums/RuleType.java | 3 +- .../client/services/AssetFileService.java | 6 +- .../client/services/AssetUserRuleService.java | 168 ++++++++++++++++++ .../types/AccessControlBlockAction.java | 4 +- .../com/kaltura/client/types/AssetFile.java | 94 ++++++++++ .../com/kaltura/client/types/AssetRule.java | 71 +------- .../kaltura/client/types/AssetRuleAction.java | 65 +++++++ .../kaltura/client/types/AssetRuleBase.java | 131 ++++++++++++++ .../types/AssetUserBlockRuleAction.java | 65 +++++++ .../kaltura/client/types/AssetUserRule.java | 106 +++++++++++ .../client/types/AssetUserRuleAction.java | 65 +++++++ .../types/AssetUserRuleBlockAction.java | 65 +++++++ .../client/types/AssetUserRuleFilter.java | 94 ++++++++++ .../com/kaltura/client/types/Country.java | 19 ++ .../com/kaltura/client/types/MediaFile.java | 24 +-- .../com/kaltura/client/types/RuleAction.java | 3 +- src/main/java/com/kaltura/client/types/T.java | 66 +++++++ .../client/types/TimeOffsetRuleAction.java | 4 +- 22 files changed, 1032 insertions(+), 101 deletions(-) create mode 100644 src/main/java/com/kaltura/client/enums/AssetUserRuleOrderBy.java create mode 100644 src/main/java/com/kaltura/client/services/AssetUserRuleService.java create mode 100644 src/main/java/com/kaltura/client/types/AssetFile.java create mode 100644 src/main/java/com/kaltura/client/types/AssetRuleAction.java create mode 100644 src/main/java/com/kaltura/client/types/AssetRuleBase.java create mode 100644 src/main/java/com/kaltura/client/types/AssetUserBlockRuleAction.java create mode 100644 src/main/java/com/kaltura/client/types/AssetUserRule.java create mode 100644 src/main/java/com/kaltura/client/types/AssetUserRuleAction.java create mode 100644 src/main/java/com/kaltura/client/types/AssetUserRuleBlockAction.java create mode 100644 src/main/java/com/kaltura/client/types/AssetUserRuleFilter.java create mode 100644 src/main/java/com/kaltura/client/types/T.java diff --git a/pom.xml b/pom.xml index 2fd750cf6..2c24491fa 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 4.0.0 com.kaltura KalturaOttApiClient - 4.81.31.22843-SNAPSHOT + 4.81.83.43131-SNAPSHOT jar @@ -246,7 +246,7 @@ src\test\resources\testng.xml ${project.basedir}/target - true + false -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" diff --git a/src/main/java/com/kaltura/client/Client.java b/src/main/java/com/kaltura/client/Client.java index 6d9760a08..3fd162473 100644 --- a/src/main/java/com/kaltura/client/Client.java +++ b/src/main/java/com/kaltura/client/Client.java @@ -43,8 +43,8 @@ public class Client extends ClientBase { public Client(ConnectionConfiguration config) { super(config); - this.setClientTag("java:18-05-07"); - this.setApiVersion("4.81.31.22843"); + this.setClientTag("java:18-05-27"); + this.setApiVersion("4.81.83.43131"); this.clientConfiguration.put("format", 1); // JSON } diff --git a/src/main/java/com/kaltura/client/enums/AssetUserRuleOrderBy.java b/src/main/java/com/kaltura/client/enums/AssetUserRuleOrderBy.java new file mode 100644 index 000000000..d801294ca --- /dev/null +++ b/src/main/java/com/kaltura/client/enums/AssetUserRuleOrderBy.java @@ -0,0 +1,69 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.enums; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ +public enum AssetUserRuleOrderBy implements EnumAsString { + NONE("NONE"); + + private String value; + + AssetUserRuleOrderBy(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static AssetUserRuleOrderBy get(String value) { + if(value == null) + { + return null; + } + + // goes over AssetUserRuleOrderBy defined values and compare the inner value with the given one: + for(AssetUserRuleOrderBy item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return AssetUserRuleOrderBy.values().length > 0 ? AssetUserRuleOrderBy.values()[0]: null; + } +} diff --git a/src/main/java/com/kaltura/client/enums/RuleActionType.java b/src/main/java/com/kaltura/client/enums/RuleActionType.java index eb5360fed..b6fe12377 100644 --- a/src/main/java/com/kaltura/client/enums/RuleActionType.java +++ b/src/main/java/com/kaltura/client/enums/RuleActionType.java @@ -36,7 +36,8 @@ public enum RuleActionType implements EnumAsString { BLOCK("BLOCK"), START_DATE_OFFSET("START_DATE_OFFSET"), - END_DATE_OFFSET("END_DATE_OFFSET"); + END_DATE_OFFSET("END_DATE_OFFSET"), + USER_BLOCK("USER_BLOCK"); private String value; diff --git a/src/main/java/com/kaltura/client/enums/RuleType.java b/src/main/java/com/kaltura/client/enums/RuleType.java index 2d12da4a4..1d5066d97 100644 --- a/src/main/java/com/kaltura/client/enums/RuleType.java +++ b/src/main/java/com/kaltura/client/enums/RuleType.java @@ -37,7 +37,8 @@ public enum RuleType implements EnumAsString { PARENTAL("parental"), GEO("geo"), USER_TYPE("user_type"), - DEVICE("device"); + DEVICE("device"), + ASSETUSER("assetUser"); private String value; diff --git a/src/main/java/com/kaltura/client/services/AssetFileService.java b/src/main/java/com/kaltura/client/services/AssetFileService.java index 74ab07c06..ff302d452 100644 --- a/src/main/java/com/kaltura/client/services/AssetFileService.java +++ b/src/main/java/com/kaltura/client/services/AssetFileService.java @@ -30,8 +30,8 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.ContextType; import com.kaltura.client.enums.PlaybackContextType; +import com.kaltura.client.types.AssetFile; import com.kaltura.client.types.AssetFileContext; -import com.kaltura.client.utils.request.NullRequestBuilder; import com.kaltura.client.utils.request.RequestBuilder; /** @@ -70,10 +70,10 @@ public static GetContextAssetFileBuilder getContext(String id, ContextType conte return new GetContextAssetFileBuilder(id, contextType); } - public static class PlayManifestAssetFileBuilder extends NullRequestBuilder { + public static class PlayManifestAssetFileBuilder extends RequestBuilder { public PlayManifestAssetFileBuilder(int partnerId, String assetId, AssetType assetType, long assetFileId, PlaybackContextType contextType, String ks) { - super("assetfile", "playManifest"); + super(AssetFile.class, "assetfile", "playManifest"); params.add("partnerId", partnerId); params.add("assetId", assetId); params.add("assetType", assetType); diff --git a/src/main/java/com/kaltura/client/services/AssetUserRuleService.java b/src/main/java/com/kaltura/client/services/AssetUserRuleService.java new file mode 100644 index 000000000..0efdf463e --- /dev/null +++ b/src/main/java/com/kaltura/client/services/AssetUserRuleService.java @@ -0,0 +1,168 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.services; + +import com.kaltura.client.types.AssetUserRule; +import com.kaltura.client.types.AssetUserRuleFilter; +import com.kaltura.client.utils.request.ListResponseRequestBuilder; +import com.kaltura.client.utils.request.NullRequestBuilder; +import com.kaltura.client.utils.request.RequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +public class AssetUserRuleService { + + public static class AddAssetUserRuleBuilder extends RequestBuilder { + + public AddAssetUserRuleBuilder(AssetUserRule assetUserRule) { + super(AssetUserRule.class, "assetuserrule", "add"); + params.add("assetUserRule", assetUserRule); + } + } + + /** + * Add asset user rule + * + * @param assetUserRule Asset user rule + */ + public static AddAssetUserRuleBuilder add(AssetUserRule assetUserRule) { + return new AddAssetUserRuleBuilder(assetUserRule); + } + + public static class AttachUser AssetUserRuleBuilder extends NullRequestBuilder { + + public AttachUser AssetUserRuleBuilder(long ruleId) { + super("assetuserrule", "attachUser "); + params.add("ruleId", ruleId); + } + + public void ruleId(String multirequestToken) { + params.add("ruleId", multirequestToken); + } + } + + /** + * Attach AssetUserRule To User + * + * @param ruleId AssetUserRule id to add + */ + public static AttachUser AssetUserRuleBuilder attachUser (long ruleId) { + return new AttachUser AssetUserRuleBuilder(ruleId); + } + + public static class DeleteAssetUserRuleBuilder extends NullRequestBuilder { + + public DeleteAssetUserRuleBuilder(long id) { + super("assetuserrule", "delete"); + params.add("id", id); + } + + public void id(String multirequestToken) { + params.add("id", multirequestToken); + } + } + + /** + * Delete asset user rule + * + * @param id Asset user rule ID + */ + public static DeleteAssetUserRuleBuilder delete(long id) { + return new DeleteAssetUserRuleBuilder(id); + } + + public static class DetachUserAssetUserRuleBuilder extends NullRequestBuilder { + + public DetachUserAssetUserRuleBuilder(long ruleId) { + super("assetuserrule", "detachUser"); + params.add("ruleId", ruleId); + } + + public void ruleId(String multirequestToken) { + params.add("ruleId", multirequestToken); + } + } + + /** + * Detach AssetUserRule from user + * + * @param ruleId AssetUserRule id to remove + */ + public static DetachUserAssetUserRuleBuilder detachUser(long ruleId) { + return new DetachUserAssetUserRuleBuilder(ruleId); + } + + public static class ListAssetUserRuleBuilder extends ListResponseRequestBuilder { + + public ListAssetUserRuleBuilder(AssetUserRuleFilter filter) { + super(AssetUserRule.class, "assetuserrule", "list"); + params.add("filter", filter); + } + } + + public static ListAssetUserRuleBuilder list() { + return list(null); + } + + /** + * Get the list of asset user rules for the partner + * + * @param filter AssetUserRule Filter + */ + public static ListAssetUserRuleBuilder list(AssetUserRuleFilter filter) { + return new ListAssetUserRuleBuilder(filter); + } + + public static class UpdateAssetUserRuleBuilder extends RequestBuilder { + + public UpdateAssetUserRuleBuilder(long id, AssetUserRule assetUserRule) { + super(AssetUserRule.class, "assetuserrule", "update"); + params.add("id", id); + params.add("assetUserRule", assetUserRule); + } + + public void id(String multirequestToken) { + params.add("id", multirequestToken); + } + } + + /** + * Update asset user rule + * + * @param id Asset user rule ID to update + * @param assetUserRule Asset user rule + */ + public static UpdateAssetUserRuleBuilder update(long id, AssetUserRule assetUserRule) { + return new UpdateAssetUserRuleBuilder(id, assetUserRule); + } +} diff --git a/src/main/java/com/kaltura/client/types/AccessControlBlockAction.java b/src/main/java/com/kaltura/client/types/AccessControlBlockAction.java index fb2ce97ba..549537696 100644 --- a/src/main/java/com/kaltura/client/types/AccessControlBlockAction.java +++ b/src/main/java/com/kaltura/client/types/AccessControlBlockAction.java @@ -40,9 +40,9 @@ @SuppressWarnings("serial") @MultiRequestBuilder.Tokenizer(AccessControlBlockAction.Tokenizer.class) -public class AccessControlBlockAction extends RuleAction { +public class AccessControlBlockAction extends AssetRuleAction { - public interface Tokenizer extends RuleAction.Tokenizer { + public interface Tokenizer extends AssetRuleAction.Tokenizer { } diff --git a/src/main/java/com/kaltura/client/types/AssetFile.java b/src/main/java/com/kaltura/client/types/AssetFile.java new file mode 100644 index 000000000..5f5c3d916 --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetFile.java @@ -0,0 +1,94 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.types.ObjectBase; +import com.kaltura.client.utils.GsonParser; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +/** + * Asset file details + */ +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetFile.Tokenizer.class) +public class AssetFile extends ObjectBase { + + public interface Tokenizer extends ObjectBase.Tokenizer { + String url(); + } + + /** + * URL of the media file to be played + */ + private String url; + + // url: + public String getUrl(){ + return this.url; + } + public void setUrl(String url){ + this.url = url; + } + + public void url(String multirequestToken){ + setToken("url", multirequestToken); + } + + + public AssetFile() { + super(); + } + + public AssetFile(JsonObject jsonObject) throws APIException { + super(jsonObject); + + if(jsonObject == null) return; + + // set members values: + url = GsonParser.parseString(jsonObject.get("url")); + + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetFile"); + kparams.add("url", this.url); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/AssetRule.java b/src/main/java/com/kaltura/client/types/AssetRule.java index 2330111d6..d87e84c97 100644 --- a/src/main/java/com/kaltura/client/types/AssetRule.java +++ b/src/main/java/com/kaltura/client/types/AssetRule.java @@ -29,7 +29,6 @@ import com.google.gson.JsonObject; import com.kaltura.client.Params; -import com.kaltura.client.types.ObjectBase; import com.kaltura.client.utils.GsonParser; import com.kaltura.client.utils.request.MultiRequestBuilder; import com.kaltura.client.utils.request.RequestBuilder; @@ -47,28 +46,13 @@ */ @SuppressWarnings("serial") @MultiRequestBuilder.Tokenizer(AssetRule.Tokenizer.class) -public class AssetRule extends ObjectBase { +public class AssetRule extends AssetRuleBase { - public interface Tokenizer extends ObjectBase.Tokenizer { - String id(); - String name(); - String description(); + public interface Tokenizer extends AssetRuleBase.Tokenizer { RequestBuilder.ListTokenizer conditions(); - RequestBuilder.ListTokenizer actions(); + RequestBuilder.ListTokenizer actions(); } - /** - * ID - */ - private Long id; - /** - * Name - */ - private String name; - /** - * Description - */ - private String description; /** * List of conditions for the rule */ @@ -76,43 +60,7 @@ public interface Tokenizer extends ObjectBase.Tokenizer { /** * List of actions for the rule */ - private List actions; - - // id: - public Long getId(){ - return this.id; - } - public void setId(Long id){ - this.id = id; - } - - public void id(String multirequestToken){ - setToken("id", multirequestToken); - } - - // name: - public String getName(){ - return this.name; - } - public void setName(String name){ - this.name = name; - } - - public void name(String multirequestToken){ - setToken("name", multirequestToken); - } - - // description: - public String getDescription(){ - return this.description; - } - public void setDescription(String description){ - this.description = description; - } - - public void description(String multirequestToken){ - setToken("description", multirequestToken); - } + private List actions; // conditions: public List getConditions(){ @@ -123,10 +71,10 @@ public void setConditions(List conditions){ } // actions: - public List getActions(){ + public List getActions(){ return this.actions; } - public void setActions(List actions){ + public void setActions(List actions){ this.actions = actions; } @@ -141,19 +89,14 @@ public AssetRule(JsonObject jsonObject) throws APIException { if(jsonObject == null) return; // set members values: - id = GsonParser.parseLong(jsonObject.get("id")); - name = GsonParser.parseString(jsonObject.get("name")); - description = GsonParser.parseString(jsonObject.get("description")); conditions = GsonParser.parseArray(jsonObject.getAsJsonArray("conditions"), Condition.class); - actions = GsonParser.parseArray(jsonObject.getAsJsonArray("actions"), RuleAction.class); + actions = GsonParser.parseArray(jsonObject.getAsJsonArray("actions"), AssetRuleAction.class); } public Params toParams() { Params kparams = super.toParams(); kparams.add("objectType", "KalturaAssetRule"); - kparams.add("name", this.name); - kparams.add("description", this.description); kparams.add("conditions", this.conditions); kparams.add("actions", this.actions); return kparams; diff --git a/src/main/java/com/kaltura/client/types/AssetRuleAction.java b/src/main/java/com/kaltura/client/types/AssetRuleAction.java new file mode 100644 index 000000000..df331ebb8 --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetRuleAction.java @@ -0,0 +1,65 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetRuleAction.Tokenizer.class) +public abstract class AssetRuleAction extends RuleAction { + + public interface Tokenizer extends RuleAction.Tokenizer { + } + + + + public AssetRuleAction() { + super(); + } + + public AssetRuleAction(JsonObject jsonObject) throws APIException { + super(jsonObject); + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetRuleAction"); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/AssetRuleBase.java b/src/main/java/com/kaltura/client/types/AssetRuleBase.java new file mode 100644 index 000000000..ea5d24d18 --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetRuleBase.java @@ -0,0 +1,131 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.types.ObjectBase; +import com.kaltura.client.utils.GsonParser; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +/** + * Asset rule base + */ +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetRuleBase.Tokenizer.class) +public abstract class AssetRuleBase extends ObjectBase { + + public interface Tokenizer extends ObjectBase.Tokenizer { + String id(); + String name(); + String description(); + } + + /** + * ID + */ + private Long id; + /** + * Name + */ + private String name; + /** + * Description + */ + private String description; + + // id: + public Long getId(){ + return this.id; + } + public void setId(Long id){ + this.id = id; + } + + public void id(String multirequestToken){ + setToken("id", multirequestToken); + } + + // name: + public String getName(){ + return this.name; + } + public void setName(String name){ + this.name = name; + } + + public void name(String multirequestToken){ + setToken("name", multirequestToken); + } + + // description: + public String getDescription(){ + return this.description; + } + public void setDescription(String description){ + this.description = description; + } + + public void description(String multirequestToken){ + setToken("description", multirequestToken); + } + + + public AssetRuleBase() { + super(); + } + + public AssetRuleBase(JsonObject jsonObject) throws APIException { + super(jsonObject); + + if(jsonObject == null) return; + + // set members values: + id = GsonParser.parseLong(jsonObject.get("id")); + name = GsonParser.parseString(jsonObject.get("name")); + description = GsonParser.parseString(jsonObject.get("description")); + + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetRuleBase"); + kparams.add("name", this.name); + kparams.add("description", this.description); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/AssetUserBlockRuleAction.java b/src/main/java/com/kaltura/client/types/AssetUserBlockRuleAction.java new file mode 100644 index 000000000..2ee4086f1 --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetUserBlockRuleAction.java @@ -0,0 +1,65 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetUserBlockRuleAction.Tokenizer.class) +public class AssetUserBlockRuleAction extends AssetUserRuleAction { + + public interface Tokenizer extends AssetUserRuleAction.Tokenizer { + } + + + + public AssetUserBlockRuleAction() { + super(); + } + + public AssetUserBlockRuleAction(JsonObject jsonObject) throws APIException { + super(jsonObject); + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetUserBlockRuleAction"); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/AssetUserRule.java b/src/main/java/com/kaltura/client/types/AssetUserRule.java new file mode 100644 index 000000000..c6ba08579 --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetUserRule.java @@ -0,0 +1,106 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.utils.GsonParser; +import com.kaltura.client.utils.request.MultiRequestBuilder; +import com.kaltura.client.utils.request.RequestBuilder; +import java.util.List; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +/** + * Asset user rule + */ +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetUserRule.Tokenizer.class) +public class AssetUserRule extends AssetRuleBase { + + public interface Tokenizer extends AssetRuleBase.Tokenizer { + RequestBuilder.ListTokenizer conditions(); + RequestBuilder.ListTokenizer actions(); + } + + /** + * List of Ksql conditions for the user rule + */ + private List conditions; + /** + * List of actions for the user rule + */ + private List actions; + + // conditions: + public List getConditions(){ + return this.conditions; + } + public void setConditions(List conditions){ + this.conditions = conditions; + } + + // actions: + public List getActions(){ + return this.actions; + } + public void setActions(List actions){ + this.actions = actions; + } + + + public AssetUserRule() { + super(); + } + + public AssetUserRule(JsonObject jsonObject) throws APIException { + super(jsonObject); + + if(jsonObject == null) return; + + // set members values: + conditions = GsonParser.parseArray(jsonObject.getAsJsonArray("conditions"), AssetCondition.class); + actions = GsonParser.parseArray(jsonObject.getAsJsonArray("actions"), AssetUserRuleAction.class); + + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetUserRule"); + kparams.add("conditions", this.conditions); + kparams.add("actions", this.actions); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/AssetUserRuleAction.java b/src/main/java/com/kaltura/client/types/AssetUserRuleAction.java new file mode 100644 index 000000000..be40cccc1 --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetUserRuleAction.java @@ -0,0 +1,65 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetUserRuleAction.Tokenizer.class) +public abstract class AssetUserRuleAction extends RuleAction { + + public interface Tokenizer extends RuleAction.Tokenizer { + } + + + + public AssetUserRuleAction() { + super(); + } + + public AssetUserRuleAction(JsonObject jsonObject) throws APIException { + super(jsonObject); + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetUserRuleAction"); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/AssetUserRuleBlockAction.java b/src/main/java/com/kaltura/client/types/AssetUserRuleBlockAction.java new file mode 100644 index 000000000..b8221dcfd --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetUserRuleBlockAction.java @@ -0,0 +1,65 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetUserRuleBlockAction.Tokenizer.class) +public class AssetUserRuleBlockAction extends AssetUserRuleAction { + + public interface Tokenizer extends AssetUserRuleAction.Tokenizer { + } + + + + public AssetUserRuleBlockAction() { + super(); + } + + public AssetUserRuleBlockAction(JsonObject jsonObject) throws APIException { + super(jsonObject); + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetUserRuleBlockAction"); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/AssetUserRuleFilter.java b/src/main/java/com/kaltura/client/types/AssetUserRuleFilter.java new file mode 100644 index 000000000..61ac51d27 --- /dev/null +++ b/src/main/java/com/kaltura/client/types/AssetUserRuleFilter.java @@ -0,0 +1,94 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.utils.GsonParser; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +/** + * Asset user rule filter + */ +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(AssetUserRuleFilter.Tokenizer.class) +public class AssetUserRuleFilter extends Filter { + + public interface Tokenizer extends Filter.Tokenizer { + String attachedUserIdEqualCurrent(); + } + + /** + * Indicates if to get the asset user rule list for the attached user or for the + entire group + */ + private Boolean attachedUserIdEqualCurrent; + + // attachedUserIdEqualCurrent: + public Boolean getAttachedUserIdEqualCurrent(){ + return this.attachedUserIdEqualCurrent; + } + public void setAttachedUserIdEqualCurrent(Boolean attachedUserIdEqualCurrent){ + this.attachedUserIdEqualCurrent = attachedUserIdEqualCurrent; + } + + public void attachedUserIdEqualCurrent(String multirequestToken){ + setToken("attachedUserIdEqualCurrent", multirequestToken); + } + + + public AssetUserRuleFilter() { + super(); + } + + public AssetUserRuleFilter(JsonObject jsonObject) throws APIException { + super(jsonObject); + + if(jsonObject == null) return; + + // set members values: + attachedUserIdEqualCurrent = GsonParser.parseBoolean(jsonObject.get("attachedUserIdEqualCurrent")); + + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaAssetUserRuleFilter"); + kparams.add("attachedUserIdEqualCurrent", this.attachedUserIdEqualCurrent); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/Country.java b/src/main/java/com/kaltura/client/types/Country.java index 877a66b05..7c24f8f39 100644 --- a/src/main/java/com/kaltura/client/types/Country.java +++ b/src/main/java/com/kaltura/client/types/Country.java @@ -56,6 +56,7 @@ public interface Tokenizer extends ObjectBase.Tokenizer { String currency(); String currencySign(); String vatPercent(); + String timeZoneId(); } /** @@ -90,6 +91,10 @@ public interface Tokenizer extends ObjectBase.Tokenizer { * Vat Percent in the country */ private Double vatPercent; + /** + * Time zone ID + */ + private String timeZoneId; // id: public Integer getId(){ @@ -187,6 +192,18 @@ public void vatPercent(String multirequestToken){ setToken("vatPercent", multirequestToken); } + // timeZoneId: + public String getTimeZoneId(){ + return this.timeZoneId; + } + public void setTimeZoneId(String timeZoneId){ + this.timeZoneId = timeZoneId; + } + + public void timeZoneId(String multirequestToken){ + setToken("timeZoneId", multirequestToken); + } + public Country() { super(); @@ -206,6 +223,7 @@ public Country(JsonObject jsonObject) throws APIException { currency = GsonParser.parseString(jsonObject.get("currency")); currencySign = GsonParser.parseString(jsonObject.get("currencySign")); vatPercent = GsonParser.parseDouble(jsonObject.get("vatPercent")); + timeZoneId = GsonParser.parseString(jsonObject.get("timeZoneId")); } @@ -219,6 +237,7 @@ public Params toParams() { kparams.add("currency", this.currency); kparams.add("currencySign", this.currencySign); kparams.add("vatPercent", this.vatPercent); + kparams.add("timeZoneId", this.timeZoneId); return kparams; } diff --git a/src/main/java/com/kaltura/client/types/MediaFile.java b/src/main/java/com/kaltura/client/types/MediaFile.java index 106021c61..e81987ebc 100644 --- a/src/main/java/com/kaltura/client/types/MediaFile.java +++ b/src/main/java/com/kaltura/client/types/MediaFile.java @@ -29,7 +29,6 @@ import com.google.gson.JsonObject; import com.kaltura.client.Params; -import com.kaltura.client.types.ObjectBase; import com.kaltura.client.types.StringValueArray; import com.kaltura.client.utils.GsonParser; import com.kaltura.client.utils.request.MultiRequestBuilder; @@ -46,13 +45,12 @@ */ @SuppressWarnings("serial") @MultiRequestBuilder.Tokenizer(MediaFile.Tokenizer.class) -public class MediaFile extends ObjectBase { +public class MediaFile extends AssetFile { - public interface Tokenizer extends ObjectBase.Tokenizer { + public interface Tokenizer extends AssetFile.Tokenizer { String assetId(); String id(); String type(); - String url(); String duration(); String externalId(); String billingType(); @@ -78,10 +76,6 @@ public interface Tokenizer extends ObjectBase.Tokenizer { * Device types as defined in the system */ private String type; - /** - * URL of the media file to be played - */ - private String url; /** * Duration of the media file */ @@ -163,18 +157,6 @@ public void type(String multirequestToken){ setToken("type", multirequestToken); } - // url: - public String getUrl(){ - return this.url; - } - public void setUrl(String url){ - this.url = url; - } - - public void url(String multirequestToken){ - setToken("url", multirequestToken); - } - // duration: public Long getDuration(){ return this.duration; @@ -317,7 +299,6 @@ public MediaFile(JsonObject jsonObject) throws APIException { assetId = GsonParser.parseInt(jsonObject.get("assetId")); id = GsonParser.parseInt(jsonObject.get("id")); type = GsonParser.parseString(jsonObject.get("type")); - url = GsonParser.parseString(jsonObject.get("url")); duration = GsonParser.parseLong(jsonObject.get("duration")); externalId = GsonParser.parseString(jsonObject.get("externalId")); billingType = GsonParser.parseString(jsonObject.get("billingType")); @@ -337,7 +318,6 @@ public Params toParams() { kparams.add("objectType", "KalturaMediaFile"); kparams.add("assetId", this.assetId); kparams.add("type", this.type); - kparams.add("url", this.url); kparams.add("duration", this.duration); kparams.add("externalId", this.externalId); kparams.add("billingType", this.billingType); diff --git a/src/main/java/com/kaltura/client/types/RuleAction.java b/src/main/java/com/kaltura/client/types/RuleAction.java index 84296b618..b2f3016b2 100644 --- a/src/main/java/com/kaltura/client/types/RuleAction.java +++ b/src/main/java/com/kaltura/client/types/RuleAction.java @@ -43,7 +43,7 @@ @SuppressWarnings("serial") @MultiRequestBuilder.Tokenizer(RuleAction.Tokenizer.class) -public class RuleAction extends ObjectBase { +public abstract class RuleAction extends ObjectBase { public interface Tokenizer extends ObjectBase.Tokenizer { String type(); @@ -102,7 +102,6 @@ public RuleAction(JsonObject jsonObject) throws APIException { public Params toParams() { Params kparams = super.toParams(); kparams.add("objectType", "KalturaRuleAction"); - kparams.add("type", this.type); kparams.add("description", this.description); return kparams; } diff --git a/src/main/java/com/kaltura/client/types/T.java b/src/main/java/com/kaltura/client/types/T.java new file mode 100644 index 000000000..7190c19be --- /dev/null +++ b/src/main/java/com/kaltura/client/types/T.java @@ -0,0 +1,66 @@ +// =================================================================================================== +// _ __ _ _ +// | |/ /__ _| | |_ _ _ _ _ __ _ +// | ' . +// +// @ignore +// =================================================================================================== +package com.kaltura.client.types; + +import com.google.gson.JsonObject; +import com.kaltura.client.Params; +import com.kaltura.client.types.ObjectBase; +import com.kaltura.client.utils.request.MultiRequestBuilder; + +/** + * This class was generated using clients-generator\exec.php + * against an XML schema provided by Kaltura. + * + * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. + */ + +@SuppressWarnings("serial") +@MultiRequestBuilder.Tokenizer(T.Tokenizer.class) +public class T extends ObjectBase { + + public interface Tokenizer extends ObjectBase.Tokenizer { + } + + + + public T() { + super(); + } + + public T(JsonObject jsonObject) throws APIException { + super(jsonObject); + } + + public Params toParams() { + Params kparams = super.toParams(); + kparams.add("objectType", "KalturaT"); + return kparams; + } + +} + diff --git a/src/main/java/com/kaltura/client/types/TimeOffsetRuleAction.java b/src/main/java/com/kaltura/client/types/TimeOffsetRuleAction.java index 24702681f..b954b3f48 100644 --- a/src/main/java/com/kaltura/client/types/TimeOffsetRuleAction.java +++ b/src/main/java/com/kaltura/client/types/TimeOffsetRuleAction.java @@ -44,9 +44,9 @@ */ @SuppressWarnings("serial") @MultiRequestBuilder.Tokenizer(TimeOffsetRuleAction.Tokenizer.class) -public abstract class TimeOffsetRuleAction extends RuleAction { +public abstract class TimeOffsetRuleAction extends AssetRuleAction { - public interface Tokenizer extends RuleAction.Tokenizer { + public interface Tokenizer extends AssetRuleAction.Tokenizer { String offset(); String timeZone(); } From 878acb7ae4d6f151a7200e02bfa15e6d1366d958 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 28 May 2018 11:03:09 +0300 Subject: [PATCH 273/605] Merge remote-tracking branch 'upstream/master' # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit. --- pom.xml | 2 +- src/main/java/com/kaltura/client/Client.java | 4 ++-- .../kaltura/client/services/AssetUserRuleService.java | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 2c24491fa..a8b2f1709 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 4.0.0 com.kaltura KalturaOttApiClient - 4.81.83.43131-SNAPSHOT + 4.81.84.13672-SNAPSHOT jar diff --git a/src/main/java/com/kaltura/client/Client.java b/src/main/java/com/kaltura/client/Client.java index 3fd162473..623f52dd5 100644 --- a/src/main/java/com/kaltura/client/Client.java +++ b/src/main/java/com/kaltura/client/Client.java @@ -43,8 +43,8 @@ public class Client extends ClientBase { public Client(ConnectionConfiguration config) { super(config); - this.setClientTag("java:18-05-27"); - this.setApiVersion("4.81.83.43131"); + this.setClientTag("java:18-05-28"); + this.setApiVersion("4.81.84.13672"); this.clientConfiguration.put("format", 1); // JSON } diff --git a/src/main/java/com/kaltura/client/services/AssetUserRuleService.java b/src/main/java/com/kaltura/client/services/AssetUserRuleService.java index 0efdf463e..dde6bf7b2 100644 --- a/src/main/java/com/kaltura/client/services/AssetUserRuleService.java +++ b/src/main/java/com/kaltura/client/services/AssetUserRuleService.java @@ -59,10 +59,10 @@ public static AddAssetUserRuleBuilder add(AssetUserRule assetUserRule) { return new AddAssetUserRuleBuilder(assetUserRule); } - public static class AttachUser AssetUserRuleBuilder extends NullRequestBuilder { + public static class AttachUserAssetUserRuleBuilder extends NullRequestBuilder { - public AttachUser AssetUserRuleBuilder(long ruleId) { - super("assetuserrule", "attachUser "); + public AttachUserAssetUserRuleBuilder(long ruleId) { + super("assetuserrule", "attachUser"); params.add("ruleId", ruleId); } @@ -76,8 +76,8 @@ public void ruleId(String multirequestToken) { * * @param ruleId AssetUserRule id to add */ - public static AttachUser AssetUserRuleBuilder attachUser (long ruleId) { - return new AttachUser AssetUserRuleBuilder(ruleId); + public static AttachUserAssetUserRuleBuilder attachUser(long ruleId) { + return new AttachUserAssetUserRuleBuilder(ruleId); } public static class DeleteAssetUserRuleBuilder extends NullRequestBuilder { From 0ada8e9ec1d0df9c9387a8adb704f77c7b35ca29 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 28 May 2018 11:24:30 +0300 Subject: [PATCH 274/605] added infraUtils class --- .gitignore | 2 + .../kaltura/client/test/utils/InfraUtils.java | 65 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/utils/InfraUtils.java diff --git a/.gitignore b/.gitignore index bb5e892b7..b5757d367 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ allure-results/ log4j.log src/test/resources/test.properties src/test/java/com/kaltura/client/test/tests/Sandbox.java +src/test/resources/db_utils_list.txt +src/test/resources/utils_list.txt diff --git a/src/test/java/com/kaltura/client/test/utils/InfraUtils.java b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java new file mode 100644 index 000000000..6549b6d07 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java @@ -0,0 +1,65 @@ +package com.kaltura.client.test.utils; + +import com.google.common.reflect.ClassPath; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.nio.charset.Charset; +import java.util.Set; + +public class InfraUtils { + + public static void writeUtilsListToFile() throws IOException { + String packageName = "com.kaltura.client.test.utils"; + + File file = new File("src/test/resources/utils_list.txt"); + FileUtils.writeStringToFile(file, "package - " + packageName, Charset.defaultCharset()); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + + Set allClasses = ClassPath.from(ClassLoader.getSystemClassLoader()).getTopLevelClasses(packageName); + for (ClassPath.ClassInfo classInfo: allClasses) { + FileUtils.writeStringToFile(file, "class - " + classInfo.getSimpleName() + ":", Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + + Class clazz = classInfo.load(); + Method[] methods = clazz.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (Modifier.isStatic(methods[i].getModifiers())) { + FileUtils.writeStringToFile(file, methods[i].getName(), Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + } + } + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + } + } + + public static void writeDbUtilsListToFile() throws IOException { + String packageName = "com.kaltura.client.test.utils.dbUtils"; + + File file = new File("src/test/resources/db_utils_list.txt"); + FileUtils.writeStringToFile(file, "package - " + packageName, Charset.defaultCharset()); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + + Set allClasses = ClassPath.from(ClassLoader.getSystemClassLoader()).getTopLevelClasses(packageName); + for (ClassPath.ClassInfo classInfo: allClasses) { + FileUtils.writeStringToFile(file, "class - " + classInfo.getSimpleName() + ":", Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + + Class clazz = classInfo.load(); + Method[] methods = clazz.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (Modifier.isStatic(methods[i].getModifiers())) { + FileUtils.writeStringToFile(file, methods[i].getName(), Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + } + } + FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + } + } +} From 9545aa9b10049cede47c7952c0b4f66b3bcdd103 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 28 May 2018 22:09:37 +0300 Subject: [PATCH 275/605] externalize timeout config param --- .../com/kaltura/client/test/Properties.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 3 +- .../householdTests/householdSuspendTests.java | 97 +++++++++++++++++-- .../kaltura/client/test/utils/BaseUtils.java | 1 + .../kaltura/client/test/utils/InfraUtils.java | 24 ++--- .../client/test/utils/PurchaseUtils.java | 6 +- 6 files changed, 102 insertions(+), 31 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index f07de1288..9035420be 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -19,6 +19,7 @@ public class Properties { // Request properties public static final String PARTNER_ID = "partner_id"; + public static final String DEFAULT_TIMEOUT_IN_SEC = "default_timeout_in_sec"; // global users public static final String DEFAULT_USER_PASSWORD = "default_user_password"; @@ -41,7 +42,6 @@ public class Properties { //cycles public static final int CYCLE_1_DAY = 1440; // in minutes - // usage modules public static final String DEFAULT_USAGE_MODULE_4_INGEST_PPV = "default_usage_module_4_ingest_ppv"; // module has 10 Minutes life cycles, 0 maximum views public static final String DEFAULT_USAGE_MODULE_4_INGEST_MPP = "default_usage_module_4_ingest_mpp"; // module has 1 Day life cycles, 0 maximum views diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 5654f9001..db244de42 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -28,7 +28,6 @@ public class BaseTest { - private final int DEFAULT_TIMEOUT_IN_SEC = 60; public static final boolean LOG_HEADERS = false; public static Client client; @@ -109,7 +108,7 @@ public void base_test_before_suite() { client = new Client(config); // set default awaitility timeout - setDefaultTimeout(DEFAULT_TIMEOUT_IN_SEC, TimeUnit.SECONDS); + setDefaultTimeout(Long.parseLong(getProperty(DEFAULT_TIMEOUT_IN_SEC)), TimeUnit.SECONDS); // set shared common params partnerId = Integer.parseInt(getProperty(PARTNER_ID)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java index 683dfefe6..8330a8ce6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.householdTests; import com.kaltura.client.enums.HouseholdState; +import com.kaltura.client.enums.TransactionType; import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.UserRoleService; import com.kaltura.client.test.tests.BaseTest; @@ -17,6 +18,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.EntitlementService.CancelEntitlementBuilder; +import static com.kaltura.client.services.EntitlementService.cancel; import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.services.OttUserService.login; import static org.assertj.core.api.Assertions.assertThat; @@ -43,7 +46,7 @@ private void household_suspendTests_beforeClass() { // set household int numberOfUsersInHousehold = 2; int numberOfDevicesInHousehold = 1; - household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); masterUser = HouseholdUtils.getMasterUserFromHousehold(household); } @@ -63,6 +66,9 @@ private void suspend() { // get household Response householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())).setKs(getOperatorKs())); assertThat(householdResponse.results.getState().getValue()).isEqualTo(HouseholdState.SUSPENDED.getValue()); + + // cleanup - resume household + executor.executeSync(HouseholdService.resume().setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUser.getUserId()))); } @Severity(SeverityLevel.MINOR) @@ -78,7 +84,7 @@ private void suspend_with_masterUser_ks() { assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500004).getCode()); } - @Severity(SeverityLevel.CRITICAL) + @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - login role - error 7013") @Test private void suspend_with_login_role() { @@ -91,7 +97,7 @@ private void suspend_with_login_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; - // suspend login + // suspend with login role SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId())); @@ -109,7 +115,7 @@ private void suspend_with_login_role() { executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); } - @Severity(SeverityLevel.CRITICAL) + @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - purchase_subscription role - error 7013") @Test private void suspend_with_purchase_subscription_role() { @@ -122,14 +128,14 @@ private void suspend_with_purchase_subscription_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; - // suspend purchase_subscription + // suspend with purchase_subscription role SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId())); Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); assertThat(booleanResponse.results).isTrue(); - // purchase_subscription + // purchase subscription String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); Response transactionResponse = PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(BaseTest.getSharedCommonSubscription().getId())); @@ -140,6 +146,85 @@ private void suspend_with_purchase_subscription_role() { executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); } + @Severity(SeverityLevel.NORMAL) + @Description("household/action/suspend - cancel_subscription role - error 1009") + @Test + private void suspend_with_cancel_subscription_role() { + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.CANCEL_SUBSCRIPTION.name()); + role.setName(Permissions.CANCEL_SUBSCRIPTION.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // purchase subscription + String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + Subscription subscription = BaseTest.getSharedCommonSubscription(); + PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(subscription.getId())); + + // suspend with cancel_subscription role + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + + // cancel subscription + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION); + booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUser.getUserId()))); + + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1009).getCode()); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } + + @Severity(SeverityLevel.NORMAL) + @Description("household/action/suspend - playback_subscription role - ") + @Test + private void suspend_with_playback_subscription_role() { + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.PLAYBACK_SUBSCRIPTION.name()); + role.setName(Permissions.PLAYBACK_SUBSCRIPTION.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // purchase subscription + String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + Subscription subscription = BaseTest.getSharedCommonSubscription(); + PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(subscription.getId())); + + // play file from subscription +// AssetService.getPlaybackContext() +// AssetFileService.playManifest() + + +// +// // suspend with cancel_subscription role +// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) +// .setKs(getOperatorKs()) +// .setUserId(Integer.valueOf(masterUser.getUserId())); +// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); +// assertThat(booleanResponse.results).isTrue(); +// +// // cancel subscription +// CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION); +// booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUser.getUserId()))); +// +// assertThat(booleanResponse.results).isNull(); +// assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1009).getCode()); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } +// playback_subscription + @AfterClass private void household_suspendTests_afterClass() { // cleanup - delete household diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index e63d54bdb..a707b98ef 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -92,6 +92,7 @@ public static APIException getAPIExceptionFromList(int code) { } Logger.getLogger(BaseUtils.class).error("No such error code in the API schema"); + return null; } diff --git a/src/test/java/com/kaltura/client/test/utils/InfraUtils.java b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java index 6549b6d07..168d2802b 100644 --- a/src/test/java/com/kaltura/client/test/utils/InfraUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java @@ -2,7 +2,6 @@ import com.google.common.reflect.ClassPath; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import java.io.File; import java.io.IOException; @@ -17,24 +16,19 @@ public static void writeUtilsListToFile() throws IOException { String packageName = "com.kaltura.client.test.utils"; File file = new File("src/test/resources/utils_list.txt"); - FileUtils.writeStringToFile(file, "package - " + packageName, Charset.defaultCharset()); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, "package - " + packageName + "\n", Charset.defaultCharset()); Set allClasses = ClassPath.from(ClassLoader.getSystemClassLoader()).getTopLevelClasses(packageName); for (ClassPath.ClassInfo classInfo: allClasses) { - FileUtils.writeStringToFile(file, "class - " + classInfo.getSimpleName() + ":", Charset.defaultCharset(), true); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, "\n" + "class - " + classInfo.getSimpleName() + ":" + "\n", Charset.defaultCharset(), true); Class clazz = classInfo.load(); Method[] methods = clazz.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (Modifier.isStatic(methods[i].getModifiers())) { - FileUtils.writeStringToFile(file, methods[i].getName(), Charset.defaultCharset(), true); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, methods[i].getName() + "\n", Charset.defaultCharset(), true); } } - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); } } @@ -42,24 +36,20 @@ public static void writeDbUtilsListToFile() throws IOException { String packageName = "com.kaltura.client.test.utils.dbUtils"; File file = new File("src/test/resources/db_utils_list.txt"); - FileUtils.writeStringToFile(file, "package - " + packageName, Charset.defaultCharset()); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, "package - " + packageName + "\n", Charset.defaultCharset()); Set allClasses = ClassPath.from(ClassLoader.getSystemClassLoader()).getTopLevelClasses(packageName); for (ClassPath.ClassInfo classInfo: allClasses) { - FileUtils.writeStringToFile(file, "class - " + classInfo.getSimpleName() + ":", Charset.defaultCharset(), true); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, "\n" + "class - " + classInfo.getSimpleName() + ":" + "\n", Charset.defaultCharset(), true); Class clazz = classInfo.load(); Method[] methods = clazz.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (Modifier.isStatic(methods[i].getModifiers())) { - FileUtils.writeStringToFile(file, methods[i].getName(), Charset.defaultCharset(), true); - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); + FileUtils.writeStringToFile(file, methods[i].getName() + "\n", Charset.defaultCharset(), true); } } - FileUtils.writeStringToFile(file, IOUtils.LINE_SEPARATOR, Charset.defaultCharset(), true); } + } } diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 994df81c5..32a948f8a 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -28,9 +28,8 @@ public class PurchaseUtils { // TODO: 14/MAR/2018 add return public static Response purchasePpv(String ks, Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { purchasePpvDetailsMap = new HashMap<>(); - int paymentGatewayId = 0; - int internalFileId = -1; + int internalFileId; if (fileId.isPresent()) { internalFileId = fileId.get(); } else { @@ -60,7 +59,6 @@ public static Response purchasePpv(String ks, Optional med purchase.setCurrency(currency); purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.PPV).get()); - purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); PurchaseTransactionBuilder transactionBuilder = TransactionService.purchase(purchase).setKs(ks); Response transactionResponse = executor.executeSync(transactionBuilder); @@ -76,7 +74,6 @@ public static Response purchasePpv(String ks, Optional med public static Response purchaseSubscription(String ks, int subscriptionId) { purchaseSubscriptionDetailsMap = new HashMap<>(); - int paymentGatewayId = 0; ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(String.valueOf(subscriptionId)); @@ -94,7 +91,6 @@ public static Response purchaseSubscription(String ks, int subscrip purchase.setCurrency(currency); purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.SUBSCRIPTION).get()); - purchase.setPaymentGatewayId(Optional.of(paymentGatewayId).get()); PurchaseTransactionBuilder purchaseTransactionBuilder = TransactionService.purchase(purchase).setKs(ks); Response transactionResponse = executor.executeSync(purchaseTransactionBuilder); From 130afed9284b941172579890d844cdc1beef167c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 29 May 2018 09:31:08 +0300 Subject: [PATCH 276/605] removed useless test --- .../four_eight/PermissionsManagementTests.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 579b80362..682f8a186 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -382,19 +382,4 @@ public void deleteOnlyFromOneTable() { int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); assertThat(rowsInRolesHavingName).isEqualTo(0); } - - // TODO: check how to use it - @Test(enabled = false, groups = {"Permission management"}) - public void readXMLFile() throws ParserConfigurationException, IOException, SAXException { - File file = new File(dataFilePath); - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - Document document = documentBuilder.parse(file); - assertThat(document).isNotNull(); - String id = document.getElementsByTagName("role").item(1).getChildNodes().item(1).getTextContent(); - String name = document.getElementsByTagName("role").item(1).getChildNodes().item(3).getTextContent(); - System.out.println("role id = " + id); - System.out.println("role name = " + name); - System.out.println("# of roles: " + document.getElementsByTagName("role").getLength()); - } } From dd6828d55359e3c47d730888610a9edcb14c70ef Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 29 May 2018 15:03:06 +0300 Subject: [PATCH 277/605] responses having lists without objects shouldn't be scheme-validated --- .../kaltura/client/test/TestAPIOkRequestsExecutor.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 61005af4c..24077d34a 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -5,6 +5,7 @@ import com.kaltura.client.ILogger; import com.kaltura.client.Logger; import com.kaltura.client.types.APIException; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.request.RequestBuilder; import com.kaltura.client.utils.request.RequestElement; import com.kaltura.client.utils.response.base.ApiCompletion; @@ -59,6 +60,14 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request String s2 = response.results.getClass().getSimpleName(); String s3 = ".json"; + // if returned list without objects scheme should not be checked + if (s2.equals("ListResponse")) { + com.kaltura.client.utils.response.base.Response listResponse = response; + if (listResponse.results.getTotalCount() == 0) { + return responseElement; + } + } + String schema = s1 + s2 + s3; Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); /*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); From 8436f382ef011645f81f55634b863d880f842ebe Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 30 May 2018 09:55:41 +0300 Subject: [PATCH 278/605] Method generateUserRole() moved into utils --- .../ottUserTests/OttUserAddRoleTests.java | 17 ++------------- .../client/test/utils/UserRoleUtils.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java index f264df0fb..38304775a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.services.OttUserService; import com.kaltura.client.services.UserRoleService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.UserRoleUtils; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.UserRole; import com.kaltura.client.types.UserRoleFilter; @@ -15,7 +16,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Random; import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.services.UserRoleService.*; @@ -35,7 +35,7 @@ private void addRole() { OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; // generate new role - UserRole userRole = generateUserRole(); + UserRole userRole = UserRoleUtils.generateUserRole(); // add role AddUserRoleBuilder addUserRoleBuilder = add(userRole) @@ -96,17 +96,4 @@ private void addRole_with_invalid_roleId() { // cleanup executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } - - private UserRole generateUserRole() { - Random r = new Random(); - int low = 9000; - int max = 10000; - long roleId = r.nextInt(max - low) + low; - - UserRole userRole = new UserRole(); - userRole.setId(roleId); - userRole.setName(String.valueOf(roleId)); - - return userRole; - } } diff --git a/src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java b/src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java new file mode 100644 index 000000000..65eb7f354 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java @@ -0,0 +1,21 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.types.UserRole; +import java.util.Random; + +public class UserRoleUtils extends BaseUtils { + + + public static UserRole generateUserRole() { + Random r = new Random(); + int low = 9000; + int max = 10000; + long roleId = r.nextInt(max - low) + low; + + UserRole userRole = new UserRole(); + userRole.setId(roleId); + userRole.setName(String.valueOf(roleId)); + + return userRole; + } +} From e469bcbbe3728ed0b913461522c438035a247157 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 30 May 2018 12:27:32 +0300 Subject: [PATCH 279/605] HouseholdSuspendTest --- ...dTests.java => HouseholdSuspendTests.java} | 150 ++++++++++++++---- .../client/test/utils/HouseholdUtils.java | 2 +- .../client/test/utils/SubscriptionUtils.java | 16 +- src/test/resources/WORK_PLAN.md | 85 +++++++++- src/test/resources/schemas/OTTUser.json | 6 +- .../resources/schemas/PlaybackContext.json | 43 +++++ 6 files changed, 263 insertions(+), 39 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/{householdSuspendTests.java => HouseholdSuspendTests.java} (57%) create mode 100644 src/test/resources/schemas/PlaybackContext.json diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java similarity index 57% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 8330a8ce6..93970f404 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -1,14 +1,10 @@ package com.kaltura.client.test.tests.servicesTests.householdTests; -import com.kaltura.client.enums.HouseholdState; -import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.enums.*; import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.UserRoleService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.OttUserUtils; -import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -18,16 +14,21 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Optional; + +import static com.kaltura.client.services.AssetService.GetPlaybackContextAssetBuilder; +import static com.kaltura.client.services.AssetService.getPlaybackContext; import static com.kaltura.client.services.EntitlementService.CancelEntitlementBuilder; import static com.kaltura.client.services.EntitlementService.cancel; import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.services.OttUserService.login; import static org.assertj.core.api.Assertions.assertThat; -public class householdSuspendTests extends BaseTest { +public class HouseholdSuspendTests extends BaseTest { private Household household; private HouseholdUser masterUser; + private String masterUserKs; private enum Permissions { PLAYBACK_SUBSCRIPTION, @@ -48,6 +49,10 @@ private void household_suspendTests_beforeClass() { int numberOfDevicesInHousehold = 1; household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); } @Severity(SeverityLevel.CRITICAL) @@ -75,8 +80,6 @@ private void suspend() { @Description("household/action/suspend - with master user ks - error 500004") @Test private void suspend_with_masterUser_ks() { - String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); - // suspend household Response booleanResponse = executor.executeSync(HouseholdService.suspend().setKs(masterUserKs)); @@ -85,7 +88,7 @@ private void suspend_with_masterUser_ks() { } @Severity(SeverityLevel.NORMAL) - @Description("household/action/suspend - login role - error 7013") + @Description("household/action/suspend - with login role - error 7013") @Test private void suspend_with_login_role() { // create role @@ -116,7 +119,7 @@ private void suspend_with_login_role() { } @Severity(SeverityLevel.NORMAL) - @Description("household/action/suspend - purchase_subscription role - error 7013") + @Description("household/action/suspend - with purchase_subscription role - error 7013") @Test private void suspend_with_purchase_subscription_role() { // create role @@ -136,8 +139,7 @@ private void suspend_with_purchase_subscription_role() { assertThat(booleanResponse.results).isTrue(); // purchase subscription - String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); - Response transactionResponse = PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(BaseTest.getSharedCommonSubscription().getId())); + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(BaseTest.getSharedCommonSubscription().getId())); assertThat(transactionResponse.results).isNull(); assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); @@ -147,7 +149,7 @@ private void suspend_with_purchase_subscription_role() { } @Severity(SeverityLevel.NORMAL) - @Description("household/action/suspend - cancel_subscription role - error 1009") + @Description("household/action/suspend - with cancel_subscription role - error 1009") @Test private void suspend_with_cancel_subscription_role() { // create role @@ -160,9 +162,8 @@ private void suspend_with_cancel_subscription_role() { role = userRoleResponse.results; // purchase subscription - String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); Subscription subscription = BaseTest.getSharedCommonSubscription(); - PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(subscription.getId())); + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); // suspend with cancel_subscription role SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) @@ -183,7 +184,7 @@ private void suspend_with_cancel_subscription_role() { } @Severity(SeverityLevel.NORMAL) - @Description("household/action/suspend - playback_subscription role - ") + @Description("household/action/suspend - with playback_subscription role") @Test private void suspend_with_playback_subscription_role() { // create role @@ -195,35 +196,118 @@ private void suspend_with_playback_subscription_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; + // suspend with playback_subscription role + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + // purchase subscription - String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); Subscription subscription = BaseTest.getSharedCommonSubscription(); - PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(subscription.getId())); + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + + // get asset from subscription + Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); - // play file from subscription -// AssetService.getPlaybackContext() -// AssetFileService.playManifest() + // get platbackContext + PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); + playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); + playbackContextOptions.setStreamerType("applehttp"); + playbackContextOptions.setMediaProtocol("http"); + GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(asset.getId()), AssetType.MEDIA, playbackContextOptions) + .setKs(masterUserKs); + Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); + assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); + assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); + assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } + +// @Severity(SeverityLevel.NORMAL) +// @Description("household/action/suspend - with purchase_ppv role") +// @Test +// private void suspend_with_purchase_ppv_role() { +// // create role +// UserRole role = new UserRole(); +// role.setExcludedPermissionNames(Permissions.PURCHASE_PPV.name()); +// role.setName(Permissions.PURCHASE_PPV.name()); // -// // suspend with cancel_subscription role +// // add role +// Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); +// role = userRoleResponse.results; +// +// // suspend with purchase_ppv role // SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) // .setKs(getOperatorKs()) // .setUserId(Integer.valueOf(masterUser.getUserId())); // Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); // assertThat(booleanResponse.results).isTrue(); // -// // cancel subscription -// CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION); -// booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUser.getUserId()))); +// // get asset from subscription +// Subscription subscription = BaseTest.getSharedCommonSubscription(); +// Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); // -// assertThat(booleanResponse.results).isNull(); -// assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1009).getCode()); - - // cleanup - delete role - executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); - } -// playback_subscription +// // get ppv +// ProductPriceFilter filter = new ProductPriceFilter(); +// filter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); +// +// ProductPrice productPrice = executor.executeSync(ProductPriceService.list(filter) +// .setKs(getOperatorKs())).results.getObjects().get(0); +// +// PurchaseUtils.purchasePpv(masterUserKs, ) +// +// assertThat(transactionResponse.results).isNull(); +// assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); +// +// // cleanup - delete role +// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); +// } + +// @Severity(SeverityLevel.NORMAL) +// @Description("household/action/suspend - with purchase_ppv role after purchase the subscription") +// @Test +// private void suspend_with_purchase_ppv_role() { +// // create role +// UserRole role = new UserRole(); +// role.setExcludedPermissionNames(Permissions.PURCHASE_PPV.name()); +// role.setName(Permissions.PURCHASE_PPV.name()); +// +// // add role +// Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); +// role = userRoleResponse.results; +// +// // suspend with purchase_ppv role +// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) +// .setKs(getOperatorKs()) +// .setUserId(Integer.valueOf(masterUser.getUserId())); +// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); +// assertThat(booleanResponse.results).isTrue(); +// +// // purchase subscription +// Subscription subscription = BaseTest.getSharedCommonSubscription(); +// PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); +// +// // get asset from subscription +// Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); +// +// // get ppv +// ProductPriceFilter filter = new ProductPriceFilter(); +// filter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); +// +// List productPrices = executor.executeSync(ProductPriceService.list(filter) +// .setKs(getOperatorKs())).results.getObjects(); +// +// assertThat(transactionResponse.results).isNull(); +// assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); +// +// // cleanup - delete role +// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); +// } @AfterClass private void household_suspendTests_afterClass() { diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 090e24e7e..dac12b5b2 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -66,7 +66,7 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO HouseholdDevice householdDevice = new HouseholdDevice(); householdDevice.setUdid(String.valueOf(uniqueString)); Random r = new Random(); - householdDevice.setBrandId(r.nextInt(30 - 1) + 1); + householdDevice.setBrandId(r.nextInt(28 - 1) + 1); householdDevice.setName(String.valueOf(uniqueString) + "device"); // add device to household diff --git a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java index b0940d7d4..e663c2ed6 100644 --- a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java @@ -9,6 +9,7 @@ import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -34,6 +35,19 @@ public static List getAssetsListBySubscription(int subscriptionId, Option } else { assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter).setKs(getOperatorKs())); } - return assetListResponse.results.getObjects(); + + // remove assets without media files from list + List assets = assetListResponse.results.getObjects(); + List assetsToRemove = new ArrayList<>(); + + for (Asset asset : assets) { + if (asset.getMediaFiles().size() < 1) { + assetsToRemove.add(asset); + } + } + + assets.removeAll(assetsToRemove); + + return assets; } } diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 2f6ef72d2..6c4ea273a 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -1,7 +1,12 @@ # PHASE 1 Migrate services tests from ReadyAPI +# PHASE 2 +Migrate features tests from ReadyAPI + + ### Services List: + | Service | Status | |------------------------------|--------| | announcement | | @@ -39,7 +44,7 @@ Migrate services tests from ReadyAPI | favorite | | | followTvSeries | | | homeNetwork | | -| household | Alon - in progress | +| household | Alon - in progress, actions: add - done, delete - done, get - done, suspend - in progress, purge, resume, resetFrequency, update | | householdDevice | | | householdLimitations | | | householdPaymentGateway | | @@ -95,3 +100,81 @@ Migrate services tests from ReadyAPI | userInterest | | | userLoginPin | | | userRole | | + + +### Features List: + +| Features | Status | +|-------------------------------------------------------------------------------------------------------|--------| +| Thor - Search recordings | | +| Thor - New DMS | | +| Thor - C-DVR bookmarks | | +| Thor - Social settings and actions | | +| Thor - Social feed | | +| Thor - Verify playback license for recordings | | +| Ultron - Delete_close household [BEO-2723] | | +| Ultron - Automated email configuration | | +| Ultron - Purchase email to be sent to the HH master only [BEO-2780] | | +| Ultron - Revoke KS | | +| Ultron - Reminders | | +| TVPAPItokens [BEO-2911] | | +| Ultron - Change subscription PM [BEO-2766] | | +| FinancialReports | | +| Ultron - Change subscription | | +| Ultron - Support for secure player playback on Phoenix | | +| Ultron - Gift Cards [BEO-2730] | | +| Vision - Elastic search events notifications | | +| Vision - Grant gift - next subscription charges discount | | +| Vision - Multi-currency support | | +| Vision - Holistic Freemium solution [BEO-3166] | | +| Vision - get seasons/episodes APIs [BEO-3234] | | +| Vision - Quota Overage [BEO-3163] | | +| Vision - Enable delete household account from TVM | | +| Vision - DRM security with DRM ID | | +| Vision - Holdback Mechanism [BEO-3122] | | +| Vision - holistic freemium solution - Ads Control as premium service (Updated in Yoda - BEO-BEO-4090] | | +| Vision - Grace period for auto-deleted recordings [BEO-3214] | | +| Vision - Cancel purchase event [BEO-3475] | | +| Wonder woman - soundex search research | | +| Wonder woman - Engagement Notification | | +| Wonder woman - Enable app-token to all users [BEO-3172] | | +| WW - Multiple coupons per subscription [BEO-2643] | | +| Wonder Woman - Maxmind enchancements [BEO-3523] | | +| WW - Multiple subscription product codes [BEO-3631] | | +| Wonder woman - subscription dependencies_groups [BEO-3516] | | +| Wonder woman - Interests | | +| Wonder woman - Series Reminders | | +| KSQL - exists / not exists operator | | +| WW - HouseholdDevice LoginwithPin [BEO-3787] | | +| Wonder Woman - scheduling rules - add rule end-date [BEO-3788] | | +| Xena - Dependency subscriptionset [BEO-3840] | | +| Xena - Package price update from BSS [BEO-3796] | | +| Xena - Content de-duplication in a channel list [BEO-3854] | | +| Xena - KalturaScheduledRecordingProgramFilter [BEO-3890] | | +| Xena - unified billing cycle [BEO-4022] | | +| Yoda - aggregated renewals transaction [BEO-4023] | | +| Yoda - Graceful subscription renewal for external wallet[BEO-3940] | | +| Yoda - Email OTP enablement [BEO-4085] | | +| Yoda - Suspend/Resume Household service (Profiles)[BEO-4088] | Tests moved to HouseholdSuspendTests | +| Zatanna - Improving concurrency - group of media assets[BEO-4294] | | +| Zatanna - Concurrency EPG [BEO - 4255] | | +| Zatanna - Collections | | +| Zatanna - Improving concurrency - updated downgrade handling [BEO-4292] | | +| Zattana - Deleted expired VOD assets from Kaltura DB [BEO-4354] | | +| Zattana - Nagra SSP integration - New Adapter [BEO-4288] | | +| Zatanna - Next Package price [BEO-4234] | | +| Zatanna - Purchase flow adjustments [BEO-3968] | | +| Zatanna - Email for X days before renewal [BEO-4381] | | +| Zatanna - Events for end of subscriptions [BEO-4483] | | +| Zatanna - GDPR - API to delete HH data [BEO-4482] | | +| 4.7.2 - Email notifications control by the user | | +| 4.7.2 - SMS notifications | | +| 4_7_2 - Nokia nPVR - Backward compatibility | | +| 4.8 - Partial billing for promo (Coupons) [BEO-4763] | | +| 4.8 - Purchased content should not be displayed in recommendations [BEO-4764] | | +| 4.8 - Watched content should not be displayed in recommendations [BEO-4823] | | +| 4.8 - Scheduling rule for business model change[BEO-4221] | | +| 4.8 - Coupons Updates[BEO-4901] | | +| 4.8.2 - GDPR - create scripts that delete the deleted and purged HH[BEO-5010] | | +| 4.8.2 - Multi-Geo Asset Availability Windowing | | +| 4.8.2 - Master user can hide part of the linear channel[BEO-4765] | | \ No newline at end of file diff --git a/src/test/resources/schemas/OTTUser.json b/src/test/resources/schemas/OTTUser.json index 41ea9045d..f2e6120af 100644 --- a/src/test/resources/schemas/OTTUser.json +++ b/src/test/resources/schemas/OTTUser.json @@ -5,7 +5,7 @@ "type": "object", "properties": { "householdId": {"type": "integer", "minimum": 0}, - "email": {"type": "string", "minLength": 5}, + "email": {"type": "string"}, "country": { "type": "object", "properties": { @@ -32,8 +32,8 @@ "userState": {"type": "string", "minLength": 1}, "id": {"type": "string", "minLength": 1}, "username": {"type": "string", "minLength": 1}, - "firstName": {"type": "string", "minLength": 1}, - "lastName": {"type": "string", "minLength": 1}, + "firstName": {"type": "string"}, + "lastName": {"type": "string"}, "objectType": {"type": "string", "enum": ["KalturaOTTUser"]} }, "required": ["householdId", "email", "countryId", "dynamicData", "isHouseholdMaster", "suspentionState", diff --git a/src/test/resources/schemas/PlaybackContext.json b/src/test/resources/schemas/PlaybackContext.json new file mode 100644 index 000000000..74aa0967f --- /dev/null +++ b/src/test/resources/schemas/PlaybackContext.json @@ -0,0 +1,43 @@ +{ + "$id": "PlaybackContext", + "definitions": { + "PlaybackContext": { + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "sources": { + "type": "array" + }, + "actions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": {"type": "string", "minLength": 1}, + "objectType": {"type": "string", "minLength": 1} + } + } + }, + "messages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "message": {"type": "string", "minLength": 1}, + "code": {"type": "string", "minLength": 1}, + "objectType": {"type": "string", "minLength": 1} + } + } + }, + "objectType": {"type": "string", "minLength": 1} + }, + "required": ["sources", "actions", "messages", "objectType"] + }, + "executionTime": {"type": "number", "minimum": 0} + } + } + }, + "ref": "#/definitions/PlaybackContext" +} \ No newline at end of file From 9fce3dbbfe5263a156d8a65994796b9694e9c491 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 30 May 2018 13:54:18 +0300 Subject: [PATCH 280/605] Added logic for getting sharedPpv --- .../kaltura/client/test/tests/BaseTest.java | 26 +++++++++++++++++++ .../EntitlementGrantTests.java | 5 ++-- .../test/utils/dbUtils/DBConstants.java | 6 +++++ .../test/utils/dbUtils/IngestFixtureData.java | 23 ++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index db244de42..307e41c3c 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -63,6 +63,9 @@ public class BaseTest { // shared ingested subscription private static Subscription sharedCommonSubscription; + // shared ingested PPV + private static Ppv sharedCommonPpv; + // cycles map with values related view/full life cycles of price plans private static Map cycles = new HashMap<>(); { @@ -166,6 +169,29 @@ public static Subscription getSharedCommonSubscription(){ return sharedCommonSubscription; } + /** + * Regression requires existing of PPV with specific parameters. + * Price Plan should be as for method public static PricePlan getSharedCommonPricePlan() + * + * PPV should be with discount (internal items) 50% + * + * @return PPV with mentioned parameters + */ + public static Ppv getSharedCommonPpv(){ + double discountPercentValue = 50.0; + String defaultCurrency = "EUR"; + if (sharedCommonPpv == null) { + sharedCommonPpv = IngestFixtureData.loadSharedCommonPpv(getSharedCommonPricePlan()); + if (sharedCommonPpv == null) { + sharedCommonPpv = IngestUtils.ingestPPV(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), + Optional.empty(), Optional.of(IngestFixtureData.getDiscount(defaultCurrency, (int) discountPercentValue)), + Optional.empty(), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), + Optional.of(false), Optional.of(false), Optional.empty(), Optional.empty(), Optional.empty()); + } + } + return sharedCommonPpv; + } + public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index d9d475dd1..cad2a4beb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -29,8 +29,8 @@ public class EntitlementGrantTests extends BaseTest { - // TODO: 4/12/2018 remove hardcoded ppv Id - private final int ppvId = 30297; + // TODO: 4/12/2018 remove hardcoded assetId + private int ppvId; private final int assetId = 607368; private int subscriptionId; private int contentId; @@ -47,6 +47,7 @@ private void grant_test_before_class() { contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); subscriptionId = Integer.valueOf(getSharedCommonSubscription().getId()); + ppvId = Integer.valueOf(getSharedCommonPpv().getId()); } @Test(description = "entitlement/action/grant - grant subscription with history = true") diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index e35c1ca02..4a27df508 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -15,6 +15,7 @@ public class DBConstants { static final String NUMBER_OF_REC_PERIODS = "num_of_rec_periods"; static final String PASSWORD = "password"; static final String ROW_COUNT = "row_count"; + static final String SUBSCRIPTION_ONLY = "subscription_only"; static final String USERNAME = "username"; static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; @@ -50,6 +51,11 @@ public class DBConstants { "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; + static final String PPV_SELECT = "select top 1 * from [Pricing].[dbo].[ppv_modules]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d and usage_module_code=%d\n" + + "order by create_date"; + static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + "where pc.[status]=1 and pc.is_active=1\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index efb8eebd0..db9f8fd65 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -182,4 +182,27 @@ public static String getIngestItemUserData(int accountId) { return result; } + + public static Ppv loadSharedCommonPpv(PricePlan pricePlan) { + Logger.getLogger(IngestFixtureData.class).debug("loadSharedCommonPpv(): pricePlan id = " + pricePlan.getId()); + + Ppv ppv = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PPV_SELECT, partnerId, + pricePlan.getId()), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return ppv; + } + + ppv = new Ppv(); + ppv.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + ppv.setName(jsonArray.getJSONObject(0).getString(NAME)); + ppv.setIsSubscriptionOnly(jsonArray.getJSONObject(0).getInt(SUBSCRIPTION_ONLY) == 0); + // TODO: add more data in case it needed + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("Ppv data can't be null"); + } + return ppv; + } } From 18b7f6386ca1b49669d9dc423ef7c31bcdc61197 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 30 May 2018 15:26:57 +0300 Subject: [PATCH 281/605] Updated AssetListTests class --- .../AssetTests/AssetListTests.java | 66 ++++++++++++++----- .../AssetHistoryCleanTests.java | 6 +- .../AssetHistoryListTests.java | 6 +- .../channelTests/ChannelAddTests.java | 4 +- .../client/test/utils/IngestUtils.java | 13 +++- 5 files changed, 68 insertions(+), 27 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java index 3c9f87ab3..f5ee991d6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -16,6 +16,11 @@ import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; @@ -24,18 +29,24 @@ public class AssetListTests extends BaseTest { private MediaAsset asset; private MediaAsset asset2; + private MediaAsset asset3; private String ksqlQuery; private AssetFilter assetFilter = null; private ListAssetBuilder listAssetBuilder = null; + private Map map = new HashMap(); + private ArrayList list = new ArrayList<>(); + private String tagName = "Genre"; + private String tagValue = "shmulik_1233"; @BeforeClass private void Asset_list_before_class() { // Get asset from shared asset method asset = BaseTest.getSharedMediaAsset(); // Ingest asset2 - asset2 = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); - - ksqlQuery = "name = '" + asset.getName() + "'"; + list.add(tagValue); + map.put(tagName, list); + asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); + asset3 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); } @@ -46,12 +57,14 @@ private void Asset_list_before_class() { @Description("Asset/action/list - VOD - name equal query") @Test private void listVodAssetsWithExactKsqlQuery() { - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, - null,null); - listAssetBuilder = AssetService.list(assetFilter,null) + ksqlQuery = "name = '" + asset.getName() + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); } @@ -60,12 +73,13 @@ private void listVodAssetsWithExactKsqlQuery() { @Test private void listVodAssetsWithExactKsqlQuery2() { ksqlQuery = "media_id = '" + asset.getId() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, - null,null); - listAssetBuilder = AssetService.list(assetFilter,null) + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); } @@ -74,12 +88,30 @@ private void listVodAssetsWithExactKsqlQuery2() { @Test private void listVodAssetsWithOrQuery() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, - null,null); - listAssetBuilder = AssetService.list(assetFilter,null) + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(2); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - AND query") + @Test + private void listVodAssetsWithAndQuery() { + ksqlQuery = "(and media_id = '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); } @@ -88,6 +120,7 @@ private void listVodAssetsWithOrQuery() { @Description("Asset/action/list - VOD - not query") @Test private void listVodAssetsWithNotKsqlQuery() { + } @@ -97,11 +130,12 @@ private void listVodAssetsWithNotKsqlQuery() { @Test private void listVodAssetsWithLikeKsqlQuery() { ksqlQuery = "name ~ '" + asset.getName() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null,null,null,null, - null,null); - listAssetBuilder = AssetService.list(assetFilter,null) + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); } @@ -114,6 +148,4 @@ private void listVodAssetsWithStartWithKsqlQuery() { } - - } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 6951edbb6..a03ab4c97 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -46,13 +46,13 @@ public class AssetHistoryCleanTests extends BaseTest { // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); + movie = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); + movie2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestBasicVOD(EPISODE_MEDIA_TYPE); + episode = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 486b8c3d2..420472883 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -45,13 +45,13 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestBasicVOD( MOVIE_MEDIA_TYPE); + movie = IngestUtils.ingestVOD( MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); + movie2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestBasicVOD(EPISODE_MEDIA_TYPE); + episode = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index d621d515c..fa5f1ea79 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -61,10 +61,10 @@ private void checkOrderOfAssetsInChannel() { //String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); // Ingest first asset - MediaAsset movieAsset = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); + MediaAsset movieAsset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); // Ingest second asset - MediaAsset episodeAsset = IngestUtils.ingestBasicVOD(MOVIE_MEDIA_TYPE); + MediaAsset episodeAsset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 1a9d609e5..6289f59db 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -1048,7 +1048,7 @@ private static String generateTagsXml(Map> metas) { // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestBasicVOD(String mediaType) { + public static MediaAsset ingestVOD(String mediaType) { MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -1056,12 +1056,21 @@ public static MediaAsset ingestBasicVOD(String mediaType) { return mediaAsset; } + // + public static MediaAsset ingestVOD(String mediaType,Map> tags) { + MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), + Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); + + return mediaAsset; + } + public static ArrayList ingestBasicVODNumOfTimes(int numOfAssets, String mediaType) { MediaAsset mediaAsset; ArrayList assetList = new ArrayList<>(); for (int i = 0; i < numOfAssets; i++) { - mediaAsset = ingestBasicVOD(mediaType); + mediaAsset = ingestVOD(mediaType); assetList.add(mediaAsset); } return assetList; From b9e0a71ce8c8c6059329024414a06e897f6284c8 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 30 May 2018 15:27:14 +0300 Subject: [PATCH 282/605] --- --- .../test/tests/servicesTests/AssetTests/AssetListTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java index f5ee991d6..c45f41f2c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -120,7 +120,7 @@ private void listVodAssetsWithAndQuery() { @Description("Asset/action/list - VOD - not query") @Test private void listVodAssetsWithNotKsqlQuery() { - + } From b6bc96eb96a6bc14e897f5e2793df80be6417ac1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 30 May 2018 17:24:33 +0300 Subject: [PATCH 283/605] HouseholdSuspendTests --- .../householdTests/HouseholdSuspendTests.java | 219 +++++++++++------- .../kaltura/client/test/utils/BaseUtils.java | 1 - .../client/test/utils/IngestUtils.java | 1 + .../client/test/utils/PurchaseUtils.java | 1 - src/test/resources/WORK_PLAN.md | 2 +- 5 files changed, 132 insertions(+), 92 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 93970f404..f40231068 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -29,6 +29,8 @@ public class HouseholdSuspendTests extends BaseTest { private Household household; private HouseholdUser masterUser; private String masterUserKs; + private Subscription subscription; + private Asset asset; private enum Permissions { PLAYBACK_SUBSCRIPTION, @@ -36,10 +38,10 @@ private enum Permissions { PURCHASE_SUBSCRIPTION, PURCHASE_PPV, RENEW_SUBSCRIPTION, - PURCHASE_SERVICE, + PURCHASE_SERVICE, // purchase preminum serivces LOGIN, CANCEL_SUBSCRIPTION, - DELETE_ALL_APP_TOKENS + DELETE_ALL_APP_TOKENS // not for checking } @BeforeClass @@ -53,6 +55,12 @@ private void household_suspendTests_beforeClass() { // set masterUserKs String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + + // set subscription + subscription = BaseTest.getSharedCommonSubscription(); + + // set asset + asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); } @Severity(SeverityLevel.CRITICAL) @@ -139,11 +147,25 @@ private void suspend_with_purchase_subscription_role() { assertThat(booleanResponse.results).isTrue(); // purchase subscription - Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(BaseTest.getSharedCommonSubscription().getId())); + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); assertThat(transactionResponse.results).isNull(); assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); + // purchase ppv in order to verify suspend is specific to role + Integer mediaFileId = asset.getMediaFiles().get(0).getId(); + transactionResponse = PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), + Optional.of(mediaFileId), null); + + assertThat(transactionResponse.error).isNull(); + assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // cleanup - cancel ppv + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Math.toIntExact(asset.getId()), TransactionType.PPV) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + executor.executeSync(cancelEntitlementBuilder); + // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); } @@ -161,10 +183,6 @@ private void suspend_with_cancel_subscription_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; - // purchase subscription - Subscription subscription = BaseTest.getSharedCommonSubscription(); - PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); - // suspend with cancel_subscription role SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) .setKs(getOperatorKs()) @@ -172,13 +190,21 @@ private void suspend_with_cancel_subscription_role() { Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); assertThat(booleanResponse.results).isTrue(); + // purchase subscription + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + // cancel subscription - CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION); - booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUser.getUserId()))); + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + booleanResponse = executor.executeSync(cancelEntitlementBuilder); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1009).getCode()); + // cleanup - cancel subscription + cancelSubscription(); + // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); } @@ -204,12 +230,8 @@ private void suspend_with_playback_subscription_role() { assertThat(booleanResponse.results).isTrue(); // purchase subscription - Subscription subscription = BaseTest.getSharedCommonSubscription(); PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); - // get asset from subscription - Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); - // get platbackContext PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); @@ -224,94 +246,113 @@ private void suspend_with_playback_subscription_role() { assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); + // cleanup - cancel subscription + cancelSubscription(); + // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); } -// @Severity(SeverityLevel.NORMAL) -// @Description("household/action/suspend - with purchase_ppv role") -// @Test -// private void suspend_with_purchase_ppv_role() { -// // create role -// UserRole role = new UserRole(); -// role.setExcludedPermissionNames(Permissions.PURCHASE_PPV.name()); -// role.setName(Permissions.PURCHASE_PPV.name()); -// -// // add role -// Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); -// role = userRoleResponse.results; -// -// // suspend with purchase_ppv role -// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) -// .setKs(getOperatorKs()) -// .setUserId(Integer.valueOf(masterUser.getUserId())); -// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); -// assertThat(booleanResponse.results).isTrue(); -// -// // get asset from subscription -// Subscription subscription = BaseTest.getSharedCommonSubscription(); -// Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); -// -// // get ppv -// ProductPriceFilter filter = new ProductPriceFilter(); -// filter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); -// -// ProductPrice productPrice = executor.executeSync(ProductPriceService.list(filter) -// .setKs(getOperatorKs())).results.getObjects().get(0); -// -// PurchaseUtils.purchasePpv(masterUserKs, ) -// + @Severity(SeverityLevel.NORMAL) + @Description("household/action/suspend - with purchase_ppv role") + @Test + private void suspend_with_purchase_ppv_role() { + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.PURCHASE_PPV.name()); + role.setName(Permissions.PURCHASE_PPV.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // suspend with purchase_ppv role + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + + // purchase ppv + Integer mediaFileId = asset.getMediaFiles().get(0).getId(); + Response transactionResponse = PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), + Optional.of(mediaFileId), null); + + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); + + // purchase subscription in order to verify suspend is specific to role + transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + + assertThat(transactionResponse.error).isNull(); + assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // cleanup - cancel subscription + cancelSubscription(); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } + + @Severity(SeverityLevel.NORMAL) + @Description("household/action/suspend - with _playback_ppv role") + @Test(enabled = false) + private void suspend_with_playback_ppv_role() { + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.PLAYBACK_PPV.name()); + role.setName(Permissions.PLAYBACK_PPV.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // suspend with purchase_ppv role + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + + // purchase ppv + Integer mediaFileId = asset.getMediaFiles().get(0).getId(); + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); + + // get platbackContext + PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); + playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); + playbackContextOptions.setStreamerType("applehttp"); + playbackContextOptions.setMediaProtocol("http"); + + GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(asset.getId()), AssetType.MEDIA, playbackContextOptions) + .setKs(masterUserKs); + Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); + + // TODO: 5/30/2018 finish test + // assertThat(transactionResponse.results).isNull(); // assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); // -// // cleanup - delete role -// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); -// } - -// @Severity(SeverityLevel.NORMAL) -// @Description("household/action/suspend - with purchase_ppv role after purchase the subscription") -// @Test -// private void suspend_with_purchase_ppv_role() { -// // create role -// UserRole role = new UserRole(); -// role.setExcludedPermissionNames(Permissions.PURCHASE_PPV.name()); -// role.setName(Permissions.PURCHASE_PPV.name()); -// -// // add role -// Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); -// role = userRoleResponse.results; -// -// // suspend with purchase_ppv role -// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) -// .setKs(getOperatorKs()) -// .setUserId(Integer.valueOf(masterUser.getUserId())); -// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); -// assertThat(booleanResponse.results).isTrue(); -// -// // purchase subscription -// Subscription subscription = BaseTest.getSharedCommonSubscription(); -// PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); -// -// // get asset from subscription -// Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); -// -// // get ppv -// ProductPriceFilter filter = new ProductPriceFilter(); -// filter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); -// -// List productPrices = executor.executeSync(ProductPriceService.list(filter) -// .setKs(getOperatorKs())).results.getObjects(); +// // purchase subscription in order to verify suspend is specific to role +// transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); // -// assertThat(transactionResponse.results).isNull(); -// assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); -// -// // cleanup - delete role -// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); -// } +// assertThat(transactionResponse.error).isNull(); +// assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } @AfterClass private void household_suspendTests_afterClass() { // cleanup - delete household executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } + + private void cancelSubscription() { + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + executor.executeSync(cancelEntitlementBuilder); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index a707b98ef..e63d54bdb 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -92,7 +92,6 @@ public static APIException getAPIExceptionFromList(int code) { } Logger.getLogger(BaseUtils.class).error("No such error code in the API schema"); - return null; } diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 167194a52..1ef090bb0 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -67,6 +67,7 @@ public class IngestUtils extends BaseUtils { "31/05/2017 23:59:59\n" + "Expired coupon group 1\n" + ""; + private static String MPP_DEFAULT_PRODUCT_CODES_VALUE = "\n" + "ProductCode1\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 32a948f8a..c261f2102 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -25,7 +25,6 @@ public class PurchaseUtils { private static Response> productPriceResponse; private static Response assetResponse; - // TODO: 14/MAR/2018 add return public static Response purchasePpv(String ks, Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { purchasePpvDetailsMap = new HashMap<>(); diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 6c4ea273a..204fe2326 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -72,7 +72,7 @@ Migrate features tests from ReadyAPI | ppv | | | priceDetails | | | pricePlan | | -| productPrice | Max - in progress | +| productPrice | Max - in progress | | purchaseSettings | | | recommendationProfile | | | recording | | From d3248ee7ed2276dc4fc01af5d6efcf4d30f4aa7a Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 31 May 2018 10:16:44 +0300 Subject: [PATCH 284/605] Updated class - "listVodAssetsWithLikeKsqlQuery" --- .../AssetTests/AssetListTests.java | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java index c45f41f2c..3b5ffeadc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.Asset; import com.kaltura.client.types.AssetFilter; @@ -12,6 +13,7 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.assertj.core.api.Assertions; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,11 +22,25 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; +import org.hamcrest.collection.IsEmptyCollection; + +import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; + +import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo; +import static org.hamcrest.number.OrderingComparison.lessThan; + +import static org.hamcrest.MatcherAssert.assertThat; + public class AssetListTests extends BaseTest { private MediaAsset asset; @@ -34,9 +50,10 @@ public class AssetListTests extends BaseTest { private AssetFilter assetFilter = null; private ListAssetBuilder listAssetBuilder = null; private Map map = new HashMap(); + private ArrayList assetList = new ArrayList<>(); private ArrayList list = new ArrayList<>(); private String tagName = "Genre"; - private String tagValue = "shmulik_1233"; + private String tagValue = BaseUtils.getRandomValue(tagName +"_",999999); @BeforeClass private void Asset_list_before_class() { @@ -48,6 +65,8 @@ private void Asset_list_before_class() { asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); asset3 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); + assetList.add(asset2.getId()); + assetList.add(asset3.getId()); } // KalturaSearchAssetFilter @@ -115,28 +134,38 @@ private void listVodAssetsWithAndQuery() { } - // TODO - complete test after ingest util was updated @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - not query") @Test private void listVodAssetsWithNotKsqlQuery() { + ksqlQuery = "(and media_id != '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; + System.out.println(ksqlQuery + "1234"); + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); } - // TODO - complete test after ingest util was updated @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - like query") @Test private void listVodAssetsWithLikeKsqlQuery() { - ksqlQuery = "name ~ '" + asset.getName() + "'"; + ksqlQuery = "" + tagName + " ~ '" + tagValue + "'"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, null); listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - Response> assetListResponse = executor.executeSync(listAssetBuilder); - assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + List assets = executor.executeSync(listAssetBuilder).results.getObjects(); + assertThat(assets.size()).isEqualTo(2); + + List assetIds = assets.stream().map(Asset::getId).collect(Collectors.toList()); + assertThat(assetIds).contains(asset3.getId(),asset2.getId()); + assertThat(assetIds).doesNotContain(asset.getId()); } // TODO - complete test after ingest util was updated From 52c8691aa6a0c48b67eb1eb7edbd092345caf552 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 31 May 2018 10:50:47 +0300 Subject: [PATCH 285/605] Added util StatisticsUtils.java --- .../client/test/utils/StatisticsUtils.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java diff --git a/src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java b/src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java new file mode 100644 index 000000000..6f18ff706 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java @@ -0,0 +1,56 @@ +package com.kaltura.client.test.utils; + +import com.google.common.reflect.ClassPath; +import com.kaltura.client.Logger; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.text.DecimalFormat; +import java.util.Set; + +public class StatisticsUtils extends BaseUtils { + + public static void displayStatisticsDisabledAndCriticalTests(String packageName) { + Logger.getLogger(StatisticsUtils.class).debug("Package: [" + packageName + "]"); + Set allClasses = null; + try { + allClasses = ClassPath.from(ClassLoader.getSystemClassLoader()).getTopLevelClassesRecursive(packageName); + } catch (IOException e) { + e.printStackTrace(); + } + int totalTests = 0; + int disabledTests = 0; + int criticalSeverityTests = 0; + for (ClassPath.ClassInfo classInfo : allClasses) { + //Logger.getLogger(StatisticsUtils.class).debug("Class: [" + classInfo.getSimpleName() + "]"); + Class clazz = classInfo.load(); + Method[] methods = clazz.getDeclaredMethods(); + //Logger.getLogger(StatisticsUtils.class).debug("Methods:"); + for (int i = 0; i < methods.length; i++) { + //Logger.getLogger(StatisticsUtils.class).debug(methods[i].getName()); + //Logger.getLogger(StatisticsUtils.class).debug("Annotations:"); + for (Annotation annotation: methods[i].getDeclaredAnnotations()) { + if (annotation.toString().contains("org.testng.annotations.Test")) { + totalTests++; + if (annotation.toString().contains("enabled=false")) { + // Logger.getLogger(StatisticsUtils.class).debug(methods[i].getName()); + // Logger.getLogger(StatisticsUtils.class).debug(annotation.toString()); + disabledTests++; + } + } + if (annotation.toString().contains("io.qameta.allure.Severity(value=CRITICAL)")) { + criticalSeverityTests++; + } + } + } + //Logger.getLogger(StatisticsUtils.class).debug("________________________________________________"); + } + Logger.getLogger(StatisticsUtils.class).debug("total amount of tests: " + totalTests); + DecimalFormat df = new DecimalFormat("#.00"); + Logger.getLogger(StatisticsUtils.class).debug("disabled tests: " + disabledTests + " or " + + df.format(disabledTests*1.0/totalTests*100) + "%"); + Logger.getLogger(StatisticsUtils.class).debug("tests with critical severity: " + criticalSeverityTests + " or " + + df.format(criticalSeverityTests*1.0/totalTests*100) + "%"); + } +} + From 4ab32f7e0bd4327188c679ecbbd8bb0d2c42b5d0 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 31 May 2018 11:35:49 +0300 Subject: [PATCH 286/605] Updated AssetListTests class --- .../AssetTests/AssetListTests.java | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java index 3b5ffeadc..20a139e86 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -5,15 +5,11 @@ import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.IngestUtils; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.AssetFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.assertj.core.api.Assertions; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,25 +18,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; -import org.hamcrest.collection.IsEmptyCollection; - -import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; - -import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo; -import static org.hamcrest.number.OrderingComparison.lessThan; - -import static org.hamcrest.MatcherAssert.assertThat; - public class AssetListTests extends BaseTest { private MediaAsset asset; @@ -59,7 +41,6 @@ public class AssetListTests extends BaseTest { private void Asset_list_before_class() { // Get asset from shared asset method asset = BaseTest.getSharedMediaAsset(); - // Ingest asset2 list.add(tagValue); map.put(tagName, list); asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); @@ -139,7 +120,6 @@ private void listVodAssetsWithAndQuery() { @Test private void listVodAssetsWithNotKsqlQuery() { ksqlQuery = "(and media_id != '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; - System.out.println(ksqlQuery + "1234"); assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, null); listAssetBuilder = AssetService.list(assetFilter, null) @@ -163,17 +143,28 @@ private void listVodAssetsWithLikeKsqlQuery() { List assets = executor.executeSync(listAssetBuilder).results.getObjects(); assertThat(assets.size()).isEqualTo(2); - List assetIds = assets.stream().map(Asset::getId).collect(Collectors.toList()); - assertThat(assetIds).contains(asset3.getId(),asset2.getId()); - assertThat(assetIds).doesNotContain(asset.getId()); + assertThat(assets).extracting("id").contains(asset3.getId(),asset2.getId()).doesNotContain(asset.getId()); } + // TODO - complete test after ingest util was updated @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - start with query") @Test private void listVodAssetsWithStartWithKsqlQuery() { + + ksqlQuery = "" + tagName + " ^ '" + tagValue + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + List assets = executor.executeSync(listAssetBuilder).results.getObjects(); + assertThat(assets.size()).isEqualTo(2); + + assertThat(assets).extracting("id").contains(asset3.getId(),asset2.getId()).doesNotContain(asset.getId()); + + } From 713ec8508e68a5d6b5026dca1e34347b4efd52bd Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 31 May 2018 11:54:13 +0300 Subject: [PATCH 287/605] fixed some failures --- .../servicesTests/assetRuleTests/AssetRuleDeleteTests.java | 2 +- .../servicesTests/productPriceTests/ProductPriceListTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java index 88e3982ac..aff6e656e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetRuleTests/AssetRuleDeleteTests.java @@ -9,7 +9,7 @@ public class AssetRuleDeleteTests extends BaseTest { @Description("/assetrule/action/delete - currently used to run util only") - @Test + @Test(enabled = false) // as test is not implemented yet private void deleteAllGeoAssetRules() { AssetRuleUtils.deleteAllGeoAssetRules(); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 811ff0885..26400599c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -135,7 +135,7 @@ public void ppvTest() { entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(webMediaFileId); - assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(getSharedMediaAsset().getId().intValue()); + assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(Math.toIntExact(getSharedMediaAsset().getId())); assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()) .isGreaterThan(entitlementResponse.results.getObjects().get(0).getCurrentDate()); assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn(PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); From 2463c0dcb8a90f5c775ca00cbe78add50b319e5f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 31 May 2018 13:10:48 +0300 Subject: [PATCH 288/605] Fixed test case ChannelAddTests.checkOrderOfAssetsInChannel --- .../java/com/kaltura/client/test/IngestConstants.java | 1 + .../tests/servicesTests/channelTests/ChannelAddTests.java | 7 +++++-- .../java/com/kaltura/client/test/utils/IngestUtils.java | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/IngestConstants.java b/src/test/java/com/kaltura/client/test/IngestConstants.java index cc72c7955..c16612ff6 100644 --- a/src/test/java/com/kaltura/client/test/IngestConstants.java +++ b/src/test/java/com/kaltura/client/test/IngestConstants.java @@ -3,6 +3,7 @@ public class IngestConstants { public static final String INGEST_ACTION_INSERT = "insert"; + public static final String INGEST_ACTION_UPDATE = "update"; public static final String INGEST_ACTION_DELETE = "delete"; public static final Long MAX_RANDOM_GENERATED_VALUE_4_INGEST = 9999999999L; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index fa5f1ea79..ced09ca92 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.ChannelUtils; import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.types.*; @@ -57,14 +58,16 @@ private void addChannel() { @Test private void checkOrderOfAssetsInChannel() { - //String asset1Name = "Movie_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); - //String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); + String asset1Name = "Movie_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); + String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); // Ingest first asset MediaAsset movieAsset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + movieAsset = IngestUtils.updateVODName(movieAsset, asset1Name); // Ingest second asset MediaAsset episodeAsset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + episodeAsset = IngestUtils.updateVODName(episodeAsset, asset2Name); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 1e56a1965..0ffdac10d 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -1053,6 +1053,14 @@ public static MediaAsset ingestVOD(String mediaType) { return mediaAsset; } + public static MediaAsset updateVODName(MediaAsset asset, String name) { + MediaAsset mediaAsset = ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + return mediaAsset; + } + // public static MediaAsset ingestVOD(String mediaType,Map> tags) { MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), From b8d39104c9eddea0594cac72123bcf656e54efcf Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 31 May 2018 16:40:00 +0300 Subject: [PATCH 289/605] Removed all hardcoded values from EntitlementrantTests --- .../entitlementTests/EntitlementGrantTests.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index cad2a4beb..9ae68b4b1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -10,7 +10,6 @@ import com.kaltura.client.services.TransactionHistoryService; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.*; @@ -18,7 +17,6 @@ import io.qameta.allure.Issue; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.services.OttUserService.RegisterOttUserBuilder; import static com.kaltura.client.services.OttUserService.register; @@ -29,9 +27,8 @@ public class EntitlementGrantTests extends BaseTest { - // TODO: 4/12/2018 remove hardcoded assetId private int ppvId; - private final int assetId = 607368; + private int assetId; private int subscriptionId; private int contentId; @@ -44,7 +41,8 @@ public class EntitlementGrantTests extends BaseTest { @BeforeClass private void grant_test_before_class() { - contentId = AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0); + assetId = Math.toIntExact(getSharedMediaAsset().getId()); + contentId = getSharedWebMediaFile().getId(); testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); subscriptionId = Integer.valueOf(getSharedCommonSubscription().getId()); ppvId = Integer.valueOf(getSharedCommonPpv().getId()); From acad25e5fcadcb80eed5adb82c5b8c02d52182a4 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 31 May 2018 17:17:03 +0300 Subject: [PATCH 290/605] HouseholdUpdateTests --- .../kaltura/client/test/tests/BaseTest.java | 11 +- ...ldAddTests.java => HouseholdAddTests.java} | 2 +- ...teTests.java => HouseholdDeleteTests.java} | 2 +- ...ldGetTests.java => HouseholdGetTests.java} | 2 +- .../householdTests/HouseholdResumeTests.java | 120 ++++++++++++ .../householdTests/HouseholdSuspendTests.java | 39 ++-- .../householdTests/HouseholdUpdateTests.java | 107 +++++++++++ ...GetTests.java => LicensedUrlGetTests.java} | 2 +- .../ottUserTests/OttUserUpdateTests.java | 178 +++++++++--------- ....java => TransactionHistoryListTests.java} | 2 +- 10 files changed, 345 insertions(+), 120 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/{householdAddTests.java => HouseholdAddTests.java} (97%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/{householdDeleteTests.java => HouseholdDeleteTests.java} (98%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/{householdGetTests.java => HouseholdGetTests.java} (98%) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java rename src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/{licensedUrlGetTests.java => LicensedUrlGetTests.java} (67%) rename src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/{ListTests.java => TransactionHistoryListTests.java} (99%) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 307e41c3c..3fe239b96 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -194,7 +194,7 @@ public static Ppv getSharedCommonPpv(){ public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId); + String userInfo = IngestFixtureData.getIngestItemUserData(partnerId); ingestBusinessModuleUserUsername = userInfo.split(":")[0]; ingestBusinessModuleUserPassword = userInfo.split(":")[1]; } @@ -203,7 +203,7 @@ public static String getIngestBusinessModuleUserName() { public static String getIngestBusinessModuleUserPassword() { if (ingestBusinessModuleUserPassword == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId); + String userInfo = IngestFixtureData.getIngestItemUserData(partnerId); ingestBusinessModuleUserUsername = userInfo.split(":")[0]; ingestBusinessModuleUserPassword = userInfo.split(":")[1]; } @@ -212,7 +212,7 @@ public static String getIngestBusinessModuleUserPassword() { public static String getIngestAssetUserName() { if (ingestAssetUserUsername == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId + 1); + String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } @@ -221,7 +221,7 @@ public static String getIngestAssetUserName() { public static String getIngestAssetUserPassword() { if (ingestAssetUserPassword == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId + 1); + String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } @@ -331,8 +331,7 @@ public static Household getSharedHousehold() { if (user.getIsMaster() != null && user.getIsMaster()) { sharedMasterUser = user; } - // TODO: ask Alon if we have cases when commented part should be there? What tests related to that logic? - if (user.getIsMaster() == null/* && user.getIsDefault() == null*/) { + if (user.getIsMaster() == null && user.getIsDefault() == null) { sharedUser = user; } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdAddTests.java similarity index 97% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdAddTests.java index 9b35b085a..46d8243e9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdAddTests.java @@ -18,7 +18,7 @@ import static com.kaltura.client.services.HouseholdService.delete; import static org.assertj.core.api.Assertions.assertThat; -public class householdAddTests extends BaseTest { +public class HouseholdAddTests extends BaseTest { private Household household; private HouseholdUser masterUser; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdDeleteTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdDeleteTests.java index 24166d964..7c1d1875b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdDeleteTests.java @@ -16,7 +16,7 @@ import static com.kaltura.client.services.HouseholdService.get; import static org.assertj.core.api.Assertions.assertThat; -public class householdDeleteTests extends BaseTest { +public class HouseholdDeleteTests extends BaseTest { private final int numberOfUsersInHousehold = 1; private final int numberOfDevicesInHousehold = 1; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdGetTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdGetTests.java index 358572063..0e51c7c4c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/householdGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdGetTests.java @@ -17,7 +17,7 @@ import static com.kaltura.client.services.HouseholdService.*; import static org.assertj.core.api.Assertions.assertThat; -public class householdGetTests extends BaseTest { +public class HouseholdGetTests extends BaseTest { private Household household; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java new file mode 100644 index 000000000..a24503a4b --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java @@ -0,0 +1,120 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.enums.HouseholdState; +import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.services.UserRoleService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.services.HouseholdService.get; +import static org.assertj.core.api.Assertions.assertThat; + +public class HouseholdResumeTests extends BaseTest { + + private Household household; + private HouseholdUser masterUser; + private String masterUserKs; + private Subscription subscription; + + @BeforeClass + private void household_resumeTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 2; + int numberOfDevicesInHousehold = 1; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + + // set subscription + subscription = BaseTest.getSharedCommonSubscription(); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/resume - suspended household") + @Test + private void resume_suspended_household() { + // suspend household + executor.executeSync(HouseholdService.suspend() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))); + + // get household - verify status is suspended + Response householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + assertThat(householdResponse.results.getState()).isEqualTo(HouseholdState.SUSPENDED); + + // resume household + Response booleanResponse = executor.executeSync(HouseholdService.resume() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // get household - verify status is ok + householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(householdResponse.results.getState()).isEqualTo(HouseholdState.OK); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/resume - suspended household") + @Test + private void resume_suspended_with_purchase_subscription_role_household() { + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames("PURCHASE_SUBSCRIPTION"); + role.setName("PURCHASE_SUBSCRIPTION"); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // suspend household + executor.executeSync(HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))); + + // get household - verify status is suspended + Response householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + assertThat(householdResponse.results.getState()).isEqualTo(HouseholdState.SUSPENDED); + + // resume household + Response booleanResponse = executor.executeSync(HouseholdService.resume() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // get household - verify status is ok + householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(householdResponse.results.getState()).isEqualTo(HouseholdState.OK); + + // purchase subscription + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + assertThat(transactionResponse.error).isNull(); + assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + } + + @AfterClass + private void household_resumeTests_afterClass() { + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + } + + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index f40231068..bc43d4005 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -8,6 +8,7 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; @@ -38,10 +39,10 @@ private enum Permissions { PURCHASE_SUBSCRIPTION, PURCHASE_PPV, RENEW_SUBSCRIPTION, - PURCHASE_SERVICE, // purchase preminum serivces + PURCHASE_SERVICE, // purchase premium services LOGIN, CANCEL_SUBSCRIPTION, - DELETE_ALL_APP_TOKENS // not for checking + DELETE_ALL_APP_TOKENS } @BeforeClass @@ -295,8 +296,9 @@ private void suspend_with_purchase_ppv_role() { } @Severity(SeverityLevel.NORMAL) + @Issue("BEO-5166") @Description("household/action/suspend - with _playback_ppv role") - @Test(enabled = false) + @Test(enabled = true) private void suspend_with_playback_ppv_role() { // create role UserRole role = new UserRole(); @@ -307,17 +309,17 @@ private void suspend_with_playback_ppv_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; - // suspend with purchase_ppv role + // purchase ppv + Integer mediaFileId = asset.getMediaFiles().get(0).getId(); + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); + + // suspend with playback_ppv role SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId())); Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); assertThat(booleanResponse.results).isTrue(); - // purchase ppv - Integer mediaFileId = asset.getMediaFiles().get(0).getId(); - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); - // get platbackContext PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); @@ -328,16 +330,17 @@ private void suspend_with_playback_ppv_role() { .setKs(masterUserKs); Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); - // TODO: 5/30/2018 finish test - -// assertThat(transactionResponse.results).isNull(); -// assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); -// -// // purchase subscription in order to verify suspend is specific to role -// transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); -// -// assertThat(transactionResponse.error).isNull(); -// assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); + assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); + assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); + + // purchase subscription in order to verify suspend is specific to role + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + assertThat(transactionResponse.error).isNull(); + assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // cleanup - cancel subscription + cancelSubscription(); // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java new file mode 100644 index 000000000..1611d0a35 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java @@ -0,0 +1,107 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.services.HouseholdService.update; +import static org.assertj.core.api.Assertions.assertThat; + +public class HouseholdUpdateTests extends BaseTest { + + private Household household; + private HouseholdUser masterUser; + private String masterUserKs; + + @BeforeClass + private void household_updateTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 2; + int numberOfDevicesInHousehold = 1; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/update - with masterUserKs") + @Test + private void update_with_masterUserKs() { + // update household + String householdUpdatedDetails = "updated details with masterUserKs"; + Household updatedHousehold = new Household(); + updatedHousehold.setName(householdUpdatedDetails); + updatedHousehold.setDescription(householdUpdatedDetails); + + updatedHousehold = executor.executeSync(update(updatedHousehold) + .setKs(masterUserKs)) + .results; + + assertThat(updatedHousehold.getName()).isEqualTo(householdUpdatedDetails); + assertThat(updatedHousehold.getDescription()).isEqualTo(householdUpdatedDetails); + assertThat(updatedHousehold).isEqualToIgnoringGivenFields(household, "name", "description", + "frequencyNextDeviceAction", "frequencyNextUserAction", "restriction"); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/update - with operatorKs") + @Test + private void update_with_operatorKs() { + // update household + String householdUpdatedDetails = "updated details with operatorKs"; + Household updatedHousehold = new Household(); + updatedHousehold.setName(householdUpdatedDetails); + updatedHousehold.setDescription(householdUpdatedDetails); + + updatedHousehold = executor.executeSync(update(updatedHousehold) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))) + .results; + + assertThat(updatedHousehold.getName()).isEqualTo(householdUpdatedDetails); + assertThat(updatedHousehold.getDescription()).isEqualTo(householdUpdatedDetails); + assertThat(updatedHousehold).isEqualToIgnoringGivenFields(household, "name", "description", + "frequencyNextDeviceAction", "frequencyNextUserAction", "restriction"); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/update - with regular userKs") + @Test + private void update_with_regular_userKs() { + // update household + String householdUpdatedDetails = "updated details with regular userKs"; + Household updatedHousehold = new Household(); + updatedHousehold.setName(householdUpdatedDetails); + updatedHousehold.setDescription(householdUpdatedDetails); + + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + + updatedHousehold = executor.executeSync(update(updatedHousehold) + .setKs(userKs)) + .results; + + assertThat(updatedHousehold.getName()).isEqualTo(householdUpdatedDetails); + assertThat(updatedHousehold.getDescription()).isEqualTo(householdUpdatedDetails); + assertThat(updatedHousehold).isEqualToIgnoringGivenFields(household, "name", "description", + "frequencyNextDeviceAction", "frequencyNextUserAction", "restriction"); + } + + @AfterClass + private void household_updateTests_afterClass() { + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/licensedUrlGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/LicensedUrlGetTests.java similarity index 67% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/licensedUrlGetTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/LicensedUrlGetTests.java index 2a369427d..b6f02f8ea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/licensedUrlGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/licensedUrlTests/LicensedUrlGetTests.java @@ -1,4 +1,4 @@ package com.kaltura.client.test.tests.servicesTests.licensedUrlTests; -public class licensedUrlGetTests { +public class LicensedUrlGetTests { } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index 022469422..475841a95 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -6,13 +6,13 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.services.OttUserService.login; +import static com.kaltura.client.services.OttUserService.register; import static com.kaltura.client.test.utils.OttUserUtils.dynamicDataMapBuilder; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -20,115 +20,111 @@ public class OttUserUpdateTests extends BaseTest { - private Response ottUserResponse; + private OTTUser user; + private String userKs; - - @Severity(SeverityLevel.CRITICAL) - @Description("ottUser/action/update - update") - @Issue("BEO-5114") - @Test(enabled = false) - private void update() { - // register user - OTTUser user = generateOttUser(); + @BeforeClass + private void ottUser_updateTests_beforeClass() { + // set household + user = generateOttUser(); user.setDynamicData(dynamicDataMapBuilder("key", "value")); - ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); - user = ottUserResponse.results; - String originalUserEmail = user.getEmail(); + // register user + user = executor.executeSync(register(partnerId, user, defaultUserPassword)).results; // login user Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); - String userKs = loginResponse.results.getLoginSession().getKs(); + user = loginResponse.results.getUser(); + userKs = loginResponse.results.getLoginSession().getKs(); + } + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/update - update") + @Test(enabled = false) + private void update() { // update user info String newUserInfo = "newUserInfo"; - user.setFirstName(newUserInfo); - user.setLastName(newUserInfo); - user.setAddress(newUserInfo); - - ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(userKs)); - assertThat(ottUserResponse.error).isNull(); + OTTUser updatedUser = new OTTUser(); + updatedUser.setFirstName(newUserInfo); + updatedUser.setLastName(newUserInfo); + updatedUser.setAddress(newUserInfo); - // get user after update - user = executor.executeSync(get().setKs(userKs)).results; + updatedUser = executor.executeSync(OttUserService.update(updatedUser).setKs(userKs)).results; // assert user new info - assertThat(ottUserResponse.error).isNull(); - assertThat(user.getFirstName()).isEqualTo(newUserInfo); - assertThat(user.getLastName()).isEqualTo(newUserInfo); - assertThat(user.getAddress()).isEqualTo(newUserInfo); - assertThat(user.getEmail()).isEqualTo(originalUserEmail); + assertThat(updatedUser.getFirstName()).isEqualTo(newUserInfo); + assertThat(updatedUser.getLastName()).isEqualTo(newUserInfo); + assertThat(updatedUser.getAddress()).isEqualTo(newUserInfo); + assertThat(updatedUser).isEqualToIgnoringGivenFields(user, "firstName", "lastName", "address"); - // cleanup - executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); +// // cleanup +// executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } @Severity(SeverityLevel.CRITICAL) - @Description("ottUser/action/update - update with administratorKs") - @Test(enabled = true) + @Description("ottUser/action/update - with administratorKs") + @Test(enabled = false) private void update_with_administratorKs() { - // register user - OTTUser user = generateOttUser(); - user.setDynamicData(dynamicDataMapBuilder("key", "value")); - - ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); - user = ottUserResponse.results; - String originalUserEmail = user.getEmail(); - - // update user info - String newUserInfo = "newUserInfo"; - user.setFirstName(newUserInfo); - user.setLastName(newUserInfo); - user.setAddress(newUserInfo); - - ottUserResponse = executor.executeSync(OttUserService.update(user) - .setKs(getAdministratorKs()) - .setUserId(Integer.valueOf(user.getId()))); - assertThat(ottUserResponse.error).isNull(); - - // get user after update - ottUserResponse = executor.executeSync(get() - .setKs(getAdministratorKs()) - .setUserId(Integer.valueOf(user.getId()))); - user = ottUserResponse.results; - - // assert user new info - assertThat(ottUserResponse.error).isNull(); - assertThat(user.getFirstName()).isEqualTo(newUserInfo); - assertThat(user.getLastName()).isEqualTo(newUserInfo); - assertThat(user.getAddress()).isEqualTo(newUserInfo); - assertThat(user.getEmail()).isEqualTo(originalUserEmail); - - // cleanup - executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); +// // register user +// OTTUser user = generateOttUser(); +// user.setDynamicData(dynamicDataMapBuilder("key", "value")); +// +// ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); +// user = ottUserResponse.results; +// String originalUserEmail = user.getEmail(); +// +// // update user info +// String newUserInfo = "newUserInfo"; +// user.setFirstName(newUserInfo); +// user.setLastName(newUserInfo); +// user.setAddress(newUserInfo); +// +// ottUserResponse = executor.executeSync(OttUserService.update(user) +// .setKs(getAdministratorKs()) +// .setUserId(Integer.valueOf(user.getId()))); +// assertThat(ottUserResponse.error).isNull(); +// +// // get user after update +// ottUserResponse = executor.executeSync(get() +// .setKs(getAdministratorKs()) +// .setUserId(Integer.valueOf(user.getId()))); +// user = ottUserResponse.results; +// +// // assert user new info +// assertThat(ottUserResponse.error).isNull(); +// assertThat(user.getFirstName()).isEqualTo(newUserInfo); +// assertThat(user.getLastName()).isEqualTo(newUserInfo); +// assertThat(user.getAddress()).isEqualTo(newUserInfo); +// assertThat(user.getEmail()).isEqualTo(originalUserEmail); +// +// // cleanup +// executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/update - update user externalId - error ") - @Test(enabled = true) + @Test(enabled = false) private void update_user_externalId() { - // register user - OTTUser user = generateOttUser(); - user.setDynamicData(dynamicDataMapBuilder("key", "value")); - - ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); - user = ottUserResponse.results; - - // login user - Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); - String userKs = loginResponse.results.getLoginSession().getKs(); - - // update user externalId - String newExternalId = "newExternalId"; - user.setExternalId(newExternalId); - - ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(userKs)); - assertThat(ottUserResponse.results).isNull(); - assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500051).getCode()); - - // cleanup - executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); +// // register user +// OTTUser user = generateOttUser(); +// user.setDynamicData(dynamicDataMapBuilder("key", "value")); +// +// ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); +// user = ottUserResponse.results; +// +// // login user +// Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); +// String userKs = loginResponse.results.getLoginSession().getKs(); +// +// // update user externalId +// String newExternalId = "newExternalId"; +// user.setExternalId(newExternalId); +// +// ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(userKs)); +// assertThat(ottUserResponse.results).isNull(); +// assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500051).getCode()); +// +// // cleanup +// executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } - - } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java similarity index 99% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index 06fad0774..89b5ecd9e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -21,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class ListTests extends BaseTest{ +public class TransactionHistoryListTests extends BaseTest{ private EntitlementFilter entitlementPpvFilter; private TransactionHistoryFilter transactionHistoryFilter; From 34996babe3b7ee9a3f8459753803e1408f1d4ca1 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 31 May 2018 17:32:30 +0300 Subject: [PATCH 291/605] Added new overload method of ingest EPG --- .../java/com/kaltura/client/test/utils/IngestUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 1e56a1965..9663e2b88 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -86,6 +86,11 @@ public class IngestUtils extends BaseUtils { private static int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; + public static List ingestEPG(String epgChannelName, Integer programCount) { + return ingestEPG(epgChannelName, Optional.of(programCount), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + } + // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project public static List ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, Optional programDuration, Optional programDurationPeriodName, @@ -1054,7 +1059,7 @@ public static MediaAsset ingestVOD(String mediaType) { } // - public static MediaAsset ingestVOD(String mediaType,Map> tags) { + public static MediaAsset ingestVOD(String mediaType, Map> tags) { MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); From 683c630a71451ded31726af106bf4a0968d74afc Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Thu, 31 May 2018 17:32:52 +0300 Subject: [PATCH 292/605] Updated class - AssetListsTests --- .../AssetTests/AssetListTests.java | 84 ++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java index 20a139e86..bb3f1d2e4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -19,7 +20,10 @@ import java.util.List; import java.util.Map; +import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; +import static com.kaltura.client.test.Properties.getProperty; import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; @@ -28,6 +32,9 @@ public class AssetListTests extends BaseTest { private MediaAsset asset; private MediaAsset asset2; private MediaAsset asset3; + private ProgramAsset program; + private ProgramAsset program2; + private String ksqlQuery; private AssetFilter assetFilter = null; private ListAssetBuilder listAssetBuilder = null; @@ -36,6 +43,8 @@ public class AssetListTests extends BaseTest { private ArrayList list = new ArrayList<>(); private String tagName = "Genre"; private String tagValue = BaseUtils.getRandomValue(tagName +"_",999999); + private String epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); + private String epgChannelName2 = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(1).getString("name"); @BeforeClass private void Asset_list_before_class() { @@ -44,15 +53,22 @@ private void Asset_list_before_class() { list.add(tagValue); map.put(tagName, list); asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); - asset3 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); + asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map); assetList.add(asset2.getId()); assetList.add(asset3.getId()); + + program = IngestUtils.ingestEPG(epgChannelName,1).get(0); + program2 = IngestUtils.ingestEPG(epgChannelName2,1).get(0); + } // KalturaSearchAssetFilter // ****************************************** + // VOD + // ****************************************** + @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - name equal query") @Test @@ -84,7 +100,7 @@ private void listVodAssetsWithExactKsqlQuery2() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - or query") + @Description("Asset/action/list - VOD - OR query") @Test private void listVodAssetsWithOrQuery() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')"; @@ -147,7 +163,6 @@ private void listVodAssetsWithLikeKsqlQuery() { } - // TODO - complete test after ingest util was updated @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - start with query") @Test @@ -163,9 +178,72 @@ private void listVodAssetsWithStartWithKsqlQuery() { assertThat(assets.size()).isEqualTo(2); assertThat(assets).extracting("id").contains(asset3.getId(),asset2.getId()).doesNotContain(asset.getId()); + } + + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - filtered by type (Movie)") + @Test + private void listVodAssetsFilteredByType() { + + ksqlQuery = "" + tagName + " = '" + tagValue + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null , getProperty(MOVIE_MEDIA_TYPE_ID), null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response> assetListResponse = executor.executeSync(listAssetBuilder); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); + } + + // EPG + // ****************************************** + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - EPG - name equal query") + @Test + private void listEpgProgramWithExactKsqlQuery() { + ksqlQuery = "name = '" + program.getName() + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - EPG - epg channel id equal query") + @Test + private void listEpgProgramWithExactKsqlQuery2() { + ksqlQuery = "epg_channel_id = '" + program.getEpgChannelId() + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + List epgPrograms = executor.executeSync(listAssetBuilder).results.getObjects(); + assertThat(epgPrograms.size()).isGreaterThan(1); + assertThat(epgPrograms).extracting("epgChannelId").contains(program.getEpgChannelId()); } + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - EPG - filter by epg channel id") + @Test + private void listEpgProgramsFilteredByEpgChannel() { + ksqlQuery = "(or name = '" + program.getName() + "' name = '" + program2.getName() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, program2.getEpgChannelId().toString(), "0", null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program2.getId()); + } } From 2fa415d7bd1ab2ec467444718a94eaafc844ae8e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 31 May 2018 20:46:07 +0300 Subject: [PATCH 293/605] no message --- .../householdTests/HouseholdSuspendTests.java | 123 +++++++++++------ .../ottUserTests/OttUserUpdateTests.java | 128 +++++++----------- 2 files changed, 131 insertions(+), 120 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index bc43d4005..e88050e04 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -11,7 +11,6 @@ import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -27,9 +26,9 @@ public class HouseholdSuspendTests extends BaseTest { - private Household household; - private HouseholdUser masterUser; - private String masterUserKs; + private final int numberOfUsersInHousehold = 2; + private final int numberOfDevicesInHousehold = 1; + private Subscription subscription; private Asset asset; @@ -47,16 +46,6 @@ private enum Permissions { @BeforeClass private void household_suspendTests_beforeClass() { - // set household - int numberOfUsersInHousehold = 2; - int numberOfDevicesInHousehold = 1; - household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - - // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); - masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); - // set subscription subscription = BaseTest.getSharedCommonSubscription(); @@ -68,6 +57,10 @@ private void household_suspendTests_beforeClass() { @Description("household/action/suspend") @Test private void suspend() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + // suspend household SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend() .setKs(getOperatorKs()) @@ -81,25 +74,40 @@ private void suspend() { Response householdResponse = executor.executeSync(get(Math.toIntExact(household.getId())).setKs(getOperatorKs())); assertThat(householdResponse.results.getState().getValue()).isEqualTo(HouseholdState.SUSPENDED.getValue()); - // cleanup - resume household - executor.executeSync(HouseholdService.resume().setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUser.getUserId()))); + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.MINOR) @Description("household/action/suspend - with master user ks - error 500004") @Test private void suspend_with_masterUser_ks() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + // suspend household Response booleanResponse = executor.executeSync(HouseholdService.suspend().setKs(masterUserKs)); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(500004).getCode()); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with login role - error 7013") @Test private void suspend_with_login_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + // create role UserRole role = new UserRole(); role.setExcludedPermissionNames(Permissions.LOGIN.name()); @@ -125,12 +133,23 @@ private void suspend_with_login_role() { // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with purchase_subscription role - error 7013") @Test private void suspend_with_purchase_subscription_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + // create role UserRole role = new UserRole(); role.setExcludedPermissionNames(Permissions.PURCHASE_SUBSCRIPTION.name()); @@ -161,20 +180,25 @@ private void suspend_with_purchase_subscription_role() { assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); - // cleanup - cancel ppv - CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Math.toIntExact(asset.getId()), TransactionType.PPV) - .setKs(getOperatorKs()) - .setUserId(Integer.valueOf(masterUser.getUserId())); - executor.executeSync(cancelEntitlementBuilder); - // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with cancel_subscription role - error 1009") @Test private void suspend_with_cancel_subscription_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + // create role UserRole role = new UserRole(); role.setExcludedPermissionNames(Permissions.CANCEL_SUBSCRIPTION.name()); @@ -203,17 +227,25 @@ private void suspend_with_cancel_subscription_role() { assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1009).getCode()); - // cleanup - cancel subscription - cancelSubscription(); - // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with playback_subscription role") @Test private void suspend_with_playback_subscription_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + // create role UserRole role = new UserRole(); role.setExcludedPermissionNames(Permissions.PLAYBACK_SUBSCRIPTION.name()); @@ -247,17 +279,25 @@ private void suspend_with_playback_subscription_role() { assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); - // cleanup - cancel subscription - cancelSubscription(); - // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with purchase_ppv role") @Test private void suspend_with_purchase_ppv_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + // create role UserRole role = new UserRole(); role.setExcludedPermissionNames(Permissions.PURCHASE_PPV.name()); @@ -288,11 +328,11 @@ private void suspend_with_purchase_ppv_role() { assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); - // cleanup - cancel subscription - cancelSubscription(); - // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.NORMAL) @@ -300,6 +340,14 @@ private void suspend_with_purchase_ppv_role() { @Description("household/action/suspend - with _playback_ppv role") @Test(enabled = true) private void suspend_with_playback_ppv_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + // create role UserRole role = new UserRole(); role.setExcludedPermissionNames(Permissions.PLAYBACK_PPV.name()); @@ -339,23 +387,10 @@ private void suspend_with_playback_ppv_role() { assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); - // cleanup - cancel subscription - cancelSubscription(); - // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); - } - @AfterClass - private void household_suspendTests_afterClass() { // cleanup - delete household executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } - - private void cancelSubscription() { - CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION) - .setKs(getOperatorKs()) - .setUserId(Integer.valueOf(masterUser.getUserId())); - executor.executeSync(cancelEntitlementBuilder); - } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index 475841a95..ea05fe555 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -1,20 +1,23 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.LoginResponse; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.login; -import static com.kaltura.client.services.OttUserService.register; -import static com.kaltura.client.test.utils.OttUserUtils.dynamicDataMapBuilder; -import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; +import static com.kaltura.client.services.OttUserService.get; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -26,21 +29,19 @@ public class OttUserUpdateTests extends BaseTest { @BeforeClass private void ottUser_updateTests_beforeClass() { // set household - user = generateOttUser(); - user.setDynamicData(dynamicDataMapBuilder("key", "value")); + int numOfUsersInHousehold = 2; + int numOfDevicesInHousehold = 1; + Household household = HouseholdUtils.createHousehold(numOfUsersInHousehold, numOfDevicesInHousehold, true); + HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); + userKs = OttUserUtils.getKs(Integer.parseInt(householdUser.getUserId()), null); - // register user - user = executor.executeSync(register(partnerId, user, defaultUserPassword)).results; - - // login user - Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); - user = loginResponse.results.getUser(); - userKs = loginResponse.results.getLoginSession().getKs(); + // get ottUser + user = executor.executeSync(get().setKs(userKs)).results; } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update") - @Test(enabled = false) + @Test(enabled = true) private void update() { // update user info String newUserInfo = "newUserInfo"; @@ -48,6 +49,7 @@ private void update() { updatedUser.setFirstName(newUserInfo); updatedUser.setLastName(newUserInfo); updatedUser.setAddress(newUserInfo); +// updatedUser.setDynamicData(dynamicDataMapBuilder("key", "value")); updatedUser = executor.executeSync(OttUserService.update(updatedUser).setKs(userKs)).results; @@ -56,75 +58,49 @@ private void update() { assertThat(updatedUser.getLastName()).isEqualTo(newUserInfo); assertThat(updatedUser.getAddress()).isEqualTo(newUserInfo); assertThat(updatedUser).isEqualToIgnoringGivenFields(user, "firstName", "lastName", "address"); - -// // cleanup -// executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - with administratorKs") - @Test(enabled = false) + @Test(enabled = true) private void update_with_administratorKs() { -// // register user -// OTTUser user = generateOttUser(); -// user.setDynamicData(dynamicDataMapBuilder("key", "value")); -// -// ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); -// user = ottUserResponse.results; -// String originalUserEmail = user.getEmail(); -// -// // update user info -// String newUserInfo = "newUserInfo"; -// user.setFirstName(newUserInfo); -// user.setLastName(newUserInfo); -// user.setAddress(newUserInfo); -// -// ottUserResponse = executor.executeSync(OttUserService.update(user) -// .setKs(getAdministratorKs()) -// .setUserId(Integer.valueOf(user.getId()))); -// assertThat(ottUserResponse.error).isNull(); -// -// // get user after update -// ottUserResponse = executor.executeSync(get() -// .setKs(getAdministratorKs()) -// .setUserId(Integer.valueOf(user.getId()))); -// user = ottUserResponse.results; -// -// // assert user new info -// assertThat(ottUserResponse.error).isNull(); -// assertThat(user.getFirstName()).isEqualTo(newUserInfo); -// assertThat(user.getLastName()).isEqualTo(newUserInfo); -// assertThat(user.getAddress()).isEqualTo(newUserInfo); -// assertThat(user.getEmail()).isEqualTo(originalUserEmail); -// -// // cleanup -// executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + // update user info + String newUserInfo = "newUserInfo"; + OTTUser updatedUser = new OTTUser(); + updatedUser.setFirstName(newUserInfo); + updatedUser.setLastName(newUserInfo); + updatedUser.setAddress(newUserInfo); +// updatedUser.setDynamicData(dynamicDataMapBuilder("key", "value")); + + updatedUser = executor.executeSync(OttUserService.update(updatedUser) + .setKs(getAdministratorKs()) + .setUserId(Integer.valueOf(user.getId()))) + .results; + + // assert user new info + assertThat(updatedUser.getFirstName()).isEqualTo(newUserInfo); + assertThat(updatedUser.getLastName()).isEqualTo(newUserInfo); + assertThat(updatedUser.getAddress()).isEqualTo(newUserInfo); + assertThat(updatedUser).isEqualToIgnoringGivenFields(user, "firstName", "lastName", "address"); } @Severity(SeverityLevel.NORMAL) - @Description("ottUser/action/update - update user externalId - error ") - @Test(enabled = false) + @Description("ottUser/action/update - update user externalId - error 500051") + @Test(enabled = true) private void update_user_externalId() { -// // register user -// OTTUser user = generateOttUser(); -// user.setDynamicData(dynamicDataMapBuilder("key", "value")); -// -// ottUserResponse = executor.executeSync(register(partnerId, user, defaultUserPassword)); -// user = ottUserResponse.results; -// -// // login user -// Response loginResponse = executor.executeSync(login(partnerId, user.getUsername(), defaultUserPassword)); -// String userKs = loginResponse.results.getLoginSession().getKs(); -// -// // update user externalId -// String newExternalId = "newExternalId"; -// user.setExternalId(newExternalId); -// -// ottUserResponse = executor.executeSync(OttUserService.update(user).setKs(userKs)); -// assertThat(ottUserResponse.results).isNull(); -// assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500051).getCode()); -// -// // cleanup -// executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + // update user externalId + String newExternalId = "newExternalId"; + OTTUser updatedUser = new OTTUser(); + updatedUser.setExternalId(newExternalId); + + Response ottUserResponse = executor.executeSync(OttUserService.update(updatedUser).setKs(userKs)); + assertThat(ottUserResponse.results).isNull(); + assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500051).getCode()); + } + + @AfterClass + private void ottUser_updateTests_afterClass() { + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } } From 03d9e8b72da16c5d7732ef7380914ec1a6865981 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Sun, 3 Jun 2018 17:14:21 +0300 Subject: [PATCH 294/605] Added new util to assetUtils - "addViewsToAsset" --- .../SearchAssetFilterTests.java} | 0 .../kaltura/client/test/utils/AssetUtils.java | 39 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/{AssetListTests.java => AssetListTests/SearchAssetFilterTests.java} (100%) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java similarity index 100% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 0ecb75b24..07f0a4924 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -1,7 +1,12 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.BookmarkService; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -10,15 +15,19 @@ import java.util.List; import java.util.Optional; +import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.services.AssetService.*; +import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.executor; + public class AssetUtils extends BaseUtils { public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nullable String idIn, @Nullable String typeIn, - @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { + @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, + String orderBy) { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); searchAssetFilter.setKSql(ksql); searchAssetFilter.setIdIn(idIn); @@ -61,16 +70,40 @@ public static List getAssetFileIds(String assetId) { } public static List getAssetsByType(String typeIn) { - AssetFilter assetFilter = getSearchAssetFilter(null, null, typeIn, null, null, null,null); + AssetFilter assetFilter = getSearchAssetFilter(null, null, typeIn, null, null, null, null); FilterPager filterPager = new FilterPager(); filterPager.setPageSize(20); filterPager.setPageIndex(1); - ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter,filterPager) + ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, filterPager) .setKs(getSharedMasterUserKs()); Response> assetResponse = executor.executeSync(listAssetBuilder); return assetResponse.results.getObjects(); } + // TODO - need to make util more efficient (creating too many HH) + public static void addViewsToAsset(Long assetId, int numOfActions, AssetType assetType) { + if (numOfActions <= 0) { + Logger.getLogger("Value must be equal or greater than 0"); + } else { + for (int i = 0; i < numOfActions; i++) { + Household household = HouseholdUtils.createHousehold(1, 1, false); + HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); + Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), + AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0), + assetType, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder bookmarkBuilder = BookmarkService.add(bookmark) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(householdUser.getUserId())); + executor.executeSync(bookmarkBuilder); + + HouseholdService.delete(Math.toIntExact(household.getId())); + } + } + } + } + + + From bbc71f3ccdc13a7244f369d75cdc04dcc7170d9b Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Sun, 3 Jun 2018 17:15:29 +0300 Subject: [PATCH 295/605] Added additional tests to "SearchAssetFilterTests" class --- .../SearchAssetFilterTests.java | 83 +++++++++++++++---- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index bb3f1d2e4..b4e18a384 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -1,10 +1,10 @@ -package com.kaltura.client.test.tests.servicesTests.AssetTests; +package com.kaltura.client.test.tests.servicesTests.AssetTests.AssetListTests; +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.enums.AssetType; import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.AssetUtils; -import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.*; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -27,11 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static com.kaltura.client.services.AssetService.*; -public class AssetListTests extends BaseTest { +public class SearchAssetFilterTests extends BaseTest { private MediaAsset asset; private MediaAsset asset2; private MediaAsset asset3; + private ProgramAsset program; private ProgramAsset program2; @@ -42,9 +43,9 @@ public class AssetListTests extends BaseTest { private ArrayList assetList = new ArrayList<>(); private ArrayList list = new ArrayList<>(); private String tagName = "Genre"; - private String tagValue = BaseUtils.getRandomValue(tagName +"_",999999); - private String epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); - private String epgChannelName2 = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(1).getString("name"); + private String tagValue = BaseUtils.getRandomValue(tagName + "_", 999999); + private String epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); + private String epgChannelName2 = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(1).getString("name"); @BeforeClass private void Asset_list_before_class() { @@ -58,13 +59,11 @@ private void Asset_list_before_class() { assetList.add(asset2.getId()); assetList.add(asset3.getId()); - program = IngestUtils.ingestEPG(epgChannelName,1).get(0); - program2 = IngestUtils.ingestEPG(epgChannelName2,1).get(0); + program = IngestUtils.ingestEPG(epgChannelName, 1).get(0); + program2 = IngestUtils.ingestEPG(epgChannelName2, 1).get(0); } - // KalturaSearchAssetFilter - // ****************************************** // VOD // ****************************************** @@ -159,7 +158,7 @@ private void listVodAssetsWithLikeKsqlQuery() { List assets = executor.executeSync(listAssetBuilder).results.getObjects(); assertThat(assets.size()).isEqualTo(2); - assertThat(assets).extracting("id").contains(asset3.getId(),asset2.getId()).doesNotContain(asset.getId()); + assertThat(assets).extracting("id").contains(asset3.getId(), asset2.getId()).doesNotContain(asset.getId()); } @@ -177,7 +176,7 @@ private void listVodAssetsWithStartWithKsqlQuery() { List assets = executor.executeSync(listAssetBuilder).results.getObjects(); assertThat(assets.size()).isEqualTo(2); - assertThat(assets).extracting("id").contains(asset3.getId(),asset2.getId()).doesNotContain(asset.getId()); + assertThat(assets).extracting("id").contains(asset3.getId(), asset2.getId()).doesNotContain(asset.getId()); } @@ -187,7 +186,7 @@ private void listVodAssetsWithStartWithKsqlQuery() { private void listVodAssetsFilteredByType() { ksqlQuery = "" + tagName + " = '" + tagValue + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery,null , getProperty(MOVIE_MEDIA_TYPE_ID), null, null, + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, getProperty(MOVIE_MEDIA_TYPE_ID), null, null, null, null); listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); @@ -246,4 +245,56 @@ private void listEpgProgramsFilteredByEpgChannel() { assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program2.getId()); } -} + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - order by VIEWS") + @Test + private void listVodAssetsByViews() { + MediaAsset assetWithTheMostViews = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + MediaAsset assetWithTheSecondMostViews = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + + AssetUtils.addViewsToAsset(assetWithTheMostViews.getId(), 10, AssetType.MEDIA); + ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + assetWithTheMostViews.getName() + "'name = '" + assetWithTheSecondMostViews.getName() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); + + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(assetWithTheMostViews.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(assetWithTheSecondMostViews.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - order by NAME (DESC/ASC") + @Test + private void listVodAssetsByNameAsc() { + + IngestUtils.updateVODName(asset, "AAA"); + IngestUtils.updateVODName(asset2, "BBB"); + IngestUtils.updateVODName(asset3, "CCC"); + + ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); + + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); + + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); + + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + } +} \ No newline at end of file From 7d05ee3ab4937fea211f91b6780e66f9e8373d25 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 4 Jun 2018 03:19:26 +0300 Subject: [PATCH 296/605] removed duplicated methods from DBUtils --- .../client/test/utils/StatisticsUtils.java | 6 + .../client/test/utils/dbUtils/DBUtils.java | 191 ------------------ 2 files changed, 6 insertions(+), 191 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java b/src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java index 6f18ff706..deb105204 100644 --- a/src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/StatisticsUtils.java @@ -10,6 +10,12 @@ public class StatisticsUtils extends BaseUtils { + /** + * method allows to get statistic about total count of tests in specified @param packageName and compare + * that value with count of failed and count of Critical tests from + * + * @param packageName + */ public static void displayStatisticsDisabledAndCriticalTests(String packageName) { Logger.getLogger(StatisticsUtils.class).debug("Package: [" + packageName + "]"); Set allClasses = null; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index a06bfd5c3..bfde264dd 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -253,195 +253,4 @@ static void prepareCall(String sql) throws SQLException { openConnection(); cStmt = conn.prepareCall(sql); } - - /** - * Call Stored Procedure to create role - */ - public static int insertRole(String role) { - int result = -1; - try { - prepareCall(SP_INSERT_ROLE); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setString(2, role); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete role and its permissions - */ - public static void deleteRoleAndItsPermissions(int roleId) { - try { - prepareCall(SP_DELETE_ROLE_AND_ITS_PERMISSIONS); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setInt(2, roleId); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permissions - */ - public static int insertPermission(String name, int type, String usersGroup) { - int result = -1; - try { - prepareCall(SP_INSERT_PERMISSION); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setString(2, name); - cStmt.setInt(3, type); - cStmt.setString(4, usersGroup); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission - */ - public static void deletePermission(int id) { - try { - prepareCall(SP_DELETE_PERMISSION); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permission role - */ - public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { - int result = -1; - try { - prepareCall(SP_INSERT_PERMISSION_ROLE); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setLong(2, roleId); - cStmt.setLong(3, permissionId); - cStmt.setInt(4, isExcluded); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to insert permission item - */ - public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { - int result = -1; - try { - prepareCall(SP_INSERT_PERMISSION_ITEM); - cStmt.setString(1, name); - cStmt.setInt(2, type); - cStmt.setString(3, service); - cStmt.setString(4, action); - cStmt.setString(5, permissionItemObject); - cStmt.setString(6, parameter); - rs = cStmt.executeQuery(); - - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission item - */ - public static void deletePermissionItem(int id) { - try { - prepareCall(SP_DELETE_PERMISSION_ITEM); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permission permission item - */ - public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { - int result = -1; - try { - prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); - cStmt.setInt(1, 0); - ; // group_id == 0 - cStmt.setLong(2, permissionId); - cStmt.setLong(3, permissionItemId); - cStmt.setInt(4, isExcluded); - rs = cStmt.executeQuery(); - - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission permission item - */ - public static void deletePermissionPermissionItem(int id) { - try { - prepareCall(SP_DELETE_PERMISSION_PERMISSION_ITEM); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } } From a22f5a6f6cb59629a0fabe025c796f6b18a29cf3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 4 Jun 2018 03:21:44 +0300 Subject: [PATCH 297/605] Updated logic of fixture data preparation --- .../kaltura/client/test/IngestConstants.java | 1 + .../client/test/utils/IngestUtils.java | 13 +++++----- .../test/utils/dbUtils/DBConstants.java | 10 ++++++- .../test/utils/dbUtils/IngestFixtureData.java | 26 ++++++++++++++++++- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/IngestConstants.java b/src/test/java/com/kaltura/client/test/IngestConstants.java index c16612ff6..10e500e2b 100644 --- a/src/test/java/com/kaltura/client/test/IngestConstants.java +++ b/src/test/java/com/kaltura/client/test/IngestConstants.java @@ -11,6 +11,7 @@ public class IngestConstants { // currency public static final String CURRENCY_EUR = "EUR"; + public static final String CURRENCY_USD = "USD"; // life cycles periods public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 040f05943..fd71702ed 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -5,18 +5,17 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.AssetService.*; +import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; @@ -525,10 +524,10 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); int maxViewsValue = maxViews.orElse(PP_DEFAULT_MAX_VIEWS_VALUE); String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT)); - String currencyValue = currency.orElse(CURRENCY_EUR); - String defaultCurrencyOfDiscount4IngestMpp = "GBP"; + String currencyValue = currency.orElse(IngestConstants.CURRENCY_EUR); int defaultPercentageOfDiscount4IngestMpp = 100; - String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); + DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount4IngestMpp); + String discountValue = discount.orElse(discountModule.toParams().get("code").toString()); boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); @@ -578,11 +577,11 @@ public static PricePlan ingestPP(Optional action, Optional ppCod pricePlan.setIsRenewable(isRenewableValue); pricePlan.setRenewalsNumber(recurringPeriodsValue); pricePlan.setName(ppCodeValue); + pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get("id").toString())); // TODO: complete COMMENTED IF NEEDED //pricePlan.setFullLifeCycle(); //pricePlan.setViewLifeCycle(); //pricePlan.setPriceDetailsId(); - //pricePlan.setDiscountId(); return pricePlan; } @@ -645,7 +644,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O int defaultPercentageOfDiscount4IngestPpv = 50; String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); - String currencyValue = currency.orElse(CURRENCY_EUR); + String currencyValue = currency.orElse(IngestConstants.CURRENCY_EUR); String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index e75d63404..e8dc90efc 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -30,6 +30,12 @@ public class DBConstants { "from [Users].[dbo].[groups_parameters]\n" + "where group_id=%d"; + static final String DISCOUNT_BY_PERCENT = "select TOP (1) *\n" + + "from [Pricing].[dbo].[discount_codes] dc \n" + + "where dc.discount_percent=%d\n" + // percent amount + "and dc.group_id=%d\n" + // group + "and dc.[status]=1 and dc.is_active=1"; + static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + @@ -67,7 +73,7 @@ public class DBConstants { static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + "where [status]=1 and is_active=1\n" + - "and group_id=%d and usage_module_code=%d\n" + + "and group_id=%d and usage_module_code=%d and discount_module_code=%d\n" + "order by create_date"; static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + @@ -124,4 +130,6 @@ public class DBConstants { static final String SP_DELETE_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionItem(?)}"; static final String SP_DELETE_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionPermissionItem(?)}"; static final String SP_DELETE_ROLE_AND_ITS_PERMISSIONS = "{call TVinci.dbo.__482V0__Delete_RolePermission(?, ?)}"; + + } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index db9f8fd65..e97bfa7c0 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -105,7 +105,7 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { Subscription subscription = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_SELECT, partnerId, - pricePlan.getId()), true); + pricePlan.getId(), pricePlan.getDiscountId()), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return subscription; } @@ -146,6 +146,30 @@ public static String getDiscount(String currency, int percent) { return code; } + public static DiscountModule getDiscount(int percent) { + Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): percent = " + percent); + DiscountModule result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT, + percent, partnerId), false); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return null; + } + + result = new DiscountModule(); + result.setPercent((double) percent); + if ("".equals(result.toParams().get(CODE))) { + throw new SQLException(); + } + result.setToken(CODE, jsonArray.getJSONObject(0).getString(CODE)); + result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error(CODE + " can't be null"); + } + return result; + } + public static int getEpgChannelId(String channelName) { Logger.getLogger(IngestFixtureData.class).debug("getEpgChannelId(): channelName = " + channelName); int epgChannelId = -1; From aa360b8f26df9a5ff4c47ea08efcb2e9739e2cb2 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 4 Jun 2018 03:22:54 +0300 Subject: [PATCH 298/605] updated purchaseSubscription util. Added more productPrice/action/list related tests --- .../kaltura/client/test/tests/BaseTest.java | 18 +- .../householdTests/HouseholdResumeTests.java | 4 +- .../householdTests/HouseholdSuspendTests.java | 10 +- .../ProductPriceListTests.java | 164 +++++++++++++++++- .../client/test/utils/PurchaseUtils.java | 12 +- 5 files changed, 180 insertions(+), 28 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 731420caa..2e7c4fdf4 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -3,6 +3,7 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.services.OttUserService; +import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.IngestUtils; @@ -10,15 +11,12 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeSuite; - import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.services.OttUserService.login; -import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; @@ -137,15 +135,14 @@ public void base_test_before_suite() { * @return common shared Price Plan with mentioned parameters */ public static PricePlan getSharedCommonPricePlan() { - String defaultCurrency = "EUR"; double defaultDiscountPrice = 0.0; double defaultDiscountPercentValue = 100.0; if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), defaultCurrency, defaultDiscountPrice, defaultDiscountPercentValue); + sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), IngestConstants.CURRENCY_EUR, defaultDiscountPrice, defaultDiscountPercentValue); if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), - Optional.of(defaultCurrency), Optional.of(IngestFixtureData.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), + Optional.of(IngestConstants.CURRENCY_EUR), Optional.of(IngestFixtureData.getDiscount(IngestConstants.CURRENCY_EUR, (int) defaultDiscountPercentValue)), Optional.of(true), Optional.of(0)); } } @@ -162,13 +159,12 @@ public static PricePlan getSharedCommonPricePlan() { */ public static Subscription getSharedCommonSubscription() { double defaultDiscountPercentValue = 100.0; - String defaultCurrency = "EUR"; if (sharedCommonSubscription == null) { sharedCommonSubscription = IngestFixtureData.loadSharedCommonSubscription(getSharedCommonPricePlan()); if (sharedCommonSubscription == null) { sharedCommonSubscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(IngestFixtureData.getDiscount(defaultCurrency, (int) defaultDiscountPercentValue)), Optional.empty(), + Optional.of(IngestFixtureData.getDiscount(IngestConstants.CURRENCY_EUR, (int) defaultDiscountPercentValue)), Optional.empty(), Optional.of(false), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -186,12 +182,11 @@ public static Subscription getSharedCommonSubscription() { */ public static Ppv getSharedCommonPpv(){ double discountPercentValue = 50.0; - String defaultCurrency = "EUR"; if (sharedCommonPpv == null) { sharedCommonPpv = IngestFixtureData.loadSharedCommonPpv(getSharedCommonPricePlan()); if (sharedCommonPpv == null) { sharedCommonPpv = IngestUtils.ingestPPV(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), - Optional.empty(), Optional.of(IngestFixtureData.getDiscount(defaultCurrency, (int) discountPercentValue)), + Optional.empty(), Optional.of(IngestFixtureData.getDiscount(IngestConstants.CURRENCY_EUR, (int) discountPercentValue)), Optional.empty(), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.of(false), Optional.of(false), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -315,10 +310,11 @@ public static MediaFile getSharedMobileMediaFile() { } public static Subscription get5MinRenewableSubscription() { + // TODO: add logic checking data from DB if (fiveMinRenewableSubscription == null) { PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), - Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(CURRENCY_EUR), Optional.of(""), + Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(IngestConstants.CURRENCY_EUR), Optional.of(""), Optional.of(true), Optional.of(3)); fiveMinRenewableSubscription = IngestUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java index a24503a4b..9d7ff2c70 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java @@ -16,6 +16,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Optional; + import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.HouseholdService.get; import static org.assertj.core.api.Assertions.assertThat; @@ -102,7 +104,7 @@ private void resume_suspended_with_purchase_subscription_role_household() { assertThat(householdResponse.results.getState()).isEqualTo(HouseholdState.OK); // purchase subscription - Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index bc43d4005..95e1665bc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -148,7 +148,7 @@ private void suspend_with_purchase_subscription_role() { assertThat(booleanResponse.results).isTrue(); // purchase subscription - Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); assertThat(transactionResponse.results).isNull(); assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); @@ -192,7 +192,7 @@ private void suspend_with_cancel_subscription_role() { assertThat(booleanResponse.results).isTrue(); // purchase subscription - PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); // cancel subscription CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.parseInt(subscription.getId()), TransactionType.SUBSCRIPTION) @@ -231,7 +231,7 @@ private void suspend_with_playback_subscription_role() { assertThat(booleanResponse.results).isTrue(); // purchase subscription - PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); // get platbackContext PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); @@ -283,7 +283,7 @@ private void suspend_with_purchase_ppv_role() { assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); // purchase subscription in order to verify suspend is specific to role - transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); @@ -335,7 +335,7 @@ private void suspend_with_playback_ppv_role() { assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); // purchase subscription in order to verify suspend is specific to role - Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 26400599c..f63de4eb2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -3,8 +3,10 @@ import com.kaltura.client.enums.*; import com.kaltura.client.services.EntitlementService; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; +import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; @@ -16,10 +18,11 @@ import io.qameta.allure.SeverityLevel; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.Optional; -import static com.kaltura.client.test.IngestConstants.CURRENCY_EUR; +import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -70,7 +73,7 @@ public void listSubscription() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); + ListProductPriceBuilder productPriceList = ProductPriceService.list(filter).setKs(getOperatorKs()); productPriceResponse = executor.executeSync(productPriceList); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); @@ -83,12 +86,12 @@ public void listSubscription() { public void listSubscriptionWithCurrencyTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(CURRENCY_EUR).setKs(getOperatorKs())); + productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(IngestConstants.CURRENCY_EUR).setKs(getOperatorKs())); // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CURRENCY_EUR); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); } @Severity(SeverityLevel.MINOR) @@ -123,7 +126,6 @@ public void ppvTest() { ppFilter.setIsLowest(false); ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); - // TODO: 4/8/2018 talk with Max about the assertions (currently it not asserting nothing as only actual was implemented) assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); @@ -183,7 +185,7 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { @Severity(SeverityLevel.CRITICAL) @Description("productPrice/action/list - subscription test") - @Test(enabled = false) // as not completed + @Test(enabled = false) // TODO: as not completed public void subscriptionTest() { String sharedWebMediaFileId = String.valueOf(getSharedWebMediaFile().getId()); @@ -236,4 +238,154 @@ public void subscriptionTest() { assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(sharedWebMediaFileId); } + + @Severity(SeverityLevel.NORMAL) + @Description("/productprice/action/list - subscription - Web_HD_File_only") + @Test() + public void productPriceSubscriptionWebHDFileTypeOnlyTest() { + // TODO: add logic of using dynamic data + int webHDFileOnlySubId = 56550; + + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setSubscriptionIdIn(String.valueOf(webHDFileOnlySubId)); + ppFilter.setFileIdIn(String.valueOf(getSharedWebMediaFile().getId()) + "," + String.valueOf(getSharedMobileMediaFile().getId())); + ppFilter.setIsLowest(false); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 3 as we have 2 files and 1 subscriptions + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(3); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(webHDFileOnlySubId)); + assertThat(productPriceResponse.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + assertThat(productPriceResponse.results.getObjects().get(2).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(2).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(2)).getFileId()).isEqualTo(getSharedMobileMediaFile().getId()); + + PurchaseUtils.purchaseSubscription(masterKs, webHDFileOnlySubId, Optional.empty()); + + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 3 as we have 2 files and 1 subscriptions + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(3); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(webHDFileOnlySubId)); + assertThat(productPriceResponse.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(1).getPrice().getAmount()).isEqualTo(0); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + assertThat(productPriceResponse.results.getObjects().get(2).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(2).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(2).getPrice().getAmount()).isGreaterThan(0); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(2)).getFileId()).isEqualTo(getSharedMobileMediaFile().getId()); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } + + @Severity(SeverityLevel.NORMAL) + @Description("productPrice/action/list - subscription - no specifed currency") + @Test() + public void productPriceSubscriptionNoSpecifiedCurrencyTest() { + // TODO: add logic of using dynamic data + int subWithMultiCurrencyId = 86445; + + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setSubscriptionIdIn(String.valueOf(subWithMultiCurrencyId)); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); + // as default group currency is EURO + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + + PurchaseUtils.purchaseSubscription(masterKs, subWithMultiCurrencyId, Optional.empty()); + + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); + // as default group currency is EURO + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } + + @Severity(SeverityLevel.NORMAL) + @Description("productPrice/action/list - subscription with discount (percentage) - specified currency") + @Test() + public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTest() { + // TODO: add logic of using dynamic data + int subWithDiscountAndCurrencyId = 116952; + double subPrice = 15.; + double subPriceAfterDiscount = 7.5; + + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setCurrency(IngestConstants.CURRENCY_USD); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_USD); + + PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(IngestConstants.CURRENCY_USD)); + + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_USD); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } + + @AfterClass + public void afterClass() { + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index c261f2102..1eba78d38 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -71,23 +71,25 @@ public static Response purchasePpv(String ks, Optional med return transactionResponse; } - public static Response purchaseSubscription(String ks, int subscriptionId) { + public static Response purchaseSubscription(String ks, int subscriptionId, Optional currency) { purchaseSubscriptionDetailsMap = new HashMap<>(); ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(String.valueOf(subscriptionId)); filter.setIsLowest(false); - ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(filter).setKs(ks); + ListProductPriceBuilder listProductPriceBuilder = currency.isPresent() + ? ProductPriceService.list(filter).setKs(ks).setCurrency(currency.get()) + : ProductPriceService.list(filter).setKs(ks); productPriceResponse = executor.executeSync(listProductPriceBuilder); - String currency = productPriceResponse.results.getObjects().get(0).getPrice().getCurrency(); + String currencyValue = currency.orElse(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); double price = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); Purchase purchase = new Purchase(); purchase.setProductId(subscriptionId); purchase.setContentId(0); - purchase.setCurrency(currency); + purchase.setCurrency(currencyValue); purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.SUBSCRIPTION).get()); @@ -96,7 +98,7 @@ public static Response purchaseSubscription(String ks, int subscrip // TODO: complete the purchase subscription test purchaseSubscriptionDetailsMap.put("price", String.valueOf(price)); - purchaseSubscriptionDetailsMap.put("currency", currency); + purchaseSubscriptionDetailsMap.put("currency", currencyValue); return transactionResponse; } From 21bc5c047736f38d0834feb4ddcb1cfd35028f42 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 4 Jun 2018 09:36:59 +0300 Subject: [PATCH 299/605] transactionHistoryList amends --- .../kaltura/client/test/tests/BaseTest.java | 25 ++ .../transactionHistoryTests/ListTests.java | 181 ------------ .../TransactionHistoryListTests.java | 262 ++++++++++++++++++ .../client/test/utils/PurchaseUtils.java | 29 ++ .../test/utils/dbUtils/DBConstants.java | 5 + .../test/utils/dbUtils/IngestFixtureData.java | 23 ++ 6 files changed, 344 insertions(+), 181 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index db244de42..00eda0a35 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,6 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; +import com.kaltura.client.Logger; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.dbUtils.DBUtils; @@ -63,6 +64,9 @@ public class BaseTest { // shared ingested subscription private static Subscription sharedCommonSubscription; + // shared collection + private static Collection sharedCommonCollection; + // cycles map with values related view/full life cycles of price plans private static Map cycles = new HashMap<>(); { @@ -166,6 +170,27 @@ public static Subscription getSharedCommonSubscription(){ return sharedCommonSubscription; } + /** + * Regression requires existence of Collection with specific parameters. + * Price should be as for method public static PricePlan getSharedCommonPricePlan() + * Usage Module should be as for method public static PricePlan getSharedCommonPricePlan() + * + * Collection should be with discount (internal items) 100% + * + * @return Collection with mentioned parameters + */ + public static Collection getSharedCommonCollection(){ + double defaultDiscountPercentValue = 100.0; + String defaultCurrency = "EUR"; + if (sharedCommonCollection == null) { + sharedCommonCollection = IngestFixtureData.loadSharedCommonCollection(getSharedCommonPricePlan()); + if (sharedCommonCollection == null) { + Logger.getLogger(BaseTest.class).error("Collection with defined parameters should exist in DB!"); + } + } + return sharedCommonCollection; + } + public static String getIngestBusinessModuleUserName() { if (ingestBusinessModuleUserUsername == null) { String userInfo = IngestFixtureData.getIngestItemUserData(BaseTest.partnerId); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java deleted file mode 100644 index 06fad0774..000000000 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/ListTests.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.kaltura.client.test.tests.servicesTests.transactionHistoryTests; - -import com.kaltura.client.enums.*; -import com.kaltura.client.services.EntitlementService; -import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; -import com.kaltura.client.services.TransactionHistoryService; -import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; -import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.PurchaseUtils; -import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.Response; -import io.qameta.allure.Severity; -import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ListTests extends BaseTest{ - - private EntitlementFilter entitlementPpvFilter; - private TransactionHistoryFilter transactionHistoryFilter; - private Response> listEntitlementServiceResponse; - private Response> listBillingTransactionResponse; - private int numberOfDevicesInHousehold = 2; - private int numberOfUsersInHousehold = 2; - public static final String PPV_MODULE_ID_KEY = "ppvModuleId"; - public static final String PPV_PRICE_AMOUNT = "price"; - public static final String PPV_PRICE_CURRENCY = "currency"; - //Epoch for transactionHistory filter (86400 sec = 24 hours) - public static final int yesterdayInEpoch = (int)((System.currentTimeMillis()/1000)-86400); - public static final int tomorrowInEpoch = (int)((System.currentTimeMillis()/1000)+86400); - - - @BeforeClass - public void beforeClass(){ - entitlementPpvFilter = new EntitlementFilter(); - //Show entitlements per household - entitlementPpvFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - //Don't show expired assets - entitlementPpvFilter.setIsExpiredEqual(false); - transactionHistoryFilter = new TransactionHistoryFilter(); - //Start date from yesterday - transactionHistoryFilter.setStartDateGreaterThanOrEqual(yesterdayInEpoch); - //End date before tomorrow - transactionHistoryFilter.setEndDateLessThanOrEqual(tomorrowInEpoch); - } - - @Severity(SeverityLevel.BLOCKER) - @Test(description = "/transactionhistory/action/list - test ppv purchases is written correctly at transactionHistory") - public void purchase_ppv(){ - - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); - //Login with master to first device - String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - //Login with user to second device - String userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); - - //All transactions per household - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); - //transactionHistory/action/list for household with master user ks - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); - //No errors appeared at response - assertThat(listBillingTransactionResponse.error).isNull(); - //No purchases were performed - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); - - int assetFileId = getSharedWebMediaFile().getId(); - //Purchase asset - PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(assetFileId), null); - //Get PPV details (ID, Price, Currency) - String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get(PPV_MODULE_ID_KEY); - String pricePpv = PurchaseUtils.purchasePpvDetailsMap.get(PPV_PRICE_AMOUNT); - String currencyPpv = PurchaseUtils.purchasePpvDetailsMap.get(PPV_PRICE_CURRENCY); - - //Show only PPV purchases - entitlementPpvFilter.setProductTypeEqual(TransactionType.PPV); - ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(entitlementPpvFilter).setKs(userKs); - //entitlement/action/list - listEntitlementServiceResponse = executor.executeSync(listEntitlementBuilder); - //Conversion from Entitlement to PpvEntitlement object - List ppvEntitlementList = new ArrayList<>(); - for(Entitlement entitlement:listEntitlementServiceResponse.results.getObjects()){ - if(entitlement.getClass() == PpvEntitlement.class) { - ppvEntitlementList.add((PpvEntitlement) entitlement); - } - } - //Verify that count of entitlements is 1 - assertThat(listEntitlementServiceResponse.results.getTotalCount()).isEqualTo(1); - //Verify that PPV is correct - assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(ppvModuleId); - //Verify that asset file is correct - assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(assetFileId); - - //All transactions per user - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); - //Use non-master user ks - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); - //transactionHistory/action/list for non-master user - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); - //No errors appeared at response - assertThat(listBillingTransactionResponse.error).isNull(); - //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); - //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); - //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); - //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); - //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); - //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); - //Verify that asset was purchased - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); - - //All transactions per household - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - //Use non-master user ks - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); - //transactionHistory/action/list for non-master user - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); - //No errors appeared at response - assertThat(listBillingTransactionResponse.error).isNull(); - //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); - //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); - //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); - //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); - //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); - //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); - //Verify that asset was purchased - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); - - //All transactions per household - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - //Use master user ks - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); - //transactionHistory/action/list for master user - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); - //No errors appeared at response - assertThat(listBillingTransactionResponse.error).isNull(); - //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); - //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); - //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); - //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); - //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); - //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); - //Verify that asset was purchased - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); - - //All transactions per user - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); - //Use master user ks - listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); - //transactionHistory/action/list for master user - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); - //No errors appeared at response - assertThat(listBillingTransactionResponse.error).isNull(); - //No transactions were performed with master user - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); - } -} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java new file mode 100644 index 000000000..ac1b6251d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -0,0 +1,262 @@ +package com.kaltura.client.test.tests.servicesTests.transactionHistoryTests; + +import com.kaltura.client.Logger; +import com.kaltura.client.enums.*; +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; +import com.kaltura.client.services.TransactionHistoryService; +import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TransactionHistoryListTests extends BaseTest{ + + private ListTransactionHistoryBuilder listTransactionHistoryBuilder; + private EntitlementFilter entitlementFilter; + private TransactionHistoryFilter transactionHistoryFilter; + private Response> listEntitlementServiceResponsePpv; + private Response> listEntitlementServiceResponseSubscription; + private Response> listBillingTransactionResponse; + private Response transactionResponseSubscription; + private Response transactionResponseCollection; + private Response transactionResponsePpv; + private int numberOfDevicesInHousehold = 2; + private int numberOfUsersInHousehold = 2; + private String masterUserKs; + private String userKs; + private String methodName; + public static final String PPV_MODULE_ID_KEY = "ppvModuleId"; + public static final String PRICE_AMOUNT = "price"; + public static final String PRICE_CURRENCY = "currency"; + //Epoch for transactionHistory filter (86400 sec = 24 hours) + public static final int yesterdayInEpoch = (int)((System.currentTimeMillis()/1000)-86400); + public static final int tomorrowInEpoch = (int)((System.currentTimeMillis()/1000)+86400); + + + @BeforeClass + public void transactionHistortTestSetup(){ + entitlementFilter = new EntitlementFilter(); + //Show entitlements per household + entitlementFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + //Don't show expired assets + entitlementFilter.setIsExpiredEqual(false); + transactionHistoryFilter = new TransactionHistoryFilter(); + //Start date from yesterday + transactionHistoryFilter.setStartDateGreaterThanOrEqual(yesterdayInEpoch); + //End date before tomorrow + transactionHistoryFilter.setEndDateLessThanOrEqual(tomorrowInEpoch); + + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); + //Login with master to first device + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + //Login with user to second device + userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); + + //All transactions per household - empty + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); + //transactionHistory/action/list for household with master user ks + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //No purchases were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); + + //Purchase asset with non-master user + transactionResponsePpv = PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(getSharedWebMediaFile().getId()), null); + //Purchase subscription with non-master user + transactionResponseSubscription = PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(getSharedCommonSubscription().getId())); + //Purchase collection with master user + transactionResponseCollection = PurchaseUtils.purchaseCollection(masterUserKs, Integer.parseInt(getSharedCommonCollection().getId())); + + //Show PPV entitlements + entitlementFilter.setProductTypeEqual(TransactionType.PPV); + ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(entitlementFilter).setKs(userKs); + //entitlement/action/list + listEntitlementServiceResponsePpv = executor.executeSync(listEntitlementBuilder); + //Verify response is correct + assertThat(listEntitlementServiceResponsePpv.error).isNull(); + assertThat(listEntitlementServiceResponsePpv.results.getObjects().get(0).getClass()).isEqualTo(PpvEntitlement.class); + assertThat(listEntitlementServiceResponsePpv.results.getTotalCount()).isEqualTo(1); + //Conversion from Entitlement to PpvEntitlement object + List ppvEntitlementList = new ArrayList<>(); + for(Entitlement entitlement:listEntitlementServiceResponsePpv.results.getObjects()){ + if(entitlement.getClass() == PpvEntitlement.class) { + ppvEntitlementList.add((PpvEntitlement) entitlement); + } + } + //TODO: change ppvModuleId to getSharedWebMediaFile().getPpvModules().getObjects().get(0).getValue() - right now it is null + String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get(PPV_MODULE_ID_KEY); + //Verify that PPV is correct + assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(ppvModuleId); + //Verify that asset file is correct + assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); + + //Show subscription entitlements + entitlementFilter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + listEntitlementBuilder = EntitlementService.list(entitlementFilter).setKs(userKs); + //entitlement/action/list + listEntitlementServiceResponseSubscription = executor.executeSync(listEntitlementBuilder); + //Verify that subscription is correct + assertThat(listEntitlementServiceResponseSubscription.results.getTotalCount()).isEqualTo(1); + assertThat(listEntitlementServiceResponseSubscription.results.getObjects().get(0).getProductId()).isEqualTo(getSharedCommonSubscription().getId()); + assertThat(listEntitlementServiceResponseSubscription.results.getObjects().get(0).getClass()).isEqualTo(SubscriptionEntitlement.class); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for non-master user") + public void testTransactionHistoryPerHouseholdWithUserKs() { + //All transactions per non-master user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); + //transactionHistory/action/list for non-master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //Verify that two transactions were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(3); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(3); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test purchases per user are written correctly at transactionHistory for non-master user") + public void testTransactionHistoryPerUserWithUserKs() { + //All transactions per non-master user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); + //transactionHistory/action/list for non-master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //Verify that two transactions were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(2); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(2); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for master user") + public void testTransactionHistoryPerHouseholdWithMasterKs() { + //All transactions per master user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); + //transactionHistory/action/list for master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //Verify that two transactions were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(3); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(3); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test no purchases per user were written at transactionHistory for master user") + public void testTransactionHistoryPerUserWithMasterKs() { + //All transactions per master user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); + //transactionHistory/action/list for master user + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + //No errors appeared at response + assertThat(listBillingTransactionResponse.error).isNull(); + //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(1); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + private void assertMethod(String methodName, List billingTransactionList) { + Logger.getLogger(TransactionHistoryListTests.class).debug(methodName); + String price, currency; + for(int i = 0; i < billingTransactionList.size(); i++) { + assertThat(listBillingTransactionResponse.results.getObjects().get(i).getClass()).isEqualTo(BillingTransaction.class); + switch (billingTransactionList.get(i).getItemType()){ + case SUBSCRIPTION: + BillingTransaction billingTransactionSubscription = billingTransactionList.get(i); + //Get subscription details (Price, Currency) + price = PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_AMOUNT); + currency = PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_CURRENCY); + assertThat(billingTransactionSubscription.getRecieptCode()).isEqualTo(transactionResponseSubscription.results.getId()); + assertThat(billingTransactionSubscription.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionSubscription.getPurchasedItemCode()).isEqualTo(getSharedCommonSubscription().getId().toString()); + assertThat(billingTransactionSubscription.getItemType()).isEqualTo(BillingItemsType.SUBSCRIPTION); + assertThat(billingTransactionSubscription.getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransactionSubscription.getPrice().getAmount().toString()).isEqualTo(price); + assertThat(billingTransactionSubscription.getPrice().getCurrency().toString()).isEqualTo(currency); + assertThat(billingTransactionSubscription.getIsRecurring()).isEqualTo(false); + assertThat(billingTransactionSubscription.getBillingProviderRef().toString().length()).isGreaterThan(1); + assertThat(billingTransactionSubscription.getPurchaseId().toString().length()).isGreaterThan(1); + assertThat(billingTransactionSubscription.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(billingTransactionSubscription.getActionDate()); + assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(transactionResponseSubscription.results.getCreatedAt().longValue()); + break; + + case PPV: + BillingTransaction billingTransactionPpv = billingTransactionList.get(i); + //Get PPV details (Price, Currency) + price = PurchaseUtils.purchasePpvDetailsMap.get(PRICE_AMOUNT); + currency = PurchaseUtils.purchasePpvDetailsMap.get(PRICE_CURRENCY); + assertThat(billingTransactionPpv.getRecieptCode()).isEqualTo(transactionResponsePpv.results.getId()); + assertThat(billingTransactionPpv.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionPpv.getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); + assertThat(billingTransactionPpv.getItemType()).isEqualTo(BillingItemsType.PPV); + assertThat(billingTransactionPpv.getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransactionPpv.getPrice().getAmount().toString()).isEqualTo(price); + assertThat(billingTransactionPpv.getPrice().getCurrency().toString()).isEqualTo(currency); + assertThat(billingTransactionPpv.getIsRecurring()).isEqualTo(false); + assertThat(billingTransactionPpv.getBillingProviderRef().toString().length()).isGreaterThan(1); + assertThat(billingTransactionPpv.getPurchaseId().toString().length()).isGreaterThan(1); + assertThat(billingTransactionPpv.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionPpv.getStartDate()).isEqualTo(billingTransactionPpv.getActionDate()); + assertThat(billingTransactionPpv.getStartDate()).isEqualTo(transactionResponsePpv.results.getCreatedAt().longValue()); + break; + + case COLLECTION: + BillingTransaction billingTransactionCollection = billingTransactionList.get(i); + //Get collection details (Price, Currency) + price = PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_AMOUNT); + currency = PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_CURRENCY); + assertThat(billingTransactionCollection.getRecieptCode()).isEqualTo(transactionResponseCollection.results.getId()); + assertThat(billingTransactionCollection.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionCollection.getPurchasedItemCode()).isEqualTo(getSharedCommonCollection().getId().toString()); + assertThat(billingTransactionCollection.getItemType()).isEqualTo(BillingItemsType.COLLECTION); + assertThat(billingTransactionCollection.getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransactionCollection.getPrice().getAmount().toString()).isEqualTo(price); + assertThat(billingTransactionCollection.getPrice().getCurrency().toString()).isEqualTo(currency); + assertThat(billingTransactionCollection.getIsRecurring()).isEqualTo(false); + assertThat(billingTransactionCollection.getBillingProviderRef().toString().length()).isGreaterThan(1); + assertThat(billingTransactionCollection.getPurchaseId().toString().length()).isGreaterThan(1); + assertThat(billingTransactionCollection.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionCollection.getActionDate()).isEqualTo(transactionResponseCollection.results.getCreatedAt().longValue()); + break; + + default: + Logger.getLogger(TransactionHistoryListTests.class).error("No valid item type found!"); + break; + } + } + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 32a948f8a..b4fff0329 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -21,6 +21,7 @@ public class PurchaseUtils { public static Map purchasePpvDetailsMap; public static Map purchaseSubscriptionDetailsMap; + public static Map purchaseCollectionDetailsMap; private static Response> productPriceResponse; private static Response assetResponse; @@ -101,4 +102,32 @@ public static Response purchaseSubscription(String ks, int subscrip return transactionResponse; } + + public static Response purchaseCollection (String ks, int collectionId){ + purchaseCollectionDetailsMap = new HashMap<>(); + + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setCollectionIdIn(String.valueOf(collectionId)); + + ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter).setKs(ks); + productPriceResponse = executor.executeSync(listProductPriceBuilder); + + String collectionPriceCurrency = productPriceResponse.results.getObjects().get(0).getPrice().getCurrency(); + double collectionPriceAmount = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); + + Purchase purchaseRequest = new Purchase(); + purchaseRequest.setCurrency(collectionPriceCurrency); + purchaseRequest.setPrice(collectionPriceAmount); + purchaseRequest.setContentId(0); + purchaseRequest.setProductId(collectionId); + purchaseRequest.setProductType(TransactionType.COLLECTION); + + PurchaseTransactionBuilder purchaseTransactionBuilder = TransactionService.purchase(purchaseRequest).setKs(ks); + Response transactionResponse = executor.executeSync(purchaseTransactionBuilder); + + purchaseCollectionDetailsMap.put("price", String.valueOf(collectionPriceAmount)); + purchaseCollectionDetailsMap.put("currency", collectionPriceCurrency); + + return transactionResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index e35c1ca02..e513abb5a 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -64,6 +64,11 @@ public class DBConstants { "and group_id=%d and usage_module_code=%d\n" + "order by create_date"; + static final String COLLECTION_SELECT = "select top 1 * from [Pricing].[dbo].[collections]\n" + + "where [status]=1 and is_active=1\n" + + "and group_id=%d and discount_id=%d and price_id=%d and usage_module_id=%d\n" + + "order by create_date"; + static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + "from [Users].[dbo].[users] u with(nolock)\n" + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index efb8eebd0..eeda7fe2d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -124,6 +124,29 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { return subscription; } + public static Collection loadSharedCommonCollection(PricePlan pricePlan) { + Logger.getLogger(IngestFixtureData.class).debug("loadSharedCommonCollection(): price_id = " + pricePlan.getPriceDetailsId() + + "discount_id = " + pricePlan.getDiscountId() + "usage_module_id = " + pricePlan.getId()); + + Collection collection = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COLLECTION_SELECT, partnerId, + pricePlan.getDiscountId(), pricePlan.getPriceDetailsId(), pricePlan.getId()), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return collection; + } + + collection = new Collection(); + collection.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + collection.setName(jsonArray.getJSONObject(0).getString(NAME)); + // TODO: add more data in case it needed + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("collection data can't be null"); + } + return collection; + } + public static String getDiscount(String currency, int percent) { Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): currency = " + currency + " percent = " + percent); String code = ""; From 0b13f517fa842b8e5051309e0ab7709dd6730596 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 4 Jun 2018 10:21:12 +0300 Subject: [PATCH 300/605] Shared Collection and amend transactionHistory --- .../kaltura/client/test/tests/BaseTest.java | 24 ++ .../TransactionHistoryListTests.java | 259 ++++++++++++------ 2 files changed, 194 insertions(+), 89 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 2e7c4fdf4..99db481ec 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -2,6 +2,7 @@ import com.kaltura.client.Client; import com.kaltura.client.Configuration; +import com.kaltura.client.Logger; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.TestAPIOkRequestsExecutor; @@ -68,6 +69,9 @@ public class BaseTest { // shared ingested subscription private static Subscription sharedCommonSubscription; + // shared collection + private static Collection sharedCommonCollection; + // shared ingested PPV private static Ppv sharedCommonPpv; @@ -172,6 +176,26 @@ public static Subscription getSharedCommonSubscription() { return sharedCommonSubscription; } + /** + * Regression requires existence of Collection with specific parameters. + * Price should be as for method public static PricePlan getSharedCommonPricePlan() + * Usage Module should be as for method public static PricePlan getSharedCommonPricePlan() + *

+ * Collection should be with discount (internal items) 100% + * + * @return Collection with mentioned parameters + */ + public static Collection getSharedCommonCollection() { + double defaultDiscountPercentValue = 100.0; + if (sharedCommonCollection == null) { + sharedCommonCollection = IngestFixtureData.loadSharedCommonCollection(getSharedCommonPricePlan()); + if (sharedCommonCollection == null) { + Logger.getLogger(BaseTest.class).error("Collection with defined parameters should exist in DB!"); + } + } + return sharedCommonCollection; + } + /** * Regression requires existing of PPV with specific parameters. * Price Plan should be as for method public static PricePlan getSharedCommonPricePlan() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index 89b5ecd9e..9335b229d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.transactionHistoryTests; +import com.kaltura.client.Logger; import com.kaltura.client.enums.*; import com.kaltura.client.services.EntitlementService; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; @@ -23,47 +24,50 @@ public class TransactionHistoryListTests extends BaseTest{ - private EntitlementFilter entitlementPpvFilter; + private ListTransactionHistoryBuilder listTransactionHistoryBuilder; + private EntitlementFilter entitlementFilter; private TransactionHistoryFilter transactionHistoryFilter; - private Response> listEntitlementServiceResponse; + private Response> listEntitlementServiceResponsePpv; + private Response> listEntitlementServiceResponseSubscription; private Response> listBillingTransactionResponse; + private Response transactionResponseSubscription; + private Response transactionResponseCollection; + private Response transactionResponsePpv; private int numberOfDevicesInHousehold = 2; private int numberOfUsersInHousehold = 2; + private String masterUserKs; + private String userKs; + private String methodName; public static final String PPV_MODULE_ID_KEY = "ppvModuleId"; - public static final String PPV_PRICE_AMOUNT = "price"; - public static final String PPV_PRICE_CURRENCY = "currency"; + public static final String PRICE_AMOUNT = "price"; + public static final String PRICE_CURRENCY = "currency"; //Epoch for transactionHistory filter (86400 sec = 24 hours) public static final int yesterdayInEpoch = (int)((System.currentTimeMillis()/1000)-86400); public static final int tomorrowInEpoch = (int)((System.currentTimeMillis()/1000)+86400); @BeforeClass - public void beforeClass(){ - entitlementPpvFilter = new EntitlementFilter(); + public void transactionHistortTestSetup(){ + entitlementFilter = new EntitlementFilter(); //Show entitlements per household - entitlementPpvFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + entitlementFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); //Don't show expired assets - entitlementPpvFilter.setIsExpiredEqual(false); + entitlementFilter.setIsExpiredEqual(false); transactionHistoryFilter = new TransactionHistoryFilter(); //Start date from yesterday transactionHistoryFilter.setStartDateGreaterThanOrEqual(yesterdayInEpoch); //End date before tomorrow transactionHistoryFilter.setEndDateLessThanOrEqual(tomorrowInEpoch); - } - - @Severity(SeverityLevel.BLOCKER) - @Test(description = "/transactionhistory/action/list - test ppv purchases is written correctly at transactionHistory") - public void purchase_ppv(){ Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); //Login with master to first device - String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); //Login with user to second device - String userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); + userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); - //All transactions per household + //All transactions per household - empty transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); + listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); //transactionHistory/action/list for household with master user ks listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response @@ -71,111 +75,188 @@ public void purchase_ppv(){ //No purchases were performed assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); - int assetFileId = getSharedWebMediaFile().getId(); - //Purchase asset - PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(assetFileId), null); - //Get PPV details (ID, Price, Currency) - String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get(PPV_MODULE_ID_KEY); - String pricePpv = PurchaseUtils.purchasePpvDetailsMap.get(PPV_PRICE_AMOUNT); - String currencyPpv = PurchaseUtils.purchasePpvDetailsMap.get(PPV_PRICE_CURRENCY); + //Purchase asset with non-master user + transactionResponsePpv = PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(getSharedWebMediaFile().getId()), null); + //Purchase subscription with non-master user + transactionResponseSubscription = PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(getSharedCommonSubscription().getId()), Optional.empty()); + //Purchase collection with master user + transactionResponseCollection = PurchaseUtils.purchaseCollection(masterUserKs, Integer.parseInt(getSharedCommonCollection().getId())); - //Show only PPV purchases - entitlementPpvFilter.setProductTypeEqual(TransactionType.PPV); - ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(entitlementPpvFilter).setKs(userKs); + //Show PPV entitlements + entitlementFilter.setProductTypeEqual(TransactionType.PPV); + ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(entitlementFilter).setKs(userKs); //entitlement/action/list - listEntitlementServiceResponse = executor.executeSync(listEntitlementBuilder); + listEntitlementServiceResponsePpv = executor.executeSync(listEntitlementBuilder); + //Verify response is correct + assertThat(listEntitlementServiceResponsePpv.error).isNull(); + assertThat(listEntitlementServiceResponsePpv.results.getObjects().get(0).getClass()).isEqualTo(PpvEntitlement.class); + assertThat(listEntitlementServiceResponsePpv.results.getTotalCount()).isEqualTo(1); //Conversion from Entitlement to PpvEntitlement object List ppvEntitlementList = new ArrayList<>(); - for(Entitlement entitlement:listEntitlementServiceResponse.results.getObjects()){ + for(Entitlement entitlement:listEntitlementServiceResponsePpv.results.getObjects()){ if(entitlement.getClass() == PpvEntitlement.class) { ppvEntitlementList.add((PpvEntitlement) entitlement); } } - //Verify that count of entitlements is 1 - assertThat(listEntitlementServiceResponse.results.getTotalCount()).isEqualTo(1); + //TODO: change ppvModuleId to getSharedWebMediaFile().getPpvModules().getObjects().get(0).getValue() - right now it is null + String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get(PPV_MODULE_ID_KEY); //Verify that PPV is correct assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(ppvModuleId); //Verify that asset file is correct - assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(assetFileId); + assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); - //All transactions per user - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); - //Use non-master user ks + //Show subscription entitlements + entitlementFilter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + listEntitlementBuilder = EntitlementService.list(entitlementFilter).setKs(userKs); + //entitlement/action/list + listEntitlementServiceResponseSubscription = executor.executeSync(listEntitlementBuilder); + //Verify that subscription is correct + assertThat(listEntitlementServiceResponseSubscription.results.getTotalCount()).isEqualTo(1); + assertThat(listEntitlementServiceResponseSubscription.results.getObjects().get(0).getProductId()).isEqualTo(getSharedCommonSubscription().getId()); + assertThat(listEntitlementServiceResponseSubscription.results.getObjects().get(0).getClass()).isEqualTo(SubscriptionEntitlement.class); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for non-master user") + public void testTransactionHistoryPerHouseholdWithUserKs() { + //All transactions per non-master user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); //transactionHistory/action/list for non-master user listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); - //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); - //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); - //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); - //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); - //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); - //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); - //Verify that asset was purchased - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); - - //All transactions per household - transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - //Use non-master user ks + //Verify that two transactions were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(3); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(3); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test purchases per user are written correctly at transactionHistory for non-master user") + public void testTransactionHistoryPerUserWithUserKs() { + //All transactions per non-master user + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); //transactionHistory/action/list for non-master user listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); - //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); - //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); - //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); - //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); - //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); - //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); - //Verify that asset was purchased - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); - - //All transactions per household + //Verify that two transactions were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(2); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(2); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for master user") + public void testTransactionHistoryPerHouseholdWithMasterKs() { + //All transactions per master user transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); - //Use master user ks listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); //transactionHistory/action/list for master user listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); - //Verify that one transaction was performed - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); - //Verify asset id is correct - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); - //Verify transaction is for PPV - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getItemType()).isEqualTo(BillingItemsType.PPV); - //Verify price amount - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount().toString()).isEqualTo(pricePpv); - //Verify price currency - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getCurrency().toString()).isEqualTo(currencyPpv); - //Verify entitlement period - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); - //Verify that asset was purchased - assertThat(listBillingTransactionResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); - - //All transactions per user + //Verify that two transactions were performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(3); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(3); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + @Severity(SeverityLevel.BLOCKER) + @Test(description = "/transactionHistory/action/list - test no purchases per user were written at transactionHistory for master user") + public void testTransactionHistoryPerUserWithMasterKs() { + //All transactions per master user transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); - //Use master user ks listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); //transactionHistory/action/list for master user listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); - //No transactions were performed with master user - assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); + //Verify that one transaction was performed + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(1); + List billingTransactionList = listBillingTransactionResponse.results.getObjects(); + methodName = new Object() {}.getClass().getEnclosingMethod().getName(); + assertMethod(methodName, billingTransactionList); + } + + private void assertMethod(String methodName, List billingTransactionList) { + Logger.getLogger(TransactionHistoryListTests.class).debug(methodName); + String price, currency; + for(int i = 0; i < billingTransactionList.size(); i++) { + assertThat(listBillingTransactionResponse.results.getObjects().get(i).getClass()).isEqualTo(BillingTransaction.class); + switch (billingTransactionList.get(i).getItemType()){ + case SUBSCRIPTION: + BillingTransaction billingTransactionSubscription = billingTransactionList.get(i); + //Get subscription details (Price, Currency) + price = PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_AMOUNT); + currency = PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_CURRENCY); + assertThat(billingTransactionSubscription.getRecieptCode()).isEqualTo(transactionResponseSubscription.results.getId()); + assertThat(billingTransactionSubscription.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionSubscription.getPurchasedItemCode()).isEqualTo(getSharedCommonSubscription().getId().toString()); + assertThat(billingTransactionSubscription.getItemType()).isEqualTo(BillingItemsType.SUBSCRIPTION); + assertThat(billingTransactionSubscription.getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransactionSubscription.getPrice().getAmount().toString()).isEqualTo(price); + assertThat(billingTransactionSubscription.getPrice().getCurrency().toString()).isEqualTo(currency); + assertThat(billingTransactionSubscription.getIsRecurring()).isEqualTo(false); + assertThat(billingTransactionSubscription.getBillingProviderRef().toString().length()).isGreaterThan(1); + assertThat(billingTransactionSubscription.getPurchaseId().toString().length()).isGreaterThan(1); + assertThat(billingTransactionSubscription.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(billingTransactionSubscription.getActionDate()); + assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(transactionResponseSubscription.results.getCreatedAt().longValue()); + break; + + case PPV: + BillingTransaction billingTransactionPpv = billingTransactionList.get(i); + //Get PPV details (Price, Currency) + price = PurchaseUtils.purchasePpvDetailsMap.get(PRICE_AMOUNT); + currency = PurchaseUtils.purchasePpvDetailsMap.get(PRICE_CURRENCY); + assertThat(billingTransactionPpv.getRecieptCode()).isEqualTo(transactionResponsePpv.results.getId()); + assertThat(billingTransactionPpv.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionPpv.getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); + assertThat(billingTransactionPpv.getItemType()).isEqualTo(BillingItemsType.PPV); + assertThat(billingTransactionPpv.getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransactionPpv.getPrice().getAmount().toString()).isEqualTo(price); + assertThat(billingTransactionPpv.getPrice().getCurrency().toString()).isEqualTo(currency); + assertThat(billingTransactionPpv.getIsRecurring()).isEqualTo(false); + assertThat(billingTransactionPpv.getBillingProviderRef().toString().length()).isGreaterThan(1); + assertThat(billingTransactionPpv.getPurchaseId().toString().length()).isGreaterThan(1); + assertThat(billingTransactionPpv.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionPpv.getStartDate()).isEqualTo(billingTransactionPpv.getActionDate()); + assertThat(billingTransactionPpv.getStartDate()).isEqualTo(transactionResponsePpv.results.getCreatedAt().longValue()); + break; + + case COLLECTION: + BillingTransaction billingTransactionCollection = billingTransactionList.get(i); + //Get collection details (Price, Currency) + price = PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_AMOUNT); + currency = PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_CURRENCY); + assertThat(billingTransactionCollection.getRecieptCode()).isEqualTo(transactionResponseCollection.results.getId()); + assertThat(billingTransactionCollection.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionCollection.getPurchasedItemCode()).isEqualTo(getSharedCommonCollection().getId().toString()); + assertThat(billingTransactionCollection.getItemType()).isEqualTo(BillingItemsType.COLLECTION); + assertThat(billingTransactionCollection.getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransactionCollection.getPrice().getAmount().toString()).isEqualTo(price); + assertThat(billingTransactionCollection.getPrice().getCurrency().toString()).isEqualTo(currency); + assertThat(billingTransactionCollection.getIsRecurring()).isEqualTo(false); + assertThat(billingTransactionCollection.getBillingProviderRef().toString().length()).isGreaterThan(1); + assertThat(billingTransactionCollection.getPurchaseId().toString().length()).isGreaterThan(1); + assertThat(billingTransactionCollection.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionCollection.getActionDate()).isEqualTo(transactionResponseCollection.results.getCreatedAt().longValue()); + break; + + default: + Logger.getLogger(TransactionHistoryListTests.class).error("No valid item type found!"); + break; + } + } } } From c45a8a5d3488b25df5e7eebbe983c0b7eb103c72 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 4 Jun 2018 10:51:52 +0300 Subject: [PATCH 301/605] add InfraUtils.printTestsNameAndDescription(); --- .../kaltura/client/test/tests/BaseTest.java | 2 - .../PermissionsManagementTests.java | 19 ++- .../channelTests/ChannelAddTests.java | 14 +- .../channelTests/ChannelDeleteTests.java | 7 +- .../channelTests/ChannelGetTests.java | 15 ++- .../EntitlementCancelTests.java | 16 ++- .../EntitlementGrantTests.java | 47 +++++-- .../householdTests/HouseholdResumeTests.java | 2 +- .../householdTests/HouseholdSuspendTests.java | 126 +++++++++++++++++- .../ottUserTests/OttUserLoginTests.java | 3 +- .../ottUserTests/OttUserUpdateTests.java | 15 ++- .../TransactionHistoryListTests.java | 4 +- .../kaltura/client/test/utils/InfraUtils.java | 19 +++ 13 files changed, 237 insertions(+), 52 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 731420caa..5be20e625 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -36,7 +36,6 @@ public class BaseTest { public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); private static Response loginResponse; - // shared common params public static int partnerId; public static String defaultUserPassword; @@ -81,7 +80,6 @@ public class BaseTest { cycles.put(1440, "1 Day"); } - /*================================================================================ testing shared params list - used as a helper common params across tests diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 682f8a186..a61864f6e 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -2,24 +2,22 @@ import com.kaltura.client.test.utils.PermissionManagementUtils; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.*; + +import java.io.File; import java.util.ArrayList; import java.util.List; -import static com.kaltura.client.test.utils.PermissionManagementUtils.*; + +import static com.kaltura.client.test.utils.BaseUtils.deleteFile; +import static com.kaltura.client.test.utils.BaseUtils.getFileContent; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; -import static com.kaltura.client.test.utils.BaseUtils.getFileContent; -import static com.kaltura.client.test.utils.BaseUtils.deleteFile; /** * @@ -53,6 +51,7 @@ public void setUp() { public static final String IMPORT_KEY = "i="; public static final String DELETE_KEY = "d="; + @Description() @Test(groups = {"Permission management"}, description = "just for deletion") public void deleteData() { //long roleId = 477L; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index ced09ca92..ced3b5aa6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -28,7 +28,7 @@ public class ChannelAddTests extends BaseTest { private Channel channel; private String channelName; - private String Description; + private String description; private Boolean isActive = true; private String filterExpression; private IntegerValue integerValue = new IntegerValue(); @@ -38,14 +38,14 @@ public class ChannelAddTests extends BaseTest { @BeforeClass private void channel_addTests_before_class() { channelName = "Channel_12345"; - Description = "description of channel"; + description = "description of channel"; } @Description("channel/action/add - with all asset types") @Test private void addChannel() { filterExpression = "name ~ 'movie'"; - channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); @@ -70,7 +70,7 @@ private void checkOrderOfAssetsInChannel() { episodeAsset = IngestUtils.updateVODName(episodeAsset, asset2Name); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; - channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); + channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); @@ -101,7 +101,7 @@ private void checkOrderOfAssetsInChannel() { private void addChannelWithInvalidAssetType() { integerValue.setValue(666); assetTypes.add(integerValue); - channel = ChannelUtils.addChannel(channelName, Description, isActive, null, AssetOrderBy.LIKES_DESC, assetTypes, null); + channel = ChannelUtils.addChannel(channelName, description, isActive, null, AssetOrderBy.LIKES_DESC, assetTypes, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel) @@ -115,7 +115,7 @@ private void addChannelWithInvalidAssetType() { @Description("channel/action/add - mandatory channel name not provided") @Test private void addChannelWithNoName() { - channel = ChannelUtils.addChannel(null, Description, isActive, null, AssetOrderBy.LIKES_DESC, null, null); + channel = ChannelUtils.addChannel(null, description, isActive, null, AssetOrderBy.LIKES_DESC, null, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel) @@ -130,7 +130,7 @@ private void addChannelWithNoName() { @Test private void addChannelWithSyntaxErrorInFilterExpression() { filterExpression = "name = 'syntax error"; - channel = ChannelUtils.addChannel(channelName, Description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 09c44c565..8d258b5b0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -7,6 +7,8 @@ import com.kaltura.client.types.Channel; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; import static com.kaltura.client.services.ChannelService.GetChannelBuilder; @@ -19,13 +21,14 @@ public class ChannelDeleteTests extends BaseTest { private int channelId; private final String channelName = "Channel_12345"; - private final String Description = "description of channel"; + private final String description = "description of channel"; private final String filterExpression = "name ~ 'movie'"; + @Severity(SeverityLevel.CRITICAL) @Description("channel/action/delete") @Test private void DeleteChannel() { - channel = ChannelUtils.addChannel(channelName, Description, true, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + channel = ChannelUtils.addChannel(channelName, description, true, filterExpression, AssetOrderBy.LIKES_DESC, null, null); // channel/action/add ChannelService.AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java index 8e21973aa..248163de1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java @@ -3,6 +3,8 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.Channel; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; public class ChannelGetTests extends BaseTest { @@ -11,15 +13,16 @@ public class ChannelGetTests extends BaseTest { private String filterExpression; private final String channelName = "Channel_12345"; - private final String Description = "description of channel"; + private final String description = "description of channel"; -public class ChannelActionGet extends BaseTest { + public class ChannelActionGet extends BaseTest { - @Description - @Test - private void channelGetTests() { + @Severity(SeverityLevel.NORMAL) + @Description() + @Test + private void channelGetTests() { + } } -} } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 8ded1301d..8bac6fac8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -11,6 +11,9 @@ import com.kaltura.client.types.Household; import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -40,7 +43,9 @@ private void cancel_test_before_class() { testSharedMasterUser = HouseholdUtils.getMasterUserFromHousehold(testSharedHousehold); } - @Test(description = "entitlement/action/cancel - cancel subscription") + @Severity(SeverityLevel.CRITICAL) + @Description("entitlement/action/cancel - cancel subscription") + @Test private void cancel_subscription() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); @@ -79,7 +84,9 @@ private void cancel_subscription() { executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); } - @Test(description = "entitlement/action/cancel - cancel invalid subscription - error 3000") + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/cancel - cancel invalid subscription - error 3000") + @Test private void cancel_with_invalid_subscription() { // cancel subscription int invalidSubscriptionId = 1; @@ -92,7 +99,9 @@ private void cancel_with_invalid_subscription() { assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3000).getCode()); } - @Test(description = "entitlement/action/cancel - cancel played subscription - error 3005") + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/cancel - cancel played subscription - error 3005") + @Test private void cancel_played_subscription() { // // set household // Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); @@ -103,7 +112,6 @@ private void cancel_played_subscription() { @AfterClass private void cancel_test_after_class() { - // delete shared household for cleanup executor.executeSync(delete(Math.toIntExact(testSharedHousehold.getId())).setKs(getAdministratorKs())); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index 9ae68b4b1..68c4bf8a6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -14,7 +14,10 @@ import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; import io.qameta.allure.Issue; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.HouseholdService.*; @@ -48,7 +51,9 @@ private void grant_test_before_class() { ppvId = Integer.valueOf(getSharedCommonPpv().getId()); } - @Test(description = "entitlement/action/grant - grant subscription with history = true") + @Severity(SeverityLevel.CRITICAL) + @Description("entitlement/action/grant - grant subscription with history = true") + @Test private void grant_subscription_with_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); @@ -112,7 +117,9 @@ private void grant_subscription_with_history() { executor.executeSync(deleteHouseholdBuilder); } - @Test(description = "entitlement/action/grant - grant subscription with history = false") + @Severity(SeverityLevel.CRITICAL) + @Description("entitlement/action/grant - grant subscription with history = false") + @Test private void grant_subscription_without_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); @@ -152,7 +159,9 @@ private void grant_subscription_without_history() { executor.executeSync(deleteHouseholdBuilder); } - @Test(description = "entitlement/action/grant - grant ppv with history = true") + @Severity(SeverityLevel.CRITICAL) + @Description("entitlement/action/grant - grant ppv with history = true") + @Test private void grant_ppv_with_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); @@ -215,7 +224,9 @@ private void grant_ppv_with_history() { executor.executeSync(deleteHouseholdBuilder); } - @Test(description = "entitlement/action/grant - grant ppv with history = false") + @Severity(SeverityLevel.CRITICAL) + @Description("entitlement/action/grant - grant ppv with history = false") + @Test private void grant_ppv_without_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); @@ -263,7 +274,8 @@ private void grant_ppv_without_history() { executor.executeSync(deleteHouseholdBuilder); } - @Test(description = "entitlement/action/grant - grant ppv with wrong id - error 6001") + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/grant - grant ppv with wrong id - error 6001") private void grant_ppv_with_wrong_id() { int productId = 1; @@ -282,7 +294,9 @@ private void grant_ppv_with_wrong_id() { assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); } - @Test(description = "entitlement/action/grant - grant purchased ppv - error 3021") + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/grant - grant purchased ppv - error 3021") + @Test private void grant_purchased_ppv() { // get user form test shared household HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); @@ -305,7 +319,9 @@ private void grant_purchased_ppv() { assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3021).getCode()); } - @Test(description = "entitlement/action/grant - grant purchased subscription - error 3024") + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/grant - grant purchased subscription - error 3024") + @Test private void grant_purchased_subscription() { // get user form test shared household HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); @@ -327,14 +343,18 @@ private void grant_purchased_subscription() { assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3024).getCode()); } + @Severity(SeverityLevel.NORMAL) @Issue("BEO-5022") - @Test(description = "entitlement/action/grant - error 3023", enabled = false) + @Description("entitlement/action/grant - error 3023") + @Test(enabled = false) private void grant_3023() { // TODO: 4/30/2018 implement test } + @Severity(SeverityLevel.NORMAL) @Issue("BEO-5022") - @Test(enabled = false, description = "entitlement/action/grant - grant ppv with invalid content id - error 3018") + @Description("entitlement/action/grant - grant ppv with invalid content id - error 3018") + @Test(enabled = false) private void grant_ppv_with_invalid_contentId() { // get user form test shared household HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); @@ -352,7 +372,9 @@ private void grant_ppv_with_invalid_contentId() { assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3018).getCode()); } - @Test(description = "entitlement/action/grant - user not in domain - error 1005") + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/grant - user not in domain - error 1005") + @Test private void grant_ppv_user_not_in_domain() { // get user form test shared household RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, OttUserUtils.generateOttUser(), defaultUserPassword); @@ -371,9 +393,10 @@ private void grant_ppv_user_not_in_domain() { assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1005).getCode()); } - @Test(description = "entitlement/action/grant - user suspend - error 2001") + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/grant - user suspend - error 2001") + @Test private void grant_ppv_user_suspend() { - // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java index a24503a4b..f5f909477 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java @@ -69,7 +69,7 @@ private void resume_suspended_household() { } @Severity(SeverityLevel.CRITICAL) - @Description("household/action/resume - suspended household") + @Description("household/action/resume - suspended with purchase_subscription role household") @Test private void resume_suspended_with_purchase_subscription_role_household() { // create role diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index e88050e04..5005c8d20 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -337,7 +337,7 @@ private void suspend_with_purchase_ppv_role() { @Severity(SeverityLevel.NORMAL) @Issue("BEO-5166") - @Description("household/action/suspend - with _playback_ppv role") + @Description("household/action/suspend - with playback_ppv role") @Test(enabled = true) private void suspend_with_playback_ppv_role() { // set household @@ -393,4 +393,128 @@ private void suspend_with_playback_ppv_role() { // cleanup - delete household executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } + + @Severity(SeverityLevel.NORMAL) + @Description("household/action/suspend - with renew_subscription role") + @Test(enabled = false) + private void suspend_with_renew_subscription_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.RENEW_SUBSCRIPTION.name()); + role.setName(Permissions.RENEW_SUBSCRIPTION.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + //productprice/list - before sleep + + + //transactionhistory/list - after sleep + //productprice/list - after sleep + +// // purchase ppv +// Integer mediaFileId = asset.getMediaFiles().get(0).getId(); +// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); +// +// // suspend with playback_ppv role +// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) +// .setKs(getOperatorKs()) +// .setUserId(Integer.valueOf(masterUser.getUserId())); +// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); +// assertThat(booleanResponse.results).isTrue(); +// +// // get platbackContext +// PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); +// playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); +// playbackContextOptions.setStreamerType("applehttp"); +// playbackContextOptions.setMediaProtocol("http"); +// +// GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(asset.getId()), AssetType.MEDIA, playbackContextOptions) +// .setKs(masterUserKs); +// Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); +// +// assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); +// assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); +// assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); +// +// // purchase subscription in order to verify suspend is specific to role +// Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); +// assertThat(transactionResponse.error).isNull(); +// assertThat(transactionResponse.results.getState()).isEqualTo("OK"); +// +// // cleanup - delete role +// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); +// +// // cleanup - delete household +// executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + } + + @Severity(SeverityLevel.NORMAL) + @Description("household/action/suspend - with purchase_service role") + @Test(enabled = true) + private void suspend_with_purchase_service_role() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + + // create role + UserRole role = new UserRole(); + role.setExcludedPermissionNames(Permissions.PURCHASE_SERVICE.name()); + role.setName(Permissions.PURCHASE_SERVICE.name()); + + // add role + Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); + role = userRoleResponse.results; + + // + +// // purchase ppv +// Integer mediaFileId = asset.getMediaFiles().get(0).getId(); +// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); + +// // suspend with playback_ppv role +// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) +// .setKs(getOperatorKs()) +// .setUserId(Integer.valueOf(masterUser.getUserId())); +// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); +// assertThat(booleanResponse.results).isTrue(); +// +// // get platbackContext +// PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); +// playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); +// playbackContextOptions.setStreamerType("applehttp"); +// playbackContextOptions.setMediaProtocol("http"); +// +// GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(asset.getId()), AssetType.MEDIA, playbackContextOptions) +// .setKs(masterUserKs); +// Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); +// +// assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); +// assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); +// assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); +// +// // purchase subscription in order to verify suspend is specific to role +// Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); +// assertThat(transactionResponse.error).isNull(); +// assertThat(transactionResponse.results.getState()).isEqualTo("OK"); +// +// // cleanup - delete role +// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); +// +// // cleanup - delete household +// executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java index 6cf5810fa..44a1ca20a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java @@ -38,7 +38,8 @@ private void ottUser_login_tests_setup() { } @Severity(SeverityLevel.CRITICAL) - @Test(description = "ottUser/action/login - login") + @Description("ottUser/action/login - login") + @Test private void login() { // login user loginResponse = executor.executeSync(OttUserService.login(partnerId, user.getUsername(), defaultUserPassword)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index ea05fe555..5ef3c76e5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -10,6 +10,7 @@ import com.kaltura.client.types.OTTUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; @@ -41,7 +42,9 @@ private void ottUser_updateTests_beforeClass() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - update") - @Test(enabled = true) + @Issue("BEO-5168") + @Issue("BEO-5169") + @Test(enabled = false) private void update() { // update user info String newUserInfo = "newUserInfo"; @@ -49,9 +52,10 @@ private void update() { updatedUser.setFirstName(newUserInfo); updatedUser.setLastName(newUserInfo); updatedUser.setAddress(newUserInfo); -// updatedUser.setDynamicData(dynamicDataMapBuilder("key", "value")); - updatedUser = executor.executeSync(OttUserService.update(updatedUser).setKs(userKs)).results; + updatedUser = executor.executeSync(OttUserService.update(updatedUser) + .setKs(userKs)) + .results; // assert user new info assertThat(updatedUser.getFirstName()).isEqualTo(newUserInfo); @@ -62,7 +66,9 @@ private void update() { @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/update - with administratorKs") - @Test(enabled = true) + @Issue("BEO-5168") + @Issue("BEO-5169") + @Test(enabled = false) private void update_with_administratorKs() { // update user info String newUserInfo = "newUserInfo"; @@ -70,7 +76,6 @@ private void update_with_administratorKs() { updatedUser.setFirstName(newUserInfo); updatedUser.setLastName(newUserInfo); updatedUser.setAddress(newUserInfo); -// updatedUser.setDynamicData(dynamicDataMapBuilder("key", "value")); updatedUser = executor.executeSync(OttUserService.update(updatedUser) .setKs(getAdministratorKs()) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index 89b5ecd9e..cb5b8df4f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -10,6 +10,7 @@ import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; @@ -52,7 +53,8 @@ public void beforeClass(){ } @Severity(SeverityLevel.BLOCKER) - @Test(description = "/transactionhistory/action/list - test ppv purchases is written correctly at transactionHistory") + @Description("/transactionhistory/action/list - test ppv purchases is written correctly at transactionHistory") + @Test public void purchase_ppv(){ Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); diff --git a/src/test/java/com/kaltura/client/test/utils/InfraUtils.java b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java index 168d2802b..4fd59e5a5 100644 --- a/src/test/java/com/kaltura/client/test/utils/InfraUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.utils; import com.google.common.reflect.ClassPath; +import io.qameta.allure.Description; import org.apache.commons.io.FileUtils; import java.io.File; @@ -50,6 +51,24 @@ public static void writeDbUtilsListToFile() throws IOException { } } } + } + + public static void printTestsNameAndDescription() throws IOException { + String packageName = "com.kaltura.client.test.tests.servicesTests"; + Set allClasses = ClassPath.from(ClassLoader.getSystemClassLoader()).getTopLevelClassesRecursive(packageName); + for (ClassPath.ClassInfo classInfo: allClasses) { + System.out.println("\n\n" + classInfo.getSimpleName()); + + Class clazz = classInfo.load(); + Method[] methods = clazz.getDeclaredMethods(); + for (Method method : methods) { + Description description = method.getAnnotation(Description.class); + if (description != null) { + System.out.println("Method: " + method.getName()); + System.out.println("Description: " + description.value() + "\n"); + } + } + } } } From a5c340999df5fb1e2ee83b51280b7b1cba3d00ba Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 4 Jun 2018 11:07:31 +0300 Subject: [PATCH 302/605] Add new util to AssetUtils --- .../com/kaltura/client/test/utils/AssetUtils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 07f0a4924..65fffbd84 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -7,6 +7,7 @@ import com.kaltura.client.services.AssetService; import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.services.SocialActionService; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -15,6 +16,7 @@ import java.util.List; import java.util.Optional; +import static com.kaltura.client.services.SocialActionService.*; import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.services.AssetService.*; import static com.kaltura.client.test.tests.BaseTest.*; @@ -102,6 +104,18 @@ public static void addViewsToAsset(Long assetId, int numOfActions, AssetType ass } } + public static void addLikesToAsset (Long assetId, int numOfActions, AssetType assetType) { + if (numOfActions <= 0) { + Logger.getLogger("Value must be equal or greater than 0"); + } else { + for (int i = 0; i < numOfActions; i++) { + Household household = HouseholdUtils.createHousehold(1, 1, false); + HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); + AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add() + } + } + } + } From 98f502a012d42f9966e070f3306cd4526b9860a1 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 4 Jun 2018 11:42:45 +0300 Subject: [PATCH 303/605] transactionHistory repull --- .../TransactionHistoryListTests.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index d354aeb85..9335b229d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -11,7 +11,6 @@ import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; -import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; @@ -59,12 +58,7 @@ public void transactionHistortTestSetup(){ transactionHistoryFilter.setStartDateGreaterThanOrEqual(yesterdayInEpoch); //End date before tomorrow transactionHistoryFilter.setEndDateLessThanOrEqual(tomorrowInEpoch); - } - @Severity(SeverityLevel.BLOCKER) - @Description("/transactionhistory/action/list - test ppv purchases is written correctly at transactionHistory") - @Test - public void purchase_ppv(){ Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); //Login with master to first device masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); From 527db3a2af02d35bb5eedc2f051ab4e1b01ecfa6 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 4 Jun 2018 13:56:06 +0300 Subject: [PATCH 304/605] Added method public static String getSubscriptionWithPremiumService() --- .../test/utils/dbUtils/DBConstants.java | 12 ++++++++++- .../client/test/utils/dbUtils/DBUtils.java | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index e8dc90efc..c8edc8674 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -15,7 +15,9 @@ public class DBConstants { static final String NUMBER_OF_REC_PERIODS = "num_of_rec_periods"; static final String PASSWORD = "password"; static final String ROW_COUNT = "row_count"; + static final String SERV_ID = "serv_id"; static final String SUBSCRIPTION_ONLY = "subscription_only"; + static final String SUB_ID = "sub_id"; static final String USERNAME = "username"; static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; @@ -76,11 +78,19 @@ public class DBConstants { "and group_id=%d and usage_module_code=%d and discount_module_code=%d\n" + "order by create_date"; + static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) SUBSCRIPTION_ID as " + SUB_ID + + ", SERVICE_ID as " + SERV_ID + "\n" + + "FROM [Pricing].[dbo].[subscriptions] s\n" + + "INNER JOIN [Pricing].[dbo].[subscriptions_services] ss\n" + + "ON s.ID = SS.SUBSCRIPTION_ID\n" + + "where s.group_id=%d"; + static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + "from [Users].[dbo].[users] u with(nolock)\n" + "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + - "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d"; + // TODO: find instead of and u.username <> 'lfaingold' how to exclude suspended users + "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d and u.username <> 'lfaingold'"; static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index bfde264dd..784b18cd2 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -127,6 +127,26 @@ public static int getUnActiveAsset() { return assetId; } + public static String getSubscriptionWithPremiumService() { + Logger.getLogger(DBUtils.class).debug("getSubscriptionWithPremiumService()"); + String result = null; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, + partnerId), false); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return result; + } + + result = jsonArray.getJSONObject(0).getInt(SUB_ID) + ":" + + jsonArray.getJSONObject(0).getInt(SERV_ID); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(DBUtils.class).error("data about premium services can't be null"); + } + + return result; + } + // public static List getUserRoles(String userId) { // List userRoles = new ArrayList<>(); From ca2be7fff3f829faa142ca34e5d0daa0a8dcb4a7 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 4 Jun 2018 14:00:54 +0300 Subject: [PATCH 305/605] Added util to SocialUtils - "getSocialAction" --- .../client/test/utils/SocialUtils.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/utils/SocialUtils.java diff --git a/src/test/java/com/kaltura/client/test/utils/SocialUtils.java b/src/test/java/com/kaltura/client/test/utils/SocialUtils.java new file mode 100644 index 000000000..a7233febd --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/SocialUtils.java @@ -0,0 +1,21 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.SocialActionType; +import com.kaltura.client.types.SocialAction; + +import javax.annotation.Nullable; + +public class SocialUtils { + public static SocialAction getSocialAction(@Nullable SocialActionType socialActionType, @Nullable Long time, Long assetId, @Nullable AssetType assetType, + @Nullable String url) { + SocialAction socialAction = new SocialAction(); + socialAction.setActionType(socialActionType); + socialAction.setTime(time); + socialAction.setAssetId(assetId); + socialAction.setAssetType(assetType); + socialAction.setUrl(url); + + return socialAction; + } +} From aa7efe59bf47e2ff1890aabd709f4fb75660999b Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 4 Jun 2018 14:01:17 +0300 Subject: [PATCH 306/605] Updated util in AssetUtils class - "addLikesToAsset" --- .../com/kaltura/client/test/utils/AssetUtils.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 65fffbd84..1ddeef74d 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -4,10 +4,12 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.enums.SocialActionType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.SocialActionService; +import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -104,14 +106,20 @@ public static void addViewsToAsset(Long assetId, int numOfActions, AssetType ass } } - public static void addLikesToAsset (Long assetId, int numOfActions, AssetType assetType) { + public static void addLikesToAsset(Long assetId, int numOfActions, AssetType assetType) { if (numOfActions <= 0) { Logger.getLogger("Value must be equal or greater than 0"); } else { for (int i = 0; i < numOfActions; i++) { Household household = HouseholdUtils.createHousehold(1, 1, false); HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); - AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add() + SocialAction socialAction = SocialUtils.getSocialAction(SocialActionType.LIKE, null, assetId, assetType, null); + AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialAction) + .setKs(BaseTest.getOperatorKs()) + .setUserId(Integer.valueOf(householdUser.getUserId())); + executor.executeSync(addSocialActionBuilder); + + HouseholdService.delete(Math.toIntExact(household.getId())); } } } From f8bab5a1b1de438a3278e0ba2de8bc6809b07070 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 4 Jun 2018 14:01:49 +0300 Subject: [PATCH 307/605] Updated class - "SearchAssetFilterTests" --- .../SearchAssetFilterTests.java | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index b4e18a384..f9143f883 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -249,12 +249,12 @@ private void listEpgProgramsFilteredByEpgChannel() { @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - order by VIEWS") @Test - private void listVodAssetsByViews() { - MediaAsset assetWithTheMostViews = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); - MediaAsset assetWithTheSecondMostViews = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + private void OrderVodAssetsByViews() { - AssetUtils.addViewsToAsset(assetWithTheMostViews.getId(), 10, AssetType.MEDIA); - ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + assetWithTheMostViews.getName() + "'name = '" + assetWithTheSecondMostViews.getName() + "')"; + AssetUtils.addViewsToAsset(asset.getId(), 3, AssetType.MEDIA); + AssetUtils.addViewsToAsset(asset2.getId(), 2, AssetType.MEDIA); + + ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) @@ -262,15 +262,15 @@ private void listVodAssetsByViews() { Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); - assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(assetWithTheMostViews.getId()); - assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(assetWithTheSecondMostViews.getId()); - assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); } @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - order by NAME (DESC/ASC") @Test - private void listVodAssetsByNameAsc() { + private void OrderVodAssetsByName() { IngestUtils.updateVODName(asset, "AAA"); IngestUtils.updateVODName(asset2, "BBB"); @@ -297,4 +297,28 @@ private void listVodAssetsByNameAsc() { assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); } -} \ No newline at end of file + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - order by LIKES") + @Test + private void orderVodAssetsByLikes() { + + AssetUtils.addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); + AssetUtils.addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); + + + ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); + + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + } +} + + From 8066256f06456b4a134a8e38e9969428a8d09518 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 4 Jun 2018 14:06:33 +0300 Subject: [PATCH 308/605] updated purchasePpv method to process currency properly --- .../java/com/kaltura/client/test/utils/PurchaseUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 1eba78d38..726fef463 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -42,7 +42,9 @@ public static Response purchasePpv(String ks, Optional med filter.setFileIdIn(String.valueOf(internalFileId)); filter.setIsLowest(false); - ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(filter).setKs(ks); + ListProductPriceBuilder listProductPriceBuilder = purchaseCurrency == null + ? ProductPriceService.list(filter).setKs(ks) + : ProductPriceService.list(filter).setKs(ks).setCurrency(purchaseCurrency); productPriceResponse = executor.executeSync(listProductPriceBuilder); double price = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); From df66d332e2a6069c61835be9823754743d035992 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 4 Jun 2018 14:07:02 +0300 Subject: [PATCH 309/605] Added more tests related productPrice/action/list actions --- .../kaltura/client/test/IngestConstants.java | 2 + .../ProductPriceListTests.java | 261 +++++++++++++++++- 2 files changed, 258 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/IngestConstants.java b/src/test/java/com/kaltura/client/test/IngestConstants.java index 10e500e2b..01ec5e743 100644 --- a/src/test/java/com/kaltura/client/test/IngestConstants.java +++ b/src/test/java/com/kaltura/client/test/IngestConstants.java @@ -12,6 +12,8 @@ public class IngestConstants { // currency public static final String CURRENCY_EUR = "EUR"; public static final String CURRENCY_USD = "USD"; + public static final String CURRENCY_ILS = "ILS"; + public static final String CURRENCY_CLP = "CLP"; // life cycles periods public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index f63de4eb2..163ee71f6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -1,11 +1,11 @@ package com.kaltura.client.test.tests.servicesTests.productPriceTests; import com.kaltura.client.enums.*; -import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.*; +import com.kaltura.client.services.AssetService.GetAssetBuilder; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; -import com.kaltura.client.services.HouseholdService; -import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; +import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; @@ -30,11 +30,14 @@ public class ProductPriceListTests extends BaseTest { private EntitlementFilter entitlementPpvsFilter; private EntitlementFilter entitlementSubsFilter; + private TransactionHistoryFilter transactionHistoryFilter; private Household household; private String classMasterUserKs; private Response> productPriceResponse; private Response> entitlementResponse; + private Response> listBillingTransactionResponse; + private Response assetGetResponse; @BeforeClass public void beforeClass() { @@ -51,6 +54,10 @@ public void beforeClass() { entitlementSubsFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); entitlementSubsFilter.setIsExpiredEqual(false); + transactionHistoryFilter = new TransactionHistoryFilter(); + transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + transactionHistoryFilter.setStartDateGreaterThanOrEqual(0); + /*Ppv ppv = IngestUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ @@ -320,6 +327,16 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); PurchaseUtils.purchaseSubscription(masterKs, subWithMultiCurrencyId, Optional.empty()); + // to check purchase + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); + // to check purchase + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); // should be 1 subscription @@ -343,8 +360,7 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTest() { // TODO: add logic of using dynamic data int subWithDiscountAndCurrencyId = 116952; - double subPrice = 15.; - double subPriceAfterDiscount = 7.5; + double subPriceAfterDiscount = 7.5; // as price 15 and discount is 50% int numberOfUsers = 1; int numberOfDevices = 1; @@ -365,6 +381,17 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_USD); PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(IngestConstants.CURRENCY_USD)); + // to check purchase + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + // to check purchase + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); // should be 1 subscription @@ -381,6 +408,230 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe executor.executeSync(deleteHouseholdBuilder); } + @Severity(SeverityLevel.NORMAL) + @Description("productPrice/action/list - subscription with discount (fixed amount) - specified currency - not in locale") + @Test() + public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLocaleTest() { + // TODO: add logic of using dynamic data + int subWithDiscountAndCurrencyId = 119303; + double subPriceAfterDiscount = 4; // as price 5 and discount is 1 + + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setCurrency(IngestConstants.CURRENCY_CLP); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_CLP); + + PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(IngestConstants.CURRENCY_CLP)); + // to check purchase + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + // to check purchase + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); + + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_CLP); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } + + @Severity(SeverityLevel.NORMAL) + @Description("productPrice/action/list - subscription with discount (percentage) - no specified currency") + @Test() + public void productPriceSubscriptionWithPercentageDiscountAndNoSpecifiedCurrencyTest() { + // TODO: add logic of using dynamic data + int subWithDiscountAndCurrencyId = 116952; + double subPriceAfterDiscount = 9.6; // as price 12 in default locale and discount is 20% in default locale + + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + + PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.empty()); + // to check purchase + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + // to check purchase + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); + + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 subscription + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } + + @Severity(SeverityLevel.NORMAL) + @Description("productPrice/action/list - PPV - with discount (percentage) - specified currency") + @Test() + public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + // TODO: add logic of using dynamic data + int assetWithMultiCurrencyId = 485467; + GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(assetWithMultiCurrencyId), + AssetReferenceType.MEDIA).setKs(masterKs); + assetGetResponse = executor.executeSync(getAssetBuilder); + int mediaFileId = assetGetResponse.results.getMediaFiles().get(1).getId(); + double ppvPriceAfterDiscount = 33.3; // as price 37 ILS and discount is 10% + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setFileIdIn(String.valueOf(mediaFileId)); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs).setCurrency(IngestConstants.CURRENCY_ILS)); + // should be 1 file + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + + PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), IngestConstants.CURRENCY_ILS); + // to check purchase + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(assetWithMultiCurrencyId); + assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(mediaFileId); + // to check purchase + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(assetWithMultiCurrencyId)); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); + + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 ppv + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); + assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(mediaFileId); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } + + @Severity(SeverityLevel.NORMAL) + @Description("productPrice/action/list - PPV - with discount (fixed amount) - specified currency") + @Test() + public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + + // TODO: add logic of using dynamic data + int assetWithMultiCurrencyId = 485618; + GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(assetWithMultiCurrencyId), + AssetReferenceType.MEDIA).setKs(masterKs); + assetGetResponse = executor.executeSync(getAssetBuilder); + int mediaFileId = assetGetResponse.results.getMediaFiles().get(1).getId(); + double ppvPriceAfterDiscount = 2; // as price 5 ILS and discount is 3 + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setFileIdIn(String.valueOf(mediaFileId)); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs).setCurrency(IngestConstants.CURRENCY_ILS)); + // should be 1 file + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + + PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), IngestConstants.CURRENCY_ILS); + // to check purchase + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(assetWithMultiCurrencyId); + assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(mediaFileId); + // to check purchase + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(assetWithMultiCurrencyId)); + assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); + + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); + // should be 1 ppv + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); + assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(mediaFileId); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) + .setKs(getAdministratorKs()); + executor.executeSync(deleteHouseholdBuilder); + } + @AfterClass public void afterClass() { //delete household for cleanup From 58445835af68ba20671a488236562abbffbd32d4 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 4 Jun 2018 14:45:49 +0300 Subject: [PATCH 310/605] Added new Schema - "UserSocialActionResponse" --- .../schemas/UserSocialActionResponse.json | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/test/resources/schemas/UserSocialActionResponse.json diff --git a/src/test/resources/schemas/UserSocialActionResponse.json b/src/test/resources/schemas/UserSocialActionResponse.json new file mode 100644 index 000000000..b9fbc0bed --- /dev/null +++ b/src/test/resources/schemas/UserSocialActionResponse.json @@ -0,0 +1,56 @@ +{ + "$id": "UserSocialActionResponse", + "definitions": { + "UserSocialActionResponse": { + "type": "object", + "properties": { + "socialAction": { + "type": "object", + "properties": { + "id": {"type": "string", "minLength": 0}, + "actionType": {"type": "string", "minLength": 0}, + "time": {"type": "integer", "minimum": 0}, + "assetId": {"type": "integer", "minimum": 0}, + "assetType": {"type": "string", "minLength": 0}, + "objectType": {"type": "string", "minLength": 0} + }, + "required": ["id", "actionType", "time", "assetId", "assetType"] + }, + "failStatus": { + "type": "array", + "items": { + "type": "object", + "properties": { + "status": { + "type": "string", + "minLength": 0 + }, + "network": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + } + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + } + }, + "type": "object", + "properties": { + "result": { + "ref": "#/definitions/UserSocialActionResponse" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file From b596abcd6be42a7acae99af35829245dad741951 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 4 Jun 2018 16:03:03 +0300 Subject: [PATCH 311/605] suspend_with_renew_subscription_role() --- .../householdTests/HouseholdSuspendTests.java | 97 +++++++++++-------- .../client/test/utils/HouseholdUtils.java | 19 ++-- 2 files changed, 68 insertions(+), 48 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 17ee0d2d5..e75efdf03 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -1,8 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.householdTests; import com.kaltura.client.enums.*; -import com.kaltura.client.services.HouseholdService; -import com.kaltura.client.services.UserRoleService; +import com.kaltura.client.services.*; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; import com.kaltura.client.types.*; @@ -180,6 +179,12 @@ private void suspend_with_purchase_subscription_role() { assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + // add device to household to verify suspend is specific to role + HouseholdDevice householdDevice = HouseholdUtils.generateHouseholdDevice(); + Response householdDeviceResponse = executor.executeSync(HouseholdDeviceService.add(householdDevice) + .setKs(masterUserKs)); + assertThat(householdDeviceResponse.error).isNull(); + // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); @@ -395,8 +400,9 @@ private void suspend_with_playback_ppv_role() { } @Severity(SeverityLevel.NORMAL) + @Issue("BEO-5173") @Description("household/action/suspend - with renew_subscription role") - @Test(enabled = false) + @Test(enabled = true, groups = "slow") private void suspend_with_renew_subscription_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); @@ -415,52 +421,59 @@ private void suspend_with_renew_subscription_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; - //productprice/list - before sleep + // purchase subscription + Subscription fiveMinRenewSubscription = get5MinRenewableSubscription(); + int fiveMinRenewSubscriptionId = Integer.parseInt(fiveMinRenewSubscription.getId().trim()); + PurchaseUtils.purchaseSubscription(masterUserKs, fiveMinRenewSubscriptionId, Optional.empty()); + + //*** + System.out.println("here!!!"); + EntitlementFilter filter1 = new EntitlementFilter(); + filter1.setProductTypeEqual(TransactionType.SUBSCRIPTION); + executor.executeSync(EntitlementService.list(filter1).setKs(masterUserKs)); + + // set productPrice filter + ProductPriceFilter filter = new ProductPriceFilter(); + filter.setSubscriptionIdIn(fiveMinRenewSubscription.getId()); + + //get productprice list - before renew + Response> productPriceListResponse = executor.executeSync(ProductPriceService.list(filter).setKs(masterUserKs)); + assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListResponse.results.getObjects().get(0).getProductId()).isEqualTo(fiveMinRenewSubscription.getId().trim()); + assertThat(productPriceListResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + + // suspend with renew_subscription role + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + + // sleep for 5 min + try { Thread.sleep(300000); } catch (InterruptedException e) { e.printStackTrace(); } + //get productprice list - after renew + productPriceListResponse = executor.executeSync(ProductPriceService.list(filter).setKs(masterUserKs)); + assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListResponse.results.getObjects().get(0).getProductId()).isEqualTo(fiveMinRenewSubscription.getId().trim()); + assertThat(productPriceListResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.USER_SUSPENDED); //transactionhistory/list - after sleep - //productprice/list - after sleep + Response> billingTransactionListResponse = executor.executeSync(TransactionHistoryService.list().setKs(masterUserKs)); + assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(billingTransactionListResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(fiveMinRenewSubscription.getId().trim()); + assertThat(billingTransactionListResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); -// // purchase ppv -// Integer mediaFileId = asset.getMediaFiles().get(0).getId(); -// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); -// -// // suspend with playback_ppv role -// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) -// .setKs(getOperatorKs()) -// .setUserId(Integer.valueOf(masterUser.getUserId())); -// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); -// assertThat(booleanResponse.results).isTrue(); -// -// // get platbackContext -// PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); -// playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); -// playbackContextOptions.setStreamerType("applehttp"); -// playbackContextOptions.setMediaProtocol("http"); -// -// GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(asset.getId()), AssetType.MEDIA, playbackContextOptions) -// .setKs(masterUserKs); -// Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); -// -// assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); -// assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); -// assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); -// -// // purchase subscription in order to verify suspend is specific to role -// Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); -// assertThat(transactionResponse.error).isNull(); -// assertThat(transactionResponse.results.getState()).isEqualTo("OK"); -// -// // cleanup - delete role -// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); -// -// // cleanup - delete household -// executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with purchase_service role") - @Test(enabled = true) + @Test(enabled = false) private void suspend_with_purchase_service_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); @@ -479,7 +492,7 @@ private void suspend_with_purchase_service_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; - // + // TODO: 6/4/2018 finsih test // // purchase ppv // Integer mediaFileId = asset.getMediaFiles().get(0).getId(); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index dac12b5b2..8a13d0c8d 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -62,12 +62,7 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO // add household devices for (int i = 0; i < numberOfDevicesInHousehold; i++) { // create household device - long uniqueString = System.currentTimeMillis(); - HouseholdDevice householdDevice = new HouseholdDevice(); - householdDevice.setUdid(String.valueOf(uniqueString)); - Random r = new Random(); - householdDevice.setBrandId(r.nextInt(28 - 1) + 1); - householdDevice.setName(String.valueOf(uniqueString) + "device"); + HouseholdDevice householdDevice = generateHouseholdDevice(); // add device to household AddHouseholdDeviceBuilder addHouseholdDeviceBuilder = HouseholdDeviceService.add(householdDevice) @@ -87,6 +82,18 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO return household; } + // generate household device + public static HouseholdDevice generateHouseholdDevice() { + long uniqueString = System.currentTimeMillis(); + HouseholdDevice householdDevice = new HouseholdDevice(); + householdDevice.setUdid(String.valueOf(uniqueString)); + Random r = new Random(); + householdDevice.setBrandId(r.nextInt(28 - 1) + 1); + householdDevice.setName(String.valueOf(uniqueString) + "device"); + + return householdDevice; + } + // get users list from given household public static List getDevicesListFromHouseHold(Household household) { From 16d6ad74974c2d3c63e9992b74b372139cc84410 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 5 Jun 2018 04:18:32 +0300 Subject: [PATCH 312/605] removed unused method --- .../four_eight/PermissionsManagementTests.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index a61864f6e..490271b1a 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -51,20 +51,6 @@ public void setUp() { public static final String IMPORT_KEY = "i="; public static final String DELETE_KEY = "d="; - @Description() - @Test(groups = {"Permission management"}, description = "just for deletion") - public void deleteData() { - //long roleId = 477L; - long permissionId = 32L; - /*long permissionItemId = 544L; - long permissionPermissionItemId = 1068;*/ - - //PermissionsManagementDBUtils.deleteRoleAndItsPermissions((int)roleId); - PermissionsManagementDBUtils.deletePermission((int)permissionId); - /*PermissionsManagementDBUtils.deletePermissionItem((int)permissionItemId); - PermissionsManagementDBUtils.deletePermissionPermissionItem((int)permissionPermissionItemId);*/ - } - @Severity(SeverityLevel.MINOR) @Test(groups = {"Permission management"}, description = "execute console util without parameters") public void runningWithoutParameters() { From c8102e1ca202d97cad184689e3e6a2aa35e2395f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 5 Jun 2018 04:19:06 +0300 Subject: [PATCH 313/605] Updated util public static void printTestsNameAndDescription() --- .../kaltura/client/test/utils/InfraUtils.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/InfraUtils.java b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java index 4fd59e5a5..87bb0115e 100644 --- a/src/test/java/com/kaltura/client/test/utils/InfraUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/InfraUtils.java @@ -3,6 +3,7 @@ import com.google.common.reflect.ClassPath; import io.qameta.allure.Description; import org.apache.commons.io.FileUtils; +import org.testng.annotations.Test; import java.io.File; import java.io.IOException; @@ -54,7 +55,7 @@ public static void writeDbUtilsListToFile() throws IOException { } public static void printTestsNameAndDescription() throws IOException { - String packageName = "com.kaltura.client.test.tests.servicesTests"; + String packageName = "com.kaltura.client.test.tests"; Set allClasses = ClassPath.from(ClassLoader.getSystemClassLoader()).getTopLevelClassesRecursive(packageName); for (ClassPath.ClassInfo classInfo: allClasses) { @@ -68,7 +69,20 @@ public static void printTestsNameAndDescription() throws IOException { System.out.println("Method: " + method.getName()); System.out.println("Description: " + description.value() + "\n"); } + + Test testAnnotation = method.getAnnotation(Test.class); + if (testAnnotation != null && !testAnnotation.toString().contains("description=,")) { + System.out.println("Method: " + method.getName()); + System.out.println("Description: " + getDescriptionFromTestAnnotation(testAnnotation.toString()) + "\n"); + } } } } + + private static String getDescriptionFromTestAnnotation(String testAnnotationContent) { + String descriptionEqual = "description="; + int descriptionStartsPosition = testAnnotationContent.indexOf(descriptionEqual) + descriptionEqual.length(); + int descriptionEndsPosition = testAnnotationContent.indexOf(",", descriptionStartsPosition); + return testAnnotationContent.substring(descriptionStartsPosition, descriptionEndsPosition); + } } From 3afecf38acf99ec81b98e6e8045aeecd4663589c Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 5 Jun 2018 09:26:09 +0300 Subject: [PATCH 314/605] Added new util to SocialActionUtil - "getSocialActionRate" --- .../kaltura/client/test/utils/SocialUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/SocialUtils.java b/src/test/java/com/kaltura/client/test/utils/SocialUtils.java index a7233febd..a035a3667 100644 --- a/src/test/java/com/kaltura/client/test/utils/SocialUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SocialUtils.java @@ -3,6 +3,7 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.SocialActionType; import com.kaltura.client.types.SocialAction; +import com.kaltura.client.types.SocialActionRate; import javax.annotation.Nullable; @@ -18,4 +19,19 @@ public static SocialAction getSocialAction(@Nullable SocialActionType socialActi return socialAction; } + + public static SocialActionRate getSocialActionRate(@Nullable SocialActionType socialActionType, @Nullable Long time, Long assetId, @Nullable AssetType assetType, + @Nullable String url, int rate) { + SocialActionRate socialActionRate = new SocialActionRate(); + socialActionRate.setActionType(socialActionType); + socialActionRate.setTime(time); + socialActionRate.setAssetId(assetId); + socialActionRate.setAssetType(assetType); + socialActionRate.setUrl(url); + socialActionRate.setRate(rate); + + return socialActionRate; + } + + } From 84fdff5c852847542586a862f2ec602cb892659f Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 5 Jun 2018 09:26:40 +0300 Subject: [PATCH 315/605] Added new overloaded ingestVod util --- .../kaltura/client/test/utils/IngestUtils.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 832ae4df0..0f36b9646 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -1050,6 +1050,15 @@ private static String generateTagsXml(Map> metas) { // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) + + public static MediaAsset ingestVOD(String mediaType, Map> tags, String catalogStartDate) { + MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(catalogStartDate), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), + Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); + + return mediaAsset; + } + public static MediaAsset ingestVOD(String mediaType) { MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), @@ -1058,6 +1067,7 @@ public static MediaAsset ingestVOD(String mediaType) { return mediaAsset; } + public static MediaAsset updateVODName(MediaAsset asset, String name) { MediaAsset mediaAsset = ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), @@ -1066,14 +1076,6 @@ public static MediaAsset updateVODName(MediaAsset asset, String name) { return mediaAsset; } - // - public static MediaAsset ingestVOD(String mediaType, Map> tags) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), - Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; - } public static ArrayList ingestBasicVODNumOfTimes(int numOfAssets, String mediaType) { From 493a7243f8f805fd6aa2a68f235c5c0467941ba7 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 5 Jun 2018 09:27:00 +0300 Subject: [PATCH 316/605] Added new util to assetUtils - AddVotesToAsset --- .../kaltura/client/test/utils/AssetUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 1ddeef74d..ed1ea4748 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -124,8 +124,26 @@ public static void addLikesToAsset(Long assetId, int numOfActions, AssetType ass } } + public static void addVotesToAsset(Long assetId, int numOfActions, AssetType assetType, int rate) { + if (numOfActions <= 0) { + Logger.getLogger("Value must be equal or greater than 0"); + } else { + for (int i = 0; i < numOfActions; i++) { + Household household = HouseholdUtils.createHousehold(1, 1, false); + HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); + SocialActionRate socialActionRate = SocialUtils.getSocialActionRate(SocialActionType.RATE, null, assetId, assetType, null, rate); + AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialActionRate) + .setKs(BaseTest.getOperatorKs()) + .setUserId(Integer.valueOf(householdUser.getUserId())); + executor.executeSync(addSocialActionBuilder); + + HouseholdService.delete(Math.toIntExact(household.getId())); + } + } + } } + From b1b99a70c2d62b4c152f178d5487bf0211834595 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 5 Jun 2018 09:27:39 +0300 Subject: [PATCH 317/605] Keep updating SearchAssetFilterTests class --- .../SearchAssetFilterTests.java | 175 ++++++++++++------ 1 file changed, 114 insertions(+), 61 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index f9143f883..635675f21 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; @@ -39,8 +38,7 @@ public class SearchAssetFilterTests extends BaseTest { private String ksqlQuery; private AssetFilter assetFilter = null; private ListAssetBuilder listAssetBuilder = null; - private Map map = new HashMap(); - private ArrayList assetList = new ArrayList<>(); + private HashMap > map = new HashMap<>(); private ArrayList list = new ArrayList<>(); private String tagName = "Genre"; private String tagValue = BaseUtils.getRandomValue(tagName + "_", 999999); @@ -53,15 +51,12 @@ private void Asset_list_before_class() { asset = BaseTest.getSharedMediaAsset(); list.add(tagValue); map.put(tagName, list); - asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map); - asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map); - assetList.add(asset2.getId()); - assetList.add(asset3.getId()); + asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInEpoch(-10))); + asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInEpoch(-100))); program = IngestUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestUtils.ingestEPG(epgChannelName2, 1).get(0); - } @@ -196,58 +191,8 @@ private void listVodAssetsFilteredByType() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); } - // EPG - // ****************************************** - - @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - EPG - name equal query") - @Test - private void listEpgProgramWithExactKsqlQuery() { - ksqlQuery = "name = '" + program.getName() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - - Response> assetListResponse = executor.executeSync(listAssetBuilder); - assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program.getId()); - } - - @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - EPG - epg channel id equal query") - @Test - private void listEpgProgramWithExactKsqlQuery2() { - ksqlQuery = "epg_channel_id = '" + program.getEpgChannelId() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - - List epgPrograms = executor.executeSync(listAssetBuilder).results.getObjects(); - assertThat(epgPrograms.size()).isGreaterThan(1); - - assertThat(epgPrograms).extracting("epgChannelId").contains(program.getEpgChannelId()); - } - - - @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - EPG - filter by epg channel id") - @Test - private void listEpgProgramsFilteredByEpgChannel() { - ksqlQuery = "(or name = '" + program.getName() + "' name = '" + program2.getName() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, program2.getEpgChannelId().toString(), "0", null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - - Response> assetListResponse = executor.executeSync(listAssetBuilder); - assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program2.getId()); - } - @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - order by VIEWS") + @Description("Asset/action/list - VOD - order by VIEWS") @Test private void OrderVodAssetsByViews() { @@ -268,7 +213,7 @@ private void OrderVodAssetsByViews() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - order by NAME (DESC/ASC") + @Description("Asset/action/list - VOD - order by NAME (DESC/ASC") @Test private void OrderVodAssetsByName() { @@ -299,7 +244,7 @@ private void OrderVodAssetsByName() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - order by LIKES") + @Description("Asset/action/list - VOD - order by LIKES") @Test private void orderVodAssetsByLikes() { @@ -319,6 +264,114 @@ private void orderVodAssetsByLikes() { assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - order by (num of) VOTES and RATING") + @Test + private void orderVodAssetsByVotesAndRating() { + + AssetUtils.addVotesToAsset(asset2.getId(), 2, AssetType.MEDIA, 1); + AssetUtils.addVotesToAsset(asset3.getId(), 1, AssetType.MEDIA, 5); + + // Order by number of votes (highest to lowest) + + ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response> assetListResponse = executor.executeSync(listAssetBuilder); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset3.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + + // Order by Ratings (highest to lowest) + + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetListResponse = executor.executeSync(listAssetBuilder); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - order by CATALOG START DATE") + @Test + private void orderVodAssetsByCatalogStartDate() { + + AssetUtils.addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); + AssetUtils.addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); + + + ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); + + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + } + + + // EPG + // ****************************************** + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - EPG - name equal query") + @Test + private void listEpgProgramWithExactKsqlQuery() { + ksqlQuery = "name = '" + program.getName() + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - EPG - epg channel id equal query") + @Test + private void listEpgProgramWithExactKsqlQuery2() { + ksqlQuery = "epg_channel_id = '" + program.getEpgChannelId() + "'"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + List epgPrograms = executor.executeSync(listAssetBuilder).results.getObjects(); + assertThat(epgPrograms.size()).isGreaterThan(1); + + assertThat(epgPrograms).extracting("epgChannelId").contains(program.getEpgChannelId()); + } + + + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - EPG - filter by epg channel id") + @Test + private void listEpgProgramsFilteredByEpgChannel() { + ksqlQuery = "(or name = '" + program.getName() + "' name = '" + program2.getName() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, program2.getEpgChannelId().toString(), "0", null, null, + null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program2.getId()); + } + } From 3c91b789f4858e086c405cd394f4714a960574d5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Tue, 5 Jun 2018 12:24:43 +0300 Subject: [PATCH 318/605] transactionHistory amend 2 --- .../TransactionHistoryListTests.java | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index 9335b229d..a413bfae5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -82,6 +82,7 @@ public void transactionHistortTestSetup(){ //Purchase collection with master user transactionResponseCollection = PurchaseUtils.purchaseCollection(masterUserKs, Integer.parseInt(getSharedCommonCollection().getId())); + //Show PPV entitlements entitlementFilter.setProductTypeEqual(TransactionType.PPV); ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(entitlementFilter).setKs(userKs); @@ -98,10 +99,8 @@ public void transactionHistortTestSetup(){ ppvEntitlementList.add((PpvEntitlement) entitlement); } } - //TODO: change ppvModuleId to getSharedWebMediaFile().getPpvModules().getObjects().get(0).getValue() - right now it is null - String ppvModuleId = PurchaseUtils.purchasePpvDetailsMap.get(PPV_MODULE_ID_KEY); //Verify that PPV is correct - assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(ppvModuleId); + assertThat(ppvEntitlementList.get(0).getProductId()).isEqualTo(PurchaseUtils.purchasePpvDetailsMap.get(PPV_MODULE_ID_KEY)); //Verify that asset file is correct assertThat(ppvEntitlementList.get(0).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); @@ -190,66 +189,45 @@ public void testTransactionHistoryPerUserWithMasterKs() { private void assertMethod(String methodName, List billingTransactionList) { Logger.getLogger(TransactionHistoryListTests.class).debug(methodName); - String price, currency; for(int i = 0; i < billingTransactionList.size(); i++) { - assertThat(listBillingTransactionResponse.results.getObjects().get(i).getClass()).isEqualTo(BillingTransaction.class); + assertThat(billingTransactionList.get(i).getClass()).isEqualTo(BillingTransaction.class); + assertThat(billingTransactionList.get(i).getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransactionList.get(i).getIsRecurring()).isEqualTo(false); + assertThat(billingTransactionList.get(i).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); switch (billingTransactionList.get(i).getItemType()){ case SUBSCRIPTION: BillingTransaction billingTransactionSubscription = billingTransactionList.get(i); - //Get subscription details (Price, Currency) - price = PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_AMOUNT); - currency = PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_CURRENCY); assertThat(billingTransactionSubscription.getRecieptCode()).isEqualTo(transactionResponseSubscription.results.getId()); - assertThat(billingTransactionSubscription.getPurchasedItemName().length()).isGreaterThan(1); + //TODO: Shared Subscription name not equals to transactionHistory name written (Title written). (deprecate this assertion or amend with another way) +// assertThat(billingTransactionSubscription.getPurchasedItemName()).isEqualTo(getSharedCommonSubscription().getName()); assertThat(billingTransactionSubscription.getPurchasedItemCode()).isEqualTo(getSharedCommonSubscription().getId().toString()); assertThat(billingTransactionSubscription.getItemType()).isEqualTo(BillingItemsType.SUBSCRIPTION); - assertThat(billingTransactionSubscription.getBillingAction()).isEqualTo(BillingAction.PURCHASE); - assertThat(billingTransactionSubscription.getPrice().getAmount().toString()).isEqualTo(price); - assertThat(billingTransactionSubscription.getPrice().getCurrency().toString()).isEqualTo(currency); - assertThat(billingTransactionSubscription.getIsRecurring()).isEqualTo(false); - assertThat(billingTransactionSubscription.getBillingProviderRef().toString().length()).isGreaterThan(1); - assertThat(billingTransactionSubscription.getPurchaseId().toString().length()).isGreaterThan(1); - assertThat(billingTransactionSubscription.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionSubscription.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_AMOUNT)); + assertThat(billingTransactionSubscription.getPrice().getCurrency().toString()).isEqualTo(PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_CURRENCY)); assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(billingTransactionSubscription.getActionDate()); assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(transactionResponseSubscription.results.getCreatedAt().longValue()); break; case PPV: BillingTransaction billingTransactionPpv = billingTransactionList.get(i); - //Get PPV details (Price, Currency) - price = PurchaseUtils.purchasePpvDetailsMap.get(PRICE_AMOUNT); - currency = PurchaseUtils.purchasePpvDetailsMap.get(PRICE_CURRENCY); assertThat(billingTransactionPpv.getRecieptCode()).isEqualTo(transactionResponsePpv.results.getId()); - assertThat(billingTransactionPpv.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionPpv.getPurchasedItemName()).isEqualTo(getSharedMediaAsset().getName()); assertThat(billingTransactionPpv.getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); assertThat(billingTransactionPpv.getItemType()).isEqualTo(BillingItemsType.PPV); - assertThat(billingTransactionPpv.getBillingAction()).isEqualTo(BillingAction.PURCHASE); - assertThat(billingTransactionPpv.getPrice().getAmount().toString()).isEqualTo(price); - assertThat(billingTransactionPpv.getPrice().getCurrency().toString()).isEqualTo(currency); - assertThat(billingTransactionPpv.getIsRecurring()).isEqualTo(false); - assertThat(billingTransactionPpv.getBillingProviderRef().toString().length()).isGreaterThan(1); - assertThat(billingTransactionPpv.getPurchaseId().toString().length()).isGreaterThan(1); - assertThat(billingTransactionPpv.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionPpv.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchasePpvDetailsMap.get(PRICE_AMOUNT)); + assertThat(billingTransactionPpv.getPrice().getCurrency().toString()).isEqualTo(PurchaseUtils.purchasePpvDetailsMap.get(PRICE_CURRENCY)); assertThat(billingTransactionPpv.getStartDate()).isEqualTo(billingTransactionPpv.getActionDate()); assertThat(billingTransactionPpv.getStartDate()).isEqualTo(transactionResponsePpv.results.getCreatedAt().longValue()); break; case COLLECTION: BillingTransaction billingTransactionCollection = billingTransactionList.get(i); - //Get collection details (Price, Currency) - price = PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_AMOUNT); - currency = PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_CURRENCY); assertThat(billingTransactionCollection.getRecieptCode()).isEqualTo(transactionResponseCollection.results.getId()); - assertThat(billingTransactionCollection.getPurchasedItemName().length()).isGreaterThan(1); + assertThat(billingTransactionCollection.getPurchasedItemName()).isEqualTo(getSharedCommonCollection().getName()); assertThat(billingTransactionCollection.getPurchasedItemCode()).isEqualTo(getSharedCommonCollection().getId().toString()); assertThat(billingTransactionCollection.getItemType()).isEqualTo(BillingItemsType.COLLECTION); - assertThat(billingTransactionCollection.getBillingAction()).isEqualTo(BillingAction.PURCHASE); - assertThat(billingTransactionCollection.getPrice().getAmount().toString()).isEqualTo(price); - assertThat(billingTransactionCollection.getPrice().getCurrency().toString()).isEqualTo(currency); - assertThat(billingTransactionCollection.getIsRecurring()).isEqualTo(false); - assertThat(billingTransactionCollection.getBillingProviderRef().toString().length()).isGreaterThan(1); - assertThat(billingTransactionCollection.getPurchaseId().toString().length()).isGreaterThan(1); - assertThat(billingTransactionCollection.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + assertThat(billingTransactionCollection.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_AMOUNT)); + assertThat(billingTransactionCollection.getPrice().getCurrency().toString()).isEqualTo(PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_CURRENCY)); assertThat(billingTransactionCollection.getActionDate()).isEqualTo(transactionResponseCollection.results.getCreatedAt().longValue()); break; From b3124a1481980d1eb0c971297dd1abf428b21e37 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 5 Jun 2018 17:04:23 +0300 Subject: [PATCH 319/605] Added test public void productPriceWithPassedPpvTest() --- .../ProductPriceListTests.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 163ee71f6..4d63e23af 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -9,6 +9,7 @@ import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; @@ -632,6 +633,48 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { executor.executeSync(deleteHouseholdBuilder); } + @Severity(SeverityLevel.NORMAL) + @Description("/productPrice/action/list - with passed PPV") + @Test() + public void productPriceWithPassedPpvTest() { + // TODO: update to use dynamic data + double nonPassedPpvPrice = 4.99; + String ppvMobileModule = getSharedCommonPpv().getName() + ";;01/01/2017 00:00:00;Camilo_4_99_EUR_PPV;;"; + MediaAsset mediaAssetWith2Ppv1Expired = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); + // should be 1 file with non passed PPV price only + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(nonPassedPpvPrice); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo( + mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); + + ppvMobileModule = getSharedCommonPpv().getName() + ";;01/01/2017 00:00:00"; + mediaAssetWith2Ppv1Expired = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + ppFilter = new ProductPriceFilter(); + ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); + productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); + // should be 1 file and free + assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FREE); + assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo( + mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); + } + @AfterClass public void afterClass() { //delete household for cleanup From 8c63090b88cb1ebebaca1b2970d2ca348cc324cf Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 6 Jun 2018 05:43:03 +0300 Subject: [PATCH 320/605] removed useless comments --- .../productPriceTests/ProductPriceListTests.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 4d63e23af..500b67317 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -42,7 +42,6 @@ public class ProductPriceListTests extends BaseTest { @BeforeClass public void beforeClass() { - entitlementPpvsFilter = new EntitlementFilter(); entitlementPpvsFilter.setOrderBy(EntitlementOrderBy.PURCHASE_DATE_ASC.getValue()); entitlementPpvsFilter.setProductTypeEqual(TransactionType.PPV); @@ -59,19 +58,10 @@ public void beforeClass() { transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); transactionHistoryFilter.setStartDateGreaterThanOrEqual(0); - /*Ppv ppv = IngestUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), - Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, - getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ - - /*Response> ingestedProgrammes = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), - Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); - System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ - int numberOfUsers = 2; int numberOfDevices = 1; household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - } @Severity(SeverityLevel.NORMAL) From f1c7e9f0f00e68157416adfba3bd31beadc04d24 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 6 Jun 2018 09:57:40 +0300 Subject: [PATCH 321/605] Added overloaded method to BaseUtils - getTimeInDate --- .../com/kaltura/client/test/utils/BaseUtils.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index e63d54bdb..4c0c4ea48 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -7,6 +7,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import javax.annotation.Nullable; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -35,9 +36,12 @@ public static String getOffsetDateInFormat(int offsetDay, String pattern) { return dateFormat.format(cal.getTime()); } - // Get Date time according to off set parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) - public static String getTimeInDate(int offSetInMinutes) { + // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) + public static String getTimeInDate(int offSetInMinutes, String timeZone) { + TimeZone theTimeZone; + theTimeZone = TimeZone.getTimeZone(timeZone); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + dateFormat.setTimeZone(theTimeZone); Date dNow = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(dNow); @@ -47,6 +51,12 @@ public static String getTimeInDate(int offSetInMinutes) { return dateFormat.format(dNow); } + // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) + public static String getTimeInDate(int offSetInMinutes) { + return getTimeInDate(offSetInMinutes,"israel"); + } + + // Get epoch time in seconds according to off set parameter provided (in minutes) public static long getTimeInEpoch(int offSetInMinutes) { //DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); @@ -143,7 +153,7 @@ public static String getFileContent(String filePath) { BufferedReader buf = new BufferedReader(new InputStreamReader(is)); String line = buf.readLine(); - while(line != null){ + while (line != null) { sb.append(line).append("\n"); line = buf.readLine(); } From 0cc766026c9069424657d3827f5519a0cfc7be47 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 6 Jun 2018 10:02:30 +0300 Subject: [PATCH 322/605] Continue updating class - "SearchAssetFilterTests" --- .../SearchAssetFilterTests.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 635675f21..1b14db5f1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -52,9 +52,8 @@ private void Asset_list_before_class() { list.add(tagValue); map.put(tagName, list); - asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInEpoch(-10))); - asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInEpoch(-100))); - + asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInDate(-100))); + asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInDate(-10))); program = IngestUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestUtils.ingestEPG(epgChannelName2, 1).get(0); } @@ -304,13 +303,8 @@ private void orderVodAssetsByVotesAndRating() { @Test private void orderVodAssetsByCatalogStartDate() { - AssetUtils.addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); - AssetUtils.addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); - - ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); - listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); @@ -319,8 +313,29 @@ private void orderVodAssetsByCatalogStartDate() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_ASC.getValue()); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); + } + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - with PersistedFilter (search query will return in assetHistory/action/list") + @Test + private void listAssetsWithPersistedFilter() { + + ksqlQuery = "name = ' This is my ksql query with PersistedFilter '"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, null); + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + } + + // EPG // ****************************************** @@ -371,7 +386,6 @@ private void listEpgProgramsFilteredByEpgChannel() { assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program2.getId()); } - } From 926cbdb65de95bf636394153158840ae9e59d963 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 6 Jun 2018 11:26:29 +0300 Subject: [PATCH 323/605] Updated purchasePpv method --- .../householdTests/HouseholdSuspendTests.java | 6 +++--- .../productPriceTests/ProductPriceListTests.java | 6 +++--- .../TransactionHistoryListTests.java | 2 +- .../kaltura/client/test/utils/PurchaseUtils.java | 13 +++++-------- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index e75efdf03..36bd177ef 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -174,7 +174,7 @@ private void suspend_with_purchase_subscription_role() { // purchase ppv in order to verify suspend is specific to role Integer mediaFileId = asset.getMediaFiles().get(0).getId(); transactionResponse = PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), - Optional.of(mediaFileId), null); + Optional.of(mediaFileId), Optional.empty()); assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); @@ -322,7 +322,7 @@ private void suspend_with_purchase_ppv_role() { // purchase ppv Integer mediaFileId = asset.getMediaFiles().get(0).getId(); Response transactionResponse = PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), - Optional.of(mediaFileId), null); + Optional.of(mediaFileId), Optional.empty()); assertThat(transactionResponse.results).isNull(); assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); @@ -364,7 +364,7 @@ private void suspend_with_playback_ppv_role() { // purchase ppv Integer mediaFileId = asset.getMediaFiles().get(0).getId(); - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), Optional.empty()); // suspend with playback_ppv role SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 500b67317..ed09d9da1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -129,7 +129,7 @@ public void ppvTest() { assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(webMediaFileId); - PurchaseUtils.purchasePpv(classMasterUserKs, Optional.empty(), Optional.of(webMediaFileId), null); + PurchaseUtils.purchasePpv(classMasterUserKs, Optional.empty(), Optional.of(webMediaFileId), Optional.empty()); ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null); entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); @@ -536,7 +536,7 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); - PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), IngestConstants.CURRENCY_ILS); + PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(IngestConstants.CURRENCY_ILS)); // to check purchase ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); entitlementResponse = executor.executeSync(entitlementListAfterPurchase); @@ -594,7 +594,7 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); - PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), IngestConstants.CURRENCY_ILS); + PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(IngestConstants.CURRENCY_ILS)); // to check purchase ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); entitlementResponse = executor.executeSync(entitlementListAfterPurchase); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index 9335b229d..a464be951 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -76,7 +76,7 @@ public void transactionHistortTestSetup(){ assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(0); //Purchase asset with non-master user - transactionResponsePpv = PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(getSharedWebMediaFile().getId()), null); + transactionResponsePpv = PurchaseUtils.purchasePpv(userKs, Optional.of(getSharedMediaAsset().getId().intValue()), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); //Purchase subscription with non-master user transactionResponseSubscription = PurchaseUtils.purchaseSubscription(userKs, Integer.parseInt(getSharedCommonSubscription().getId()), Optional.empty()); //Purchase collection with master user diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index ceaa0fb48..71d719a12 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -26,7 +26,7 @@ public class PurchaseUtils { private static Response> productPriceResponse; private static Response assetResponse; - public static Response purchasePpv(String ks, Optional mediaId, Optional fileId, @Nullable String purchaseCurrency) { + public static Response purchasePpv(String ks, Optional mediaId, Optional fileId, Optional purchaseCurrency) { purchasePpvDetailsMap = new HashMap<>(); int internalFileId; @@ -43,9 +43,9 @@ public static Response purchasePpv(String ks, Optional med filter.setFileIdIn(String.valueOf(internalFileId)); filter.setIsLowest(false); - ListProductPriceBuilder listProductPriceBuilder = purchaseCurrency == null - ? ProductPriceService.list(filter).setKs(ks) - : ProductPriceService.list(filter).setKs(ks).setCurrency(purchaseCurrency); + ListProductPriceBuilder listProductPriceBuilder = purchaseCurrency.isPresent() + ? ProductPriceService.list(filter).setKs(ks).setCurrency(purchaseCurrency.get()) + : ProductPriceService.list(filter).setKs(ks); productPriceResponse = executor.executeSync(listProductPriceBuilder); double price = productPriceResponse.results.getObjects().get(0).getPrice().getAmount(); @@ -54,10 +54,7 @@ public static Response purchasePpv(String ks, Optional med Purchase purchase = new Purchase(); purchase.setProductId(Integer.valueOf(ppvModuleId)); purchase.setContentId(internalFileId); - String currency = purchaseCurrency; - if (purchaseCurrency == null || purchaseCurrency.isEmpty()) { - currency = productPriceResponse.results.getObjects().get(0).getPrice().getCurrency(); - } + String currency = purchaseCurrency.orElse(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); purchase.setCurrency(currency); purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.PPV).get()); From e52e0839311477efc29585a0158e05d64b04fe5a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 6 Jun 2018 11:27:26 +0300 Subject: [PATCH 324/605] update method get5MinRenewableSubscription() to get data from DB before ingest --- .../kaltura/client/test/tests/BaseTest.java | 20 ++--- .../test/utils/dbUtils/DBConstants.java | 16 ++++ .../test/utils/dbUtils/IngestFixtureData.java | 76 ++++++++++++++++--- 3 files changed, 92 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 38d78469f..e69af69c9 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -332,16 +332,18 @@ public static MediaFile getSharedMobileMediaFile() { } public static Subscription get5MinRenewableSubscription() { - // TODO: add logic checking data from DB if (fiveMinRenewableSubscription == null) { - PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), - Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(IngestConstants.CURRENCY_EUR), Optional.of(""), - Optional.of(true), Optional.of(3)); - fiveMinRenewableSubscription = IngestUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + fiveMinRenewableSubscription = IngestFixtureData.loadShared5MinutesRenewableSubscription(); + if (fiveMinRenewableSubscription == null) { + PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), + Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(IngestConstants.CURRENCY_EUR), Optional.of(""), + Optional.of(true), Optional.of(3)); + fiveMinRenewableSubscription = IngestUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + } } return fiveMinRenewableSubscription; } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 1ae608056..38cd91490 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -8,12 +8,15 @@ public class DBConstants { static final String CP_TOKEN = "cp_token"; static final String FULL_LIFE_CYCLE_MINUTES = "full_life_cycle_min"; static final String ID = "id"; + static final String INT_DISCOUNT_ID = "internal_discount_id"; static final String IS_ACTIVATION_NEEDED = "is_activation_needed"; static final String IS_RENEWED = "is_renew"; static final String MAX_VIEWS_COUNT = "max_views_number"; static final String NAME = "name"; static final String NUMBER_OF_REC_PERIODS = "num_of_rec_periods"; static final String PASSWORD = "password"; + static final String PRICE_PLAN_ID = "usage_module_code"; + static final String PRICING_ID = "pricing_id"; static final String ROW_COUNT = "row_count"; static final String SERV_ID = "serv_id"; static final String SUBSCRIPTION_ONLY = "subscription_only"; @@ -73,11 +76,24 @@ public class DBConstants { "where [status]=1 and is_active=1\n" + "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; + static final String PRICE_PLAN_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + + "where [status]=1 and is_active=1\n" + + "and view_life_cycle_min = 5\n" + + "and full_life_cycle_min = 5\n" + + "and is_renew=1\n" + + "and ((num_of_rec_periods > 2) or (num_of_rec_periods = 0))\n" + // TODO: do we really want it "num_of_rec_periods > 2"? + "and group_id=%d"; + static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d and usage_module_code=%d and discount_module_code=%d\n" + "order by create_date"; + static final String SUBSCRIPTION_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + + "where [status]=1 and is_active=1 and [type]=0 and is_recurring=1\n" + + "and group_id=%d and usage_module_code=%d\n" + + "order by create_date"; + static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) SUBSCRIPTION_ID as " + SUB_ID + ", SERVICE_ID as " + SERV_ID + "\n" + "FROM [Pricing].[dbo].[subscriptions] s\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 723c2d99f..dd58a9b9c 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -82,16 +82,41 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl return pricePlan; } - pricePlan = new PricePlan(); - pricePlan.setId(jsonArray.getJSONObject(0).getLong(ID)); - pricePlan.setName(jsonArray.getJSONObject(0).getString(NAME)); - pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt(VIEW_LIFE_CYCLE_MINUTES)); - pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt(FULL_LIFE_CYCLE_MINUTES)); - pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt(MAX_VIEWS_COUNT)); - pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get(ID).toString())); - pricePlan.setPriceDetailsId(priceCode.getId().longValue()); - pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt(IS_RENEWED)); - pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt(NUMBER_OF_REC_PERIODS)); + pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); + } + return pricePlan; + } + + private static PricePlan loadFirstPricePlanFromJsonArray(JSONArray jsonArray) { + PricePlan pricePlan = new PricePlan(); + pricePlan.setId(jsonArray.getJSONObject(0).getLong(ID)); + pricePlan.setName(jsonArray.getJSONObject(0).getString(NAME)); + pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt(VIEW_LIFE_CYCLE_MINUTES)); + pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt(FULL_LIFE_CYCLE_MINUTES)); + pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt(MAX_VIEWS_COUNT)); + pricePlan.setDiscountId(jsonArray.getJSONObject(0).getLong(INT_DISCOUNT_ID)); + pricePlan.setPriceDetailsId(jsonArray.getJSONObject(0).getLong(PRICING_ID)); + pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt(IS_RENEWED)); + pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt(NUMBER_OF_REC_PERIODS)); + + return pricePlan; + } + + public static PricePlan load5MinRenewablePricePlan() { + Logger.getLogger(IngestFixtureData.class).debug("load5MinRenewablePricePlan()"); + + PricePlan pricePlan = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_5_MIN_RENEW_SELECT, partnerId), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return pricePlan; + } + + pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); @@ -113,7 +138,7 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { subscription = new Subscription(); subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); - subscription.setPricePlanIds(String.valueOf(pricePlan.getId())); + subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); subscription.setIsRenewable(false); subscription.setDependencyType(SubscriptionDependencyType.BASE); // TODO: add more data in case it needed @@ -252,4 +277,33 @@ public static Ppv loadSharedCommonPpv(PricePlan pricePlan) { } return ppv; } + + public static Subscription loadShared5MinutesRenewableSubscription() { + Logger.getLogger(IngestFixtureData.class).debug("loadShared5MinutesRenewableSubscription()"); + PricePlan pricePlan = load5MinRenewablePricePlan(); + if (pricePlan == null) { + return null; + } + Subscription subscription = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_5_MIN_RENEW_SELECT, partnerId, + pricePlan.getId()), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return subscription; + } + + subscription = new Subscription(); + subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); + subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); + subscription.setIsRenewable(false); + subscription.setDependencyType(SubscriptionDependencyType.BASE); + // TODO: add more data in case it needed + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("subscription data can't be null"); + } + return subscription; + } } From 03af447ee9dd29aaa905a434d63fa686012fbb89 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 6 Jun 2018 12:02:56 +0300 Subject: [PATCH 325/605] trimmed strings result of ingest items processing --- .../java/com/kaltura/client/test/utils/IngestUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 832ae4df0..16605be39 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -432,7 +432,7 @@ public static Subscription ingestMPP(Optional action, Optional m Logger.getLogger(IngestUtils.class).debug(resp.asString()); //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); + String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); Subscription subscription = new Subscription(); subscription.setId(id); @@ -694,7 +694,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O System.out.println(resp.asString()); System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - String id = resp.asString().split(" = ")[1].replaceAll("\\.", ""); + String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); Ppv ppv = new Ppv(); ppv.setId(id); @@ -834,7 +834,7 @@ public static MediaAsset ingestVOD(Optional action, Optional cog MediaAsset mediaAsset = new MediaAsset(); mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id)); + mediaAsset.setId(Long.valueOf(id.trim())); mediaAsset.setDescription(descriptionValue); //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); From 3abf7861fc571748b169e3eb580ad66090b3e89e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 6 Jun 2018 13:02:18 +0300 Subject: [PATCH 326/605] finsih household suspend tests --- .../householdTests/HouseholdResumeTests.java | 12 +- .../householdTests/HouseholdSuspendTests.java | 127 +++++++++--------- .../householdTests/HouseholdUpdateTests.java | 19 +++ .../client/test/utils/dbUtils/DBUtils.java | 14 +- src/test/resources/WORK_PLAN.md | 2 +- 5 files changed, 97 insertions(+), 77 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java index 0fdbe7e15..9d350e3f6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.householdTests; import com.kaltura.client.enums.HouseholdState; -import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.UserRoleService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; @@ -18,8 +17,7 @@ import java.util.Optional; -import static com.kaltura.client.services.HouseholdService.delete; -import static com.kaltura.client.services.HouseholdService.get; +import static com.kaltura.client.services.HouseholdService.*; import static org.assertj.core.api.Assertions.assertThat; public class HouseholdResumeTests extends BaseTest { @@ -50,7 +48,7 @@ private void household_resumeTests_beforeClass() { @Test private void resume_suspended_household() { // suspend household - executor.executeSync(HouseholdService.suspend() + executor.executeSync(suspend() .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId()))); @@ -59,7 +57,7 @@ private void resume_suspended_household() { assertThat(householdResponse.results.getState()).isEqualTo(HouseholdState.SUSPENDED); // resume household - Response booleanResponse = executor.executeSync(HouseholdService.resume() + Response booleanResponse = executor.executeSync(resume() .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId()))); assertThat(booleanResponse.results.booleanValue()).isTrue(); @@ -84,7 +82,7 @@ private void resume_suspended_with_purchase_subscription_role_household() { role = userRoleResponse.results; // suspend household - executor.executeSync(HouseholdService.suspend(Math.toIntExact(role.getId())) + executor.executeSync(suspend(Math.toIntExact(role.getId())) .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId()))); @@ -93,7 +91,7 @@ private void resume_suspended_with_purchase_subscription_role_household() { assertThat(householdResponse.results.getState()).isEqualTo(HouseholdState.SUSPENDED); // resume household - Response booleanResponse = executor.executeSync(HouseholdService.resume() + Response booleanResponse = executor.executeSync(resume() .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId()))); assertThat(booleanResponse.results.booleanValue()).isTrue(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index e75efdf03..5dba25ab9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.services.*; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -37,7 +38,7 @@ private enum Permissions { PURCHASE_SUBSCRIPTION, PURCHASE_PPV, RENEW_SUBSCRIPTION, - PURCHASE_SERVICE, // purchase premium services + PURCHASE_SERVICE, LOGIN, CANCEL_SUBSCRIPTION, DELETE_ALL_APP_TOKENS @@ -343,7 +344,7 @@ private void suspend_with_purchase_ppv_role() { @Severity(SeverityLevel.NORMAL) @Issue("BEO-5166") @Description("household/action/suspend - with playback_ppv role") - @Test(enabled = true) + @Test private void suspend_with_playback_ppv_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); @@ -400,9 +401,8 @@ private void suspend_with_playback_ppv_role() { } @Severity(SeverityLevel.NORMAL) - @Issue("BEO-5173") @Description("household/action/suspend - with renew_subscription role") - @Test(enabled = true, groups = "slow") + @Test(groups = "slow") private void suspend_with_renew_subscription_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); @@ -426,18 +426,12 @@ private void suspend_with_renew_subscription_role() { int fiveMinRenewSubscriptionId = Integer.parseInt(fiveMinRenewSubscription.getId().trim()); PurchaseUtils.purchaseSubscription(masterUserKs, fiveMinRenewSubscriptionId, Optional.empty()); - //*** - System.out.println("here!!!"); - EntitlementFilter filter1 = new EntitlementFilter(); - filter1.setProductTypeEqual(TransactionType.SUBSCRIPTION); - executor.executeSync(EntitlementService.list(filter1).setKs(masterUserKs)); - - // set productPrice filter - ProductPriceFilter filter = new ProductPriceFilter(); - filter.setSubscriptionIdIn(fiveMinRenewSubscription.getId()); - //get productprice list - before renew - Response> productPriceListResponse = executor.executeSync(ProductPriceService.list(filter).setKs(masterUserKs)); + ProductPriceFilter subscriptionFilter = new ProductPriceFilter(); + subscriptionFilter.setSubscriptionIdIn(fiveMinRenewSubscription.getId()); + Response> productPriceListResponse = executor.executeSync(ProductPriceService.list(subscriptionFilter) + .setKs(masterUserKs)); + assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceListResponse.results.getObjects().get(0).getProductId()).isEqualTo(fiveMinRenewSubscription.getId().trim()); assertThat(productPriceListResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); @@ -449,21 +443,42 @@ private void suspend_with_renew_subscription_role() { Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); assertThat(booleanResponse.results).isTrue(); - // sleep for 5 min - try { Thread.sleep(300000); } catch (InterruptedException e) { e.printStackTrace(); } + // sleep for 6 min + try { + Thread.sleep(360000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + // get productprice list for asset in subscription - after renew + Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); + ProductPriceFilter assetFilter = new ProductPriceFilter(); + assetFilter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); - //get productprice list - after renew - productPriceListResponse = executor.executeSync(ProductPriceService.list(filter).setKs(masterUserKs)); + productPriceListResponse = executor.executeSync(ProductPriceService.list(assetFilter) + .setKs(masterUserKs)); assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListResponse.results.getObjects().get(0).getProductId()).isEqualTo(fiveMinRenewSubscription.getId().trim()); - assertThat(productPriceListResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.USER_SUSPENDED); + assertThat(productPriceListResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - //transactionhistory/list - after sleep - Response> billingTransactionListResponse = executor.executeSync(TransactionHistoryService.list().setKs(masterUserKs)); + // transactionHistory list - verify media file related to subscription billing status = purchase + Response> billingTransactionListResponse = executor.executeSync(TransactionHistoryService.list() + .setKs(masterUserKs)); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(billingTransactionListResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(fiveMinRenewSubscription.getId().trim()); assertThat(billingTransactionListResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); + // entitlement list - verify subscription isSuspend = true + EntitlementFilter entitlementFilter = new EntitlementFilter(); + entitlementFilter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + entitlementFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + entitlementFilter.setIsExpiredEqual(false); + + Response> entitlementListResponse = executor.executeSync(EntitlementService.list(entitlementFilter) + .setKs(masterUserKs)); + assertThat(entitlementListResponse.results.getTotalCount()).isEqualTo(1); + SubscriptionEntitlement subscriptionEntitlement = (SubscriptionEntitlement) entitlementListResponse.results.getObjects().get(0); + assertThat(subscriptionEntitlement.getProductId()).isEqualTo(fiveMinRenewSubscription.getId().trim()); + assertThat(subscriptionEntitlement.getIsSuspended()).isTrue(); + // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); @@ -473,7 +488,7 @@ private void suspend_with_renew_subscription_role() { @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with purchase_service role") - @Test(enabled = false) + @Test(enabled = true) private void suspend_with_purchase_service_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); @@ -492,42 +507,30 @@ private void suspend_with_purchase_service_role() { Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); role = userRoleResponse.results; - // TODO: 6/4/2018 finsih test - -// // purchase ppv -// Integer mediaFileId = asset.getMediaFiles().get(0).getId(); -// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), null); - -// // suspend with playback_ppv role -// SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) -// .setKs(getOperatorKs()) -// .setUserId(Integer.valueOf(masterUser.getUserId())); -// Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); -// assertThat(booleanResponse.results).isTrue(); -// -// // get platbackContext -// PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); -// playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); -// playbackContextOptions.setStreamerType("applehttp"); -// playbackContextOptions.setMediaProtocol("http"); -// -// GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(asset.getId()), AssetType.MEDIA, playbackContextOptions) -// .setKs(masterUserKs); -// Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); -// -// assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); -// assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); -// assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); -// -// // purchase subscription in order to verify suspend is specific to role -// Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId())); -// assertThat(transactionResponse.error).isNull(); -// assertThat(transactionResponse.results.getState()).isEqualTo("OK"); -// -// // cleanup - delete role -// executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); -// -// // cleanup - delete household -// executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + // suspend with purchase_service role + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId())); + Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); + + // purchase subscription with premium service + int subscriptionId = DBUtils.getSubscriptionWithPremiumService(); + Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, subscriptionId, Optional.empty()); + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); + + // purchase ppv in order to verify suspend is specific to role + Integer mediaFileId = asset.getMediaFiles().get(0).getId(); + transactionResponse = PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), + Optional.of(mediaFileId), null); + assertThat(transactionResponse.error).isNull(); + assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // cleanup - delete role + executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java index 1611d0a35..4500bf305 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java @@ -99,6 +99,25 @@ private void update_with_regular_userKs() { "frequencyNextDeviceAction", "frequencyNextUserAction", "restriction"); } + @Severity(SeverityLevel.MINOR) + @Description("household/action/update - with empty household object") + @Test(enabled = false) + private void update_with_empty_household() { + // update household + String householdUpdatedDetails = "updated details with empty household"; + Household updatedHousehold = new Household(); + + HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + + updatedHousehold = executor.executeSync(update(updatedHousehold) + .setKs(userKs)) + .results; + + assertThat(updatedHousehold).isEqualToIgnoringGivenFields(household, "frequencyNextDeviceAction", + "frequencyNextUserAction", "restriction"); + } + @AfterClass private void household_updateTests_afterClass() { // cleanup - delete household diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 784b18cd2..4bdcf9292 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -45,6 +45,7 @@ public static boolean isActivationOfUsersNeeded() { public static String getUserData(String userRole) { Logger.getLogger(DBUtils.class).debug("getUserData(): userRole = " + userRole); + String sqlQuery = USER_BY_ROLE_SELECT; if (isActivationOfUsersNeeded()) { sqlQuery += AND_ACTIVE_STATUS; @@ -127,24 +128,23 @@ public static int getUnActiveAsset() { return assetId; } - public static String getSubscriptionWithPremiumService() { - Logger.getLogger(DBUtils.class).debug("getSubscriptionWithPremiumService()"); - String result = null; + public static int getSubscriptionWithPremiumService() { + int subscriptionId = 0; + try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, partnerId), false); if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; + return subscriptionId; } - result = jsonArray.getJSONObject(0).getInt(SUB_ID) + ":" + - jsonArray.getJSONObject(0).getInt(SERV_ID); + subscriptionId = jsonArray.getJSONObject(0).getInt(SUB_ID); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(DBUtils.class).error("data about premium services can't be null"); } - return result; + return subscriptionId; } diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 5dd6e1a56..821e13900 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -44,7 +44,7 @@ Migrate features tests from ReadyAPI | favorite | | | followTvSeries | | | homeNetwork | | -| household | Alon - in progress, actions: add - done, delete - done, get - done, suspend - in progress, purge, resume, resetFrequency, update | +| household | Alon - in progress, actions: add - done, delete - done, get - done, suspend - done, resume - done, resetFrequency, update, purge | | householdDevice | | | householdLimitations | | | householdPaymentGateway | | From c0504ce40a85575fd39a91a30152d1123c02d649 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 6 Jun 2018 14:10:15 +0300 Subject: [PATCH 327/605] Created enum with currencies --- .../kaltura/client/test/IngestConstants.java | 6 --- .../kaltura/client/test/tests/BaseTest.java | 12 ++--- .../client/test/tests/enums/Currency.java | 41 +++++++++++++++++ .../ProductPriceListTests.java | 46 +++++++++---------- .../client/test/utils/IngestUtils.java | 6 +-- 5 files changed, 73 insertions(+), 38 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/Currency.java diff --git a/src/test/java/com/kaltura/client/test/IngestConstants.java b/src/test/java/com/kaltura/client/test/IngestConstants.java index 01ec5e743..221b82a0f 100644 --- a/src/test/java/com/kaltura/client/test/IngestConstants.java +++ b/src/test/java/com/kaltura/client/test/IngestConstants.java @@ -9,12 +9,6 @@ public class IngestConstants { public static final Long MAX_RANDOM_GENERATED_VALUE_4_INGEST = 9999999999L; public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - // currency - public static final String CURRENCY_EUR = "EUR"; - public static final String CURRENCY_USD = "USD"; - public static final String CURRENCY_ILS = "ILS"; - public static final String CURRENCY_CLP = "CLP"; - // life cycles periods public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index e69af69c9..dc4b9ef88 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -4,7 +4,6 @@ import com.kaltura.client.Configuration; import com.kaltura.client.Logger; import com.kaltura.client.services.OttUserService; -import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.IngestUtils; @@ -21,6 +20,7 @@ import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; @@ -140,11 +140,11 @@ public static PricePlan getSharedCommonPricePlan() { double defaultDiscountPrice = 0.0; double defaultDiscountPercentValue = 100.0; if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), IngestConstants.CURRENCY_EUR, defaultDiscountPrice, defaultDiscountPercentValue); + sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), EUR.getValue(), defaultDiscountPrice, defaultDiscountPercentValue); if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), - Optional.of(IngestConstants.CURRENCY_EUR), Optional.of(IngestFixtureData.getDiscount(IngestConstants.CURRENCY_EUR, (int) defaultDiscountPercentValue)), + Optional.of(EUR.getValue()), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)), Optional.of(true), Optional.of(0)); } } @@ -166,7 +166,7 @@ public static Subscription getSharedCommonSubscription() { if (sharedCommonSubscription == null) { sharedCommonSubscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(IngestFixtureData.getDiscount(IngestConstants.CURRENCY_EUR, (int) defaultDiscountPercentValue)), Optional.empty(), + Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)), Optional.empty(), Optional.of(false), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -208,7 +208,7 @@ public static Ppv getSharedCommonPpv(){ sharedCommonPpv = IngestFixtureData.loadSharedCommonPpv(getSharedCommonPricePlan()); if (sharedCommonPpv == null) { sharedCommonPpv = IngestUtils.ingestPPV(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), - Optional.empty(), Optional.of(IngestFixtureData.getDiscount(IngestConstants.CURRENCY_EUR, (int) discountPercentValue)), + Optional.empty(), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) discountPercentValue)), Optional.empty(), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.of(false), Optional.of(false), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -337,7 +337,7 @@ public static Subscription get5MinRenewableSubscription() { if (fiveMinRenewableSubscription == null) { PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), - Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(IngestConstants.CURRENCY_EUR), Optional.of(""), + Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(EUR.getValue()), Optional.of(""), Optional.of(true), Optional.of(3)); fiveMinRenewableSubscription = IngestUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), diff --git a/src/test/java/com/kaltura/client/test/tests/enums/Currency.java b/src/test/java/com/kaltura/client/test/tests/enums/Currency.java new file mode 100644 index 000000000..d263c9d2e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/Currency.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum Currency implements EnumAsString { + EUR("EUR"), + ILS("ILS"), + CLP("CLP"), + USD("USD"); + + private String value; + + Currency(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static Currency get(String value) { + if(value == null) + { + return null; + } + + // goes over Currency defined values and compare the inner value with the given one: + for(Currency item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return Currency.values().length > 0 ? Currency.values()[0]: null; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index ed09d9da1..a807f81d7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; -import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.IngestUtils; @@ -24,6 +23,7 @@ import org.testng.annotations.Test; import java.util.Optional; import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.test.tests.enums.Currency.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -84,12 +84,12 @@ public void listSubscription() { public void listSubscriptionWithCurrencyTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(IngestConstants.CURRENCY_EUR).setKs(getOperatorKs())); + productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(EUR.getValue()).setKs(getOperatorKs())); // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(EUR.getValue()); } @Severity(SeverityLevel.MINOR) @@ -315,7 +315,7 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); // as default group currency is EURO - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(EUR.getValue()); PurchaseUtils.purchaseSubscription(masterKs, subWithMultiCurrencyId, Optional.empty()); // to check purchase @@ -337,7 +337,7 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); // as default group currency is EURO - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(EUR.getValue()); //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) @@ -361,7 +361,7 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); - ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setCurrency(IngestConstants.CURRENCY_USD); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setCurrency(USD.getValue()); productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); // should be 1 subscription assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); @@ -369,9 +369,9 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_USD); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(USD.getValue()); - PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(IngestConstants.CURRENCY_USD)); + PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(USD.getValue())); // to check purchase ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); entitlementResponse = executor.executeSync(entitlementListAfterPurchase); @@ -391,7 +391,7 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_USD); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(USD.getValue()); //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) @@ -415,7 +415,7 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); - ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setCurrency(IngestConstants.CURRENCY_CLP); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setCurrency(CLP.getValue()); productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs)); // should be 1 subscription assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); @@ -423,9 +423,9 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_CLP); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CLP.getValue()); - PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(IngestConstants.CURRENCY_CLP)); + PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(CLP.getValue())); // to check purchase ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); entitlementResponse = executor.executeSync(entitlementListAfterPurchase); @@ -445,7 +445,7 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_CLP); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CLP.getValue()); //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) @@ -477,7 +477,7 @@ public void productPriceSubscriptionWithPercentageDiscountAndNoSpecifiedCurrency assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(EUR.getValue()); PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.empty()); // to check purchase @@ -499,7 +499,7 @@ public void productPriceSubscriptionWithPercentageDiscountAndNoSpecifiedCurrency assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_EUR); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(EUR.getValue()); //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) @@ -528,15 +528,15 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaFileId)); ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs).setCurrency(IngestConstants.CURRENCY_ILS)); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs).setCurrency(ILS.getValue())); // should be 1 file assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(ILS.getValue()); - PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(IngestConstants.CURRENCY_ILS)); + PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(ILS.getValue())); // to check purchase ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); entitlementResponse = executor.executeSync(entitlementListAfterPurchase); @@ -557,7 +557,7 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(mediaFileId); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(ILS.getValue()); //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) @@ -586,15 +586,15 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaFileId)); ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs).setCurrency(IngestConstants.CURRENCY_ILS)); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(masterKs).setCurrency(ILS.getValue())); // should be 1 file assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(ILS.getValue()); - PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(IngestConstants.CURRENCY_ILS)); + PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(ILS.getValue())); // to check purchase ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); entitlementResponse = executor.executeSync(entitlementListAfterPurchase); @@ -615,7 +615,7 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(mediaFileId); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(IngestConstants.CURRENCY_ILS); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(ILS.getValue()); //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 16605be39..07f1a7c3a 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -5,7 +5,6 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.AssetService.*; -import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -19,6 +18,7 @@ import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.enums.Currency.EUR; import static io.restassured.path.xml.XmlPath.from; import static org.awaitility.Awaitility.await; @@ -529,7 +529,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); int maxViewsValue = maxViews.orElse(PP_DEFAULT_MAX_VIEWS_VALUE); String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT)); - String currencyValue = currency.orElse(IngestConstants.CURRENCY_EUR); + String currencyValue = currency.orElse(EUR.getValue()); int defaultPercentageOfDiscount4IngestMpp = 100; DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount4IngestMpp); String discountValue = discount.orElse(discountModule.toParams().get("code").toString()); @@ -649,7 +649,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O int defaultPercentageOfDiscount4IngestPpv = 50; String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); - String currencyValue = currency.orElse(IngestConstants.CURRENCY_EUR); + String currencyValue = currency.orElse(EUR.getValue()); String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; From 3d42bd4174c48a7b2ba3953b6daa4adeeea2cdf0 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 6 Jun 2018 14:36:07 +0300 Subject: [PATCH 328/605] removed useless class --- .../productPriceTests/ListTests.java | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java deleted file mode 100644 index 4211b5d5b..000000000 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/productPriceTests/ListTests.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.kaltura.client.test.tests.featuresTests.productPriceTests; - -import com.kaltura.client.Client; -import com.kaltura.client.test.tests.BaseTest; -import org.testng.annotations.BeforeClass; - -public class ListTests extends BaseTest { - - private Client client; - - @BeforeClass - public void beforeClass() { - - /*Ppv ppv = IngestUtils.ingestPPV(INGEST_ACTION_INSERT, true, "My ingest PPV", getProperty(FIFTY_PERCENTS_ILS_DISCOUNT_NAME), - Double.valueOf(getProperty(PRICE_CODE_AMOUNT_4_99)), CURRENCY_EUR, getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV), false, false, - getProperty(DEFAULT_PRODUCT_CODE), getProperty(WEB_FILE_TYPE), getProperty(MOBILE_FILE_TYPE));*/ - - /*Response> ingestedProgrammes = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.of(2), Optional.empty(), Optional.of(30), - Optional.of("minutes"), Optional.empty(), Optional.of(1), Optional.empty(), Optional.empty(), Optional.empty()); - System.out.println("ID:" + ingestedProgrammes.results.getObjects().get(0).getId());*/ - } -} From 9b74fd09f19eb0c0dd55c877358dcda9a12b7244 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 6 Jun 2018 15:02:36 +0300 Subject: [PATCH 329/605] added class and test logging in BaseTest beforeMethod --- .../kaltura/client/test/tests/BaseTest.java | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index e69af69c9..66ffc00d9 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -6,17 +6,21 @@ import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.IngestConstants; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; + +import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; + import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; @@ -35,6 +39,11 @@ public class BaseTest { public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); private static Response loginResponse; + + /*================================================================================ + Shared Test Params - used as a helper common params across tests + ================================================================================*/ + // shared common params public static int partnerId; public static String defaultUserPassword; @@ -83,33 +92,12 @@ public class BaseTest { } /*================================================================================ - testing shared params list - used as a helper common params across tests - - int partnerId - String defaultUserPassword - - String administratorKs - String operatorKs - String managerKs - String anonymousKs - - MediaAsset mediaAsset - - MediaFile webMediaFile - MediaFile mobileMediaFile - - Subscription fiveMinRenewableSubscription - - Household sharedHousehold - HouseholdUser sharedMasterUser - HouseholdUser sharedUser - String sharedMasterUserKs - String sharedUserKs + Shared Test Params - end ================================================================================*/ @BeforeSuite - public void base_test_before_suite() { + public void baseTest_beforeSuite() { // set configuration config = new Configuration(); config.setEndpoint(getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION)); @@ -126,6 +114,11 @@ public void base_test_before_suite() { defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } + @BeforeMethod + public void baseTest_beforeMethod(Method method) { + Logger.getLogger(BaseTest.class).debug("Class: " + getClass().getSimpleName() + ", Test: " + method.getName()); + } + /** * Regression requires existing of Price Plan with specific parameters. * Price should be 5 Euros From 5c4a475026d9ebdec71277ba0c59f5e8b4cab489 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 6 Jun 2018 15:51:29 +0300 Subject: [PATCH 330/605] no message --- .../householdTests/HouseholdSuspendTests.java | 2 +- .../kaltura/client/test/utils/PurchaseUtils.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 3d346c6c4..4a9ca40ad 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -523,7 +523,7 @@ private void suspend_with_purchase_service_role() { // purchase ppv in order to verify suspend is specific to role Integer mediaFileId = asset.getMediaFiles().get(0).getId(); transactionResponse = PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), - Optional.of(mediaFileId), null); + Optional.of(mediaFileId), Optional.empty()); assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index 71d719a12..f5f3aafb6 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -11,10 +11,11 @@ import com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; -import javax.annotation.Nullable; + import java.util.HashMap; import java.util.Map; import java.util.Optional; + import static com.kaltura.client.test.tests.BaseTest.executor; public class PurchaseUtils { @@ -26,7 +27,7 @@ public class PurchaseUtils { private static Response> productPriceResponse; private static Response assetResponse; - public static Response purchasePpv(String ks, Optional mediaId, Optional fileId, Optional purchaseCurrency) { + public static Response purchasePpv(String ks, Optional mediaId, Optional fileId, Optional currency) { purchasePpvDetailsMap = new HashMap<>(); int internalFileId; @@ -43,8 +44,8 @@ public static Response purchasePpv(String ks, Optional med filter.setFileIdIn(String.valueOf(internalFileId)); filter.setIsLowest(false); - ListProductPriceBuilder listProductPriceBuilder = purchaseCurrency.isPresent() - ? ProductPriceService.list(filter).setKs(ks).setCurrency(purchaseCurrency.get()) + ListProductPriceBuilder listProductPriceBuilder = currency.isPresent() + ? ProductPriceService.list(filter).setKs(ks).setCurrency(currency.get()) : ProductPriceService.list(filter).setKs(ks); productPriceResponse = executor.executeSync(listProductPriceBuilder); @@ -54,8 +55,8 @@ public static Response purchasePpv(String ks, Optional med Purchase purchase = new Purchase(); purchase.setProductId(Integer.valueOf(ppvModuleId)); purchase.setContentId(internalFileId); - String currency = purchaseCurrency.orElse(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); - purchase.setCurrency(currency); + String currencyValue = currency.orElse(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setCurrency(currencyValue); purchase.setPrice(price); purchase.setProductType(Optional.of(TransactionType.PPV).get()); @@ -64,7 +65,7 @@ public static Response purchasePpv(String ks, Optional med // TODO: complete the purchase ppv test purchasePpvDetailsMap.put("price", String.valueOf(price)); - purchasePpvDetailsMap.put("currency", currency); + purchasePpvDetailsMap.put("currency", currencyValue); purchasePpvDetailsMap.put("ppvModuleId", ppvModuleId); purchasePpvDetailsMap.put("fileId", String.valueOf(internalFileId)); From 8df20198dfbf7bd41d5533bfa7c956d5fdf7c523 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 7 Jun 2018 07:44:14 +0300 Subject: [PATCH 331/605] fixed build problems after merge --- src/test/java/com/kaltura/client/test/utils/AssetUtils.java | 2 +- src/test/java/com/kaltura/client/test/utils/IngestUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 1ddeef74d..fbded7475 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -33,7 +33,7 @@ public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nul @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); - searchAssetFilter.setKSql(ksql); + searchAssetFilter.setKsql(ksql); searchAssetFilter.setIdIn(idIn); searchAssetFilter.setTypeIn(typeIn); searchAssetFilter.setDynamicOrderBy(dynamicOrderBy); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 07f1a7c3a..fe5a35894 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -190,7 +190,7 @@ public static List ingestEPG(String epgChannelName, Optional= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + assetFilter.setKsql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); int delayBetweenRetriesInSeconds = 3; int maxTimeExpectingValidResponseInSeconds = 60; await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) From be0a1798971b3a6fb9dd96951b4f82073583d22f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 7 Jun 2018 07:45:13 +0300 Subject: [PATCH 332/605] Updated test subscriptionTest() --- .../ProductPriceListTests.java | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index a807f81d7..67db8df84 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -3,7 +3,9 @@ import com.kaltura.client.enums.*; import com.kaltura.client.services.*; import com.kaltura.client.services.AssetService.GetAssetBuilder; +import com.kaltura.client.services.AssetService.ListAssetBuilder; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; +import com.kaltura.client.services.EntitlementService.ForceCancelEntitlementBuilder; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; @@ -34,6 +36,7 @@ public class ProductPriceListTests extends BaseTest { private TransactionHistoryFilter transactionHistoryFilter; private Household household; private String classMasterUserKs; + private String classMasterUserId; private Response> productPriceResponse; private Response> entitlementResponse; @@ -62,12 +65,13 @@ public void beforeClass() { int numberOfDevices = 1; household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + classMasterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); } @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription test by Operator without currency") @Test(enabled = false) // as used in feature tests - public void listSubscription() { + public void listSubscriptionTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); @@ -95,7 +99,7 @@ public void listSubscriptionWithCurrencyTest() { @Severity(SeverityLevel.MINOR) @Description("productPrice/action/list - without required fields (subscriptionIdIn, collectionIdIn and fileIdIn are empty)") @Test() - public void listWithoutRequiredFields() { + public void listWithoutRequiredFieldsTest() { ProductPriceFilter filter = new ProductPriceFilter(); ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); productPriceResponse = executor.executeSync(productPriceList.setKs(getOperatorKs())); @@ -183,47 +187,55 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { @Severity(SeverityLevel.CRITICAL) @Description("productPrice/action/list - subscription test") - @Test(enabled = false) // TODO: as not completed + @Test(enabled = false) // TODO: as not completed because of problem with getting subscription having medias public void subscriptionTest() { - String sharedWebMediaFileId = String.valueOf(getSharedWebMediaFile().getId()); - // TODO: 3/7/2018 add remarks when possible such as below - show to Shmulik / Michael and see if test is clear - ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementSubsFilter, null); + ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(classMasterUserKs); entitlementResponse = executor.executeSync(entitlementListBeforePurchase); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); - ppFilter.setSubscriptionIdIn(get5MinRenewableSubscription().getId().trim()); + ppFilter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); ppFilter.setIsLowest(false); - ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setKs(classMasterUserKs); productPriceResponse = executor.executeSync(productPriceListBeforePurchase); assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId()); - ListProductPriceBuilder productPriceListBeforePurchase4Anonymous = ProductPriceService.list(ppFilter); + ListProductPriceBuilder productPriceListBeforePurchase4Anonymous = ProductPriceService.list(ppFilter).setKs(getAnonymousKs()); productPriceResponse = executor.executeSync(productPriceListBeforePurchase4Anonymous); assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId()); - //PurchaseUtils.purchaseSubscription(client, Integer.valueOf(get5MinRenewableSubscription().getId().trim())); + PurchaseUtils.purchaseSubscription(classMasterUserKs, Integer.valueOf(get5MinRenewableSubscription().getId()), Optional.empty()); - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(classMasterUserKs); entitlementResponse = executor.executeSync(entitlementListAfterPurchase); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); - assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId()); assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isGreaterThan( entitlementResponse.results.getObjects().get(0).getCurrentDate()); MatcherAssert.assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod(), Matchers.anyOf(Matchers.is(PaymentMethodType.OFFLINE), Matchers.is(PaymentMethodType.UNKNOWN))); + // get data about assets inside subscription to get file + BundleFilter bundleFilter = new BundleFilter(); + bundleFilter.setBundleTypeEqual(BundleType.SUBSCRIPTION); + bundleFilter.setIdEqual(Integer.valueOf(get5MinRenewableSubscription().getId())); + ListAssetBuilder listAssetBuilder = AssetService.list(bundleFilter).setKs(classMasterUserKs); + Response> listResponseAssets = executor.executeSync(listAssetBuilder); + assertThat(listResponseAssets.results.getTotalCount()).isGreaterThan(0); + String sharedWebMediaFileId = String.valueOf(listResponseAssets.results.getObjects().get(0).getMediaFiles().get(0).getId()); + ppFilter.setFileIdIn(sharedWebMediaFileId); - ListProductPriceBuilder productPriceListAfterPurchase = ProductPriceService.list(ppFilter); + ListProductPriceBuilder productPriceListAfterPurchase = ProductPriceService.list(ppFilter).setKs(classMasterUserKs); productPriceResponse = executor.executeSync(productPriceListAfterPurchase); + // as we have file and subscription in filter assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(2); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); assertThat(productPriceResponse.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); @@ -233,8 +245,14 @@ public void subscriptionTest() { assertThat(productPriceResponse.results.getObjects().get(1).getClass().getSimpleName()).isEqualToIgnoringCase("PpvPrice"); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId()); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(sharedWebMediaFileId); + + //delete entitlement data for cleanup + ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel( + Integer.valueOf(get5MinRenewableSubscription().getId()), TransactionType.SUBSCRIPTION) + .setKs(getOperatorKs()).setUserId(Integer.valueOf(classMasterUserId)); + executor.executeSync(forceCancelEntitlementBuilder); } @Severity(SeverityLevel.NORMAL) From 0aa8defcfe03cf10b93f31070c2594259c8c8062 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Thu, 7 Jun 2018 09:40:27 +0300 Subject: [PATCH 333/605] handling tests with delay --- .../SlowTestsRunner/SlowTestsRunner.java | 36 ++++++++ .../appTokenTests/AppTokenAddTests.java | 28 ++++--- .../householdTests/HouseholdSuspendTests.java | 82 ++++++++++-------- .../OttUserLoginWithPinTests.java | 25 +++--- .../TransactionHistoryListTests.java | 84 ++++++++++--------- src/test/resources/testng.xml | 27 ++++-- 6 files changed, 175 insertions(+), 107 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java new file mode 100644 index 000000000..b865b57e3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java @@ -0,0 +1,36 @@ +package com.kaltura.client.test.tests.servicesTests.SlowTestsRunner; + +import com.kaltura.client.test.tests.BaseTest; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +import java.lang.reflect.Method; + + +public class SlowTestsRunner extends BaseTest{ + + @BeforeSuite(groups = "slow_before") + public void setupSlowTests(Method method){ + baseTest_beforeSuite(); + baseTest_beforeMethod(method); + } + + @Test(groups = "slow", dependsOnGroups = {"slow_before"}) + public void prepareSlowTests(){ + System.out.println("waiting timeout"); + + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + System.out.println("finished timeout"); + } + + @Test(alwaysRun = true, groups = "slow", dependsOnGroups = {"slow_after"}, dependsOnMethods = {"prepareSlowTests"}) + public void succedeed(Method method){ + System.out.println("Good shot! Proud of you!"); + } + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index e66c4ba9a..cf6385990 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -22,6 +22,7 @@ public class AppTokenAddTests extends BaseTest { private String sessionUserId; private AppToken appToken; private String sessionPrivileges; + Response addAppTokenResponseSlowTest; // TODO: 5/3/2018 Add comments! @BeforeClass @@ -78,31 +79,34 @@ private void addAppTokenWithPrivileges() { } @Description("appToken/action/add - with expiry date") - @Test(groups = "slow") - private void addAppTokenWithExpiryDate() { + @Test(groups = "slow_before") + private void addAppTokenWithExpiryDate_before() { + // setup for test + System.out.println("before started"); + add_tests_before_class(); Long expiryDate = BaseUtils.getTimeInEpoch(1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) .setKs(getOperatorKs()); - Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); + addAppTokenResponseSlowTest = executor.executeSync(addAppTokenBuilder); - assertThat(addAppTokenResponse.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); + assertThat(addAppTokenResponseSlowTest.results.getExpiry()).isEqualTo(Math.toIntExact(expiryDate)); // Wait until token is expired (according to expiry date) - System.out.println("Waiting 1 minute until token expiry date reached"); - - try { - Thread.sleep(72000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + System.out.println("Waiting until token expiry date reached"); + System.out.println("before finished"); + } - GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponse.results.getId()) + @Test(groups = "slow_after", dependsOnMethods = "addAppTokenWithExpiryDate_before") + private void addAppTokenWithExpiryDate_after() { + System.out.println("after started"); + GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponseSlowTest.results.getId()) .setKs(getOperatorKs()); Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + System.out.println("after finished"); } @Description("appToken/action/add - with no expiry date (return default expiry date -" + diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 3d346c6c4..32fb5cd3a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -31,6 +31,11 @@ public class HouseholdSuspendTests extends BaseTest { private Subscription subscription; private Asset asset; + private Household householdSlowTest; + private Response> productPriceListResponseSlowTest; + private String masterUserKsSlowTest; + private UserRole roleSlowTest; + private Subscription fiveMinRenewSubscriptionSlowTest; private enum Permissions { PLAYBACK_SUBSCRIPTION, @@ -402,67 +407,69 @@ private void suspend_with_playback_ppv_role() { @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with renew_subscription role") - @Test(groups = "slow") - private void suspend_with_renew_subscription_role() { + @Test(groups = "slow_before") + private void suspend_with_renew_subscription_role_before() { + System.out.println("before started"); + // setup for test + household_suspendTests_beforeClass(); + // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + householdSlowTest = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(householdSlowTest); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); - String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + String udid = HouseholdUtils.getDevicesListFromHouseHold(householdSlowTest).get(0).getUdid(); + masterUserKsSlowTest = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role - UserRole role = new UserRole(); - role.setExcludedPermissionNames(Permissions.RENEW_SUBSCRIPTION.name()); - role.setName(Permissions.RENEW_SUBSCRIPTION.name()); + roleSlowTest = new UserRole(); + roleSlowTest.setExcludedPermissionNames(Permissions.RENEW_SUBSCRIPTION.name()); + roleSlowTest.setName(Permissions.RENEW_SUBSCRIPTION.name()); // add role - Response userRoleResponse = executor.executeSync(UserRoleService.add(role).setKs(getOperatorKs())); - role = userRoleResponse.results; + Response userRoleResponse = executor.executeSync(UserRoleService.add(roleSlowTest).setKs(getOperatorKs())); + roleSlowTest = userRoleResponse.results; // purchase subscription - Subscription fiveMinRenewSubscription = get5MinRenewableSubscription(); - int fiveMinRenewSubscriptionId = Integer.parseInt(fiveMinRenewSubscription.getId().trim()); - PurchaseUtils.purchaseSubscription(masterUserKs, fiveMinRenewSubscriptionId, Optional.empty()); + fiveMinRenewSubscriptionSlowTest = get5MinRenewableSubscription(); + int fiveMinRenewSubscriptionId = Integer.parseInt(fiveMinRenewSubscriptionSlowTest.getId().trim()); + PurchaseUtils.purchaseSubscription(masterUserKsSlowTest, fiveMinRenewSubscriptionId, Optional.empty()); //get productprice list - before renew ProductPriceFilter subscriptionFilter = new ProductPriceFilter(); - subscriptionFilter.setSubscriptionIdIn(fiveMinRenewSubscription.getId()); - Response> productPriceListResponse = executor.executeSync(ProductPriceService.list(subscriptionFilter) - .setKs(masterUserKs)); + subscriptionFilter.setSubscriptionIdIn(fiveMinRenewSubscriptionSlowTest.getId()); + productPriceListResponseSlowTest = executor.executeSync(ProductPriceService.list(subscriptionFilter) + .setKs(masterUserKsSlowTest)); - assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListResponse.results.getObjects().get(0).getProductId()).isEqualTo(fiveMinRenewSubscription.getId().trim()); - assertThat(productPriceListResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + assertThat(productPriceListResponseSlowTest.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListResponseSlowTest.results.getObjects().get(0).getProductId()).isEqualTo(fiveMinRenewSubscriptionSlowTest.getId().trim()); + assertThat(productPriceListResponseSlowTest.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); // suspend with renew_subscription role - SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(role.getId())) + SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend(Math.toIntExact(roleSlowTest.getId())) .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId())); Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); assertThat(booleanResponse.results).isTrue(); + System.out.println("before finished"); + } - // sleep for 6 min - try { - Thread.sleep(360000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - + @Test(groups = "slow_after", dependsOnMethods = {"suspend_with_renew_subscription_role_before"}) + private void suspend_with_renew_subscription_role_after() { + System.out.println("after started"); // get productprice list for asset in subscription - after renew Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); ProductPriceFilter assetFilter = new ProductPriceFilter(); assetFilter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); - productPriceListResponse = executor.executeSync(ProductPriceService.list(assetFilter) - .setKs(masterUserKs)); - assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + productPriceListResponseSlowTest = executor.executeSync(ProductPriceService.list(assetFilter) + .setKs(masterUserKsSlowTest)); + assertThat(productPriceListResponseSlowTest.results.getTotalCount()).isEqualTo(1); + assertThat(productPriceListResponseSlowTest.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); // transactionHistory list - verify media file related to subscription billing status = purchase Response> billingTransactionListResponse = executor.executeSync(TransactionHistoryService.list() - .setKs(masterUserKs)); + .setKs(masterUserKsSlowTest)); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); assertThat(billingTransactionListResponse.results.getObjects().get(0).getBillingAction()).isEqualTo(BillingAction.PURCHASE); @@ -473,17 +480,18 @@ private void suspend_with_renew_subscription_role() { entitlementFilter.setIsExpiredEqual(false); Response> entitlementListResponse = executor.executeSync(EntitlementService.list(entitlementFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsSlowTest)); assertThat(entitlementListResponse.results.getTotalCount()).isEqualTo(1); SubscriptionEntitlement subscriptionEntitlement = (SubscriptionEntitlement) entitlementListResponse.results.getObjects().get(0); - assertThat(subscriptionEntitlement.getProductId()).isEqualTo(fiveMinRenewSubscription.getId().trim()); + assertThat(subscriptionEntitlement.getProductId()).isEqualTo(fiveMinRenewSubscriptionSlowTest.getId().trim()); assertThat(subscriptionEntitlement.getIsSuspended()).isTrue(); // cleanup - delete role - executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); + executor.executeSync(UserRoleService.delete(roleSlowTest.getId()).setKs(getOperatorKs())); // cleanup - delete household - executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + executor.executeSync(delete(Math.toIntExact(householdSlowTest.getId())).setKs(getOperatorKs())); + System.out.println("after finished"); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index b8ed7c1b4..cd8ba50cd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -27,6 +27,7 @@ public class OttUserLoginWithPinTests extends BaseTest { private Response userLoginPinResponse; private final String SECRET = "secret"; + private String pinSlowTest; @BeforeClass private void ottUser_login_tests_setup() { @@ -78,8 +79,12 @@ private void loginWithPin_with_invalid_secret() { @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") - @Test(groups = "slow") - private void loginWithPin_with_expired_pinCode() { + @Test(groups = "slow_before") + private void loginWithPin_with_expired_pinCode_before() { + System.out.println("before started"); + // setup for test + ottUser_login_tests_setup(); + // add pin AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) .setKs(getAdministratorKs()) @@ -87,19 +92,19 @@ private void loginWithPin_with_expired_pinCode() { userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); // login with expired pin - String pin = userLoginPinResponse.results.getPinCode(); + pinSlowTest = userLoginPinResponse.results.getPinCode(); + System.out.println("before finished"); + } - // sleep for 1.5 minutes - try { - Thread.sleep(120000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, SECRET); + @Test(groups = "slow_after", dependsOnMethods = {"loginWithPin_with_expired_pinCode_before"}) + private void loginWithPin_with_expired_pinCode_after() { + System.out.println("after started"); + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pinSlowTest, null, SECRET); loginResponse = executor.executeSync(loginWithPinOttUserBuilder); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2004).getCode()); + System.out.println("after finished"); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index adb21f362..082f93bdb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -11,6 +11,7 @@ import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; @@ -21,6 +22,8 @@ import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.assertj.core.api.Assertions.within; public class TransactionHistoryListTests extends BaseTest{ @@ -116,8 +119,9 @@ public void transactionHistortTestSetup(){ } @Severity(SeverityLevel.BLOCKER) - @Test(description = "/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for non-master user") - public void testTransactionHistoryPerHouseholdWithUserKs() { + @Description("/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for non-master user") + @Test + public void transactionHistoryPerHouseholdWithUserKs() { //All transactions per non-master user transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); @@ -134,8 +138,9 @@ public void testTransactionHistoryPerHouseholdWithUserKs() { } @Severity(SeverityLevel.BLOCKER) - @Test(description = "/transactionHistory/action/list - test purchases per user are written correctly at transactionHistory for non-master user") - public void testTransactionHistoryPerUserWithUserKs() { + @Description("/transactionHistory/action/list - test purchases per user are written correctly at transactionHistory for non-master user") + @Test + public void transactionHistoryPerUserWithUserKs() { //All transactions per non-master user transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(userKs); @@ -152,8 +157,9 @@ public void testTransactionHistoryPerUserWithUserKs() { } @Severity(SeverityLevel.BLOCKER) - @Test(description = "/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for master user") - public void testTransactionHistoryPerHouseholdWithMasterKs() { + @Description("/transactionHistory/action/list - test purchases per household are written correctly at transactionHistory for master user") + @Test + public void transactionHistoryPerHouseholdWithMasterKs() { //All transactions per master user transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); @@ -170,8 +176,9 @@ public void testTransactionHistoryPerHouseholdWithMasterKs() { } @Severity(SeverityLevel.BLOCKER) - @Test(description = "/transactionHistory/action/list - test no purchases per user were written at transactionHistory for master user") - public void testTransactionHistoryPerUserWithMasterKs() { + @Description("/transactionHistory/action/list - test no purchases per user were written at transactionHistory for master user") + @Test + public void transactionHistoryPerUserWithMasterKs() { //All transactions per master user transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.USER); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterUserKs); @@ -189,50 +196,49 @@ public void testTransactionHistoryPerUserWithMasterKs() { private void assertMethod(String methodName, List billingTransactionList) { Logger.getLogger(TransactionHistoryListTests.class).debug(methodName); - for(int i = 0; i < billingTransactionList.size(); i++) { - assertThat(billingTransactionList.get(i).getClass()).isEqualTo(BillingTransaction.class); - assertThat(billingTransactionList.get(i).getBillingAction()).isEqualTo(BillingAction.PURCHASE); - assertThat(billingTransactionList.get(i).getIsRecurring()).isEqualTo(false); - assertThat(billingTransactionList.get(i).getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); - switch (billingTransactionList.get(i).getItemType()){ + for(BillingTransaction billingTransaction : billingTransactionList) { + assertThat(billingTransaction.getClass()).isEqualTo(BillingTransaction.class); + assertThat(billingTransaction.getBillingAction()).isEqualTo(BillingAction.PURCHASE); + assertThat(billingTransaction.getIsRecurring()).isEqualTo(false); + assertThat(billingTransaction.getBillingPriceType()).isEqualTo(BillingPriceType.FULLPERIOD); + switch (billingTransaction.getItemType()){ case SUBSCRIPTION: - BillingTransaction billingTransactionSubscription = billingTransactionList.get(i); - assertThat(billingTransactionSubscription.getRecieptCode()).isEqualTo(transactionResponseSubscription.results.getId()); + assertThat(billingTransaction.getRecieptCode()).isEqualTo(transactionResponseSubscription.results.getId()); //TODO: Shared Subscription name not equals to transactionHistory name written (Title written). (deprecate this assertion or amend with another way) // assertThat(billingTransactionSubscription.getPurchasedItemName()).isEqualTo(getSharedCommonSubscription().getName()); - assertThat(billingTransactionSubscription.getPurchasedItemCode()).isEqualTo(getSharedCommonSubscription().getId().toString()); - assertThat(billingTransactionSubscription.getItemType()).isEqualTo(BillingItemsType.SUBSCRIPTION); - assertThat(billingTransactionSubscription.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_AMOUNT)); - assertThat(billingTransactionSubscription.getPrice().getCurrency().toString()).isEqualTo(PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_CURRENCY)); - assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(billingTransactionSubscription.getActionDate()); - assertThat(billingTransactionSubscription.getStartDate()).isEqualTo(transactionResponseSubscription.results.getCreatedAt().longValue()); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(getSharedCommonSubscription().getId()); + assertThat(billingTransaction.getItemType()).isEqualTo(BillingItemsType.SUBSCRIPTION); + assertThat(billingTransaction.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_AMOUNT)); + assertThat(billingTransaction.getPrice().getCurrency()).isEqualTo(PurchaseUtils.purchaseSubscriptionDetailsMap.get(PRICE_CURRENCY)); + assertThat(billingTransaction.getStartDate().intValue()).isCloseTo(transactionResponseSubscription.results.getCreatedAt(), within(2)); + assertThat(billingTransaction.getActionDate().intValue()).isCloseTo(transactionResponseSubscription.results.getCreatedAt(), within(2)); break; case PPV: - BillingTransaction billingTransactionPpv = billingTransactionList.get(i); - assertThat(billingTransactionPpv.getRecieptCode()).isEqualTo(transactionResponsePpv.results.getId()); - assertThat(billingTransactionPpv.getPurchasedItemName()).isEqualTo(getSharedMediaAsset().getName()); - assertThat(billingTransactionPpv.getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); - assertThat(billingTransactionPpv.getItemType()).isEqualTo(BillingItemsType.PPV); - assertThat(billingTransactionPpv.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchasePpvDetailsMap.get(PRICE_AMOUNT)); - assertThat(billingTransactionPpv.getPrice().getCurrency().toString()).isEqualTo(PurchaseUtils.purchasePpvDetailsMap.get(PRICE_CURRENCY)); - assertThat(billingTransactionPpv.getStartDate()).isEqualTo(billingTransactionPpv.getActionDate()); - assertThat(billingTransactionPpv.getStartDate()).isEqualTo(transactionResponsePpv.results.getCreatedAt().longValue()); + assertThat(billingTransaction.getRecieptCode()).isEqualTo(transactionResponsePpv.results.getId()); + assertThat(billingTransaction.getPurchasedItemName()).isEqualTo(getSharedMediaAsset().getName()); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(getSharedMediaAsset().getId().toString()); + assertThat(billingTransaction.getItemType()).isEqualTo(BillingItemsType.PPV); + assertThat(billingTransaction.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchasePpvDetailsMap.get(PRICE_AMOUNT)); + assertThat(billingTransaction.getPrice().getCurrency()).isEqualTo(PurchaseUtils.purchasePpvDetailsMap.get(PRICE_CURRENCY)); + assertThat(billingTransaction.getStartDate().intValue()).isCloseTo(transactionResponsePpv.results.getCreatedAt(), within(2)); + assertThat(billingTransaction.getActionDate().intValue()).isCloseTo(transactionResponsePpv.results.getCreatedAt(), within(2)); break; case COLLECTION: - BillingTransaction billingTransactionCollection = billingTransactionList.get(i); - assertThat(billingTransactionCollection.getRecieptCode()).isEqualTo(transactionResponseCollection.results.getId()); - assertThat(billingTransactionCollection.getPurchasedItemName()).isEqualTo(getSharedCommonCollection().getName()); - assertThat(billingTransactionCollection.getPurchasedItemCode()).isEqualTo(getSharedCommonCollection().getId().toString()); - assertThat(billingTransactionCollection.getItemType()).isEqualTo(BillingItemsType.COLLECTION); - assertThat(billingTransactionCollection.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_AMOUNT)); - assertThat(billingTransactionCollection.getPrice().getCurrency().toString()).isEqualTo(PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_CURRENCY)); - assertThat(billingTransactionCollection.getActionDate()).isEqualTo(transactionResponseCollection.results.getCreatedAt().longValue()); + assertThat(billingTransaction.getRecieptCode()).isEqualTo(transactionResponseCollection.results.getId()); + assertThat(billingTransaction.getPurchasedItemName()).isEqualTo(getSharedCommonCollection().getName()); + assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(getSharedCommonCollection().getId()); + assertThat(billingTransaction.getItemType()).isEqualTo(BillingItemsType.COLLECTION); + assertThat(billingTransaction.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_AMOUNT)); + assertThat(billingTransaction.getPrice().getCurrency()).isEqualTo(PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_CURRENCY)); + assertThat(billingTransaction.getStartDate().intValue()).isCloseTo(transactionResponseCollection.results.getCreatedAt(), within(2)); + assertThat(billingTransaction.getActionDate().intValue()).isCloseTo(transactionResponseCollection.results.getCreatedAt(), within(2)); break; default: Logger.getLogger(TransactionHistoryListTests.class).error("No valid item type found!"); + fail("No valid item type found!"); break; } } diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 0c943be1b..de6072904 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,25 +1,34 @@ - - + + + + - + + + + + + + + + - - - - - + + + + - + \ No newline at end of file From 812880ba1ccf6b43c1f45398a9d427583f4b0bb2 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 10 Jun 2018 10:08:07 +0300 Subject: [PATCH 334/605] Completed productPrice service --- .../com/kaltura/client/test/Properties.java | 22 +- .../ProductPriceListTests.java | 299 +++++++++++------- .../client/test/utils/IngestUtils.java | 6 +- .../test/utils/dbUtils/DBConstants.java | 4 +- .../test/utils/dbUtils/IngestFixtureData.java | 6 +- src/test/resources/WORK_PLAN.md | 4 +- 6 files changed, 219 insertions(+), 122 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 9035420be..00f028e7f 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -35,10 +35,30 @@ public class Properties { // channels public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" - // price codes + // price codes values public static final String PRICE_CODE_AMOUNT = "price_code_amount"; // 4.99 public static final String COMMON_PRICE_CODE_AMOUNT = "5"; // TODO: should we document it as requirement? + // price plans + // INGEST doesn't allow create PP with multi-currencies + // TODO: should we document it as requirement? price plan having few locales (EUR + few others) with different prices + // should we leave there name or id if we do use name in ingest + public static final String PRICE_PLAN_WITH_MULTI_CURRENCIES = "lior's PriceCode price plan"; + // TODO: should we document it as requirement? price plan having few locales (USD + few others) with different prices and discount for subscriptions 50% + // should we leave there name or id if we do use name in ingest + public static final String PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS = "shmulik_multi_currency_with_discount"; + // TODO: should we document it as requirement? price plan having few locales (USD + few others) with different prices and fixed discount for subscriptions 1 + // should we leave there name or id if we do use name in ingest + public static final String PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_FIXED = "shmulik_multi_currency_with_discount (fixed amount)"; + + // PPVs + // Ingest doesn't allow create PP with multi currencies + // TODO: should we document it as requirement? + public static final String PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS = "multi price code with 50% discount"; + // TODO: should we document it as requirement? + public static final String PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT = "multi price code with fixed amount discount"; + + //cycles public static final int CYCLE_1_DAY = 1440; // in minutes diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 67db8df84..044838302 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -2,20 +2,19 @@ import com.kaltura.client.enums.*; import com.kaltura.client.services.*; -import com.kaltura.client.services.AssetService.GetAssetBuilder; +import com.kaltura.client.services.ChannelService.AddChannelBuilder; +import com.kaltura.client.services.ChannelService.DeleteChannelBuilder; import com.kaltura.client.services.AssetService.ListAssetBuilder; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; import com.kaltura.client.services.EntitlementService.ForceCancelEntitlementBuilder; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.IngestUtils; -import com.kaltura.client.test.utils.OttUserUtils; -import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.hamcrest.MatcherAssert; @@ -25,6 +24,9 @@ import org.testng.annotations.Test; import java.util.Optional; import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -37,11 +39,12 @@ public class ProductPriceListTests extends BaseTest { private Household household; private String classMasterUserKs; private String classMasterUserId; + private Channel sharedChannel; + private Subscription subscriptionWithMultiCurrenciesAndDiscountPercentage; private Response> productPriceResponse; private Response> entitlementResponse; private Response> listBillingTransactionResponse; - private Response assetGetResponse; @BeforeClass public void beforeClass() { @@ -66,6 +69,18 @@ public void beforeClass() { household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); classMasterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); + + sharedChannel = new Channel(); + sharedChannel.setName(BaseUtils.getRandomValue("Channel_", 999999)); + sharedChannel.setDescription("Description of " + sharedChannel.getName()); + sharedChannel.setIsActive(true); + sharedChannel.setAssetTypes(null); + + subscriptionWithMultiCurrenciesAndDiscountPercentage = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), + Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) @@ -75,8 +90,8 @@ public void listSubscriptionTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); - ListProductPriceBuilder productPriceList = ProductPriceService.list(filter).setKs(getOperatorKs()); - productPriceResponse = executor.executeSync(productPriceList); + ListProductPriceBuilder productPriceList = ProductPriceService.list(filter); + productPriceResponse = executor.executeSync(productPriceList.setKs(getOperatorKs())); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); @@ -89,7 +104,6 @@ public void listSubscriptionWithCurrencyTest() { ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); productPriceResponse = executor.executeSync(ProductPriceService.list(filter).setCurrency(EUR.getValue()).setKs(getOperatorKs())); - // TODO: should we create ENUMs for currencies? A: Yes if library doesn't contain them assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId().trim()); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); @@ -113,10 +127,10 @@ public void listWithoutRequiredFieldsTest() { @Severity(SeverityLevel.CRITICAL) @Description("productPrice/action/list - ppv test") - @Test() + @Issue("BEO-5184") + @Test public void ppvTest() { // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType - ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementPpvsFilter, null); entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); @@ -172,9 +186,9 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); filter.setFileIdIn(String.valueOf(getSharedWebMediaFile().getId())); filter.setIsLowest(false); - ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter) - .setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null)); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase + .setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null))); // should be 2 ss one item is subscription an another is media file assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(2); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); @@ -187,36 +201,46 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { @Severity(SeverityLevel.CRITICAL) @Description("productPrice/action/list - subscription test") - @Test(enabled = false) // TODO: as not completed because of problem with getting subscription having medias + @Test public void subscriptionTest() { // TODO: 3/7/2018 add remarks when possible such as below - show to Shmulik / Michael and see if test is clear - ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(classMasterUserKs); - entitlementResponse = executor.executeSync(entitlementListBeforePurchase); + // create mpp with supporting of 1 type only and having at least 1 media on its channel + sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); + Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + sharedChannel.setId(channelResponse.results.getId()); + Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + + ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); ProductPriceFilter ppFilter = new ProductPriceFilter(); - ppFilter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); + ppFilter.setSubscriptionIdIn(subscription.getId()); ppFilter.setIsLowest(false); - ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter).setKs(classMasterUserKs); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase); + ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId()); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(subscription.getId()); - ListProductPriceBuilder productPriceListBeforePurchase4Anonymous = ProductPriceService.list(ppFilter).setKs(getAnonymousKs()); - productPriceResponse = executor.executeSync(productPriceListBeforePurchase4Anonymous); + ListProductPriceBuilder productPriceListBeforePurchase4Anonymous = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListBeforePurchase4Anonymous.setKs(getAnonymousKs())); assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); - assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(get5MinRenewableSubscription().getId()); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(subscription.getId()); - PurchaseUtils.purchaseSubscription(classMasterUserKs, Integer.valueOf(get5MinRenewableSubscription().getId()), Optional.empty()); + PurchaseUtils.purchaseSubscription(classMasterUserKs, Integer.valueOf(subscription.getId()), Optional.empty()); - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(classMasterUserKs); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); - assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId()); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(subscription.getId()); assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isGreaterThan( entitlementResponse.results.getObjects().get(0).getCurrentDate()); MatcherAssert.assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod(), @@ -225,15 +249,15 @@ public void subscriptionTest() { // get data about assets inside subscription to get file BundleFilter bundleFilter = new BundleFilter(); bundleFilter.setBundleTypeEqual(BundleType.SUBSCRIPTION); - bundleFilter.setIdEqual(Integer.valueOf(get5MinRenewableSubscription().getId())); - ListAssetBuilder listAssetBuilder = AssetService.list(bundleFilter).setKs(classMasterUserKs); - Response> listResponseAssets = executor.executeSync(listAssetBuilder); + bundleFilter.setIdEqual(Integer.valueOf(subscription.getId())); + ListAssetBuilder listAssetBuilder = AssetService.list(bundleFilter); + Response> listResponseAssets = executor.executeSync(listAssetBuilder.setKs(classMasterUserKs)); assertThat(listResponseAssets.results.getTotalCount()).isGreaterThan(0); - String sharedWebMediaFileId = String.valueOf(listResponseAssets.results.getObjects().get(0).getMediaFiles().get(0).getId()); + String sharedWebMediaFileId = String.valueOf(listResponseAssets.results.getObjects().get(0).getMediaFiles().get(0).getId()).trim(); ppFilter.setFileIdIn(sharedWebMediaFileId); - ListProductPriceBuilder productPriceListAfterPurchase = ProductPriceService.list(ppFilter).setKs(classMasterUserKs); - productPriceResponse = executor.executeSync(productPriceListAfterPurchase); + ListProductPriceBuilder productPriceListAfterPurchase = ProductPriceService.list(ppFilter); + productPriceResponse = executor.executeSync(productPriceListAfterPurchase.setKs(classMasterUserKs)); // as we have file and subscription in filter assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(2); @@ -245,22 +269,34 @@ public void subscriptionTest() { assertThat(productPriceResponse.results.getObjects().get(1).getClass().getSimpleName()).isEqualToIgnoringCase("PpvPrice"); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(get5MinRenewableSubscription().getId()); - assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(sharedWebMediaFileId); + assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(subscription.getId()); + assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(Integer.valueOf(sharedWebMediaFileId)); //delete entitlement data for cleanup ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel( - Integer.valueOf(get5MinRenewableSubscription().getId()), TransactionType.SUBSCRIPTION) - .setKs(getOperatorKs()).setUserId(Integer.valueOf(classMasterUserId)); - executor.executeSync(forceCancelEntitlementBuilder); + Integer.valueOf(subscription.getId()), TransactionType.SUBSCRIPTION); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(classMasterUserId))); + //delete subscription + IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) @Description("/productprice/action/list - subscription - Web_HD_File_only") @Test() public void productPriceSubscriptionWebHDFileTypeOnlyTest() { - // TODO: add logic of using dynamic data - int webHDFileOnlySubId = 56550; + // create mpp with supporting of 1 type only and having at least 1 media on its channel + sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); + Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + sharedChannel.setId(channelResponse.results.getId()); + Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + int webHDFileOnlySubId = Integer.valueOf(subscription.getId()); int numberOfUsers = 1; int numberOfDevices = 1; @@ -304,17 +340,27 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(2)).getFileId()).isEqualTo(getSharedMobileMediaFile().getId()); //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) - .setKs(getAdministratorKs()); - executor.executeSync(deleteHouseholdBuilder); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + // delete channel + DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(Math.toIntExact(sharedChannel.getId())); + executor.executeSync(deleteChannelBuilder.setKs(getManagerKs())); + //delete subscription + IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription - no specifed currency") @Test() public void productPriceSubscriptionNoSpecifiedCurrencyTest() { - // TODO: add logic of using dynamic data - int subWithMultiCurrencyId = 86445; + Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + int subWithMultiCurrencyId = Integer.valueOf(subscription.getId()); int numberOfUsers = 1; int numberOfDevices = 1; @@ -337,13 +383,13 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { PurchaseUtils.purchaseSubscription(masterKs, subWithMultiCurrencyId, Optional.empty()); // to check purchase - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); // to check purchase - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder.setKs(masterKs)); assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithMultiCurrencyId)); @@ -358,18 +404,22 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(EUR.getValue()); //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) - .setKs(getAdministratorKs()); - executor.executeSync(deleteHouseholdBuilder); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + //delete subscription + IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription with discount (percentage) - specified currency") @Test() public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTest() { - // TODO: add logic of using dynamic data - int subWithDiscountAndCurrencyId = 116952; + // TODO: should we save it in Properties? double subPriceAfterDiscount = 7.5; // as price 15 and discount is 50% + int subWithDiscountAndCurrencyId = Integer.valueOf(subscriptionWithMultiCurrenciesAndDiscountPercentage.getId()); int numberOfUsers = 1; int numberOfDevices = 1; @@ -391,13 +441,13 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(USD.getValue())); // to check purchase - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); // to check purchase - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder.setKs(masterKs)); assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); @@ -412,18 +462,21 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(USD.getValue()); //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) - .setKs(getAdministratorKs()); - executor.executeSync(deleteHouseholdBuilder); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); } @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription with discount (fixed amount) - specified currency - not in locale") @Test() public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLocaleTest() { - // TODO: add logic of using dynamic data - int subWithDiscountAndCurrencyId = 119303; + // TODO: should we save it in Properties? double subPriceAfterDiscount = 4; // as price 5 and discount is 1 + Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_FIXED), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + int subWithDiscountAndCurrencyId = Integer.valueOf(subscription.getId()); int numberOfUsers = 1; int numberOfDevices = 1; @@ -445,13 +498,13 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.of(CLP.getValue())); // to check purchase - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); // to check purchase - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder.setKs(masterKs)); assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); @@ -466,18 +519,22 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(CLP.getValue()); //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) - .setKs(getAdministratorKs()); - executor.executeSync(deleteHouseholdBuilder); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + //delete subscription + IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription with discount (percentage) - no specified currency") @Test() public void productPriceSubscriptionWithPercentageDiscountAndNoSpecifiedCurrencyTest() { - // TODO: add logic of using dynamic data - int subWithDiscountAndCurrencyId = 116952; + // TODO: should we save it in Properties? double subPriceAfterDiscount = 9.6; // as price 12 in default locale and discount is 20% in default locale + int subWithDiscountAndCurrencyId = Integer.valueOf(subscriptionWithMultiCurrenciesAndDiscountPercentage.getId()); int numberOfUsers = 1; int numberOfDevices = 1; @@ -499,13 +556,13 @@ public void productPriceSubscriptionWithPercentageDiscountAndNoSpecifiedCurrency PurchaseUtils.purchaseSubscription(masterKs, subWithDiscountAndCurrencyId, Optional.empty()); // to check purchase - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null).setKs(masterKs); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementSubsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); // to check purchase - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder.setKs(masterKs)); assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(subWithDiscountAndCurrencyId)); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(subPriceAfterDiscount); @@ -535,13 +592,15 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); - // TODO: add logic of using dynamic data - int assetWithMultiCurrencyId = 485467; - GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(assetWithMultiCurrencyId), - AssetReferenceType.MEDIA).setKs(masterKs); - assetGetResponse = executor.executeSync(getAssetBuilder); - int mediaFileId = assetGetResponse.results.getMediaFiles().get(1).getId(); + // TODO: should we save it in Properties? double ppvPriceAfterDiscount = 33.3; // as price 37 ILS and discount is 10% + MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), + Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); + int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaFileId)); @@ -556,14 +615,14 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(ILS.getValue())); // to check purchase - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(assetWithMultiCurrencyId); assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(mediaFileId); // to check purchase - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder.setKs(masterKs)); assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(assetWithMultiCurrencyId)); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); @@ -578,9 +637,13 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(ILS.getValue()); //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) - .setKs(getAdministratorKs()); - executor.executeSync(deleteHouseholdBuilder); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), + Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) @@ -593,12 +656,13 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); - // TODO: add logic of using dynamic data - int assetWithMultiCurrencyId = 485618; - GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(assetWithMultiCurrencyId), - AssetReferenceType.MEDIA).setKs(masterKs); - assetGetResponse = executor.executeSync(getAssetBuilder); - int mediaFileId = assetGetResponse.results.getMediaFiles().get(1).getId(); + MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT), + Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); + int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); double ppvPriceAfterDiscount = 2; // as price 5 ILS and discount is 3 ProductPriceFilter ppFilter = new ProductPriceFilter(); @@ -614,14 +678,14 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { PurchaseUtils.purchasePpv(masterKs, Optional.of(assetWithMultiCurrencyId), Optional.of(mediaFileId), Optional.of(ILS.getValue())); // to check purchase - ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null).setKs(masterKs); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(entitlementPpvsFilter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(assetWithMultiCurrencyId); assertThat(((PpvEntitlement) entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(mediaFileId); // to check purchase - ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter).setKs(masterKs); - listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); + ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryFilter); + listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder.setKs(masterKs)); assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPurchasedItemCode()).isEqualTo(String.valueOf(assetWithMultiCurrencyId)); assertThat(listBillingTransactionResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(ppvPriceAfterDiscount); @@ -636,18 +700,21 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()).isEqualTo(ILS.getValue()); //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) - .setKs(getAdministratorKs()); - executor.executeSync(deleteHouseholdBuilder); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), + Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) @Description("/productPrice/action/list - with passed PPV") @Test() public void productPriceWithPassedPpvTest() { - // TODO: update to use dynamic data - double nonPassedPpvPrice = 4.99; - String ppvMobileModule = getSharedCommonPpv().getName() + ";;01/01/2017 00:00:00;Camilo_4_99_EUR_PPV;;"; + String ppvWithExpiredDate = ";;01/01/2017 00:00:00"; + String ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate + PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS + ";;"; MediaAsset mediaAssetWith2Ppv1Expired = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), @@ -661,11 +728,11 @@ public void productPriceWithPassedPpvTest() { assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.PPV); - assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(nonPassedPpvPrice); + assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isGreaterThan(0); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo( mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); - ppvMobileModule = getSharedCommonPpv().getName() + ";;01/01/2017 00:00:00"; + ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate; mediaAssetWith2Ppv1Expired = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), @@ -681,13 +748,23 @@ public void productPriceWithPassedPpvTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo( mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); + // delete media + IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAssetWith2Ppv1Expired.getName()), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), + Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); } @AfterClass public void afterClass() { //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())) - .setKs(getAdministratorKs()); - executor.executeSync(deleteHouseholdBuilder); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + // delete subscription + IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscriptionWithMultiCurrenciesAndDiscountPercentage.getName()), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index fe5a35894..a1c700563 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -839,10 +839,10 @@ public static MediaAsset ingestVOD(Optional action, Optional cog //mediaAsset.setStartDate(startDate); //mediaAsset.setEndDate(endDate); - int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 60; - await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), id, actionValue)); if (!INGEST_ACTION_DELETE.equals(actionValue)) { + int delayBetweenRetriesInSeconds = 3; + int maxTimeExpectingValidResponseInSeconds = 60; + await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), id, actionValue)); mediaAsset.setMediaFiles(executor.executeSync( AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 38cd91490..ebdfd622d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -35,6 +35,8 @@ public class DBConstants { "from [Users].[dbo].[groups_parameters]\n" + "where group_id=%d"; + static final String CURRENCY_CODE_SELECT = "select ID from [Pricing].[dbo].[lu_currency] WHERE CODE3='%s'"; + static final String DISCOUNT_BY_PERCENT = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes] dc \n" + "where dc.discount_percent=%d\n" + // percent amount @@ -62,7 +64,7 @@ public class DBConstants { "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=%d order by UPDATE_DATE DESC"; - static final String PPV_SELECT = "select top 1 * from [Pricing].[dbo].[ppv_modules]\n" + + static final String PPV_SELECT_BY_PRICE_PLAN = "select top 1 * from [Pricing].[dbo].[ppv_modules]\n" + "where [status]=1 and is_active=1\n" + "and group_id=%d and usage_module_code=%d\n" + "order by create_date"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index dd58a9b9c..131e7ae50 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -5,9 +5,7 @@ import com.kaltura.client.enums.SubscriptionDependencyType; import com.kaltura.client.types.*; import org.json.JSONArray; - import java.sql.SQLException; - import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; import static com.kaltura.client.test.utils.dbUtils.DBUtils.ERROR_MESSAGE; @@ -260,7 +258,7 @@ public static Ppv loadSharedCommonPpv(PricePlan pricePlan) { Ppv ppv = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PPV_SELECT, partnerId, + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PPV_SELECT_BY_PRICE_PLAN, partnerId, pricePlan.getId()), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return ppv; @@ -294,7 +292,7 @@ public static Subscription loadShared5MinutesRenewableSubscription() { } subscription = new Subscription(); - subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID)).trim()); subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); subscription.setIsRenewable(false); diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 821e13900..b69bdf49f 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -38,7 +38,7 @@ Migrate features tests from ReadyAPI | email | | | engagement | | | engagementAdapter | | -| entitlement | | +| entitlement | Maksim - in progress | | exportTask | | | externalChannelProfile | | | favorite | | @@ -72,7 +72,7 @@ Migrate features tests from ReadyAPI | ppv | | | priceDetails | | | pricePlan | | -| productPrice | Max - in progress | +| productPrice | Done | | purchaseSettings | | | recommendationProfile | | | recording | | From 2a9403c856a5f628a8d58e233bc20aba47e2397c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 10 Jun 2018 11:33:45 +0300 Subject: [PATCH 335/605] HouseholdResetFrequencyTests --- .../householdTests/HouseholdPurgeTests.java | 76 +++++++++++++ .../HouseholdResetFrequencyTests.java | 105 ++++++++++++++++++ .../householdTests/HouseholdUpdateTests.java | 2 + .../OttUserLoginWithPinTests.java | 21 ++-- .../kaltura/client/test/utils/AssetUtils.java | 2 +- .../client/test/utils/IngestUtils.java | 2 +- src/test/resources/WORK_PLAN.md | 2 +- 7 files changed, 199 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java new file mode 100644 index 000000000..750f34c8f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java @@ -0,0 +1,76 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class HouseholdPurgeTests extends BaseTest { + + private Household household; + private HouseholdUser masterUser; + private String masterUserKs; + + @BeforeClass + private void household_purgeTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 1; + int numberOfDevicesInHousehold = 1; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/purge") + @Test(enabled = false) + private void purge() { + Response booleanResponse = executor.executeSync(HouseholdService.purge(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + System.out.println(household.getId()); + + +// // delete devices until error 1014 return +// List devices = HouseholdUtils.getDevicesListFromHouseHold(household); +// +// executor.executeSync(delete(devices.get(1).getUdid()).setKs(masterUserKs)); +// Response booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); +// assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1014).getCode()); +// +// // reset frequency for household devices +// Response householdResponse = executor.executeSync(resetFrequency(HouseholdFrequencyType.DEVICES) +// .setKs(getOperatorKs()) +// .setUserId(Integer.valueOf(masterUser.getUserId()))); +// assertThat(householdResponse.error).isNull(); +// assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); +// +// // delete additional device to verify frequency was reset +// booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); +// assertThat(booleanResponse.results.booleanValue()).isTrue(); +// +// // assert devices list size = 1 +// devices = HouseholdUtils.getDevicesListFromHouseHold(household); +// assertThat(devices.size()).isEqualTo(1); + } + + @AfterClass + private void household_purgeTests_afterClass() { + // delete household + executor.executeSync(HouseholdService.delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java new file mode 100644 index 000000000..9c8333b42 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java @@ -0,0 +1,105 @@ +package com.kaltura.client.test.tests.servicesTests.householdTests; + +import com.kaltura.client.enums.HouseholdFrequencyType; +import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.services.HouseholdUserService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdDevice; +import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +import static com.kaltura.client.services.HouseholdDeviceService.delete; +import static com.kaltura.client.services.HouseholdService.*; +import static org.assertj.core.api.Assertions.assertThat; + +public class HouseholdResetFrequencyTests extends BaseTest { + + private Household household; + private HouseholdUser masterUser; + private String masterUserKs; + + @BeforeClass + private void household_resetFrequencyTests_beforeClass() { + // set household + int numberOfUsersInHousehold = 3; + int numberOfDevicesInHousehold = 3; + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + + // set masterUserKs + String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/resetFrequency - household devices") + @Test + private void resetFrequency_household_devices() { + // delete devices until error 1014 return + List devices = HouseholdUtils.getDevicesListFromHouseHold(household); + + executor.executeSync(delete(devices.get(1).getUdid()).setKs(masterUserKs)); + Response booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1014).getCode()); + + // reset frequency for household devices + Response householdResponse = executor.executeSync(resetFrequency(HouseholdFrequencyType.DEVICES) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))); + assertThat(householdResponse.error).isNull(); + assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); + + // delete additional device to verify frequency was reset + booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert devices list size = 1 + devices = HouseholdUtils.getDevicesListFromHouseHold(household); + assertThat(devices.size()).isEqualTo(1); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/resetFrequency - household users") + @Test + private void resetFrequency_household_users() { + // delete users until error 1014 return + List users = HouseholdUtils.getRegularUsersListFromHouseHold(household); + + executor.executeSync(HouseholdUserService.delete(users.get(0).getUserId()).setKs(masterUserKs)); + Response booleanResponse = executor.executeSync(HouseholdUserService.delete(users.get(1).getUserId()).setKs(masterUserKs)); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1014).getCode()); + + // reset frequency for household users + Response householdResponse = executor.executeSync(resetFrequency(HouseholdFrequencyType.USERS) + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))); + assertThat(householdResponse.error).isNull(); + assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); + + // delete additional user to verify frequency was reset + booleanResponse = executor.executeSync(HouseholdUserService.delete(users.get(1).getUserId()).setKs(masterUserKs)); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert regular users list size = 1 + users = HouseholdUtils.getRegularUsersListFromHouseHold(household); + assertThat(users.size()).isEqualTo(1); + } + + @AfterClass + private void household_resetFrequencyTests_afterClass() { + // delete household + executor.executeSync(HouseholdService.delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java index 4500bf305..97a20dcc7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java @@ -6,6 +6,7 @@ import com.kaltura.client.types.Household; import com.kaltura.client.types.HouseholdUser; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; @@ -101,6 +102,7 @@ private void update_with_regular_userKs() { @Severity(SeverityLevel.MINOR) @Description("household/action/update - with empty household object") + @Issue("BEO-5169") @Test(enabled = false) private void update_with_empty_household() { // update household diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index b8ed7c1b4..2bb9e5d7b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.UserLoginPin; @@ -12,12 +13,15 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.concurrent.TimeUnit; + import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.services.UserLoginPinService.AddUserLoginPinBuilder; import static com.kaltura.client.services.UserLoginPinService.add; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.given; public class OttUserLoginWithPinTests extends BaseTest { @@ -78,7 +82,7 @@ private void loginWithPin_with_invalid_secret() { @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") - @Test(groups = "slow") + @Test(groups = "slow", enabled = false) private void loginWithPin_with_expired_pinCode() { // add pin AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) @@ -86,15 +90,16 @@ private void loginWithPin_with_expired_pinCode() { .setUserId(Integer.valueOf(user.getId())); userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); + // wait for pin to expire + given().pollThread(Thread::new).pollInterval(15, TimeUnit.SECONDS).await().atMost(3, TimeUnit.MINUTES).until(() -> { + long expire = userLoginPinResponse.results.getExpirationTime(); + long now = BaseUtils.getTimeInEpoch(0); + System.out.println("now: " + now + " " + "expire: " + expire); + return now > expire + 65; + }); + // login with expired pin String pin = userLoginPinResponse.results.getPinCode(); - - // sleep for 1.5 minutes - try { - Thread.sleep(120000); - } catch (InterruptedException e) { - e.printStackTrace(); - } LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pin, null, SECRET); loginResponse = executor.executeSync(loginWithPinOttUserBuilder); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 1ddeef74d..fbded7475 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -33,7 +33,7 @@ public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nul @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); - searchAssetFilter.setKSql(ksql); + searchAssetFilter.setKsql(ksql); searchAssetFilter.setIdIn(idIn); searchAssetFilter.setTypeIn(typeIn); searchAssetFilter.setDynamicOrderBy(dynamicOrderBy); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 07f1a7c3a..fe5a35894 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -190,7 +190,7 @@ public static List ingestEPG(String epgChannelName, Optional= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + assetFilter.setKsql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); int delayBetweenRetriesInSeconds = 3; int maxTimeExpectingValidResponseInSeconds = 60; await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 821e13900..16ad51601 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -44,7 +44,7 @@ Migrate features tests from ReadyAPI | favorite | | | followTvSeries | | | homeNetwork | | -| household | Alon - in progress, actions: add - done, delete - done, get - done, suspend - done, resume - done, resetFrequency, update, purge | +| household | Alon - in progress, actions: add - done, delete - done, get - done, suspend - done, resume - done, resetFrequency - done, update, purge | | householdDevice | | | householdLimitations | | | householdPaymentGateway | | From c10662e56612e1a598c09e40d91d4a562e624a25 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 10 Jun 2018 16:38:22 +0300 Subject: [PATCH 336/605] Fixed running of all tests --- .../tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java | 4 ++-- src/test/resources/testng.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java index b865b57e3..71ed87975 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java @@ -10,9 +10,9 @@ public class SlowTestsRunner extends BaseTest{ @BeforeSuite(groups = "slow_before") - public void setupSlowTests(Method method){ + public void setupSlowTests(){ baseTest_beforeSuite(); - baseTest_beforeMethod(method); + //baseTest_beforeMethod(method); } @Test(groups = "slow", dependsOnGroups = {"slow_before"}) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index de6072904..6c59e529d 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,6 +1,6 @@ - + From 970885a06f23455903a340fb84bdf19bdf041f0a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 10 Jun 2018 16:39:25 +0300 Subject: [PATCH 337/605] Added EntitlementListTests --- .../EntitlementListTests.java | 229 ++++++++++++++++++ .../schemas/SubscriptionEntitlement.json | 6 + 2 files changed, 235 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java new file mode 100644 index 000000000..597cdcb80 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -0,0 +1,229 @@ +package com.kaltura.client.test.tests.servicesTests.entitlementTests; + +import com.kaltura.client.enums.EntityReferenceBy; +import com.kaltura.client.enums.PaymentMethodType; +import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.EntitlementService.ForceCancelEntitlementBuilder; +import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; +import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import java.util.Optional; +import static com.kaltura.client.enums.EntitlementOrderBy.PURCHASE_DATE_ASC; +import static com.kaltura.client.services.HouseholdService.delete; +import static org.assertj.core.api.Assertions.assertThat; + +public class EntitlementListTests extends BaseTest { + + private Household sharedHousehold; + private EntitlementFilter filter; + + private Response> entitlementResponse; + + private final int numberOfUsersInHousehold = 1; + private final int numberOfDevicesInHousehold = 1; + private String classMasterUserKs; + + @BeforeClass + public void setUp() { + sharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + classMasterUserKs = HouseholdUtils.getHouseholdUserKs(sharedHousehold, HouseholdUtils.getDevicesListFromHouseHold(sharedHousehold).get(0).getUdid()); + + filter = new EntitlementFilter(); + filter.setOrderBy(PURCHASE_DATE_ASC.getValue()); + filter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + } + + @Severity(SeverityLevel.NORMAL) + @Description("/entitlement/action/list before purchase") + @Test + public void entitlementListBeforePurchase() { + // subscription + filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + filter.setIsExpiredEqual(false); + ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); + + // ppv + filter.setProductTypeEqual(TransactionType.PPV); + entitlementListBeforePurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); + + //with is expiredEqual: true + filter.setIsExpiredEqual(true); + // ppv + filter.setProductTypeEqual(TransactionType.PPV); + entitlementListBeforePurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); + + // subscription + filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("/entitlement/action/list after purchase") + @Test + public void entitlementListAfterPurchase() { + PurchaseUtils.purchasePpv(classMasterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), + Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); + PurchaseUtils.purchaseSubscription(classMasterUserKs, Integer.valueOf(getSharedCommonSubscription().getId()), + Optional.empty()); + + // subscription + filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + filter.setIsExpiredEqual(false); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); // only sub + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(getSharedCommonSubscription().getId()); + assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isGreaterThan( + entitlementResponse.results.getObjects().get(0).getCurrentDate()); + assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn( + PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + + // ppv + filter.setProductTypeEqual(TransactionType.PPV); + entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); // only Ppv + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(Math.toIntExact(getSharedMediaAsset().getId())); + assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isGreaterThan( + entitlementResponse.results.getObjects().get(0).getCurrentDate()); + assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn( + PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("/entitlement/action/list after forceCancel") + @Test + public void entitlementListAfterForceCancel() { + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); + String masterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), + Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.valueOf(getSharedCommonSubscription().getId()), + Optional.empty()); + + // after purchase + // ppv + filter.setProductTypeEqual(TransactionType.PPV); + filter.setIsExpiredEqual(true); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); + + // subscription + filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); + + // cancel purchases + ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel( + Integer.valueOf(getSharedCommonSubscription().getId()), TransactionType.SUBSCRIPTION); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + forceCancelEntitlementBuilder = EntitlementService.forceCancel(getSharedWebMediaFile().getId(), TransactionType.PPV); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + + // after cancel purchase + // ppv + filter.setProductTypeEqual(TransactionType.PPV); + filter.setIsExpiredEqual(true); + entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); // only Ppv + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(Math.toIntExact(getSharedMediaAsset().getId())); + assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isLessThanOrEqualTo( + entitlementResponse.results.getObjects().get(0).getCurrentDate()); + assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn( + PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + + // subscription + filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); // only sub + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(getSharedCommonSubscription().getId()); + assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isLessThanOrEqualTo( + entitlementResponse.results.getObjects().get(0).getCurrentDate()); + assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn( + PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + } + + @Severity(SeverityLevel.NORMAL) + @Description("/entitlement/action/list paging") + @Test + public void entitlementListWithPaging() { + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + //String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); + String masterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), + Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), + Optional.of(getSharedMobileMediaFile().getId()), Optional.empty()); + + // after purchase + // without paging + filter.setProductTypeEqual(TransactionType.PPV); + filter.setIsExpiredEqual(false); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(2); // 2 files + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(1)).getMediaFileId()).isEqualTo(getSharedMobileMediaFile().getId()); + + // with paging on 1st page + FilterPager pager = new FilterPager(); + pager.setPageSize(1); + pager.setPageIndex(1); + entitlementListAfterPurchase = EntitlementService.list(filter, pager); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(2); // purchased 2 files + assertThat(entitlementResponse.results.getObjects().size()).isEqualTo(1); // only 1st file + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); + + // with paging on 2nd page + pager.setPageIndex(2); + entitlementListAfterPurchase = EntitlementService.list(filter, pager); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(2); // purchased 2 files + assertThat(entitlementResponse.results.getObjects().size()).isEqualTo(1); // only 2nd file + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedMobileMediaFile().getId()); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + } + + @AfterClass + public void tearDown() { + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(sharedHousehold.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + } +} diff --git a/src/test/resources/schemas/SubscriptionEntitlement.json b/src/test/resources/schemas/SubscriptionEntitlement.json index 800dc8869..ac86f8d88 100644 --- a/src/test/resources/schemas/SubscriptionEntitlement.json +++ b/src/test/resources/schemas/SubscriptionEntitlement.json @@ -100,6 +100,12 @@ "enum": [ "KalturaSubscriptionEntitlement" ] + }, + "type": { + "type": "string", + "enum": [ + "subscription" + ] } }, "required": [ From bcf0eb6bc61e4c8247a56fde259e912a14c27d8a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 11 Jun 2018 10:43:06 +0300 Subject: [PATCH 338/605] completed entitlement/list --- .../EntitlementCancelTests.java | 2 - .../EntitlementListTests.java | 106 +++++++++++++----- .../client/test/utils/dbUtils/DBUtils.java | 12 +- src/test/resources/WORK_PLAN.md | 2 +- 4 files changed, 86 insertions(+), 36 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 8bac6fac8..b4914f3d4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -17,9 +17,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import java.util.List; - import static com.kaltura.client.services.EntitlementService.*; import static com.kaltura.client.services.HouseholdService.delete; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index 597cdcb80..1bf53f24e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -25,40 +25,49 @@ public class EntitlementListTests extends BaseTest { - private Household sharedHousehold; private EntitlementFilter filter; + private Household household; + private String masterUserId; + private String masterUserKs; + private String regularUserId; + private String regularUserKs; private Response> entitlementResponse; - private final int numberOfUsersInHousehold = 1; + private final int numberOfUsersInHousehold = 2; private final int numberOfDevicesInHousehold = 1; - private String classMasterUserKs; @BeforeClass public void setUp() { - sharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - classMasterUserKs = HouseholdUtils.getHouseholdUserKs(sharedHousehold, HouseholdUtils.getDevicesListFromHouseHold(sharedHousehold).get(0).getUdid()); - filter = new EntitlementFilter(); filter.setOrderBy(PURCHASE_DATE_ASC.getValue()); filter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); + + household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + regularUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); + regularUserId = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0).getUserId(); } @Severity(SeverityLevel.NORMAL) @Description("/entitlement/action/list before purchase") @Test public void entitlementListBeforePurchase() { + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + String masterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + // subscription filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); filter.setIsExpiredEqual(false); ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(filter, null); - entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); // ppv filter.setProductTypeEqual(TransactionType.PPV); entitlementListBeforePurchase = EntitlementService.list(filter, null); - entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); //with is expiredEqual: true @@ -66,30 +75,34 @@ public void entitlementListBeforePurchase() { // ppv filter.setProductTypeEqual(TransactionType.PPV); entitlementListBeforePurchase = EntitlementService.list(filter, null); - entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); // subscription filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); EntitlementService.list(filter, null); - entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); + entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(0); + + //delete household for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); } @Severity(SeverityLevel.CRITICAL) @Description("/entitlement/action/list after purchase") @Test public void entitlementListAfterPurchase() { - PurchaseUtils.purchasePpv(classMasterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); - PurchaseUtils.purchaseSubscription(classMasterUserKs, Integer.valueOf(getSharedCommonSubscription().getId()), + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.valueOf(getSharedCommonSubscription().getId()), Optional.empty()); // subscription filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); filter.setIsExpiredEqual(false); ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(filter, null); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); // only sub assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(getSharedCommonSubscription().getId()); assertThat(entitlementResponse.results.getObjects().get(0).getEndDate()).isGreaterThan( @@ -100,7 +113,7 @@ public void entitlementListAfterPurchase() { // ppv filter.setProductTypeEqual(TransactionType.PPV); entitlementListAfterPurchase = EntitlementService.list(filter, null); - entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(classMasterUserKs)); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); // only Ppv assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaId()).isEqualTo(Math.toIntExact(getSharedMediaAsset().getId())); @@ -108,16 +121,19 @@ public void entitlementListAfterPurchase() { entitlementResponse.results.getObjects().get(0).getCurrentDate()); assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn( PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); + + //cancel household purchases for cleanup + ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel( + Integer.valueOf(getSharedCommonSubscription().getId()), TransactionType.SUBSCRIPTION); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + forceCancelEntitlementBuilder = EntitlementService.forceCancel(getSharedWebMediaFile().getId(), TransactionType.PPV); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); } @Severity(SeverityLevel.CRITICAL) @Description("/entitlement/action/list after forceCancel") @Test public void entitlementListAfterForceCancel() { - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); - String masterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); PurchaseUtils.purchaseSubscription(masterUserKs, Integer.valueOf(getSharedCommonSubscription().getId()), @@ -168,20 +184,12 @@ public void entitlementListAfterForceCancel() { entitlementResponse.results.getObjects().get(0).getCurrentDate()); assertThat(entitlementResponse.results.getObjects().get(0).getPaymentMethod()).isIn( PaymentMethodType.OFFLINE, PaymentMethodType.UNKNOWN); - - //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); - executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); } @Severity(SeverityLevel.NORMAL) @Description("/entitlement/action/list paging") @Test public void entitlementListWithPaging() { - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - //String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); - String masterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), @@ -215,15 +223,53 @@ public void entitlementListWithPaging() { assertThat(entitlementResponse.results.getObjects().size()).isEqualTo(1); // only 2nd file assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedMobileMediaFile().getId()); - //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); - executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + //cancel household purchases for cleanup + ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel(getSharedWebMediaFile().getId(), TransactionType.PPV); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + forceCancelEntitlementBuilder = EntitlementService.forceCancel(getSharedMobileMediaFile().getId(), TransactionType.PPV); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + } + + @Severity(SeverityLevel.NORMAL) + @Description("/entitlement/action/list paging") + @Test + public void entitlementListByUser() { + EntitlementFilter filter = new EntitlementFilter(); + filter.setEntityReferenceEqual(EntityReferenceBy.USER); + filter.setIsExpiredEqual(false); + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), + Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); + PurchaseUtils.purchaseSubscription(regularUserKs, Integer.valueOf(getSharedCommonSubscription().getId()), + Optional.empty()); + + // after purchase + // by 1st user + filter.setProductTypeEqual(TransactionType.PPV); + ListEntitlementBuilder entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); + + // by 2nd user + filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); + entitlementListAfterPurchase = EntitlementService.list(filter, null); + entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(regularUserKs)); + assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(1); + assertThat(entitlementResponse.results.getObjects().get(0).getProductId()).isEqualTo(getSharedCommonSubscription().getId()); + + //cancel household purchases for cleanup + ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel(getSharedWebMediaFile().getId(), TransactionType.PPV); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + forceCancelEntitlementBuilder = EntitlementService.forceCancel(Integer.valueOf(getSharedCommonSubscription().getId()), TransactionType.SUBSCRIPTION); + executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(regularUserId))); } @AfterClass public void tearDown() { //delete household for cleanup - HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(sharedHousehold.getId())); + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); } } + +// TODO: add tests for collections? \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 4bdcf9292..1317b0a19 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -7,15 +7,16 @@ import com.microsoft.sqlserver.jdbc.SQLServerException; import org.json.JSONArray; import org.json.JSONObject; - import java.sql.*; - import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; public class DBUtils extends BaseUtils { + private static boolean isActivationNeeded = false; + private static boolean isActivationNeededWasLoaded = false; + private static SQLServerDataSource dataSource; private static Connection conn; private static Statement stam; @@ -26,6 +27,9 @@ public class DBUtils extends BaseUtils { public static boolean isActivationOfUsersNeeded() { Logger.getLogger(DBUtils.class).debug("isActivationOfUsersNeeded()"); + if (isActivationNeededWasLoaded) { + return isActivationNeeded; + } int result = -1; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, partnerId), false); @@ -39,8 +43,10 @@ public static boolean isActivationOfUsersNeeded() { e.printStackTrace(); Logger.getLogger(DBUtils.class).error(IS_ACTIVATION_NEEDED + " can't be null"); } + isActivationNeeded = result == 1; + isActivationNeededWasLoaded = true; - return result == 1; + return isActivationNeeded; } public static String getUserData(String userRole) { diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index b69bdf49f..a5d9b8b3f 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -38,7 +38,7 @@ Migrate features tests from ReadyAPI | email | | | engagement | | | engagementAdapter | | -| entitlement | Maksim - in progress | +| entitlement | Maksim - in progress, actions: cancel - CHECK, cancelRenewal, cancelScheduledSubscription, externalReconcile, forceCancel, getNextRenewal, grant - CHECK, list - done, swap, update | exportTask | | | externalChannelProfile | | | favorite | | From ea6b562593bf17ef38db2cb41b92d8a8cb0d528a Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 11 Jun 2018 12:31:01 +0300 Subject: [PATCH 339/605] Updated class - "SearchAssetFilterTests" --- .../SearchAssetFilterTests.java | 101 +++++++++--------- .../client/test/utils/AssetHistoryUtils.java | 1 + 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 1b14db5f1..fe71fd0d8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.services.AssetService; + import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; import com.kaltura.client.test.utils.dbUtils.DBUtils; @@ -38,7 +39,7 @@ public class SearchAssetFilterTests extends BaseTest { private String ksqlQuery; private AssetFilter assetFilter = null; private ListAssetBuilder listAssetBuilder = null; - private HashMap > map = new HashMap<>(); + private HashMap> map = new HashMap<>(); private ArrayList list = new ArrayList<>(); private String tagName = "Genre"; private String tagValue = BaseUtils.getRandomValue(tagName + "_", 999999); @@ -48,14 +49,18 @@ public class SearchAssetFilterTests extends BaseTest { @BeforeClass private void Asset_list_before_class() { // Get asset from shared asset method - asset = BaseTest.getSharedMediaAsset(); list.add(tagValue); map.put(tagName, list); - asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInDate(-100))); - asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map,String.valueOf(BaseUtils.getTimeInDate(-10))); + asset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-100))); + asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-10))); program = IngestUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestUtils.ingestEPG(epgChannelName2, 1).get(0); + + System.out.println("Asset3!! " + asset3.getId()); + System.out.println("Asset2!! " + asset2.getId()); + System.out.println("Asset!! " + asset.getId()); } @@ -197,8 +202,10 @@ private void OrderVodAssetsByViews() { AssetUtils.addViewsToAsset(asset.getId(), 3, AssetType.MEDIA); AssetUtils.addViewsToAsset(asset2.getId(), 2, AssetType.MEDIA); + AssetUtils.addViewsToAsset(asset3.getId(), 1, AssetType.MEDIA); + - ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; + ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) @@ -211,36 +218,37 @@ private void OrderVodAssetsByViews() { assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); } - @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - order by NAME (DESC/ASC") - @Test - private void OrderVodAssetsByName() { - - IngestUtils.updateVODName(asset, "AAA"); - IngestUtils.updateVODName(asset2, "BBB"); - IngestUtils.updateVODName(asset3, "CCC"); - - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); - - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - - Response> assetListResponse = executor.executeSync(listAssetBuilder); - assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); - assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); - assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); - - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); - - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - - assetListResponse = executor.executeSync(listAssetBuilder); - assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); - assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); - assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); - } + //TODO - Enable test after fixing updateVodName method +// @Severity(SeverityLevel.CRITICAL) +// @Description("Asset/action/list - VOD - order by NAME (DESC/ASC") +// @Test +// private void OrderVodAssetsByName() { +// +// IngestUtils.updateVODName(asset, "AAA"); +// IngestUtils.updateVODName(asset2, "BBB"); +// IngestUtils.updateVODName(asset3, "CCC"); +// +// ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; +// assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); +// +// listAssetBuilder = AssetService.list(assetFilter, null) +// .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); +// +// Response> assetListResponse = executor.executeSync(listAssetBuilder); +// assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); +// assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); +// assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); +// +// assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); +// +// listAssetBuilder = AssetService.list(assetFilter, null) +// .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); +// +// assetListResponse = executor.executeSync(listAssetBuilder); +// assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); +// assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); +// assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); +// } @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - order by LIKES") @@ -249,9 +257,9 @@ private void orderVodAssetsByLikes() { AssetUtils.addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); AssetUtils.addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); + AssetUtils.addLikesToAsset(asset.getId(), 1, AssetType.MEDIA); - - ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; + ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) @@ -274,7 +282,7 @@ private void orderVodAssetsByVotesAndRating() { // Order by number of votes (highest to lowest) - ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; + ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); @@ -303,7 +311,7 @@ private void orderVodAssetsByVotesAndRating() { @Test private void orderVodAssetsByCatalogStartDate() { - ksqlQuery = "(or name = '" + asset.getName() + "' name = '" + asset2.getName() + "'name = '" + asset3.getName() + "')"; + ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); @@ -324,18 +332,7 @@ private void orderVodAssetsByCatalogStartDate() { } - @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - with PersistedFilter (search query will return in assetHistory/action/list") - @Test - private void listAssetsWithPersistedFilter() { - - ksqlQuery = "name = ' This is my ksql query with PersistedFilter '"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - } - - + //TODO - add test for KalturaPersistedFilter in searchHistory class // EPG // ****************************************** @@ -345,7 +342,7 @@ private void listAssetsWithPersistedFilter() { @Test private void listEpgProgramWithExactKsqlQuery() { ksqlQuery = "name = '" + program.getName() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, "0", null, null, null, null); listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java index ed08d2e0e..edb2bbdce 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetHistoryUtils.java @@ -13,6 +13,7 @@ public static AssetHistoryFilter getAssetHistoryFilter(@Nullable String assetIdI assetHistoryFilter.setDaysLessThanOrEqual(days); assetHistoryFilter.setStatusEqual(statusEqual); assetHistoryFilter.setTypeIn(typeIn); + assetHistoryFilter.setOrderBy("NONE"); return assetHistoryFilter; From 11b1abf11977ab30debef10ca9b17b5870ae2018 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 11 Jun 2018 16:16:47 +0300 Subject: [PATCH 340/605] no message --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b5757d367..a1b4e5640 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ src/test/resources/test.properties src/test/java/com/kaltura/client/test/tests/Sandbox.java src/test/resources/db_utils_list.txt src/test/resources/utils_list.txt +src/test/resources/testXml.xml From b12979d4b76666b4e13c176534db363742f36f1a Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 11 Jun 2018 16:30:01 +0300 Subject: [PATCH 341/605] additional thread for slow tests --- .../kaltura/client/test/tests/BaseTest.java | 7 ++-- .../SlowTestsRunner/SlowTestsRunner.java | 21 ++--------- .../appTokenTests/AppTokenAddTests.java | 33 +++++++++++------ .../householdTests/HouseholdSuspendTests.java | 21 +++++++---- .../OttUserLoginWithPinTests.java | 33 +++++++++++------ .../client/test/utils/SubscriptionUtils.java | 2 +- src/test/resources/testng.xml | 36 +++++++++---------- 7 files changed, 85 insertions(+), 68 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 032d35d05..ff8a67dd4 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -26,6 +26,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getDevicesListFromHouseHold; import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; import static org.awaitility.Awaitility.setDefaultTimeout; @@ -365,13 +366,13 @@ public static Household getSharedHousehold() { } } - + List sharedHouseholdDevices = getDevicesListFromHouseHold(sharedHousehold); String sharedMasterUserName = getOttUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(); - loginResponse = executor.executeSync(login(partnerId, sharedMasterUserName, defaultUserPassword,null,null)); + loginResponse = executor.executeSync(login(partnerId, sharedMasterUserName, defaultUserPassword,null,sharedHouseholdDevices.get(0).getUdid())); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); String sharedUserName = getOttUserById(Integer.parseInt(sharedUser.getUserId())).getUsername(); - loginResponse = executor.executeSync(login(partnerId, sharedUserName, defaultUserPassword,null,null)); + loginResponse = executor.executeSync(login(partnerId, sharedUserName, defaultUserPassword,null,sharedHouseholdDevices.get(1).getUdid())); sharedUserKs = loginResponse.results.getLoginSession().getKs(); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java index b865b57e3..69cd1f687 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java @@ -4,33 +4,16 @@ import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import java.lang.reflect.Method; - - public class SlowTestsRunner extends BaseTest{ @BeforeSuite(groups = "slow_before") - public void setupSlowTests(Method method){ + public void setupSlowTests(){ baseTest_beforeSuite(); - baseTest_beforeMethod(method); } - @Test(groups = "slow", dependsOnGroups = {"slow_before"}) + @Test(alwaysRun = true, groups = "slow", dependsOnGroups = {"slow_before", "slow_after"}) public void prepareSlowTests(){ - System.out.println("waiting timeout"); - try { - Thread.sleep(60000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("finished timeout"); } - - @Test(alwaysRun = true, groups = "slow", dependsOnGroups = {"slow_after"}, dependsOnMethods = {"prepareSlowTests"}) - public void succedeed(Method method){ - System.out.println("Good shot! Proud of you!"); - } - } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index cf6385990..e6e535809 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -5,24 +5,29 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.APIException; import com.kaltura.client.types.AppToken; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.concurrent.TimeUnit; + import static com.kaltura.client.services.AppTokenService.AddAppTokenBuilder; import static com.kaltura.client.services.AppTokenService.GetAppTokenBuilder; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class AppTokenAddTests extends BaseTest { private String sessionUserId; private AppToken appToken; private String sessionPrivileges; - Response addAppTokenResponseSlowTest; + private Response addAppTokenResponseSlowTest; + private APIException apiException;; // TODO: 5/3/2018 Add comments! @BeforeClass @@ -55,7 +60,7 @@ private void addAppToken() { @Test private void addAppTokenWithDefaultHashType() { appToken = AppTokenUtils.addAppToken(sessionUserId, null, null, null); - + // Invoke AppToken/action/add - with no hash type (will return the default hash type) AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) .setKs(getOperatorKs()); @@ -82,8 +87,8 @@ private void addAppTokenWithPrivileges() { @Test(groups = "slow_before") private void addAppTokenWithExpiryDate_before() { // setup for test - System.out.println("before started"); add_tests_before_class(); + // prepare token with expiration after 1 minute Long expiryDate = BaseUtils.getTimeInEpoch(1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); @@ -95,18 +100,26 @@ private void addAppTokenWithExpiryDate_before() { // Wait until token is expired (according to expiry date) System.out.println("Waiting until token expiry date reached"); - System.out.println("before finished"); } - @Test(groups = "slow_after", dependsOnMethods = "addAppTokenWithExpiryDate_before") + + @Test(groups = "slow_after", dependsOnMethods = "addAppTokenWithExpiryDate_before", priority = 1) private void addAppTokenWithExpiryDate_after() { - System.out.println("after started"); + // prepare builder and variables for await() functionality GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponseSlowTest.results.getId()) .setKs(getOperatorKs()); - Response getAppTokenResponse = executor.executeSync(getAppTokenBuilder); - - assertThat(getAppTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); - System.out.println("after finished"); + int delayBetweenRetriesInSeconds = 10; + int maxTimeExpectingValidResponseInSeconds = 150; + // test that token expired + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + apiException = executor.executeSync(getAppTokenBuilder).error; + return (apiException != null); + }); + + assertThat(apiException.getCode().equals(getAPIExceptionFromList(500055).getCode())); } @Description("appToken/action/add - with no expiry date (return default expiry date -" + diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 841eb6990..da464493f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -15,6 +15,7 @@ import org.testng.annotations.Test; import java.util.Optional; +import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.AssetService.GetPlaybackContextAssetBuilder; import static com.kaltura.client.services.AssetService.getPlaybackContext; @@ -23,6 +24,7 @@ import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.services.OttUserService.login; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class HouseholdSuspendTests extends BaseTest { @@ -409,7 +411,6 @@ private void suspend_with_playback_ppv_role() { @Description("household/action/suspend - with renew_subscription role") @Test(groups = "slow_before") private void suspend_with_renew_subscription_role_before() { - System.out.println("before started"); // setup for test household_suspendTests_beforeClass(); @@ -451,21 +452,29 @@ private void suspend_with_renew_subscription_role_before() { .setUserId(Integer.valueOf(masterUser.getUserId())); Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); assertThat(booleanResponse.results).isTrue(); - System.out.println("before finished"); } - @Test(groups = "slow_after", dependsOnMethods = {"suspend_with_renew_subscription_role_before"}) + @Test(groups = "slow_after", dependsOnMethods = {"suspend_with_renew_subscription_role_before"}, priority = 3) private void suspend_with_renew_subscription_role_after() { - System.out.println("after started"); // get productprice list for asset in subscription - after renew - Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); + Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(fiveMinRenewSubscriptionSlowTest.getId()), Optional.empty()).get(0); ProductPriceFilter assetFilter = new ProductPriceFilter(); assetFilter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 20; + int maxTimeExpectingValidResponseInSeconds = 300; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() ->{ + return (executor.executeSync(ProductPriceService.list(assetFilter) + .setKs(masterUserKsSlowTest)).results.getObjects().get(0).getPurchaseStatus()).equals(PurchaseStatus.FOR_PURCHASE); + }); productPriceListResponseSlowTest = executor.executeSync(ProductPriceService.list(assetFilter) .setKs(masterUserKsSlowTest)); assertThat(productPriceListResponseSlowTest.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceListResponseSlowTest.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); +// assertThat(productPriceListResponseSlowTest.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); // transactionHistory list - verify media file related to subscription billing status = purchase Response> billingTransactionListResponse = executor.executeSync(TransactionHistoryService.list() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index cd8ba50cd..f6ef13c11 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -1,6 +1,8 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.APIException; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.UserLoginPin; @@ -12,12 +14,15 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.concurrent.TimeUnit; + import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.services.UserLoginPinService.AddUserLoginPinBuilder; import static com.kaltura.client.services.UserLoginPinService.add; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class OttUserLoginWithPinTests extends BaseTest { @@ -27,7 +32,7 @@ public class OttUserLoginWithPinTests extends BaseTest { private Response userLoginPinResponse; private final String SECRET = "secret"; - private String pinSlowTest; + private APIException apiException; @BeforeClass private void ottUser_login_tests_setup() { @@ -81,30 +86,36 @@ private void loginWithPin_with_invalid_secret() { @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") @Test(groups = "slow_before") private void loginWithPin_with_expired_pinCode_before() { - System.out.println("before started"); // setup for test ottUser_login_tests_setup(); - // add pin AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(user.getId())); userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); - - // login with expired pin - pinSlowTest = userLoginPinResponse.results.getPinCode(); - System.out.println("before finished"); } - @Test(groups = "slow_after", dependsOnMethods = {"loginWithPin_with_expired_pinCode_before"}) + @Test(groups = "slow_after", dependsOnMethods = {"loginWithPin_with_expired_pinCode_before"}, priority = 2) private void loginWithPin_with_expired_pinCode_after() { - System.out.println("after started"); - LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, pinSlowTest, null, SECRET); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 10; + int maxTimeExpectingValidResponseInSeconds = 200; + // wait for pin to expire + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + long expire = userLoginPinResponse.results.getExpirationTime() + 70; + long now = BaseUtils.getTimeInEpoch(0); + return now > expire; + }); + + LoginWithPinOttUserBuilder loginWithPinOttUserBuilder = loginWithPin(partnerId, userLoginPinResponse.results.getPinCode(), null, SECRET); loginResponse = executor.executeSync(loginWithPinOttUserBuilder); assertThat(loginResponse.results).isNull(); assertThat(loginResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2004).getCode()); - System.out.println("after finished"); + } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java index e663c2ed6..c88f3190b 100644 --- a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java @@ -33,7 +33,7 @@ public static List getAssetsListBySubscription(int subscriptionId, Option assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter, pager).setKs(getOperatorKs())); } else { - assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter).setKs(getOperatorKs())); + assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter).setKs(BaseTest.SharedHousehold.getSharedMasterUserKs())); } // remove assets without media files from list diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index de6072904..029775b07 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,12 +1,12 @@ - + - - + + @@ -16,19 +16,19 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file From 0917c697752ddbd302f408e512263a112ba58c67 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 12 Jun 2018 02:59:15 +0300 Subject: [PATCH 342/605] additions for entitlement/cancel. small refactoring and more logs in ingest --- .../kaltura/client/test/tests/BaseTest.java | 23 ++-- .../EntitlementCancelTests.java | 130 +++++++++++++----- .../EntitlementListTests.java | 2 +- .../client/test/utils/IngestUtils.java | 6 +- 4 files changed, 113 insertions(+), 48 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 032d35d05..2441d4779 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -177,7 +177,6 @@ public static Subscription getSharedCommonSubscription() { * @return Collection with mentioned parameters */ public static Collection getSharedCommonCollection() { - double defaultDiscountPercentValue = 100.0; if (sharedCommonCollection == null) { sharedCommonCollection = IngestFixtureData.loadSharedCommonCollection(getSharedCommonPricePlan()); if (sharedCommonCollection == null) { @@ -304,26 +303,28 @@ public static ProgramAsset getSharedEpgProgram() { public static MediaFile getSharedWebMediaFile() { if (webMediaFile == null) { - if (getProperty(WEB_FILE_TYPE).equals(getSharedMediaAsset().getMediaFiles().get(0).getType())) { - webMediaFile = mediaAsset.getMediaFiles().get(0); - } else { - webMediaFile = mediaAsset.getMediaFiles().get(1); - } + webMediaFile = getMediaFileByType(getSharedMediaAsset(), getProperty(WEB_FILE_TYPE)); } return webMediaFile; } public static MediaFile getSharedMobileMediaFile() { if (mobileMediaFile == null) { - if (getProperty(MOBILE_FILE_TYPE).equals(getSharedMediaAsset().getMediaFiles().get(0).getType())) { - mobileMediaFile = mediaAsset.getMediaFiles().get(0); - } else { - mobileMediaFile = mediaAsset.getMediaFiles().get(1); - } + mobileMediaFile = getMediaFileByType(getSharedMediaAsset(), getProperty(MOBILE_FILE_TYPE)); } return mobileMediaFile; } + public static MediaFile getMediaFileByType(MediaAsset asset, String type) { + MediaFile result; + if (type.equals(asset.getMediaFiles().get(0).getType())) { + result = mediaAsset.getMediaFiles().get(0); + } else { + result = mediaAsset.getMediaFiles().get(1); + } + return result; + } + public static Subscription get5MinRenewableSubscription() { if (fiveMinRenewableSubscription == null) { fiveMinRenewableSubscription = IngestFixtureData.loadShared5MinutesRenewableSubscription(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index b4914f3d4..49234c57f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -1,15 +1,15 @@ package com.kaltura.client.test.tests.servicesTests.entitlementTests; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.*; +import com.kaltura.client.services.ChannelService.AddChannelBuilder; +import com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; +import com.kaltura.client.services.LicensedUrlService.GetLicensedUrlBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.OttUserUtils; -import com.kaltura.client.types.Entitlement; -import com.kaltura.client.types.EntitlementFilter; -import com.kaltura.client.types.Household; -import com.kaltura.client.types.HouseholdUser; +import com.kaltura.client.test.utils.*; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; @@ -18,8 +18,13 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.List; +import java.util.Optional; import static com.kaltura.client.services.EntitlementService.*; import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.Properties.WEB_FILE_TYPE; +import static com.kaltura.client.test.Properties.getProperty; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementCancelTests extends BaseTest { @@ -28,23 +33,42 @@ public class EntitlementCancelTests extends BaseTest { private Household testSharedHousehold; private HouseholdUser testSharedMasterUser; + private BookmarkPlayerData playerData; + private Bookmark bookmark; + private Channel sharedChannel; private final int numberOfUsersInHousehold = 2; private final int numberOfDevicesInHousehold = 1; @BeforeClass - private void cancel_test_before_class() { + public void cancelTestBeforeClass() { subscriptionId = Integer.valueOf(getSharedCommonSubscription().getId()); // set household testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); testSharedMasterUser = HouseholdUtils.getMasterUserFromHousehold(testSharedHousehold); + + playerData = new BookmarkPlayerData(); + playerData.setAction(BookmarkActionType.FIRST_PLAY); + playerData.setAverageBitrate(0); + playerData.setTotalBitrate(0); + playerData.setCurrentBitrate(0); + + bookmark = new Bookmark(); + bookmark.setPosition(0); + bookmark.setType(AssetType.MEDIA); + + sharedChannel = new Channel(); + sharedChannel.setName(BaseUtils.getRandomValue("Channel_", 999999)); + sharedChannel.setDescription("Description of " + sharedChannel.getName()); + sharedChannel.setIsActive(true); + sharedChannel.setAssetTypes(null); } @Severity(SeverityLevel.CRITICAL) @Description("entitlement/action/cancel - cancel subscription") @Test - private void cancel_subscription() { + public void cancelSubscription() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); @@ -52,8 +76,7 @@ private void cancel_subscription() { // grant subscription GrantEntitlementBuilder grantEntitlementBuilder = grant(subscriptionId, TransactionType.SUBSCRIPTION, true, 0) - .setKs(getAdministratorKs()) - .setUserId(Integer.valueOf(masterUser.getUserId())); + .setKs(getAdministratorKs()).setUserId(Integer.valueOf(masterUser.getUserId())); executor.executeSync(grantEntitlementBuilder); // set entitlementFilter @@ -61,20 +84,17 @@ private void cancel_subscription() { filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); // assert entitlement list size == 1 - ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(filter) - .setKs(userKs); + ListEntitlementBuilder listEntitlementBuilder = EntitlementService.list(filter).setKs(userKs); List entitlementList = executor.executeSync(listEntitlementBuilder).results.getObjects(); assertThat(entitlementList.size()).isEqualTo(1); // cancel subscription - CancelEntitlementBuilder cancelEntitlementBuilder = cancel(subscriptionId, TransactionType.SUBSCRIPTION) - .setKs(userKs); + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(subscriptionId, TransactionType.SUBSCRIPTION).setKs(userKs); Response booleanResponse = executor.executeSync(cancelEntitlementBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); // assert entitlement list size == 0 - listEntitlementBuilder = EntitlementService.list(filter) - .setKs(userKs); + listEntitlementBuilder = EntitlementService.list(filter).setKs(userKs); entitlementList = executor.executeSync(listEntitlementBuilder).results.getObjects(); assertThat(entitlementList.size()).isEqualTo(0); @@ -83,37 +103,81 @@ private void cancel_subscription() { } @Severity(SeverityLevel.NORMAL) - @Description("entitlement/action/cancel - cancel invalid subscription - error 3000") + @Description("entitlement/action/cancel - cancel non-purchased subscription - error 3000") @Test - private void cancel_with_invalid_subscription() { + public void cancelWithInvalidSubscription() { // cancel subscription int invalidSubscriptionId = 1; String userKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId()), null); - CancelEntitlementBuilder cancelEntitlementBuilder = cancel(invalidSubscriptionId, TransactionType.SUBSCRIPTION) - .setKs(userKs); - Response booleanResponse = executor.executeSync(cancelEntitlementBuilder); + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(invalidSubscriptionId, TransactionType.SUBSCRIPTION); + Response booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(userKs)); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3000).getCode()); } @Severity(SeverityLevel.NORMAL) @Description("entitlement/action/cancel - cancel played subscription - error 3005") - @Test - private void cancel_played_subscription() { -// // set household -// Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); -// HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); -// String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); - // TODO: 5/23/2018 complete test + @Test(enabled = false) // TODO: as not completed + public void cancelPlayedSubscription() { + // create mpp having at least 1 media on its channel + sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); + Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + sharedChannel.setId(channelResponse.results.getId()); + Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + //HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String masterKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + + PurchaseUtils.purchaseSubscription(masterKs, Integer.valueOf(subscription.getId()), Optional.empty()); + + // get CDN code for media + MediaFile mediaFile = getMediaFileByType(getSharedMediaAsset(), getProperty(WEB_FILE_TYPE)); + String cdnCode = mediaFile.getCdnCode(); + + // check license for play + LicensedUrlMediaRequest licensedUrlRequest = new LicensedUrlMediaRequest(); + licensedUrlRequest.setAssetId(String.valueOf(getSharedMediaAsset().getId())); + licensedUrlRequest.setContentId(mediaFile.getId()); + licensedUrlRequest.setBaseUrl(cdnCode); + GetLicensedUrlBuilder licensedUrlBuilder = LicensedUrlService.get(licensedUrlRequest); + Response urlResponse = executor.executeSync(licensedUrlBuilder.setKs(masterKs)); + assertThat(urlResponse.results).isNotNull(); + // play + playerData.setFileId(mediaFile.getId().longValue()); + bookmark.setPlayerData(playerData); + bookmark.setId(String.valueOf(getSharedMediaAsset().getId())); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + Response booleanResponse = executor.executeSync(addBookmarkBuilder.setKs(masterKs)); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // try cancel + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.valueOf(subscription.getId()), + TransactionType.SUBSCRIPTION); + booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(masterKs)); + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3005).getCode()); + // TODO: 5/23/2018 complete test + + // delete household for cleanup + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); + //delete subscription + IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } @AfterClass - private void cancel_test_after_class() { + public void cancelTestAfterClass() { // delete shared household for cleanup executor.executeSync(delete(Math.toIntExact(testSharedHousehold.getId())).setKs(getAdministratorKs())); } - - // TODO: 5/22/2018 add cancel ppv test with dynamic data } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index 1bf53f24e..7046c6156 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -272,4 +272,4 @@ public void tearDown() { } } -// TODO: add tests for collections? \ No newline at end of file +// TODO: add tests for collections? A: Yes. Examples can be found in BaseTest.getSharedCommonCollection() \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index a1c700563..88a204670 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -418,7 +418,7 @@ public static Subscription ingestMPP(Optional action, Optional m .body(reqBody) .post(url); - //Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug(reqBody); Logger.getLogger(IngestUtils.class).debug(resp.asString()); String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); @@ -691,8 +691,8 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O .log().all() .get(url); - System.out.println(resp.asString()); - System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + Logger.getLogger(IngestUtils.class).debug(resp.asString().split(" = ")[1].replaceAll("\\.", "")); String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); From 120c448d4c23243f2ff30b9756a21f354a2b9677 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 12 Jun 2018 11:36:26 +0300 Subject: [PATCH 343/605] no message --- .../householdTests/HouseholdSuspendTests.java | 11 ++++++----- src/test/resources/testng.xml | 16 ++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index da464493f..6b4f905f3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -56,6 +56,9 @@ private void household_suspendTests_beforeClass() { // set subscription subscription = BaseTest.getSharedCommonSubscription(); + // set subscription with 5 min renew + fiveMinRenewSubscriptionSlowTest = get5MinRenewableSubscription(); + // set asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty()).get(0); } @@ -432,7 +435,6 @@ private void suspend_with_renew_subscription_role_before() { roleSlowTest = userRoleResponse.results; // purchase subscription - fiveMinRenewSubscriptionSlowTest = get5MinRenewableSubscription(); int fiveMinRenewSubscriptionId = Integer.parseInt(fiveMinRenewSubscriptionSlowTest.getId().trim()); PurchaseUtils.purchaseSubscription(masterUserKsSlowTest, fiveMinRenewSubscriptionId, Optional.empty()); @@ -467,10 +469,9 @@ private void suspend_with_renew_subscription_role_after() { await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(() ->{ - return (executor.executeSync(ProductPriceService.list(assetFilter) - .setKs(masterUserKsSlowTest)).results.getObjects().get(0).getPurchaseStatus()).equals(PurchaseStatus.FOR_PURCHASE); - }); + .until(() -> (executor.executeSync(ProductPriceService.list(assetFilter) + .setKs(masterUserKsSlowTest)).results.getObjects().get(0).getPurchaseStatus()).equals(PurchaseStatus.FOR_PURCHASE)); + productPriceListResponseSlowTest = executor.executeSync(ProductPriceService.list(assetFilter) .setKs(masterUserKsSlowTest)); assertThat(productPriceListResponseSlowTest.results.getTotalCount()).isEqualTo(1); diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 029775b07..f1667b48f 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -24,11 +24,15 @@ - - - - - - + + + + + + + + + + \ No newline at end of file From a7975b087e7d60180ca010dd48c1b063087028f0 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 12 Jun 2018 14:19:10 +0300 Subject: [PATCH 344/605] DBUtils refactoring to support multi thread --- pom.xml | 6 + .../PermissionsManagementTests.java | 740 +++++++++--------- .../kaltura/client/test/utils/AssetUtils.java | 2 +- .../client/test/utils/IngestUtils.java | 2 +- .../test/utils/PermissionManagementUtils.java | 306 ++++---- .../test/utils/dbUtils/DBConstants.java | 2 - .../client/test/utils/dbUtils/DBUtils.java | 210 +++-- .../dbUtils/PermissionsManagementDBUtils.java | 636 +++++++-------- 8 files changed, 946 insertions(+), 958 deletions(-) diff --git a/pom.xml b/pom.xml index 10f55daae..191e382e7 100644 --- a/pom.xml +++ b/pom.xml @@ -202,6 +202,12 @@ 25.0-jre + + commons-dbutils + commons-dbutils + 1.7 + + diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 490271b1a..26175d93c 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -1,370 +1,370 @@ -package com.kaltura.client.test.tests.featuresTests.versions.four_eight; - -import com.kaltura.client.test.utils.PermissionManagementUtils; -import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; -import io.qameta.allure.Description; -import io.qameta.allure.Severity; -import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import static com.kaltura.client.test.utils.BaseUtils.deleteFile; -import static com.kaltura.client.test.utils.BaseUtils.getFileContent; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; -import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; -import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; -import static org.assertj.core.api.Assertions.assertThat; - -/** - * - * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 - */ -public class PermissionsManagementTests { - - String mainFile = "PermissionsDeployment.exe"; - // that file generated automatically - String path2Log = "C:\\log\\permissions\\permissions.log"; - String path2Util = "C:\\123\\222\\"; - - // these files are generated - String dataFilePath = path2Util + "333\\" + "exp1.txt"; - String generatedDataFilePath = path2Util + "333\\" + "import.txt"; - - // these files added into project - String importOnly4TablesFilePath; - String path2EmptyFile; - - @BeforeClass - public void setUp() { - ClassLoader classLoader = PermissionsManagementTests.class.getClassLoader(); - File file = new File(classLoader.getResource("permission_management_data/empty_file.txt").getFile()); - path2EmptyFile = file.getAbsolutePath(); - file = new File(classLoader.getResource("permission_management_data/importOnly4Tables.txt").getFile()); - importOnly4TablesFilePath = file.getAbsolutePath(); - } - - public static final String EXPORT_KEY = "e="; - public static final String IMPORT_KEY = "i="; - public static final String DELETE_KEY = "d="; - - @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util without parameters") - public void runningWithoutParameters() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - String consoleOutput = executeCommandsInColsole(commands); - - assertThat(consoleOutput).contains("Permissions deployment tool"); - assertThat(consoleOutput).contains("Shortcut: e"); - assertThat(consoleOutput).contains("Shortcut: i"); - } - - @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") - public void runningExportWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(EXPORT_KEY); - String consoleOutput = executeCommandsInColsole(commands); - - assertThat(consoleOutput).contains("The system cannot find the file specified"); - } - - @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") - public void runningImportWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY); - String consoleOutput = executeCommandsInColsole(commands); - - assertThat(consoleOutput).contains("The system cannot find the file specified"); - } - - @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") - public void runningDeleteWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY); - String consoleOutput = executeCommandsInColsole(commands); - - assertThat(consoleOutput).contains("The system cannot find the file specified"); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") - public void export() { - // prepare data inserting them in DB using stored procedures - String suffix = String.valueOf(getTimeInEpoch(0)); - PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix); - - // export from DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(EXPORT_KEY + dataFilePath); - executeCommandsInColsole(commands); - - // checks that created file contains inserted data - String fileContent = getFileContent(dataFilePath); - assertThat(fileContent).contains("MaxTest" + suffix); - assertThat(fileContent).contains("Asset_List_Max" + suffix); - assertThat(fileContent).contains("permissionItemObject" + suffix); - assertThat(fileContent).contains("parameter" + suffix); - } - - @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from file having only 4 tables instead of 5") - public void runningImportFromFileNotHavingAllTables() { - // remove log file - deleteFile(path2Log); - - // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + importOnly4TablesFilePath); - executeCommandsInColsole(commands); - - String fileContent = getFileContent(path2Log); - assertThat(fileContent).contains("Import failed: reading from XML resulted in empty data set or data set with less than 5 tables"); - } - - @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to try import data into DB from empty file") - public void runningImportFromEmptyFile() { - // remove log file - deleteFile(path2Log); - - // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + path2EmptyFile); - executeCommandsInColsole(commands); - - String fileContent = getFileContent(path2Log); - assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); - } - - @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to try delete data from DB using empty file") - public void runningDeleteUsingEmptyFile() { - // remove log file - deleteFile(path2Log); - - // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + path2EmptyFile); - executeCommandsInColsole(commands); - - String fileContent = getFileContent(path2Log); - assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") - public void importFromFile() { - String suffix = String.valueOf(getTimeInEpoch(0)); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); - - // import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); - - // check data in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); - assertThat(rowsInRolesHavingName).isEqualTo(1); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); - - int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); - assertThat(rowsInPermissionsHavingName).isEqualTo(1); - int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); - - int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); - assertThat(idRolePermission).isEqualTo(1); - - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); - assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); - - int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, - idPermissionItemHavingName, 0); - assertThat(rowsInPermissionsPermissions).isEqualTo(1); - } - - @Severity(SeverityLevel.NORMAL) - @Test(groups = {"Permission management"}, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") - public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { - // remove log file - deleteFile(path2Log); - - // insert data in DB - String suffix = String.valueOf(getTimeInEpoch(0)) + "inserted"; - PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); - - // generate import file data - suffix = String.valueOf(getTimeInEpoch(0)); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); - - // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + path2EmptyFile); - executeCommandsInColsole(commands); - - String fileContent = getFileContent(path2Log); - assertThat(fileContent).contains("!!NOT EXISTS IN SOURCE!! Table : role Id : " + idRoleHavingName + " Name : " + "MaxTest" + suffix); - assertThat(fileContent).contains("Asset_List_Max" + suffix); - assertThat(fileContent).contains("permissionItemObject" + suffix); - assertThat(fileContent).contains("parameter" + suffix); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") - public void deleteFromDB() { - String suffix = String.valueOf(getTimeInEpoch(0)); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); - - // import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); - - // check data in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); - assertThat(rowsInRolesHavingName).isEqualTo(1); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); - - int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); - assertThat(rowsInPermissionsHavingName).isEqualTo(1); - int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); - - int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); - assertThat(idRolePermission).isEqualTo(1); - - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); - assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); - - int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, - idPermissionItemHavingName, 0); - assertThat(rowsInPermissionsPermissions).isEqualTo(1); - - // remove log file - deleteFile(path2Log); - - // delete from DB - commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); - - // DB should be empty - rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); - assertThat(rowsInRolesHavingName).isEqualTo(0); - - rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); - assertThat(rowsInPermissionsHavingName).isEqualTo(0); - - rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); - assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") - public void importAlreadyExistedFromFile() { - String suffix = String.valueOf(getTimeInEpoch(0)); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); - - // import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); - - // retry import - executeCommandsInColsole(commands); - - // check data in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); - assertThat(rowsInRolesHavingName).isEqualTo(1); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); - - int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); - assertThat(rowsInPermissionsHavingName).isEqualTo(1); - int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); - - int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); - assertThat(idRolePermission).isEqualTo(1); - - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); - assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); - - int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, - idPermissionItemHavingName, 0); - assertThat(rowsInPermissionsPermissions).isEqualTo(1); - } - - @Severity(SeverityLevel.NORMAL) - @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") - public void runningDeleteUsingFileWithInvalidTags() { - // insert role in DB - String suffix = String.valueOf(getTimeInEpoch(0)); - PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); - - PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); - - // try delete - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); - - // check data still in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); - assertThat(rowsInRolesHavingName).isEqualTo(1); - } - - @Severity(SeverityLevel.NORMAL) - @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") - public void deleteOnlyFromOneTable() { - // insert role in DB - String suffix = String.valueOf(getTimeInEpoch(0)); - PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); - - PermissionManagementUtils.generateFileForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); - - // delete - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); - - // check data deleted from DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); - assertThat(rowsInRolesHavingName).isEqualTo(0); - } -} +//package com.kaltura.client.test.tests.featuresTests.versions.four_eight; +// +//import com.kaltura.client.test.utils.PermissionManagementUtils; +//import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +//import io.qameta.allure.Description; +//import io.qameta.allure.Severity; +//import io.qameta.allure.SeverityLevel; +//import org.testng.annotations.BeforeClass; +//import org.testng.annotations.Test; +// +//import java.io.File; +//import java.util.ArrayList; +//import java.util.List; +// +//import static com.kaltura.client.test.utils.BaseUtils.deleteFile; +//import static com.kaltura.client.test.utils.BaseUtils.getFileContent; +//import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +//import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; +//import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; +//import static org.assertj.core.api.Assertions.assertThat; +// +///** +// * +// * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 +// */ +//public class PermissionsManagementTests { +// +// String mainFile = "PermissionsDeployment.exe"; +// // that file generated automatically +// String path2Log = "C:\\log\\permissions\\permissions.log"; +// String path2Util = "C:\\123\\222\\"; +// +// // these files are generated +// String dataFilePath = path2Util + "333\\" + "exp1.txt"; +// String generatedDataFilePath = path2Util + "333\\" + "import.txt"; +// +// // these files added into project +// String importOnly4TablesFilePath; +// String path2EmptyFile; +// +// @BeforeClass +// public void setUp() { +// ClassLoader classLoader = PermissionsManagementTests.class.getClassLoader(); +// File file = new File(classLoader.getResource("permission_management_data/empty_file.txt").getFile()); +// path2EmptyFile = file.getAbsolutePath(); +// file = new File(classLoader.getResource("permission_management_data/importOnly4Tables.txt").getFile()); +// importOnly4TablesFilePath = file.getAbsolutePath(); +// } +// +// public static final String EXPORT_KEY = "e="; +// public static final String IMPORT_KEY = "i="; +// public static final String DELETE_KEY = "d="; +// +// @Severity(SeverityLevel.MINOR) +// @Test(groups = {"Permission management"}, description = "execute console util without parameters") +// public void runningWithoutParameters() { +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// String consoleOutput = executeCommandsInColsole(commands); +// +// assertThat(consoleOutput).contains("Permissions deployment tool"); +// assertThat(consoleOutput).contains("Shortcut: e"); +// assertThat(consoleOutput).contains("Shortcut: i"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") +// public void runningExportWithoutFile() { +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(EXPORT_KEY); +// String consoleOutput = executeCommandsInColsole(commands); +// +// assertThat(consoleOutput).contains("The system cannot find the file specified"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") +// public void runningImportWithoutFile() { +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(IMPORT_KEY); +// String consoleOutput = executeCommandsInColsole(commands); +// +// assertThat(consoleOutput).contains("The system cannot find the file specified"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") +// public void runningDeleteWithoutFile() { +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(DELETE_KEY); +// String consoleOutput = executeCommandsInColsole(commands); +// +// assertThat(consoleOutput).contains("The system cannot find the file specified"); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") +// public void export() { +// // prepare data inserting them in DB using stored procedures +// String suffix = String.valueOf(getTimeInEpoch(0)); +// PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", +// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, +// "parameter" + suffix); +// +// // export from DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(EXPORT_KEY + dataFilePath); +// executeCommandsInColsole(commands); +// +// // checks that created file contains inserted data +// String fileContent = getFileContent(dataFilePath); +// assertThat(fileContent).contains("MaxTest" + suffix); +// assertThat(fileContent).contains("Asset_List_Max" + suffix); +// assertThat(fileContent).contains("permissionItemObject" + suffix); +// assertThat(fileContent).contains("parameter" + suffix); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from file having only 4 tables instead of 5") +// public void runningImportFromFileNotHavingAllTables() { +// // remove log file +// deleteFile(path2Log); +// +// // try to import into DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(IMPORT_KEY + importOnly4TablesFilePath); +// executeCommandsInColsole(commands); +// +// String fileContent = getFileContent(path2Log); +// assertThat(fileContent).contains("Import failed: reading from XML resulted in empty data set or data set with less than 5 tables"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(groups = {"Permission management"}, description = "execute console util to try import data into DB from empty file") +// public void runningImportFromEmptyFile() { +// // remove log file +// deleteFile(path2Log); +// +// // try to import into DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(IMPORT_KEY + path2EmptyFile); +// executeCommandsInColsole(commands); +// +// String fileContent = getFileContent(path2Log); +// assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(groups = {"Permission management"}, description = "execute console util to try delete data from DB using empty file") +// public void runningDeleteUsingEmptyFile() { +// // remove log file +// deleteFile(path2Log); +// +// // try to import into DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(DELETE_KEY + path2EmptyFile); +// executeCommandsInColsole(commands); +// +// String fileContent = getFileContent(path2Log); +// assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") +// public void importFromFile() { +// String suffix = String.valueOf(getTimeInEpoch(0)); +// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", +// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, +// "parameter" + suffix, 1, 2, 3, 4, 5); +// +// // import into DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(IMPORT_KEY + generatedDataFilePath); +// executeCommandsInColsole(commands); +// +// // check data in DB +// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); +// assertThat(rowsInRolesHavingName).isEqualTo(1); +// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); +// +// int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); +// assertThat(rowsInPermissionsHavingName).isEqualTo(1); +// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); +// +// int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); +// assertThat(idRolePermission).isEqualTo(1); +// +// int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); +// assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); +// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); +// +// int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, +// idPermissionItemHavingName, 0); +// assertThat(rowsInPermissionsPermissions).isEqualTo(1); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(groups = {"Permission management"}, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") +// public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { +// // remove log file +// deleteFile(path2Log); +// +// // insert data in DB +// String suffix = String.valueOf(getTimeInEpoch(0)) + "inserted"; +// PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", +// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, +// "parameter" + suffix); +// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); +// +// // generate import file data +// suffix = String.valueOf(getTimeInEpoch(0)); +// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", +// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, +// "parameter" + suffix, 1, 2, 3, 4, 5); +// +// // try to import into DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(DELETE_KEY + path2EmptyFile); +// executeCommandsInColsole(commands); +// +// String fileContent = getFileContent(path2Log); +// assertThat(fileContent).contains("!!NOT EXISTS IN SOURCE!! Table : role Id : " + idRoleHavingName + " Name : " + "MaxTest" + suffix); +// assertThat(fileContent).contains("Asset_List_Max" + suffix); +// assertThat(fileContent).contains("permissionItemObject" + suffix); +// assertThat(fileContent).contains("parameter" + suffix); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") +// public void deleteFromDB() { +// String suffix = String.valueOf(getTimeInEpoch(0)); +// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", +// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, +// "parameter" + suffix, 1, 2, 3, 4, 5); +// +// // import into DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(IMPORT_KEY + generatedDataFilePath); +// executeCommandsInColsole(commands); +// +// // check data in DB +// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); +// assertThat(rowsInRolesHavingName).isEqualTo(1); +// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); +// +// int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); +// assertThat(rowsInPermissionsHavingName).isEqualTo(1); +// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); +// +// int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); +// assertThat(idRolePermission).isEqualTo(1); +// +// int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); +// assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); +// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); +// +// int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, +// idPermissionItemHavingName, 0); +// assertThat(rowsInPermissionsPermissions).isEqualTo(1); +// +// // remove log file +// deleteFile(path2Log); +// +// // delete from DB +// commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(DELETE_KEY + generatedDataFilePath); +// executeCommandsInColsole(commands); +// +// // DB should be empty +// rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); +// assertThat(rowsInRolesHavingName).isEqualTo(0); +// +// rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); +// assertThat(rowsInPermissionsHavingName).isEqualTo(0); +// +// rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); +// assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") +// public void importAlreadyExistedFromFile() { +// String suffix = String.valueOf(getTimeInEpoch(0)); +// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", +// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, +// "parameter" + suffix, 1, 2, 3, 4, 5); +// +// // import into DB +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(IMPORT_KEY + generatedDataFilePath); +// executeCommandsInColsole(commands); +// +// // retry import +// executeCommandsInColsole(commands); +// +// // check data in DB +// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); +// assertThat(rowsInRolesHavingName).isEqualTo(1); +// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); +// +// int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); +// assertThat(rowsInPermissionsHavingName).isEqualTo(1); +// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); +// +// int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); +// assertThat(idRolePermission).isEqualTo(1); +// +// int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); +// assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); +// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); +// +// int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, +// idPermissionItemHavingName, 0); +// assertThat(rowsInPermissionsPermissions).isEqualTo(1); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") +// public void runningDeleteUsingFileWithInvalidTags() { +// // insert role in DB +// String suffix = String.valueOf(getTimeInEpoch(0)); +// PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); +// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); +// +// PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); +// +// // try delete +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(DELETE_KEY + generatedDataFilePath); +// executeCommandsInColsole(commands); +// +// // check data still in DB +// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); +// assertThat(rowsInRolesHavingName).isEqualTo(1); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") +// public void deleteOnlyFromOneTable() { +// // insert role in DB +// String suffix = String.valueOf(getTimeInEpoch(0)); +// PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); +// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); +// +// PermissionManagementUtils.generateFileForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); +// +// // delete +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(DELETE_KEY + generatedDataFilePath); +// executeCommandsInColsole(commands); +// +// // check data deleted from DB +// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); +// assertThat(rowsInRolesHavingName).isEqualTo(0); +// } +//} diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index b349fdc03..ed1ea4748 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -33,7 +33,7 @@ public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nul @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); - searchAssetFilter.setKsql(ksql); + searchAssetFilter.setKSql(ksql); searchAssetFilter.setIdIn(idIn); searchAssetFilter.setTypeIn(typeIn); searchAssetFilter.setDynamicOrderBy(dynamicOrderBy); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index e27d80a56..79662c788 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -190,7 +190,7 @@ public static List ingestEPG(String epgChannelName, Optional= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); int delayBetweenRetriesInSeconds = 3; int maxTimeExpectingValidResponseInSeconds = 60; await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index be97f5558..096742dbf 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -1,153 +1,153 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; -import java.io.*; -import java.util.List; - -public class PermissionManagementUtils extends BaseUtils { - - public static void printPermissionPermissionItem(PrintWriter writer, long id, long permissionId, long permissionItemId, - int isExcluded, String permissionItemName, String permissionName) { - writer.println(""); - writer.println("" + id + ""); - writer.println("" + permissionId + ""); - writer.println("" + permissionItemId + ""); - writer.println("" + isExcluded + ""); - writer.println("" + permissionItemName + ""); - writer.println("" + permissionName + ""); - writer.println(""); - } - - public static void printPermissionItem(PrintWriter writer, long id, String name, int type, String service, String action, - String object, String parameter) { - writer.println(""); - writer.println("" + id + ""); - writer.println("" + name + ""); - writer.println("" + type + ""); - writer.println("" + service + ""); - writer.println("" + action + ""); - writer.println("" + object + ""); - writer.println("" + parameter + ""); - writer.println(""); - } - - public static void printPermission(PrintWriter writer, long id, String name, int type, String usersGroup) { - writer.println(""); - writer.println("" + id + ""); - writer.println("" + name + ""); - writer.println("" + type + ""); - writer.println("" + usersGroup + ""); - writer.println(""); - } - - public static void printRolePermission(PrintWriter writer, long permissionRoleId, long roleId, long permissionId, - int isExcluded, String roleName, String permissionName) { - writer.println(""); - writer.println("" + permissionRoleId + ""); - writer.println("" + roleId + ""); - writer.println("" + permissionId + ""); - writer.println("" + isExcluded + ""); - writer.println("" + roleName + ""); - writer.println("" + permissionName + ""); - writer.println(""); - } - - public static void printRole(PrintWriter writer, Long roleId, String roleName) { - writer.println(""); - writer.println("" + roleId + ""); - writer.println("" + roleName + ""); - writer.println(""); - } - - public static String executeCommandsInColsole(List commands) { - StringBuilder output = new StringBuilder(); - - ProcessBuilder pb = new ProcessBuilder(commands); - pb.redirectErrorStream(true); - BufferedReader inStreamReader; - try { - Process process = pb.start(); - inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream())); - String line; - while((line = inStreamReader.readLine()) != null){ - output.append(line); - } - } catch (IOException e) { - e.printStackTrace(); - output.append(e.getMessage()); - } - - return output.toString(); - } - - public static void insertDataInAllTables(String path2ResultFile, String role, String usersGroup, String permissionItemName, - String service, String action, String permissionItemObject, String parameter) { - long roleId = PermissionsManagementDBUtils.insertRole(role); - long permissionId = PermissionsManagementDBUtils.insertPermission(role, 2, usersGroup); - long permissionRoleId = PermissionsManagementDBUtils.insertPermissionRole(roleId, permissionId, 0); - - long permissionItemId = PermissionsManagementDBUtils.insertPermissionItem(permissionItemName, 1, service, action, permissionItemObject, parameter); - long permissionPermissionItemId = PermissionsManagementDBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); - - generateFileWithInsertedIntoDBData(path2ResultFile, role, usersGroup, permissionItemName, service, action, - permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId); - } - - public static void generateFileWithInsertedIntoDBData(String path2ResultFile, String role, String usersGroup, String permissionItemName, - String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, - long permissionRoleId, long permissionItemId, long permissionPermissionItemId) { - try { - File file = new File(path2ResultFile); - PrintWriter writer = new PrintWriter(file); - printOpenTag(writer); - printRole(writer, roleId, role); - printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); - printPermission(writer, permissionId, role, 2, usersGroup); - printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); - printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); - printCloseTag(writer); - writer.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - public static void generateFileWithInvalidTagForRole(String path2ResultFile, String roleName, int roleId) { - try { - File file = new File(path2ResultFile); - PrintWriter writer = new PrintWriter(file); - printOpenTag(writer); - writer.println(""); // this 1 here to make tag invalid - writer.println("" + roleId + ""); - writer.println("" + roleName + ""); - writer.println(""); // this 1 here to make tag invalid - printCloseTag(writer); - writer.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - private static void printOpenTag(PrintWriter writer) { - writer.println(""); - writer.println(""); - } - - private static void printCloseTag(PrintWriter writer) { - writer.println(""); - } - - public static void generateFileForRole(String path2ResultFile, String roleName, long roleId) { - try { - File file = new File(path2ResultFile); - PrintWriter writer = new PrintWriter(file); - printOpenTag(writer); - printRole(writer, roleId, roleName); - printCloseTag(writer); - writer.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } -} - +//package com.kaltura.client.test.utils; +// +//import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +//import java.io.*; +//import java.util.List; +// +//public class PermissionManagementUtils extends BaseUtils { +// +// public static void printPermissionPermissionItem(PrintWriter writer, long id, long permissionId, long permissionItemId, +// int isExcluded, String permissionItemName, String permissionName) { +// writer.println(""); +// writer.println("" + id + ""); +// writer.println("" + permissionId + ""); +// writer.println("" + permissionItemId + ""); +// writer.println("" + isExcluded + ""); +// writer.println("" + permissionItemName + ""); +// writer.println("" + permissionName + ""); +// writer.println(""); +// } +// +// public static void printPermissionItem(PrintWriter writer, long id, String name, int type, String service, String action, +// String object, String parameter) { +// writer.println(""); +// writer.println("" + id + ""); +// writer.println("" + name + ""); +// writer.println("" + type + ""); +// writer.println("" + service + ""); +// writer.println("" + action + ""); +// writer.println("" + object + ""); +// writer.println("" + parameter + ""); +// writer.println(""); +// } +// +// public static void printPermission(PrintWriter writer, long id, String name, int type, String usersGroup) { +// writer.println(""); +// writer.println("" + id + ""); +// writer.println("" + name + ""); +// writer.println("" + type + ""); +// writer.println("" + usersGroup + ""); +// writer.println(""); +// } +// +// public static void printRolePermission(PrintWriter writer, long permissionRoleId, long roleId, long permissionId, +// int isExcluded, String roleName, String permissionName) { +// writer.println(""); +// writer.println("" + permissionRoleId + ""); +// writer.println("" + roleId + ""); +// writer.println("" + permissionId + ""); +// writer.println("" + isExcluded + ""); +// writer.println("" + roleName + ""); +// writer.println("" + permissionName + ""); +// writer.println(""); +// } +// +// public static void printRole(PrintWriter writer, Long roleId, String roleName) { +// writer.println(""); +// writer.println("" + roleId + ""); +// writer.println("" + roleName + ""); +// writer.println(""); +// } +// +// public static String executeCommandsInColsole(List commands) { +// StringBuilder output = new StringBuilder(); +// +// ProcessBuilder pb = new ProcessBuilder(commands); +// pb.redirectErrorStream(true); +// BufferedReader inStreamReader; +// try { +// Process process = pb.start(); +// inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream())); +// String line; +// while((line = inStreamReader.readLine()) != null){ +// output.append(line); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// output.append(e.getMessage()); +// } +// +// return output.toString(); +// } +// +// public static void insertDataInAllTables(String path2ResultFile, String role, String usersGroup, String permissionItemName, +// String service, String action, String permissionItemObject, String parameter) { +// long roleId = PermissionsManagementDBUtils.insertRole(role); +// long permissionId = PermissionsManagementDBUtils.insertPermission(role, 2, usersGroup); +// long permissionRoleId = PermissionsManagementDBUtils.insertPermissionRole(roleId, permissionId, 0); +// +// long permissionItemId = PermissionsManagementDBUtils.insertPermissionItem(permissionItemName, 1, service, action, permissionItemObject, parameter); +// long permissionPermissionItemId = PermissionsManagementDBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); +// +// generateFileWithInsertedIntoDBData(path2ResultFile, role, usersGroup, permissionItemName, service, action, +// permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId); +// } +// +// public static void generateFileWithInsertedIntoDBData(String path2ResultFile, String role, String usersGroup, String permissionItemName, +// String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, +// long permissionRoleId, long permissionItemId, long permissionPermissionItemId) { +// try { +// File file = new File(path2ResultFile); +// PrintWriter writer = new PrintWriter(file); +// printOpenTag(writer); +// printRole(writer, roleId, role); +// printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); +// printPermission(writer, permissionId, role, 2, usersGroup); +// printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); +// printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); +// printCloseTag(writer); +// writer.close(); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } +// } +// +// public static void generateFileWithInvalidTagForRole(String path2ResultFile, String roleName, int roleId) { +// try { +// File file = new File(path2ResultFile); +// PrintWriter writer = new PrintWriter(file); +// printOpenTag(writer); +// writer.println(""); // this 1 here to make tag invalid +// writer.println("" + roleId + ""); +// writer.println("" + roleName + ""); +// writer.println(""); // this 1 here to make tag invalid +// printCloseTag(writer); +// writer.close(); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } +// } +// +// private static void printOpenTag(PrintWriter writer) { +// writer.println(""); +// writer.println(""); +// } +// +// private static void printCloseTag(PrintWriter writer) { +// writer.println(""); +// } +// +// public static void generateFileForRole(String path2ResultFile, String roleName, long roleId) { +// try { +// File file = new File(path2ResultFile); +// PrintWriter writer = new PrintWriter(file); +// printOpenTag(writer); +// printRole(writer, roleId, roleName); +// printCloseTag(writer); +// writer.close(); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } +// } +//} +// diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index ebdfd622d..2bc0d6e5e 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -115,8 +115,6 @@ public class DBConstants { // TODO: find instead of and u.username <> 'lfaingold' how to exclude suspended users "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d and u.username <> 'lfaingold'"; - static final String USER_ROLES_SELECT = "SELECT [ROLE_ID] FROM [Users].[dbo].[users_roles] WHERE [USER_ID] = '%S'"; - static final String COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[roles]\n" + "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 1317b0a19..62cbe31ef 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -4,10 +4,12 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.utils.BaseUtils; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; -import com.microsoft.sqlserver.jdbc.SQLServerException; +import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; import org.json.JSONObject; + import java.sql.*; + import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; @@ -17,11 +19,10 @@ public class DBUtils extends BaseUtils { private static boolean isActivationNeeded = false; private static boolean isActivationNeededWasLoaded = false; - private static SQLServerDataSource dataSource; - private static Connection conn; - private static Statement stam; - static ResultSet rs; - static CallableStatement cStmt; +// private static Connection conn; +// private static Statement stam; +// static ResultSet rs; +// static CallableStatement cStmt; static final String ERROR_MESSAGE = "No results found"; @@ -153,130 +154,113 @@ public static int getSubscriptionWithPremiumService() { return subscriptionId; } + // Return json array from DB + static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) { + SQLServerDataSource dataSource = getDataSource(); + Connection conn = null; + Statement stam = null; + ResultSet rs = null; -// public static List getUserRoles(String userId) { -// List userRoles = new ArrayList<>(); -// -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(USER_ROLES_SELECT, userId)); -// -// if (Strings.isNullOrEmpty(jsonArray.toString())) { -// Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); -// return userRoles; -// } -// -// for (int i = 0; i < jsonArray.length(); i++) { -// userRoles.add(jsonArray.getInt(i)); -// } -// -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return userRoles; -// } + JSONArray jsonArray = null; - // Return json array from DB - static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) throws Exception { - openConnection(); + try { + conn = dataSource.getConnection(); + stam = conn.createStatement(); + rs = stam.executeQuery(query); + + if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { + jsonArray = buildJsonArrayFromQueryResult(rs); + Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); + } else { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DbUtils.closeQuietly(rs); + DbUtils.closeQuietly(stam); + DbUtils.closeQuietly(conn); + } + + return jsonArray; + } + + private static JSONArray buildJsonArrayFromQueryResult(ResultSet rs) throws SQLException { JSONArray jsonArray = new JSONArray(); - rs = stam.executeQuery(query); ResultSetMetaData rsmd = rs.getMetaData(); - if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { - while (rs.next()) { - int numColumns = rsmd.getColumnCount(); - JSONObject obj = new JSONObject(); - - for (int i = 1; i < numColumns + 1; i++) { - String column_name = rsmd.getColumnName(i).toLowerCase(); - - if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { - obj.put(column_name, rs.getArray(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { - obj.put(column_name, rs.getBoolean(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { - obj.put(column_name, rs.getBlob(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { - obj.put(column_name, rs.getDouble(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { - obj.put(column_name, rs.getFloat(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { - obj.put(column_name, rs.getNString(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { - obj.put(column_name, rs.getString(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { - obj.put(column_name, rs.getInt(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { - obj.put(column_name, rs.getDate(column_name)); - } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { - obj.put(column_name, rs.getTimestamp(column_name)); - } else { - obj.put(column_name, rs.getObject(column_name)); - } + while (rs.next()) { + int numColumns = rsmd.getColumnCount(); + JSONObject obj = new JSONObject(); + + for (int i = 1; i < numColumns + 1; i++) { + String column_name = rsmd.getColumnName(i).toLowerCase(); + + if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { + obj.put(column_name, rs.getArray(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { + obj.put(column_name, rs.getBoolean(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { + obj.put(column_name, rs.getBlob(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { + obj.put(column_name, rs.getDouble(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { + obj.put(column_name, rs.getFloat(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { + obj.put(column_name, rs.getNString(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { + obj.put(column_name, rs.getString(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { + obj.put(column_name, rs.getInt(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { + obj.put(column_name, rs.getDate(column_name)); + } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { + obj.put(column_name, rs.getTimestamp(column_name)); + } else { + obj.put(column_name, rs.getObject(column_name)); } - jsonArray.put(obj); } - closeConnection(); - Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); - return jsonArray; - - } else { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); - closeConnection(); - return null; + jsonArray.put(obj); } - + return jsonArray; } - private static void openConnection() { - dataSource = new SQLServerDataSource(); + private static SQLServerDataSource getDataSource(){ + SQLServerDataSource dataSource = new SQLServerDataSource(); dataSource.setUser(getProperty(DB_USER)); dataSource.setPassword(getProperty(DB_PASSWORD)); dataSource.setServerName(getProperty(DB_URL)); dataSource.setApplicationIntent("ReadOnly"); dataSource.setMultiSubnetFailover(true); - try { - conn = dataSource.getConnection(); - } catch (SQLServerException e) { - e.printStackTrace(); - } - try { - stam = conn.createStatement(); - } catch (SQLException e) { - e.printStackTrace(); - } + return dataSource; } - static void closeConnection() { - try { - if (rs != null) { - rs.close(); - } - } catch (SQLException e) { - e.printStackTrace(); - } - try { - stam.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - try { - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } +// private static void openConnection() { +// SQLServerDataSource dataSource = getDataSource(); +// +// try { +// conn = dataSource.getConnection(); +// stam = conn.createStatement(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } +// } +// +// static void closeConnection() { +// DbUtils.closeQuietly(rs); +// DbUtils.closeQuietly(stam); +// DbUtils.closeQuietly(conn); +// } - static void prepareCall(String sql) throws SQLException { - openConnection(); - cStmt = conn.prepareCall(sql); - } +// static void prepareCall(String sql) throws SQLException { +// openConnection(); +// cStmt = conn.prepareCall(sql); +// } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java index b7dc87705..5a97bbc1f 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java @@ -1,318 +1,318 @@ -package com.kaltura.client.test.utils.dbUtils; - -import org.json.JSONArray; -import java.sql.*; -import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; - -public class PermissionsManagementDBUtils extends DBUtils { - - /** - * Call Stored Procedure to create role - */ - public static int insertRole(String role) { - int result =-1; - try { - prepareCall(SP_INSERT_ROLE); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setString(2, role); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete role and its permissions - */ - public static void deleteRoleAndItsPermissions(int roleId) { - try { - prepareCall(SP_DELETE_ROLE_AND_ITS_PERMISSIONS); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setInt(2, roleId); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permissions - */ - public static int insertPermission(String name, int type, String usersGroup) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setString(2, name); - cStmt.setInt(3, type); - cStmt.setString(4, usersGroup); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission - */ - public static void deletePermission(int id) { - try { - prepareCall(SP_DELETE_PERMISSION); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permission role - */ - public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION_ROLE); - cStmt.setInt(1, 0); // group_id == 0 - cStmt.setLong(2, roleId); - cStmt.setLong(3, permissionId); - cStmt.setInt(4, isExcluded); - - rs = cStmt.executeQuery(); - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to insert permission item - */ - public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION_ITEM); - cStmt.setString(1, name); - cStmt.setInt(2, type); - cStmt.setString(3, service); - cStmt.setString(4, action); - cStmt.setString(5, permissionItemObject); - cStmt.setString(6, parameter); - rs = cStmt.executeQuery(); - - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission item - */ - public static void deletePermissionItem(int id) { - try { - prepareCall(SP_DELETE_PERMISSION_ITEM); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - /** - * Call Stored Procedure to insert permission permission item - */ - public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { - int result =-1; - try { - prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); - cStmt.setInt(1, 0);; // group_id == 0 - cStmt.setLong(2, permissionId); - cStmt.setLong(3, permissionItemId); - cStmt.setInt(4, isExcluded); - rs = cStmt.executeQuery(); - - String columnName = rs.getMetaData().getColumnName(1); - while (rs.next()) { - result = rs.getInt(columnName); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - return result; - } - } - - /** - * Call Stored Procedure to delete permission permission item - */ - public static void deletePermissionPermissionItem(int id) { - try { - prepareCall(SP_DELETE_PERMISSION_PERMISSION_ITEM); - cStmt.setInt(1, id); - - cStmt.execute(); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeConnection(); - } - } - - public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { - int count = 0; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, - name, groupId), true); - if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return count; - } - - public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { - int id =-1; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT, - name, groupId), true); - if (!jsonArray.isNull(0)) { - id = jsonArray.getJSONObject(0).getInt(ID); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return id; - } - - public static int getCountRowsHavingRoleNameInPermissions(String name, int groupId) { - int count = 0; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, - name, groupId), true); - if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return count; - } - - public static int getIdRecordHavingRoleNameInPermissions(String name, int groupId) { - int count =-1; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, - name, groupId), true); - if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return count; - } - - public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permissionId, int groupId) { - int count = 0; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT, - roleId, permissionId, groupId), true); - if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return count; - } - - public static int getCountRowsHavingNameInPermissionItems(String name, int groupId) { - int count = 0; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT, - name, groupId), true); - if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return count; - } - - public static int getIdRecordHavingNameInPermissionItems(String name, int groupId) { - int count =-1; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT, - name, groupId), true); - if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return count; - } - - public static int getCountSpecificRowsFromPermissionsPermissionsItems(int permissionId, int permissionItemId, int groupId) { - int count = 0; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT, - permissionId, permissionItemId, groupId), true); - if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return count; - } -} +//package com.kaltura.client.test.utils.dbUtils; +// +//import org.json.JSONArray; +//import java.sql.*; +//import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; +// +//public class PermissionsManagementDBUtils extends DBUtils { +// +// /** +// * Call Stored Procedure to create role +// */ +// public static int insertRole(String role) { +// int result =-1; +// try { +// prepareCall(SP_INSERT_ROLE); +// cStmt.setInt(1, 0); // group_id == 0 +// cStmt.setString(2, role); +// +// rs = cStmt.executeQuery(); +// String columnName = rs.getMetaData().getColumnName(1); +// while (rs.next()) { +// result = rs.getInt(columnName); +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// return result; +// } +// } +// +// /** +// * Call Stored Procedure to delete role and its permissions +// */ +// public static void deleteRoleAndItsPermissions(int roleId) { +// try { +// prepareCall(SP_DELETE_ROLE_AND_ITS_PERMISSIONS); +// cStmt.setInt(1, 0); // group_id == 0 +// cStmt.setInt(2, roleId); +// +// cStmt.execute(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// } +// } +// +// /** +// * Call Stored Procedure to insert permissions +// */ +// public static int insertPermission(String name, int type, String usersGroup) { +// int result =-1; +// try { +// prepareCall(SP_INSERT_PERMISSION); +// cStmt.setInt(1, 0); // group_id == 0 +// cStmt.setString(2, name); +// cStmt.setInt(3, type); +// cStmt.setString(4, usersGroup); +// +// rs = cStmt.executeQuery(); +// String columnName = rs.getMetaData().getColumnName(1); +// while (rs.next()) { +// result = rs.getInt(columnName); +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// return result; +// } +// } +// +// /** +// * Call Stored Procedure to delete permission +// */ +// public static void deletePermission(int id) { +// try { +// prepareCall(SP_DELETE_PERMISSION); +// cStmt.setInt(1, id); +// +// cStmt.execute(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// } +// } +// +// /** +// * Call Stored Procedure to insert permission role +// */ +// public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { +// int result =-1; +// try { +// prepareCall(SP_INSERT_PERMISSION_ROLE); +// cStmt.setInt(1, 0); // group_id == 0 +// cStmt.setLong(2, roleId); +// cStmt.setLong(3, permissionId); +// cStmt.setInt(4, isExcluded); +// +// rs = cStmt.executeQuery(); +// String columnName = rs.getMetaData().getColumnName(1); +// while (rs.next()) { +// result = rs.getInt(columnName); +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// return result; +// } +// } +// +// /** +// * Call Stored Procedure to insert permission item +// */ +// public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { +// int result =-1; +// try { +// prepareCall(SP_INSERT_PERMISSION_ITEM); +// cStmt.setString(1, name); +// cStmt.setInt(2, type); +// cStmt.setString(3, service); +// cStmt.setString(4, action); +// cStmt.setString(5, permissionItemObject); +// cStmt.setString(6, parameter); +// rs = cStmt.executeQuery(); +// +// String columnName = rs.getMetaData().getColumnName(1); +// while (rs.next()) { +// result = rs.getInt(columnName); +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// return result; +// } +// } +// +// /** +// * Call Stored Procedure to delete permission item +// */ +// public static void deletePermissionItem(int id) { +// try { +// prepareCall(SP_DELETE_PERMISSION_ITEM); +// cStmt.setInt(1, id); +// +// cStmt.execute(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// } +// } +// +// /** +// * Call Stored Procedure to insert permission permission item +// */ +// public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { +// int result =-1; +// try { +// prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); +// cStmt.setInt(1, 0);; // group_id == 0 +// cStmt.setLong(2, permissionId); +// cStmt.setLong(3, permissionItemId); +// cStmt.setInt(4, isExcluded); +// rs = cStmt.executeQuery(); +// +// String columnName = rs.getMetaData().getColumnName(1); +// while (rs.next()) { +// result = rs.getInt(columnName); +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// return result; +// } +// } +// +// /** +// * Call Stored Procedure to delete permission permission item +// */ +// public static void deletePermissionPermissionItem(int id) { +// try { +// prepareCall(SP_DELETE_PERMISSION_PERMISSION_ITEM); +// cStmt.setInt(1, id); +// +// cStmt.execute(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// closeConnection(); +// } +// } +// +// public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { +// int count = 0; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, +// name, groupId), true); +// if (!jsonArray.isNull(0)) { +// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return count; +// } +// +// public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { +// int id =-1; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT, +// name, groupId), true); +// if (!jsonArray.isNull(0)) { +// id = jsonArray.getJSONObject(0).getInt(ID); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return id; +// } +// +// public static int getCountRowsHavingRoleNameInPermissions(String name, int groupId) { +// int count = 0; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, +// name, groupId), true); +// if (!jsonArray.isNull(0)) { +// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return count; +// } +// +// public static int getIdRecordHavingRoleNameInPermissions(String name, int groupId) { +// int count =-1; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, +// name, groupId), true); +// if (!jsonArray.isNull(0)) { +// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return count; +// } +// +// public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permissionId, int groupId) { +// int count = 0; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT, +// roleId, permissionId, groupId), true); +// if (!jsonArray.isNull(0)) { +// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return count; +// } +// +// public static int getCountRowsHavingNameInPermissionItems(String name, int groupId) { +// int count = 0; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT, +// name, groupId), true); +// if (!jsonArray.isNull(0)) { +// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return count; +// } +// +// public static int getIdRecordHavingNameInPermissionItems(String name, int groupId) { +// int count =-1; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT, +// name, groupId), true); +// if (!jsonArray.isNull(0)) { +// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return count; +// } +// +// public static int getCountSpecificRowsFromPermissionsPermissionsItems(int permissionId, int permissionItemId, int groupId) { +// int count = 0; +// try { +// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT, +// permissionId, permissionItemId, groupId), true); +// if (!jsonArray.isNull(0)) { +// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return count; +// } +//} From ea402136d549faac783690e7a6eed0549c3415fc Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 12 Jun 2018 15:29:50 +0300 Subject: [PATCH 345/605] Fixed failed tests --- .../AssetHistoryListTests.java | 17 +++++++++----- .../EntitlementListTests.java | 23 +++++++++++++++---- .../ProductPriceListTests.java | 13 +++++++---- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 420472883..5ee01989e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -82,16 +82,21 @@ private void vodAssetHistory() { .setKs(masterUserKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); - // First object - AssetHistory assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); - // Second object - AssetHistory assetHistoryObject2 = assetHistoryListResponse.results.getObjects().get(1); + // objects can be returned in any order + AssetHistory assetHistoryObject1, assetHistoryObject2; + if (assetHistoryListResponse.results.getObjects().get(0).getAssetId().equals(movie2.getId())) { + assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); + assetHistoryObject2 = assetHistoryListResponse.results.getObjects().get(1); + } else { + assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(1); + assetHistoryObject2 = assetHistoryListResponse.results.getObjects().get(0); + } // Assertions for first object returned - assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movie2.getId()); assertThat(assetHistoryObject1.getAssetType()).isEqualTo(AssetType.MEDIA); - assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); + assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); + assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movie2.getId()); // Verify that flag is set to false (user hasn't finish watching the asset) assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index 7046c6156..abda85379 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -9,6 +9,7 @@ import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.IngestUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -21,6 +22,8 @@ import java.util.Optional; import static com.kaltura.client.enums.EntitlementOrderBy.PURCHASE_DATE_ASC; import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; +import static com.kaltura.client.test.Properties.PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementListTests extends BaseTest { @@ -192,8 +195,13 @@ public void entitlementListAfterForceCancel() { public void entitlementListWithPaging() { PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), - Optional.of(getSharedMobileMediaFile().getId()), Optional.empty()); + MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(mediaAsset.getId())), + Optional.of(mediaFileId), Optional.empty()); // after purchase // without paging @@ -203,7 +211,7 @@ public void entitlementListWithPaging() { entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(2); // 2 files assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedWebMediaFile().getId()); - assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(1)).getMediaFileId()).isEqualTo(getSharedMobileMediaFile().getId()); + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(1)).getMediaFileId()).isEqualTo(mediaFileId); // with paging on 1st page FilterPager pager = new FilterPager(); @@ -221,13 +229,18 @@ public void entitlementListWithPaging() { entitlementResponse = executor.executeSync(entitlementListAfterPurchase.setKs(masterUserKs)); assertThat(entitlementResponse.results.getTotalCount()).isEqualTo(2); // purchased 2 files assertThat(entitlementResponse.results.getObjects().size()).isEqualTo(1); // only 2nd file - assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(getSharedMobileMediaFile().getId()); + assertThat(((PpvEntitlement)entitlementResponse.results.getObjects().get(0)).getMediaFileId()).isEqualTo(mediaFileId); //cancel household purchases for cleanup ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel(getSharedWebMediaFile().getId(), TransactionType.PPV); executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); - forceCancelEntitlementBuilder = EntitlementService.forceCancel(getSharedMobileMediaFile().getId(), TransactionType.PPV); + forceCancelEntitlementBuilder = EntitlementService.forceCancel(mediaFileId, TransactionType.PPV); executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + // delete media + IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 044838302..256878557 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -204,6 +204,12 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { @Test public void subscriptionTest() { // TODO: 3/7/2018 add remarks when possible such as below - show to Shmulik / Michael and see if test is clear + int numberOfUsers = 1; + int numberOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); + //HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + // create mpp with supporting of 1 type only and having at least 1 media on its channel sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); @@ -272,10 +278,9 @@ public void subscriptionTest() { assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualToIgnoringCase(subscription.getId()); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(Integer.valueOf(sharedWebMediaFileId)); - //delete entitlement data for cleanup - ForceCancelEntitlementBuilder forceCancelEntitlementBuilder = EntitlementService.forceCancel( - Integer.valueOf(subscription.getId()), TransactionType.SUBSCRIPTION); - executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(classMasterUserId))); + //delete HH for cleanup + HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); + executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); //delete subscription IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), From e9271b97f59df9a8b2507c9ca040eed5e1d90bcd Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 12 Jun 2018 15:32:38 +0300 Subject: [PATCH 346/605] removed mentioning of closed bug --- .../servicesTests/productPriceTests/ProductPriceListTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 256878557..eb4fe1e45 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -127,7 +127,6 @@ public void listWithoutRequiredFieldsTest() { @Severity(SeverityLevel.CRITICAL) @Description("productPrice/action/list - ppv test") - @Issue("BEO-5184") @Test public void ppvTest() { // TODO: after fix of BEO-4967 change HouseholdDevice.json to have only 1 enum value in objectType From b54aae597f6b201e3a1d73cc4943bc157ea8ff05 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 12 Jun 2018 15:39:54 +0300 Subject: [PATCH 347/605] Updated class - "AssetHistoryListTests" --- .../AssetHistoryCleanTests.java | 52 +++++++++---------- .../AssetHistoryListTests.java | 32 ++++-------- 2 files changed, 37 insertions(+), 47 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index a03ab4c97..771ec1924 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -61,35 +61,35 @@ private void clean_tests_before_class() { private void cleanHistory() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); //assetHistory/action/list - both assets should returned ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) - .setKs(masterUserKs); + .setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); //assetHistory/action/clean CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - no object returned listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) - .setKs(masterUserKs); + .setKs(userKs); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); @@ -100,23 +100,23 @@ private void cleanHistory() { private void cleanSpecifcAssetHistory() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movie.getId()), null, WatchStatus.ALL, null); //assetHistory/action/clean CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) @@ -124,7 +124,7 @@ private void cleanSpecifcAssetHistory() { // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(masterUserKs); + listAssetHistoryBuilder.setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -136,16 +136,16 @@ private void cleanSpecifcAssetHistory() { private void cleanSpecifcAssetTypeHistory() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(EPISODE_MEDIA_TYPE_ID)); @@ -153,7 +153,7 @@ private void cleanSpecifcAssetTypeHistory() { //assetHistory/action/clean - only episode type (episode) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) @@ -162,7 +162,7 @@ private void cleanSpecifcAssetTypeHistory() { // assetHistory/action/list - after clean - only movie returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(masterUserKs); + listAssetHistoryBuilder.setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -174,16 +174,16 @@ private void cleanSpecifcAssetTypeHistory() { private void cleanAssetsAccordingToWatchStatusDone() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); @@ -191,7 +191,7 @@ private void cleanAssetsAccordingToWatchStatusDone() { //assetHistory/action/clean - only asset that were finished (episode) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); @@ -199,7 +199,7 @@ private void cleanAssetsAccordingToWatchStatusDone() { // assetHistory/action/list - after clean - only movie returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(masterUserKs); + listAssetHistoryBuilder.setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -211,30 +211,30 @@ private void cleanAssetsAccordingToWatchStatusDone() { private void cleanAssetsAccordingToWatchStatusProgress() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); //assetHistory/action/clean - only asset that in progress (movie) CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); // assetHistory/action/list - after clean - only episode returned (was not cleaned) ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(masterUserKs); + listAssetHistoryBuilder.setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 420472883..858b14191 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -55,23 +55,22 @@ private void list_tests_before_class() { episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } - @Description("/AssetHistory/action/list - with no filter") @Test private void vodAssetHistory() { // Create HH with one user and one device Household household = createHousehold(numOfUsers, numbOfDevices, false); - String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Build AssetHistoryFilter object @@ -79,7 +78,7 @@ private void vodAssetHistory() { //assetHistory/action/list - both assets should returned ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) - .setKs(masterUserKs); + .setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); // First object @@ -106,28 +105,26 @@ private void vodAssetHistory() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); } - - @Description("/AssetHistory/action/list -filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String masterUserKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household, null); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark Second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark third asset bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movie2.getId()), @@ -136,7 +133,7 @@ private void vodAssetHistoryFilteredByAssetId() { //assetHistory/action/list - filter by asset 2 id ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) - .setKs(masterUserKs); + .setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); @@ -149,11 +146,10 @@ private void vodAssetHistoryFilteredByAssetId() { assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, null, WatchStatus.ALL, null); listAssetHistoryBuilder = list(assetHistoryFilter, null) - .setKs(masterUserKs); + .setKs(userKs); assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); List assetHistoryList = assetHistoryListResponse.results.getObjects(); - assertThat(assetHistoryList); List assetHistoryIdsList = new ArrayList<>(); for (AssetHistory assetHistory : assetHistoryList) { @@ -162,8 +158,6 @@ private void vodAssetHistoryFilteredByAssetId() { assertThat(assetHistoryIdsList).containsOnly(movie2.getId(), episode.getId()); } - - @Description("/AssetHistory/action/list -filtered by movie type id") @Test private void vodAssetHistoryFilteredByAssetType() { @@ -171,7 +165,6 @@ private void vodAssetHistoryFilteredByAssetType() { Household household = createHousehold(numOfUsers, numbOfDevices, false); String userKs = getHouseholdMasterUserKs(household, null); - // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); @@ -182,21 +175,19 @@ private void vodAssetHistoryFilteredByAssetType() { addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(MOVIE_MEDIA_TYPE_ID)); //assetHistory/action/list - filter by in progress assets only ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(getHouseholdMasterUserKs(household, null)); + listAssetHistoryBuilder.setKs(userKs); Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); } - @Description("/AssetHistory/action/list -filtered by assets progress") @Test private void vodAssetHistoryFilteredByAssetProgress() { @@ -209,7 +200,6 @@ private void vodAssetHistoryFilteredByAssetProgress() { AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - // Bookmark Second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); addBookmarkBuilder = add(bookmark).setKs(userKs); From 86dee89e1613f6b15af1f45741375758443828b0 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Tue, 12 Jun 2018 15:46:27 +0300 Subject: [PATCH 348/605] amend multi thread --- .../SlowTestsRunner/SlowTestsRunner.java | 19 ------------------- .../appTokenTests/AppTokenAddTests.java | 2 +- .../OttUserLoginWithPinTests.java | 2 +- src/test/resources/testng.xml | 8 -------- 4 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java deleted file mode 100644 index 69cd1f687..000000000 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/SlowTestsRunner/SlowTestsRunner.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.kaltura.client.test.tests.servicesTests.SlowTestsRunner; - -import com.kaltura.client.test.tests.BaseTest; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; - -public class SlowTestsRunner extends BaseTest{ - - @BeforeSuite(groups = "slow_before") - public void setupSlowTests(){ - baseTest_beforeSuite(); - } - - @Test(alwaysRun = true, groups = "slow", dependsOnGroups = {"slow_before", "slow_after"}) - public void prepareSlowTests(){ - - - } -} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index e6e535809..fbfc50f80 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -103,7 +103,7 @@ private void addAppTokenWithExpiryDate_before() { } - @Test(groups = "slow_after", dependsOnMethods = "addAppTokenWithExpiryDate_before", priority = 1) + @Test(groups = "slow_after", dependsOnGroups = {"slow_before"}, priority = 1) private void addAppTokenWithExpiryDate_after() { // prepare builder and variables for await() functionality GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponseSlowTest.results.getId()) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index f6ef13c11..901d50c84 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -95,7 +95,7 @@ private void loginWithPin_with_expired_pinCode_before() { userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); } - @Test(groups = "slow_after", dependsOnMethods = {"loginWithPin_with_expired_pinCode_before"}, priority = 2) + @Test(groups = "slow_after", dependsOnGroups = {"slow_before"}, priority = 2) private void loginWithPin_with_expired_pinCode_after() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 10; diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index f1667b48f..19df6e11b 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -4,7 +4,6 @@ - @@ -19,7 +18,6 @@ - @@ -28,11 +26,5 @@ - - - - - - \ No newline at end of file From 0f839d3f026380b38b7952e24f1e283fffac7f87 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 12 Jun 2018 16:34:39 +0300 Subject: [PATCH 349/605] no message --- .../householdTests/HouseholdSuspendTests.java | 10 ++++++---- .../kaltura/client/test/utils/SubscriptionUtils.java | 10 ++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 6b4f905f3..9c50993ed 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -413,7 +413,7 @@ private void suspend_with_playback_ppv_role() { @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with renew_subscription role") @Test(groups = "slow_before") - private void suspend_with_renew_subscription_role_before() { + private void suspend_with_renew_subscription_role_before_wait() { // setup for test household_suspendTests_beforeClass(); @@ -456,9 +456,10 @@ private void suspend_with_renew_subscription_role_before() { assertThat(booleanResponse.results).isTrue(); } - @Test(groups = "slow_after", dependsOnMethods = {"suspend_with_renew_subscription_role_before"}, priority = 3) - private void suspend_with_renew_subscription_role_after() { + @Test(groups = "slow_after", dependsOnGroups = {"slow_before"}, priority = 3) + private void suspend_with_renew_subscription_role_after_wait() { // get productprice list for asset in subscription - after renew + Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(fiveMinRenewSubscriptionSlowTest.getId()), Optional.empty()).get(0); ProductPriceFilter assetFilter = new ProductPriceFilter(); assetFilter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); @@ -470,7 +471,8 @@ private void suspend_with_renew_subscription_role_after() { .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(() -> (executor.executeSync(ProductPriceService.list(assetFilter) - .setKs(masterUserKsSlowTest)).results.getObjects().get(0).getPurchaseStatus()).equals(PurchaseStatus.FOR_PURCHASE)); + .setKs(masterUserKsSlowTest)).results.getObjects().get(0).getPurchaseStatus()) + .equals(PurchaseStatus.FOR_PURCHASE)); productPriceListResponseSlowTest = executor.executeSync(ProductPriceService.list(assetFilter) .setKs(masterUserKsSlowTest)); diff --git a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java index c88f3190b..bc47e4394 100644 --- a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.utils; +import com.google.common.base.Verify; import com.kaltura.client.enums.BundleType; import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; @@ -33,11 +34,13 @@ public static List getAssetsListBySubscription(int subscriptionId, Option assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter, pager).setKs(getOperatorKs())); } else { - assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter).setKs(BaseTest.SharedHousehold.getSharedMasterUserKs())); + assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter).setKs(getOperatorKs())); } - // remove assets without media files from list List assets = assetListResponse.results.getObjects(); + Verify.verify(assetListResponse.results.getTotalCount() > 0, "Asset list can't be empty"); + + // remove assets without media files from list List assetsToRemove = new ArrayList<>(); for (Asset asset : assets) { @@ -50,4 +53,7 @@ public static List getAssetsListBySubscription(int subscriptionId, Option return assets; } + + // TODO: 6/12/2018 add getChannelsListBySubscription + } From 5080aaff6accdf8606ac973ebf6ca97b9adadcc9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Thu, 14 Jun 2018 10:29:08 +0300 Subject: [PATCH 350/605] PreparedStatement added to DB connection --- .../appTokenTests/AppTokenAddTests.java | 5 +- .../test/utils/dbUtils/DBConstants.java | 66 ++++---- .../client/test/utils/dbUtils/DBUtils.java | 148 +++++++++++++----- .../test/utils/dbUtils/IngestFixtureData.java | 38 +++-- 4 files changed, 159 insertions(+), 98 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index fbfc50f80..4c9ab5984 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -83,8 +83,9 @@ private void addAppTokenWithPrivileges() { assertThat(appTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); } + // priority needed, because at parralel execution both test threads launch setup method of this class and this cause to Error 1 at login with operator user. @Description("appToken/action/add - with expiry date") - @Test(groups = "slow_before") + @Test(groups = "slow_before", priority = 1) private void addAppTokenWithExpiryDate_before() { // setup for test add_tests_before_class(); @@ -119,7 +120,7 @@ private void addAppTokenWithExpiryDate_after() { return (apiException != null); }); - assertThat(apiException.getCode().equals(getAPIExceptionFromList(500055).getCode())); + assertThat(apiException.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } @Description("appToken/action/add - with no expiry date (return default expiry date -" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 2bc0d6e5e..2d1723f5e 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -25,58 +25,58 @@ public class DBConstants { static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; //queries - static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + static final String ACTIVATION_TOKEN_SELECT = "SELECT [ACTIVATION_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = ?"; static final String AND_ACTIVE_STATUS = " and u.activate_status=1"; - static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = ?"; static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + "from [Users].[dbo].[groups_parameters]\n" + - "where group_id=%d"; + "where group_id= ?"; - static final String CURRENCY_CODE_SELECT = "select ID from [Pricing].[dbo].[lu_currency] WHERE CODE3='%s'"; + static final String CURRENCY_CODE_SELECT = "select ID from [Pricing].[dbo].[lu_currency] WHERE CODE3=?"; static final String DISCOUNT_BY_PERCENT = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes] dc \n" + - "where dc.discount_percent=%d\n" + // percent amount - "and dc.group_id=%d\n" + // group + "where dc.discount_percent=?\n" + // percent amount + "and dc.group_id=?\n" + // group "and dc.[status]=1 and dc.is_active=1"; static final String DISCOUNT_BY_PERCENT_AND_CURRENCY = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes] dc with(nolock)\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (dc.currency_cd=lc.id)\n" + - "where lc.code3='%S'\n" + // CURRENCY - "and dc.discount_percent=%d\n" + // percent amount - "and dc.group_id=%d\n" + // group + "where lc.code3=?\n" + // CURRENCY + "and dc.discount_percent=?\n" + // percent amount + "and dc.group_id=?\n" + // group "and dc.[status]=1 and dc.is_active=1"; static final String DISCOUNT_BY_PRICE_AND_PERCENT_SELECT = "select TOP (1) *\n" + "from [Pricing].[dbo].[discount_codes]\n" + "where [status]=1 and is_active=1\n" + - "and group_id=%d\n" + // group - "and price=%f\n" + // price amount - "and discount_percent=%f"; // percent amount + "and group_id=?\n" + // group + "and price=?\n" + // price amount + "and discount_percent=?"; // percent amount - static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = %d AND [NAME] = '%S'"; + static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = ? AND [NAME] = ?"; static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + - "where [group_id]=%d order by UPDATE_DATE DESC"; + "where [group_id]=? order by UPDATE_DATE DESC"; static final String PPV_SELECT_BY_PRICE_PLAN = "select top 1 * from [Pricing].[dbo].[ppv_modules]\n" + "where [status]=1 and is_active=1\n" + - "and group_id=%d and usage_module_code=%d\n" + + "and group_id=? and usage_module_code=?\n" + "order by create_date"; static final String PRICE_CODE_SELECT = "select top 1 * from [Pricing].[dbo].[price_codes] pc\n" + "join [Pricing].[dbo].[lu_currency] lc with(nolock) on (pc.currency_cd=lc.id)\n" + "where pc.[status]=1 and pc.is_active=1\n" + - "and pc.group_id=%d and pc.price=%f and lc.CODE3='%S'"; + "and pc.group_id=? and pc.price=? and lc.CODE3=?"; static final String PRICE_PLAN_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + - "and group_id=%d and internal_discount_id=%d and pricing_id=%d"; + "and group_id=? and internal_discount_id=? and pricing_id=?"; static final String PRICE_PLAN_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + @@ -84,16 +84,16 @@ public class DBConstants { "and full_life_cycle_min = 5\n" + "and is_renew=1\n" + "and ((num_of_rec_periods > 2) or (num_of_rec_periods = 0))\n" + // TODO: do we really want it "num_of_rec_periods > 2"? - "and group_id=%d"; + "and group_id=?"; static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + "where [status]=1 and is_active=1\n" + - "and group_id=%d and usage_module_code=%d and discount_module_code=%d\n" + + "and group_id=? and usage_module_code=? and discount_module_code=?\n" + "order by create_date"; static final String SUBSCRIPTION_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + "where [status]=1 and is_active=1 and [type]=0 and is_recurring=1\n" + - "and group_id=%d and usage_module_code=%d\n" + + "and group_id=? and usage_module_code=?\n" + "order by create_date"; static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) SUBSCRIPTION_ID as " + SUB_ID + @@ -101,11 +101,11 @@ public class DBConstants { "FROM [Pricing].[dbo].[subscriptions] s\n" + "INNER JOIN [Pricing].[dbo].[subscriptions_services] ss\n" + "ON s.ID = SS.SUBSCRIPTION_ID\n" + - "where s.group_id=%d"; + "where s.group_id=?"; static final String COLLECTION_SELECT = "select top 1 * from [Pricing].[dbo].[collections]\n" + "where [status]=1 and is_active=1\n" + - "and group_id=%d and discount_id=%d and price_id=%d and usage_module_id=%d\n" + + "and group_id=? and discount_id=? and price_id=? and usage_module_id=?\n" + "order by create_date"; static final String USER_BY_ROLE_SELECT = "select top(1) u.username, u.[password]\n" + @@ -113,43 +113,43 @@ public class DBConstants { "join [Users].[dbo].[users_roles] ur with(nolock) on (u.id=ur.[user_id])\n" + "join [TVinci].[dbo].[roles] r with(nolock) on (r.id=ur.role_id)\n" + // TODO: find instead of and u.username <> 'lfaingold' how to exclude suspended users - "where r.[NAME]='%S' and u.is_active=1 and u.[status]=1 and u.group_id=%d and u.username <> 'lfaingold'"; + "where r.[NAME]=? and u.is_active=1 and u.[status]=1 and u.group_id=? and u.username <> 'lfaingold'"; static final String COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[roles]\n" + - "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; static final String ID_BY_ROLE_NAME_IN_ROLES_SELECT = "select " + ID + "\n" + "from [TVinci].[dbo].[roles]\n" + - "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; static final String COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[permissions]\n" + - "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; static final String ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT = "select " + ID + "\n" + "from [TVinci].[dbo].[permissions]\n" + - "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; static final String COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[roles_permissions]\n" + - "where role_id=%d and permission_id=%d and is_active=1 and [status]=1 and group_id=%d"; + "where role_id=? and permission_id=? and is_active=1 and [status]=1 and group_id=?"; static final String COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[permission_items]\n" + - "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; static final String ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT = "select " + ID + "\n" + "from [TVinci].[dbo].[permission_items]\n" + - "where [NAME]='%S' and is_active=1 and [status]=1 and group_id=%d"; + "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; static final String COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[permissions_permission_items]\n" + - "where permission_id=%d and permission_item_id=%d and is_active=1 and [status]=1 and group_id=%d"; + "where permission_id=? and permission_item_id=? and is_active=1 and [status]=1 and group_id=?"; - static final String ASSET_ID_SELECT = "SELECT [media_id],[name] FROM [TVinci].[dbo].[epg_channels] WHERE group_id=%d and status=1 and DATALENGTH(media_id) > 0"; + static final String ASSET_ID_SELECT = "SELECT [media_id],[name] FROM [TVinci].[dbo].[epg_channels] WHERE group_id=? and status=1 and DATALENGTH(media_id) > 0"; - static final String UNACTIVE_ASSET_ID_SELECT = "SELECT top 1 [id] FROM [TVinci].[dbo].[media] where group_id = %d and status = 2"; + static final String UNACTIVE_ASSET_ID_SELECT = "SELECT top 1 [id] FROM [TVinci].[dbo].[media] where group_id = ? and status = 2"; // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 62cbe31ef..5c8a0823d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -13,17 +13,13 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; +import static org.assertj.core.api.Assertions.fail; public class DBUtils extends BaseUtils { private static boolean isActivationNeeded = false; private static boolean isActivationNeededWasLoaded = false; -// private static Connection conn; -// private static Statement stam; -// static ResultSet rs; -// static CallableStatement cStmt; - static final String ERROR_MESSAGE = "No results found"; public static boolean isActivationOfUsersNeeded() { @@ -33,7 +29,7 @@ public static boolean isActivationOfUsersNeeded() { } int result = -1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHECK_IS_ACTIVATION_USERS_NEEDED, partnerId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(CHECK_IS_ACTIVATION_USERS_NEEDED, false, partnerId); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); return false; @@ -59,7 +55,7 @@ public static String getUserData(String userRole) { } String userdData = ""; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(sqlQuery, userRole, partnerId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(sqlQuery, false, userRole, partnerId); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); return null; @@ -80,7 +76,7 @@ public static String getActivationToken(String username) { String activationToken = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ACTIVATION_TOKEN_SELECT, username), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(ACTIVATION_TOKEN_SELECT, false, username); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); return null; @@ -98,7 +94,7 @@ public static String getResetPasswordToken(String username) { String resetPasswordToken = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(RESET_PASSWORD_TOKEN_SELECT, username), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(RESET_PASSWORD_TOKEN_SELECT, false, username); resetPasswordToken = jsonArray.getJSONObject(0).getString(CP_TOKEN); } catch (Exception e) { e.printStackTrace(); @@ -111,7 +107,7 @@ public static String getResetPasswordToken(String username) { public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { JSONArray jsonArray = null; try { - jsonArray = getJsonArrayFromQueryResult(String.format(ASSET_ID_SELECT, Integer.valueOf(getProperty(PARTNER_ID)) + 1), false); + jsonArray = getJsonArrayFromQueryResult(ASSET_ID_SELECT, false, Integer.valueOf(getProperty(PARTNER_ID)) + 1); if (jsonArray == null || jsonArray.length() <= 0) { Logger.getLogger("Response is empty"); } @@ -126,8 +122,7 @@ public static int getUnActiveAsset() { int assetId = 0; try { - assetId = getJsonArrayFromQueryResult(String.format(UNACTIVE_ASSET_ID_SELECT, - Integer.valueOf(getProperty(PARTNER_ID)) + 1), false).getJSONObject(0).getInt("id"); + assetId = getJsonArrayFromQueryResult(UNACTIVE_ASSET_ID_SELECT, false, Integer.valueOf(getProperty(PARTNER_ID)) + 1).getJSONObject(0).getInt("id"); } catch (Exception e) { e.printStackTrace(); } @@ -139,8 +134,7 @@ public static int getSubscriptionWithPremiumService() { int subscriptionId = 0; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, - partnerId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, false, partnerId); if (Strings.isNullOrEmpty(jsonArray.toString())) { return subscriptionId; } @@ -155,35 +149,35 @@ public static int getSubscriptionWithPremiumService() { } // Return json array from DB - static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) { - SQLServerDataSource dataSource = getDataSource(); - Connection conn = null; - Statement stam = null; - ResultSet rs = null; - - JSONArray jsonArray = null; - - try { - conn = dataSource.getConnection(); - stam = conn.createStatement(); - rs = stam.executeQuery(query); - - if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { - jsonArray = buildJsonArrayFromQueryResult(rs); - Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); - } else { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - DbUtils.closeQuietly(rs); - DbUtils.closeQuietly(stam); - DbUtils.closeQuietly(conn); - } - - return jsonArray; - } +// static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) { +// SQLServerDataSource dataSource = getDataSource(); +// Connection conn = null; +// Statement stam = null; +// ResultSet rs = null; +// +// JSONArray jsonArray = null; +// +// try { +// conn = dataSource.getConnection(); +// stam = conn.createStatement(); +// rs = stam.executeQuery(query); +// +// if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { +// jsonArray = buildJsonArrayFromQueryResult(rs); +// Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); +// } else { +// Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } finally { +// DbUtils.closeQuietly(rs); +// DbUtils.closeQuietly(stam); +// DbUtils.closeQuietly(conn); +// } +// +// return jsonArray; +// } private static JSONArray buildJsonArrayFromQueryResult(ResultSet rs) throws SQLException { JSONArray jsonArray = new JSONArray(); @@ -242,6 +236,74 @@ private static SQLServerDataSource getDataSource(){ return dataSource; } + + // Return json array from DB + static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed, Object... args) { + SQLServerDataSource dataSource = getDataSource(); + Connection conn = null; + PreparedStatement pstm = null; + ResultSet rs = null; + JSONArray jsonArray = null; + + try { + conn = dataSource.getConnection(); + if (args.length >0) { + pstm = preparedStatementExecution(conn, query, args); + } + else { + pstm = conn.prepareStatement(query); + } + rs = pstm.executeQuery(); + + if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { + jsonArray = buildJsonArrayFromQueryResult(rs); + Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); + } else { + Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DbUtils.closeQuietly(rs); + DbUtils.closeQuietly(pstm); + DbUtils.closeQuietly(conn); + } + + return jsonArray; + } + + private static PreparedStatement preparedStatementExecution(Connection conn, String query, Object... args) { + PreparedStatement pstm = null; + try { + pstm = conn.prepareStatement(query); + for (int i = 0; i < args.length; i++) { + switch(args[i].getClass().getSimpleName()){ + case "String": + pstm.setString(i+1, (String) args[i]); + break; + case "Integer": + pstm.setInt(i+1, (int) args[i]); + break; + case "Double": + pstm.setDouble(i+1, (double) args[i]); + break; + case "Long": + pstm.setLong(i+1, (long) args[i]); + break; + default: + Logger.getLogger(DBUtils.class).error("No valid type found!"); + fail("No valid type found!"); + break; + } + } + + } catch (SQLException e){ + e.printStackTrace(); + } + return pstm; + } + + // private static void openConnection() { // SQLServerDataSource dataSource = getDataSource(); // diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 131e7ae50..9cdbdde6f 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -17,7 +17,7 @@ public static PriceDetails loadPriceCode(Double priceAmount, String currency) { Logger.getLogger(IngestFixtureData.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); PriceDetails result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_CODE_SELECT, partnerId, priceAmount, currency), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_CODE_SELECT, true, partnerId, priceAmount, currency); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } @@ -41,8 +41,7 @@ public static DiscountModule loadDiscount(Double discountPrice, Double discountP Logger.getLogger(IngestFixtureData.class).debug("loadDiscount(): discountPrice = " + discountPrice + " discountPercent = " + discountPercent); DiscountModule result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, - partnerId, discountPrice, discountPercent), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, true, partnerId, discountPrice, discountPercent); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } @@ -74,8 +73,8 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl return pricePlan; } - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_SELECT, partnerId, - Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_SELECT, true, partnerId, + Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()); if (Strings.isNullOrEmpty(jsonArray.toString())) { return pricePlan; } @@ -109,7 +108,7 @@ public static PricePlan load5MinRenewablePricePlan() { PricePlan pricePlan = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PRICE_PLAN_5_MIN_RENEW_SELECT, partnerId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_5_MIN_RENEW_SELECT, true, partnerId); if (Strings.isNullOrEmpty(jsonArray.toString())) { return pricePlan; } @@ -127,8 +126,8 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { Subscription subscription = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_SELECT, partnerId, - pricePlan.getId(), pricePlan.getDiscountId()), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_SELECT, true, partnerId, + pricePlan.getId(), pricePlan.getDiscountId()); if (Strings.isNullOrEmpty(jsonArray.toString())) { return subscription; } @@ -153,8 +152,8 @@ public static Collection loadSharedCommonCollection(PricePlan pricePlan) { Collection collection = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COLLECTION_SELECT, partnerId, - pricePlan.getDiscountId(), pricePlan.getPriceDetailsId(), pricePlan.getId()), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(COLLECTION_SELECT, true, partnerId, + pricePlan.getDiscountId(), pricePlan.getPriceDetailsId(), pricePlan.getId()); if (Strings.isNullOrEmpty(jsonArray.toString())) { return collection; } @@ -174,8 +173,7 @@ public static String getDiscount(String currency, int percent) { Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): currency = " + currency + " percent = " + percent); String code = ""; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, - percent, partnerId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT_AND_CURRENCY, false, currency, percent, partnerId); if (Strings.isNullOrEmpty(jsonArray.toString())) { return null; } @@ -196,8 +194,8 @@ public static DiscountModule getDiscount(int percent) { Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): percent = " + percent); DiscountModule result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(DISCOUNT_BY_PERCENT, - percent, partnerId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT, false, + percent, partnerId); if (Strings.isNullOrEmpty(jsonArray.toString())) { return null; } @@ -220,7 +218,7 @@ public static int getEpgChannelId(String channelName) { Logger.getLogger(IngestFixtureData.class).debug("getEpgChannelId(): channelName = " + channelName); int epgChannelId = -1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(EPG_CHANNEL_ID_SELECT, partnerId + 1, channelName), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(EPG_CHANNEL_ID_SELECT, false, partnerId + 1, channelName); if (Strings.isNullOrEmpty(jsonArray.toString())) { Logger.getLogger(IngestFixtureData.class).error(ERROR_MESSAGE); return epgChannelId; @@ -238,7 +236,7 @@ public static String getIngestItemUserData(int accountId) { Logger.getLogger(IngestFixtureData.class).debug("getIngestItemUserData(): accountId = " + accountId); String result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(INGEST_ITEMS_DATA_SELECT, accountId), false); + JSONArray jsonArray = getJsonArrayFromQueryResult(INGEST_ITEMS_DATA_SELECT, false, accountId); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } @@ -258,8 +256,8 @@ public static Ppv loadSharedCommonPpv(PricePlan pricePlan) { Ppv ppv = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(PPV_SELECT_BY_PRICE_PLAN, partnerId, - pricePlan.getId()), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(PPV_SELECT_BY_PRICE_PLAN, true, partnerId, + pricePlan.getId()); if (Strings.isNullOrEmpty(jsonArray.toString())) { return ppv; } @@ -285,8 +283,8 @@ public static Subscription loadShared5MinutesRenewableSubscription() { Subscription subscription = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_5_MIN_RENEW_SELECT, partnerId, - pricePlan.getId()), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_5_MIN_RENEW_SELECT, true, partnerId, + pricePlan.getId()); if (Strings.isNullOrEmpty(jsonArray.toString())) { return subscription; } From 65c80f1592110147ff8a3cb97a9ff9a8adb29a6d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 14 Jun 2018 12:44:06 +0300 Subject: [PATCH 351/605] Added logic related ingest common shared subscriptions --- .../com/kaltura/client/test/Properties.java | 1 - .../kaltura/client/test/tests/BaseTest.java | 96 +++++- .../client/test/tests/enums/ChannelType.java | 40 +++ .../householdTests/HouseholdSuspendTests.java | 2 +- .../client/test/utils/SubscriptionUtils.java | 34 +- .../test/utils/dbUtils/DBConstants.java | 28 +- .../test/utils/dbUtils/IngestFixtureData.java | 57 +++- src/test/resources/schemas/ListResponse.json | 6 +- src/test/resources/schemas/Subscription.json | 297 ++++++++++++++++++ 9 files changed, 533 insertions(+), 28 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/ChannelType.java create mode 100644 src/test/resources/schemas/Subscription.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 00f028e7f..a72f540ab 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -58,7 +58,6 @@ public class Properties { // TODO: should we document it as requirement? public static final String PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT = "multi price code with fixed amount discount"; - //cycles public static final int CYCLE_1_DAY = 1440; // in minutes diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 0b8a79c97..f3c39efe0 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -1,25 +1,28 @@ package com.kaltura.client.test.tests; +import com.google.common.base.Verify; import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; +import com.kaltura.client.services.ChannelService; +import com.kaltura.client.services.ChannelService.AddChannelBuilder; import com.kaltura.client.services.OttUserService; +import com.kaltura.client.services.SubscriptionService; +import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.SubscriptionUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; +import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; - import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; @@ -164,6 +167,11 @@ public static Subscription getSharedCommonSubscription() { Optional.of(false), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } + + // it should have at least 1 VOD + if (SubscriptionUtils.getAssetsListBySubscription(Integer.valueOf(sharedCommonSubscription.getId()), Optional.empty()).size() == 0) { + ingestVODIntoSubscription(sharedCommonSubscription); + } } return sharedCommonSubscription; } @@ -329,20 +337,92 @@ public static MediaFile getMediaFileByType(MediaAsset asset, String type) { public static Subscription get5MinRenewableSubscription() { if (fiveMinRenewableSubscription == null) { fiveMinRenewableSubscription = IngestFixtureData.loadShared5MinutesRenewableSubscription(); + // it should have at least 1 VOD + if (SubscriptionUtils.getAssetsListBySubscription(Integer.valueOf(fiveMinRenewableSubscription.getId()), Optional.empty()).size() == 0) { + ingestVODIntoSubscription(fiveMinRenewableSubscription); + } if (fiveMinRenewableSubscription == null) { PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(EUR.getValue()), Optional.of(""), Optional.of(true), Optional.of(3)); + + // it should have at least 1 VOD + Channel channel = loadDefaultChannel(); + channel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + channel.setId(channelResponse.results.getId()); + fiveMinRenewableSubscription = IngestUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), + Optional.of(channel.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } } return fiveMinRenewableSubscription; } + private static void ingestVODIntoSubscription(Subscription subscription) { + // getting channel + SubscriptionFilter filter = new SubscriptionFilter(); + filter.setSubscriptionIdIn(subscription.getId()); + ListSubscriptionBuilder listSubscriptionBuilder = SubscriptionService.list(filter); + Response> listResponse = executor.executeSync(listSubscriptionBuilder.setKs(getOperatorKs())); + Verify.verify(listResponse.results.getObjects().get(0).getChannels().size() > 0); + int channelId = listResponse.results.getObjects().get(0).getChannels().get(0).getId().intValue(); + + Channel channel = IngestFixtureData.getChannel(channelId); + String[] parameters; + String tag = null, name = null; + if (null == channel.getFilterExpression()) { + // automatic channel + String automaticChannelExpression = IngestFixtureData.getAutomaticChannelExpression(channelId); + parameters = automaticChannelExpression.split(":"); + Verify.verify(parameters.length == 2); + tag = parameters[0]; + } else { + // KSQL channel + parameters = channel.getFilterExpression().split("="); + Verify.verify(parameters.length == 2); + if ("name".equals(parameters[0].toLowerCase())) { + // ingest VOD with mentioned name + name = parameters[0]; + } else { + // ingest VOD with Tag/Meta (currently supports only tags!!!) + tag = parameters[0]; + } + } + if (name != null) { + // ingest VOD by name + MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + IngestUtils.updateVODName(mediaAsset, name); + } + if (tag != null) { + // ingest VOD by tag + Map> tags = new HashMap<>(); + List values = new ArrayList<>(); + values.add(parameters[1].replaceAll("'", "")); + tags.put(tag, values); + IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(tags), Optional.empty(), + Optional.empty(), Optional.empty()); + } + } + + private static Channel loadDefaultChannel() { + Channel channel = new Channel(); + channel.setName(BaseUtils.getRandomValue("Channel_", 999999)); + channel.setDescription("Description of " + channel.getName()); + channel.setIsActive(true); + channel.setAssetTypes(null); + return channel; + } + // shared household public static class SharedHousehold { diff --git a/src/test/java/com/kaltura/client/test/tests/enums/ChannelType.java b/src/test/java/com/kaltura/client/test/tests/enums/ChannelType.java new file mode 100644 index 000000000..96de7d6c2 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/ChannelType.java @@ -0,0 +1,40 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum ChannelType implements EnumAsString { + AUTOMATIC_CHANNEL_TYPE("1"), + KSQL_CHANNEL_TYPE("4"), + MANUAL_CHANNEL_TYPE("2"); + + private String value; + + ChannelType(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static ChannelType get(String value) { + if(value == null) + { + return null; + } + + // goes over Channel types defined values and compare the inner value with the given one: + for(ChannelType item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return ChannelType.values().length > 0 ? ChannelType.values()[0]: null; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 9c50993ed..3a00847e1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -466,7 +466,7 @@ private void suspend_with_renew_subscription_role_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 20; - int maxTimeExpectingValidResponseInSeconds = 300; + int maxTimeExpectingValidResponseInSeconds = 360; await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) diff --git a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java index bc47e4394..90092e7c6 100644 --- a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java @@ -3,17 +3,16 @@ import com.google.common.base.Verify; import com.kaltura.client.enums.BundleType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.SubscriptionService; +import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.BundleFilter; -import com.kaltura.client.types.FilterPager; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.test.tests.enums.ChannelType; +import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; - import java.util.ArrayList; import java.util.List; import java.util.Optional; - import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; public class SubscriptionUtils extends BaseUtils { @@ -54,6 +53,27 @@ public static List getAssetsListBySubscription(int subscriptionId, Option return assets; } - // TODO: 6/12/2018 add getChannelsListBySubscription + public static Channel loadAutomaticOrKsqlChannel(String subscriptionId) { + List channels = getChannelsListBySubscription(subscriptionId); + String channelType; + Channel result; + for (BaseChannel channel: channels) { + result = IngestFixtureData.getChannel(channel.getId().intValue()); + channelType = result.toParams().get("channel_type").toString(); + if (ChannelType.AUTOMATIC_CHANNEL_TYPE.getValue().equals(channelType) || + ChannelType.KSQL_CHANNEL_TYPE.getValue().equals(channelType)) { + return result; + } + } + return null; + } + public static List getChannelsListBySubscription(String subscriptionId) { + SubscriptionFilter filter = new SubscriptionFilter(); + filter.setSubscriptionIdIn(subscriptionId); + ListSubscriptionBuilder listSubscriptionBuilder = SubscriptionService.list(filter); + Response> listResponse = BaseTest.executor.executeSync(listSubscriptionBuilder.setKs(getOperatorKs())); + Verify.verify(listResponse.results.getObjects().get(0).getChannels().size() > 0); + return listResponse.results.getObjects().get(0).getChannels(); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 2bc0d6e5e..5da391034 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -1,11 +1,15 @@ package com.kaltura.client.test.utils.dbUtils; +import com.kaltura.client.test.tests.enums.ChannelType; + public class DBConstants { // fields: static final String ACTIVATION_TOKEN = "activation_token"; static final String CODE = "code"; + static final String CHANNEL_TYPE = "channel_type"; static final String CP_TOKEN = "cp_token"; + static final String FILTER_EXPRESSION = "ksql_filter"; static final String FULL_LIFE_CYCLE_MINUTES = "full_life_cycle_min"; static final String ID = "id"; static final String INT_DISCOUNT_ID = "internal_discount_id"; @@ -21,6 +25,8 @@ public class DBConstants { static final String SERV_ID = "serv_id"; static final String SUBSCRIPTION_ONLY = "subscription_only"; static final String SUB_ID = "sub_id"; + static final String TAG_TYPE = "tag_type"; + static final String TAG_VALUE = "tag_value"; static final String USERNAME = "username"; static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; @@ -31,6 +37,14 @@ public class DBConstants { static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = '%S'"; + static final String CHANNEL_EXPRESSION_SELECT = "select t.tag_type_id as tag_name, t.value as tag_value\n" + + "from [TVinci].[dbo].[tags] t, [TVinci].[dbo].[channel_tags] ct\n" + + "where ct.status=1 and t.status=1 and ct.channel_id=%d and ct.tag_id=t.id"; + + static final String CHANNEL_SELECT = "select *\n" + + "from [TVinci].[dbo].[channels]\n" + + "where id=%d"; + static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + "from [Users].[dbo].[groups_parameters]\n" + "where group_id=%d"; @@ -91,10 +105,16 @@ public class DBConstants { "and group_id=%d and usage_module_code=%d and discount_module_code=%d\n" + "order by create_date"; - static final String SUBSCRIPTION_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + - "where [status]=1 and is_active=1 and [type]=0 and is_recurring=1\n" + - "and group_id=%d and usage_module_code=%d\n" + - "order by create_date"; + static final String SUBSCRIPTION_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions] s with(nolock)\n" + + "join [Pricing].[dbo].[usage_modules] um with(nolock) on (s.usage_module_code=um.id)\n" + + "join [Pricing].[dbo].[subscriptions_channels] sc with(nolock) on (sc.subscription_id=s.id)\n" + + "join [TVinci].[dbo].[channels] c with(nolock) on (c.id=sc.channel_id)\n" + + "where um.[status]=1 and um.is_active=1 and um.view_life_cycle_min=5 and um.full_life_cycle_min=5 and " + + // TODO: not sure about um.num_of_rec_periods > 2 + "um.is_renew=1 and ((um.num_of_rec_periods > 2) or (um.num_of_rec_periods = 0))\n" + + "and s.is_recurring=1 and c.channel_type!=" + ChannelType.MANUAL_CHANNEL_TYPE.getValue() + " " + + "and s.group_id=%d and s.is_active=1 and s.[status]=1 and s.[type]=0\n" + + "order by s.create_date"; static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) SUBSCRIPTION_ID as " + SUB_ID + ", SERVICE_ID as " + SERV_ID + "\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 131e7ae50..111925af7 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -1,11 +1,18 @@ package com.kaltura.client.test.utils.dbUtils; import com.google.common.base.Strings; +import com.google.common.base.Verify; import com.kaltura.client.Logger; import com.kaltura.client.enums.SubscriptionDependencyType; +import com.kaltura.client.services.SubscriptionService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.SubscriptionUtils; import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; import org.json.JSONArray; import java.sql.SQLException; + +import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; import static com.kaltura.client.test.utils.dbUtils.DBUtils.ERROR_MESSAGE; @@ -278,15 +285,10 @@ public static Ppv loadSharedCommonPpv(PricePlan pricePlan) { public static Subscription loadShared5MinutesRenewableSubscription() { Logger.getLogger(IngestFixtureData.class).debug("loadShared5MinutesRenewableSubscription()"); - PricePlan pricePlan = load5MinRenewablePricePlan(); - if (pricePlan == null) { - return null; - } Subscription subscription = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_5_MIN_RENEW_SELECT, partnerId, - pricePlan.getId()), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(SUBSCRIPTION_5_MIN_RENEW_SELECT, partnerId), true); if (Strings.isNullOrEmpty(jsonArray.toString())) { return subscription; } @@ -304,4 +306,47 @@ public static Subscription loadShared5MinutesRenewableSubscription() { } return subscription; } + + public static Channel getChannel(int id) { + Logger.getLogger(IngestFixtureData.class).debug("getChannel(): id = " + id); + Channel channel = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHANNEL_SELECT, id), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return channel; + } + + channel = new Channel(); + channel.setId(jsonArray.getJSONObject(0).getLong(ID)); + channel.setName(jsonArray.getJSONObject(0).getString(NAME)); + // logic if FILTER_EXPRESSION is not null so we have KSQL channel, otherwise we have automatic channel + channel.setFilterExpression(jsonArray.getJSONObject(0).getString(FILTER_EXPRESSION)); + channel.setToken(CHANNEL_TYPE, String.valueOf(jsonArray.getJSONObject(0).getInt(CHANNEL_TYPE))); + // TODO: add more data in case it needed + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("channel data can't be null"); + } + return channel; + } + + public static String getAutomaticChannelExpression(int channelId) { + Logger.getLogger(IngestFixtureData.class).debug("getAutomaticChannelExpression(): channelId = " + channelId); + String result = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHANNEL_EXPRESSION_SELECT, channelId), true); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return result; + } + + result = jsonArray.getJSONObject(0).getString(TAG_TYPE) + ":" + + jsonArray.getJSONObject(0).getString(TAG_VALUE); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("channel tags data can't be null"); + } + return result; + } } diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index d9fabe795..82f0cd45d 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -41,6 +41,9 @@ }, { "$ref": "UserRole.json#/definitions/UserRole" + }, + { + "$ref": "Subscription.json#/definitions/Subscription" } ] } @@ -62,7 +65,8 @@ "KalturaBookmarkListResponse", "KalturaAssetCommentListResponse", "KalturaAssetHistoryListResponse", - "KalturaUserRoleListResponse" + "KalturaUserRoleListResponse", + "KalturaSubscriptionListResponse" ] } }, diff --git a/src/test/resources/schemas/Subscription.json b/src/test/resources/schemas/Subscription.json new file mode 100644 index 000000000..4eeb100ac --- /dev/null +++ b/src/test/resources/schemas/Subscription.json @@ -0,0 +1,297 @@ +{ + "$id": "Subscription", + "definitions": { + "Subscription": { + "type": "object", + "properties": { + "result": { + "type": "object", + "additionalProperties": false, + "properties": { + "objects": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "default": "" + }, + "channels": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": "integer", + "default": 0 + }, + "objectType": { + "type": "string", + "default": "KalturaBaseChannel" + } + }, + "required": [ + "id", + "objectType" + ] + } + }, + "startDate": { + "type": "integer", + "default": 0 + }, + "endDate": { + "type": "integer", + "default": 0 + }, + "fileTypes": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "value": { + "type": "integer", + "default": 0 + }, + "objectType": { + "type": "string", + "default": "KalturaIntegerValue" + } + }, + "required": [ + "value", + "objectType" + ] + } + }, + "isRenewable": { + "type": "boolean", + "default": false + }, + "renewalsNumber": { + "type": "integer", + "default": 0 + }, + "isInfiniteRenewal": { + "type": "boolean", + "default": false + }, + "price": { + "$ref": "Price.json#/definitions/Price" + }, + "discountModule": { + "type": "object", + "additionalProperties": false, + "properties": { + "percent": { + "type": "integer", + "default": 0 + }, + "startDate": { + "type": "integer", + "default": 0 + }, + "endDate": { + "type": "integer", + "default": 0 + }, + "objectType": { + "type": "string", + "default": "KalturaDiscountModule" + } + }, + "required": [ + "percent", + "startDate", + "endDate", + "objectType" + ] + }, + "name": { + "type": "string", + "default": "" + }, + "description": { + "type": "string", + "default": "" + }, + "mediaId": { + "type": "integer", + "default": 0 + }, + "prorityInOrder": { + "type": "integer", + "default": 0 + }, + "pricePlanIds": { + "type": "string", + "default": "" + }, + "householdLimitationsId": { + "type": "integer", + "default": 0 + }, + "gracePeriodMinutes": { + "type": "integer", + "default": 0 + }, + "premiumServices": { + "type": "array" + }, + "maxViewsNumber": { + "type": "integer", + "default": 0 + }, + "viewLifeCycle": { + "type": "integer", + "default": 0 + }, + "waiverPeriod": { + "type": "integer", + "default": 0 + }, + "isWaiverEnabled": { + "type": "boolean", + "default": false + }, + "userTypes": { + "type": "array" + }, + "couponsGroups": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "default": "" + }, + "name": { + "type": "string", + "default": "" + }, + "startDate": { + "type": "integer", + "default": 0 + }, + "endDate": { + "type": "integer", + "default": 0 + }, + "maxUsesNumber": { + "type": "integer", + "default": 0 + }, + "maxUsesNumberOnRenewableSub": { + "type": "integer", + "default": 0 + }, + "couponGroupType": { + "type": "string", + "default": "" + }, + "maxHouseholdUses": { + "type": "integer", + "default": 0 + }, + "objectType": { + "type": "string", + "default": "KalturaCouponsGroup" + } + }, + "required": [ + "id", + "name", + "startDate", + "endDate", + "maxUsesNumber", + "maxUsesNumberOnRenewableSub", + "couponGroupType", + "maxHouseholdUses", + "objectType" + ] + } + }, + "productCodes": { + "type": "array" + }, + "dependencyType": { + "type": "string", + "default": "" + }, + "externalId": { + "type": "string", + "default": "" + }, + "isCancellationBlocked": { + "type": "boolean", + "default": false + }, + "objectType": { + "type": "string", + "default": "KalturaSubscription" + } + }, + "required": [ + "id", + "channels", + "startDate", + "endDate", + "fileTypes", + "isRenewable", + "renewalsNumber", + "isInfiniteRenewal", + "name", + "description", + "mediaId", + "prorityInOrder", + "pricePlanIds", + "householdLimitationsId", + "gracePeriodMinutes", + "premiumServices", + "maxViewsNumber", + "viewLifeCycle", + "waiverPeriod", + "isWaiverEnabled", + "userTypes", + "couponsGroups", + "productCodes", + "dependencyType", + "externalId", + "isCancellationBlocked", + "objectType" + ] + } + }, + "totalCount": { + "type": "integer", + "default": 0 + }, + "objectType": { + "type": "string", + "default": "KalturaSubscriptionListResponse" + } + }, + "required": [ + "objects", + "totalCount", + "objectType" + ] + } + } + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/Subscription" + }, + "executionTime": {"type": "number"} + }, + "required": ["result", "executionTime"] +} From eadee71a269a5edabfc9d937cf2c10e0d0c6198f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 14 Jun 2018 15:13:04 +0300 Subject: [PATCH 352/605] changed request getting MPP with media --- .../java/com/kaltura/client/test/utils/dbUtils/DBConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 7afd0d1ae..62b8542b5 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -114,7 +114,7 @@ public class DBConstants { "um.is_renew=1 and ((um.num_of_rec_periods > 2) or (um.num_of_rec_periods = 0))\n" + "and s.is_recurring=1 and c.channel_type!=" + ChannelType.MANUAL_CHANNEL_TYPE.getValue() + " " + "and s.group_id=? and s.is_active=1 and s.[status]=1 and s.[type]=0\n" + - "order by s.create_date"; + "order by s.create_date desc"; static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) SUBSCRIPTION_ID as " + SUB_ID + ", SERVICE_ID as " + SERV_ID + "\n" + From 2334c467159552b6543b97830156a3d43af1551e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 14 Jun 2018 15:34:11 +0300 Subject: [PATCH 353/605] refactor ingestUtils - part 1 --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../SearchAssetFilterTests.java | 93 +++++++------------ .../appTokenTests/AppTokenAddTests.java | 2 +- .../client/test/utils/IngestUtils.java | 45 +++++---- .../kaltura/client/test/utils/XmlUtils.java | 33 +++++++ .../ingest_xml_templates/ingestVOD.xml | 72 ++++++++++++++ 6 files changed, 170 insertions(+), 77 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/XmlUtils.java create mode 100644 src/test/resources/ingest_xml_templates/ingestVOD.xml diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 0b8a79c97..52841207a 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -286,7 +286,7 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { - mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + mediaAsset = IngestUtils.ingestVOD (Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index fe71fd0d8..fcd44fa9e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -57,16 +57,9 @@ private void Asset_list_before_class() { asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-10))); program = IngestUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestUtils.ingestEPG(epgChannelName2, 1).get(0); - - System.out.println("Asset3!! " + asset3.getId()); - System.out.println("Asset2!! " + asset2.getId()); - System.out.println("Asset!! " + asset.getId()); } - // VOD - // ****************************************** - @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - name equal query") @Test @@ -128,7 +121,6 @@ private void listVodAssetsWithAndQuery() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); } - @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - not query") @Test @@ -142,7 +134,6 @@ private void listVodAssetsWithNotKsqlQuery() { Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); - } @Severity(SeverityLevel.CRITICAL) @@ -160,30 +151,26 @@ private void listVodAssetsWithLikeKsqlQuery() { assertThat(assets).extracting("id").contains(asset3.getId(), asset2.getId()).doesNotContain(asset.getId()); } - @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - start with query") @Test private void listVodAssetsWithStartWithKsqlQuery() { - - ksqlQuery = "" + tagName + " ^ '" + tagValue + "'"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, null); listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); List assets = executor.executeSync(listAssetBuilder).results.getObjects(); - assertThat(assets.size()).isEqualTo(2); + assertThat(assets).isNotNull(); + assertThat(assets.size()).isEqualTo(2); assertThat(assets).extracting("id").contains(asset3.getId(), asset2.getId()).doesNotContain(asset.getId()); } - @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - filtered by type (Movie)") @Test private void listVodAssetsFilteredByType() { - ksqlQuery = "" + tagName + " = '" + tagValue + "'"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, getProperty(MOVIE_MEDIA_TYPE_ID), null, null, null, null); @@ -191,15 +178,15 @@ private void listVodAssetsFilteredByType() { .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results).isNotNull(); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - order by VIEWS") + @Description("Asset/action/list - VOD - order by VIEWS") @Test private void OrderVodAssetsByViews() { - AssetUtils.addViewsToAsset(asset.getId(), 3, AssetType.MEDIA); AssetUtils.addViewsToAsset(asset2.getId(), 2, AssetType.MEDIA); AssetUtils.addViewsToAsset(asset3.getId(), 1, AssetType.MEDIA); @@ -219,42 +206,40 @@ private void OrderVodAssetsByViews() { } //TODO - Enable test after fixing updateVodName method -// @Severity(SeverityLevel.CRITICAL) -// @Description("Asset/action/list - VOD - order by NAME (DESC/ASC") -// @Test -// private void OrderVodAssetsByName() { -// -// IngestUtils.updateVODName(asset, "AAA"); -// IngestUtils.updateVODName(asset2, "BBB"); -// IngestUtils.updateVODName(asset3, "CCC"); -// -// ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; -// assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); -// -// listAssetBuilder = AssetService.list(assetFilter, null) -// .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); -// -// Response> assetListResponse = executor.executeSync(listAssetBuilder); -// assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); -// assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); -// assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); -// -// assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); -// -// listAssetBuilder = AssetService.list(assetFilter, null) -// .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); -// -// assetListResponse = executor.executeSync(listAssetBuilder); -// assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); -// assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); -// assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); -// } + @Severity(SeverityLevel.CRITICAL) + @Description("Asset/action/list - VOD - order by NAME (DESC/ASC") + @Test(enabled = false) + private void OrderVodAssetsByName() { + IngestUtils.updateVODName(asset, "AAA"); + IngestUtils.updateVODName(asset2, "BBB"); + IngestUtils.updateVODName(asset3, "CCC"); + + ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); + + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); + + assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); + + listAssetBuilder = AssetService.list(assetFilter, null) + .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + + assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); + } @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - VOD - order by LIKES") @Test private void orderVodAssetsByLikes() { - AssetUtils.addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); AssetUtils.addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); AssetUtils.addLikesToAsset(asset.getId(), 1, AssetType.MEDIA); @@ -276,12 +261,10 @@ private void orderVodAssetsByLikes() { @Description("Asset/action/list - VOD - order by (num of) VOTES and RATING") @Test private void orderVodAssetsByVotesAndRating() { - AssetUtils.addVotesToAsset(asset2.getId(), 2, AssetType.MEDIA, 1); AssetUtils.addVotesToAsset(asset3.getId(), 1, AssetType.MEDIA, 5); // Order by number of votes (highest to lowest) - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) @@ -294,7 +277,6 @@ private void orderVodAssetsByVotesAndRating() { assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); // Order by Ratings (highest to lowest) - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); @@ -310,7 +292,6 @@ private void orderVodAssetsByVotesAndRating() { @Description("Asset/action/list - VOD - order by CATALOG START DATE") @Test private void orderVodAssetsByCatalogStartDate() { - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); listAssetBuilder = AssetService.list(assetFilter, null) @@ -329,14 +310,10 @@ private void orderVodAssetsByCatalogStartDate() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); - } //TODO - add test for KalturaPersistedFilter in searchHistory class - // EPG - // ****************************************** - @Severity(SeverityLevel.CRITICAL) @Description("Asset/action/list - EPG - name equal query") @Test @@ -383,6 +360,4 @@ private void listEpgProgramsFilteredByEpgChannel() { assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program2.getId()); } -} - - +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index fbfc50f80..96b0264bd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -84,7 +84,7 @@ private void addAppTokenWithPrivileges() { } @Description("appToken/action/add - with expiry date") - @Test(groups = "slow_before") + @Test(groups = "slow_before", priority = 1) private void addAppTokenWithExpiryDate_before() { // setup for test add_tests_before_class(); diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java index 79662c788..836983208 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/IngestUtils.java @@ -5,6 +5,7 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.AssetService.*; +import com.kaltura.client.test.tests.Sandbox; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -191,9 +192,12 @@ public static List ingestEPG(String epgChannelName, Optional= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 60; - await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + int maxTimeExpectingValidResponseInSeconds = 90; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue * seasonCountValue)); Response> ingestedProgrammes = executor.executeSync( @@ -202,7 +206,6 @@ public static List ingestEPG(String epgChannelName, Optional) (Object) ingestedProgrammes.results.getObjects(); - } private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { @@ -776,9 +779,8 @@ private static String buildIngestPpvXML(String action, String ppvCode, boolean i */ // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project public static MediaAsset ingestVOD(Optional action, Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, - Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, - Optional mediaType, Optional ppvWebName, Optional ppvMobileName, - Optional>> tags, Optional> strings, + Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, Optional mediaType, + Optional ppvWebName, Optional ppvMobileName, Optional>> tags, Optional> strings, Optional> numbers, Optional> dates) { String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; String coguidDatePattern = "yyMMddHHmmssSS"; @@ -806,7 +808,8 @@ public static MediaAsset ingestVOD(Optional action, Optional cog String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; HashMap headerMap = new HashMap<>(); headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestTvinciData\""); + headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestTvinciData"); + String reqBody = "\n" + " \n" + " \n" + @@ -816,14 +819,23 @@ public static MediaAsset ingestVOD(Optional action, Optional cog " ]]>\n" + " \n" + ""; + + String reqBody1 = null; + try { + reqBody1 = Sandbox.buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, + catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); + } catch (Exception e) { + e.printStackTrace(); + } + io.restassured.response.Response resp = RestAssured.given() .log().all() .headers(headerMap) - .body(reqBody) + .body(reqBody1) .post(url); - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); +// Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug("\n" + resp.asString()); String id; if (INGEST_ACTION_INSERT.equals(actionValue)) { @@ -841,8 +853,12 @@ public static MediaAsset ingestVOD(Optional action, Optional cog if (!INGEST_ACTION_DELETE.equals(actionValue)) { int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 60; - await().pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS).atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS).until(isDataReturned(getAnonymousKs(), id, actionValue)); + int maxTimeExpectingValidResponseInSeconds = 90; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(isDataReturned(getAnonymousKs(), id, actionValue)); + mediaAsset.setMediaFiles(executor.executeSync( AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); } @@ -1028,6 +1044,7 @@ private static String generateTagsXml(Map> metas) { if (metas.isEmpty()) { return ""; } + StringBuilder result = new StringBuilder(); String key; List values; @@ -1050,7 +1067,6 @@ private static String generateTagsXml(Map> metas) { // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestVOD(String mediaType, Map> tags, String catalogStartDate) { MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(catalogStartDate), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), @@ -1067,7 +1083,6 @@ public static MediaAsset ingestVOD(String mediaType) { return mediaAsset; } - public static MediaAsset updateVODName(MediaAsset asset, String name) { MediaAsset mediaAsset = ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), @@ -1076,8 +1091,6 @@ public static MediaAsset updateVODName(MediaAsset asset, String name) { return mediaAsset; } - - public static ArrayList ingestBasicVODNumOfTimes(int numOfAssets, String mediaType) { MediaAsset mediaAsset; ArrayList assetList = new ArrayList<>(); diff --git a/src/test/java/com/kaltura/client/test/utils/XmlUtils.java b/src/test/java/com/kaltura/client/test/utils/XmlUtils.java new file mode 100644 index 000000000..6b211e266 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/XmlUtils.java @@ -0,0 +1,33 @@ +package com.kaltura.client.test.utils; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.util.AbstractList; +import java.util.Collections; +import java.util.List; +import java.util.RandomAccess; + +public class XmlUtils extends BaseUtils { + + public static List asList(NodeList n) { + return n.getLength() == 0 ? Collections.emptyList() : new NodeListWrapper(n); + } + + static final class NodeListWrapper extends AbstractList implements RandomAccess { + private final NodeList list; + + NodeListWrapper(NodeList nodeList) { + list = nodeList; + } + + public Node get(int index) { + return list.item(index); + } + + public int size() { + return list.getLength(); + } + } + +} diff --git a/src/test/resources/ingest_xml_templates/ingestVOD.xml b/src/test/resources/ingest_xml_templates/ingestVOD.xml new file mode 100644 index 000000000..eb5cf9682 --- /dev/null +++ b/src/test/resources/ingest_xml_templates/ingestVOD.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Parent Allowed + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c42ed73196ef99cc0be5041771574afec809f732 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 14 Jun 2018 17:09:24 +0300 Subject: [PATCH 354/605] move IngestUtils place --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../client/test/tests/enums/Currency.java | 3 +- .../SearchAssetFilterTests.java | 4 +- .../AssetCommentAddTests.java | 2 +- .../AssetCommentListTests.java | 2 +- .../AssetHistoryCleanTests.java | 2 +- .../AssetHistoryListTests.java | 2 +- .../channelTests/ChannelAddTests.java | 2 +- .../EntitlementCancelTests.java | 1 + .../EntitlementListTests.java | 3 +- .../ProductPriceListTests.java | 3 +- .../utils/{ => ingestUtils}/IngestUtils.java | 173 ++-------------- .../utils/ingestUtils/IngestVodUtils.java | 191 ++++++++++++++++++ .../ingest_xml_templates/ingestVOD.xml | 52 ++--- 14 files changed, 242 insertions(+), 200 deletions(-) rename src/test/java/com/kaltura/client/test/utils/{ => ingestUtils}/IngestUtils.java (85%) create mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 52841207a..026b78917 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -5,7 +5,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; diff --git a/src/test/java/com/kaltura/client/test/tests/enums/Currency.java b/src/test/java/com/kaltura/client/test/tests/enums/Currency.java index d263c9d2e..8b23a2570 100644 --- a/src/test/java/com/kaltura/client/test/tests/enums/Currency.java +++ b/src/test/java/com/kaltura/client/test/tests/enums/Currency.java @@ -24,8 +24,7 @@ public void setValue(String value) { } public static Currency get(String value) { - if(value == null) - { + if(value == null) { return null; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index fcd44fa9e..034d45bc9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -7,6 +7,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -146,8 +147,9 @@ private void listVodAssetsWithLikeKsqlQuery() { listAssetBuilder = AssetService.list(assetFilter, null) .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); List assets = executor.executeSync(listAssetBuilder).results.getObjects(); - assertThat(assets.size()).isEqualTo(2); + assertThat(assets).isNotNull(); + assertThat(assets.size()).isEqualTo(2); assertThat(assets).extracting("id").contains(asset3.getId(), asset2.getId()).doesNotContain(asset.getId()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 793ced13c..749b83c5c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -6,7 +6,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index a530f0b7c..ea9ae8dea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.services.AssetCommentService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; import com.kaltura.client.types.Household; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 771ec1924..bce584a49 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -8,7 +8,7 @@ import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 536cc1685..a9525075f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -7,7 +7,7 @@ import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index ced3b5aa6..cb44cd0ea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -7,7 +7,7 @@ import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.ChannelUtils; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 49234c57f..2d0ea31ce 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -9,6 +9,7 @@ import com.kaltura.client.services.LicensedUrlService.GetLicensedUrlBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index abda85379..e9047cc3c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -9,7 +9,7 @@ import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -23,7 +23,6 @@ import static com.kaltura.client.enums.EntitlementOrderBy.PURCHASE_DATE_ASC; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; -import static com.kaltura.client.test.Properties.PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementListTests extends BaseTest { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index eb4fe1e45..8037c1ca5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -6,15 +6,14 @@ import com.kaltura.client.services.ChannelService.DeleteChannelBuilder; import com.kaltura.client.services.AssetService.ListAssetBuilder; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; -import com.kaltura.client.services.EntitlementService.ForceCancelEntitlementBuilder; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.hamcrest.MatcherAssert; diff --git a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java similarity index 85% rename from src/test/java/com/kaltura/client/test/utils/IngestUtils.java rename to src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java index 836983208..f5e6354ee 100644 --- a/src/test/java/com/kaltura/client/test/utils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java @@ -1,25 +1,28 @@ -package com.kaltura.client.test.utils; +package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.AssetService.*; -import com.kaltura.client.test.tests.Sandbox; +import com.kaltura.client.services.AssetService.GetAssetBuilder; +import com.kaltura.client.services.AssetService.ListAssetBuilder; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; -import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; + import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.buildIngestVodXml; import static io.restassured.path.xml.XmlPath.from; import static org.awaitility.Awaitility.await; @@ -810,19 +813,9 @@ public static MediaAsset ingestVOD(Optional action, Optional cog headerMap.put("Content-Type", "text/xml;charset=UTF-8"); headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestTvinciData"); - String reqBody = "\n" + - " \n" + - " \n" + - " " + getIngestAssetUserName() + "" + getIngestAssetUserPassword() + "" + - " \n" + - " \n" + - ""; - - String reqBody1 = null; + String reqBody = null; try { - reqBody1 = Sandbox.buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, + reqBody = buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); } catch (Exception e) { e.printStackTrace(); @@ -831,11 +824,11 @@ public static MediaAsset ingestVOD(Optional action, Optional cog io.restassured.response.Response resp = RestAssured.given() .log().all() .headers(headerMap) - .body(reqBody1) + .body(reqBody) .post(url); // Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug("\n" + resp.asString()); + Logger.getLogger(IngestUtils.class).debug("Ingest response: \n" + resp.asString()); String id; if (INGEST_ACTION_INSERT.equals(actionValue)) { @@ -886,8 +879,6 @@ private static Map> getDefaultTags() { tags.put("Free", tagValues); tagValues = new ArrayList<>(); tags.put("Parental Rating", tagValues); - /*tagValues = new ArrayList<>(); - tags.put("", tagValues);*/ return tags; } @@ -926,147 +917,7 @@ private static Callable isDataReturned(String ks, String mediaId, Strin } } - private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, - String description, String catalogStartDate, String catalogEndDate, - String startDate, String endDate, String mediaType, String ppvWebName, - String ppvMobileName, Map> tags, - Map strings, Map numbers, Map dates) { - return "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + name + "\n" + - " \n" + - " \n" + - " \n" + - " " + description + "\n" + - " \n" + - " \n" + - " " + catalogStartDate + "\n" + - " " + startDate + "\n" + - " " + catalogEndDate + "\n" + - " " + endDate + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + mediaType + "\n" + - " \n" + - //" ${#TestCase#i_geo_block_rule}\n" + - // TODO: check where to put that value (is it env-dependent?) - " Parent Allowed\n" + - //" ${#TestCase#i_device_block_rule}\n" + - " \n" + - " \n" + - " \n" + - generateStringsXml(strings) + - " \n" + - generateNumbersXml(numbers) + - generateDatesXml(dates) + - generateTagsXml(tags) + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - } - - private static String generateNumbersXml(Map numbers) { - if (numbers.isEmpty()) { - return ""; - } - StringBuilder result = new StringBuilder(); - String key; - int value; - result.append(" \n"); - for (Map.Entry entry : numbers.entrySet()) { - key = entry.getKey(); - value = entry.getValue(); - result.append("" + value + "\n"); - } - result.append(" \n"); - - return result.toString(); - } - - private static String getMetaXml(String key, String value) { - StringBuilder sb = new StringBuilder(); - sb.append(" \n"); - sb.append(" " + value + "\n"); - sb.append(" \n"); - - return sb.toString(); - } - - private static String generateStringsXml(Map strings) { - if (strings.isEmpty()) { - return ""; - } - StringBuilder result = new StringBuilder(); - String key, value; - result.append(" \n"); - for (Map.Entry entry : strings.entrySet()) { - key = entry.getKey(); - value = entry.getValue(); - result.append(" \n"); - result.append(" " + value + "\n"); - result.append(" \n"); - //result.append(getMetaXml(key, value)); - } - result.append(" \n"); - - return result.toString(); - } - - private static String generateDatesXml(Map dates) { - if (dates.isEmpty()) { - return ""; - } - StringBuilder result = new StringBuilder(); - String key, value; - result.append(" \n"); - for (Map.Entry entry : dates.entrySet()) { - key = entry.getKey(); - value = entry.getValue(); - result.append("" + value + "\n"); - } - result.append(" \n"); - - return result.toString(); - } - - private static String generateTagsXml(Map> metas) { - if (metas.isEmpty()) { - return ""; - } - - StringBuilder result = new StringBuilder(); - String key; - List values; - result.append(" \n"); - for (Map.Entry> entry : metas.entrySet()) { - key = entry.getKey(); - values = entry.getValue(); - result.append(" \n"); - for (String value : values) { - result.append(" \n"); - result.append(" " + value + "\n"); - result.append(" \n"); - } - result.append(" \n"); - } - result.append(" \n"); - - return result.toString(); - } - // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestVOD(String mediaType, Map> tags, String catalogStartDate) { MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(catalogStartDate), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), @@ -1100,4 +951,4 @@ public static ArrayList ingestBasicVODNumOfTimes(int numOfAssets, String mediaTy } return assetList; } -} +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java new file mode 100644 index 000000000..7a4bda936 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -0,0 +1,191 @@ +package com.kaltura.client.test.utils.ingestUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.StringWriter; +import java.io.Writer; +import java.util.List; +import java.util.Map; + +import static com.kaltura.client.test.Properties.MOBILE_FILE_TYPE; +import static com.kaltura.client.test.Properties.WEB_FILE_TYPE; +import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.tests.BaseTest.getIngestAssetUserName; +import static com.kaltura.client.test.tests.BaseTest.getIngestAssetUserPassword; +import static com.kaltura.client.test.utils.XmlUtils.asList; + +public class IngestVodUtils { + + public static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, + String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName, Map> tags, Map strings, + Map numbers, Map dates) { + + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder; + Document doc = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestVOD.xml"); + } catch (Exception e) { + e.printStackTrace(); + } + + // user and password + doc.getElementsByTagName("userName").item(0).setTextContent(getIngestAssetUserName()); + doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestAssetUserPassword()); + +// // add CDATA section +// CDATASection cdata = doc.createCDATASection(""); +// doc.getElementsByTagName("tem:request").item(0).appendChild(cdata); + + // media + Element media = (Element) doc.getElementsByTagName("media").item(0); + media.setAttribute("co_guid", coguid); + media.setAttribute("entry_id", "entry_" + coguid); + media.setAttribute("action", action); + media.setAttribute("is_active", Boolean.toString(isActive)); + + // name + Element nameElement = (Element) media.getElementsByTagName("name").item(0); + nameElement.getElementsByTagName("value").item(0).setTextContent(name); + + // thumb + Element thumb = (Element) media.getElementsByTagName("thumb").item(0); + thumb.setAttribute("url", thumbUrl); + + // description + Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); + descriptionElement.getElementsByTagName("value").item(0).setTextContent(description); + + // dates + Element datesElement = (Element) media.getElementsByTagName("dates").item(0); + datesElement.getElementsByTagName("catalog_start").item(0).setTextContent(catalogStartDate); + datesElement.getElementsByTagName("start").item(0).setTextContent(startDate); + datesElement.getElementsByTagName("catalog_end").item(0).setTextContent(catalogEndDate); + datesElement.getElementsByTagName("end").item(0).setTextContent(endDate); + + // pic_ratios + Element picRatios = (Element) media.getElementsByTagName("pic_ratios").item(0); + for (Node n : asList(picRatios.getElementsByTagName("ratio"))) { + Element e = (Element) n; + e.setAttribute("thumb", thumbUrl); + } + + // media type + media.getElementsByTagName("media_type").item(0).setTextContent(mediaType); + + // strings + Element stringsElement = (Element) media.getElementsByTagName("strings").item(0); + for (Map.Entry entry : strings.entrySet()) { + // meta node + Element meta = generateAndAppendMetaNode(doc, stringsElement, entry.getKey()); + + // value node + Element value = doc.createElement("value"); + value.setAttribute("lang", "eng"); + value.setTextContent(entry.getValue()); + meta.appendChild(value); + } + + // doubles + Element doublesElement = (Element) media.getElementsByTagName("doubles").item(0); + for (Map.Entry entry : numbers.entrySet()) { + // meta node + Element meta = generateAndAppendMetaNode(doc, doublesElement, entry.getKey()); + meta.setTextContent(String.valueOf(entry.getValue())); + } + + // dates + Element datesMetaElement = (Element) media.getElementsByTagName("dates").item(1); + for (Map.Entry entry : dates.entrySet()) { + // meta node + Element metaElement = generateAndAppendMetaNode(doc, datesMetaElement, entry.getKey()); + metaElement.setTextContent(entry.getValue()); + } + + // metas + Element metasElement = (Element) media.getElementsByTagName("metas").item(0); + for (Map.Entry> entry : tags.entrySet()) { + // meta node + generateAndAppendMetaNode(doc, metasElement, entry.getKey()); + if (entry.getValue() != null) { + // container node + for (String s : entry.getValue()) { + Element container = doc.createElement("container"); + metasElement.appendChild(container); + + // value node + Element value = doc.createElement("value"); + value.setTextContent(s); + value.setAttribute("lang", "eng"); + container.appendChild(value); + } + } + } + + // file types + Element file1 = (Element) media.getElementsByTagName("file").item(0); + file1.setAttribute("type", getProperty(WEB_FILE_TYPE)); + file1.setAttribute("co_guid", "web_" + coguid); + file1.setAttribute("PPV_MODULE", ppvWebName); + + Element file2 = (Element) media.getElementsByTagName("file").item(1); + file2.setAttribute("type", getProperty(MOBILE_FILE_TYPE)); + file2.setAttribute("co_guid", "ipad_" + coguid); + file2.setAttribute("PPV_MODULE", ppvMobileName); + + // uncomment cdata + String docAsString = docToString(doc); + docAsString = docAsString + .replace("", "-->", "]]>"); + + return docAsString; + } + + private static Element generateAndAppendMetaNode(Document doc, Element rootElement, String name) { + // meta node + Element meta = doc.createElement("meta"); + meta.setAttribute("name", name); + meta.setAttribute("ml_handling", "unique"); + rootElement.appendChild(meta); + + return meta; + } + + private static String docToString(Document doc) { + try { + StringWriter sw = new StringWriter(); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + + transformer.transform(new DOMSource(doc), new StreamResult(sw)); + return sw.toString(); + } catch (Exception ex) { + throw new RuntimeException("Error converting to String", ex); + } + } + + private static void prettyPrint(Document doc) throws Exception { + Transformer tf = TransformerFactory.newInstance().newTransformer(); + tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + tf.setOutputProperty(OutputKeys.INDENT, "yes"); + Writer out = new StringWriter(); + tf.transform(new DOMSource(doc), new StreamResult(out)); + System.out.println(out.toString()); + } +} diff --git a/src/test/resources/ingest_xml_templates/ingestVOD.xml b/src/test/resources/ingest_xml_templates/ingestVOD.xml index eb5cf9682..99b688f2d 100644 --- a/src/test/resources/ingest_xml_templates/ingestVOD.xml +++ b/src/test/resources/ingest_xml_templates/ingestVOD.xml @@ -4,61 +4,61 @@ - - + + - + - + - + - + - - - - + + + + - - + + - + - + Parent Allowed - + - + - - - + + + - - From 799861f0397f4e5f5f325e391435fb7a8d612c99 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 14 Jun 2018 17:11:28 +0300 Subject: [PATCH 355/605] no message --- .../kaltura/client/test/tests/BaseTest.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index de8ba1be7..64267fa13 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -10,32 +10,28 @@ import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -<<<<<<< HEAD -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; -======= import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.IngestUtils; -import com.kaltura.client.test.utils.SubscriptionUtils; ->>>>>>> master import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; + import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.TimeUnit; + import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; -import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; -import static com.kaltura.client.test.utils.HouseholdUtils.getDevicesListFromHouseHold; -import static com.kaltura.client.test.utils.HouseholdUtils.getUsersListFromHouseHold; +import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; +import static com.kaltura.client.test.utils.SubscriptionUtils.getAssetsListBySubscription; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -173,8 +169,8 @@ public static Subscription getSharedCommonSubscription() { } // it should have at least 1 VOD - if (SubscriptionUtils.getAssetsListBySubscription(Integer.valueOf(sharedCommonSubscription.getId()), Optional.empty(), true) == null || - SubscriptionUtils.getAssetsListBySubscription(Integer.valueOf(sharedCommonSubscription.getId()), Optional.empty(), true).size() == 0) { + if (getAssetsListBySubscription(Integer.valueOf(sharedCommonSubscription.getId()), Optional.empty(), true) == null || + getAssetsListBySubscription(Integer.valueOf(sharedCommonSubscription.getId()), Optional.empty(), true).size() == 0) { ingestVODIntoSubscription(sharedCommonSubscription); } } @@ -343,8 +339,8 @@ public static Subscription get5MinRenewableSubscription() { if (fiveMinRenewableSubscription == null) { fiveMinRenewableSubscription = IngestFixtureData.loadShared5MinutesRenewableSubscription(); // it should have at least 1 VOD - if (SubscriptionUtils.getAssetsListBySubscription(Integer.valueOf(fiveMinRenewableSubscription.getId()), Optional.empty(), true) == null || - SubscriptionUtils.getAssetsListBySubscription(Integer.valueOf(fiveMinRenewableSubscription.getId()), Optional.empty(), true).size() == 0) { + if (getAssetsListBySubscription(Integer.valueOf(fiveMinRenewableSubscription.getId()), Optional.empty(), true) == null || + getAssetsListBySubscription(Integer.valueOf(fiveMinRenewableSubscription.getId()), Optional.empty(), true).size() == 0) { ingestVODIntoSubscription(fiveMinRenewableSubscription); } if (fiveMinRenewableSubscription == null) { From da70b6f791c1f150586e71aa5d324fe325a63648 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 17 Jun 2018 17:26:32 +0300 Subject: [PATCH 356/605] refactor ingestUtils --- .../kaltura/client/test/tests/BaseTest.java | 4 +- .../utils/ingestUtils/BaseIngestUtils.java | 42 +++ .../utils/ingestUtils/IngestEpgUtils.java | 43 +++ .../utils/ingestUtils/IngestMppUtils.java | 126 ++++++++ .../test/utils/ingestUtils/IngestPpUtils.java | 78 +++++ .../utils/ingestUtils/IngestPpvUtils.java | 76 +++++ .../test/utils/ingestUtils/IngestUtils.java | 289 ++++-------------- .../utils/ingestUtils/IngestVodUtils.java | 39 +-- .../ingest_xml_templates/ingestEPG.xml | 68 +++++ .../ingest_xml_templates/ingestMPP.xml | 51 ++++ .../ingest_xml_templates/ingestPP.xml | 30 ++ .../ingest_xml_templates/ingestPPV.xml | 39 +++ 12 files changed, 622 insertions(+), 263 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java create mode 100644 src/test/resources/ingest_xml_templates/ingestEPG.xml create mode 100644 src/test/resources/ingest_xml_templates/ingestMPP.xml create mode 100644 src/test/resources/ingest_xml_templates/ingestPP.xml create mode 100644 src/test/resources/ingest_xml_templates/ingestPPV.xml diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 64267fa13..c9ccf5dc4 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -88,7 +88,7 @@ public class BaseTest { private static Ppv sharedCommonPpv; // cycles map with values related view/full life cycles of price plans - private static Map cycles = new HashMap<>(); + public static Map cycles = new HashMap<>(); { // TODO: complete other values @@ -103,7 +103,7 @@ public class BaseTest { @BeforeSuite public void baseTest_beforeSuite() { // set configuration - config = new Configuration(); + config = new Configuration(); config.setEndpoint(getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION)); config.setAcceptGzipEncoding(false); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java new file mode 100644 index 000000000..fdb2195b6 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -0,0 +1,42 @@ +package com.kaltura.client.test.utils.ingestUtils; + +import org.w3c.dom.Document; + +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.StringWriter; +import java.io.Writer; + +public class BaseIngestUtils { + + + + public static String docToString(Document doc) { + try { + StringWriter sw = new StringWriter(); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + + transformer.transform(new DOMSource(doc), new StreamResult(sw)); + return sw.toString(); + } catch (Exception ex) { + throw new RuntimeException("Error converting to String", ex); + } + } + + public static void prettyPrint(Document doc) throws Exception { + Transformer tf = TransformerFactory.newInstance().newTransformer(); + tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + tf.setOutputProperty(OutputKeys.INDENT, "yes"); + Writer out = new StringWriter(); + tf.transform(new DOMSource(doc), new StreamResult(out)); + System.out.println(out.toString()); + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java new file mode 100644 index 000000000..ec3ea4fb3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -0,0 +1,43 @@ +package com.kaltura.client.test.utils.ingestUtils; + +import org.w3c.dom.Document; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import java.util.Optional; + +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; + +public class IngestEpgUtils extends BaseIngestUtils { + + public static String buildIngestEpgXml(String epgChannelName, Optional programCount, Optional firstProgramStartDate, + Optional programDuration, Optional programDurationPeriodName, + Optional isCridUnique4AllPrograms, Optional seasonCount, + Optional coguid, Optional crid, Optional seriesId) { + + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder; + Document doc = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestEPG.xml"); + } catch (Exception e) { + e.printStackTrace(); + } + + // user and password + doc.getElementsByTagName("userName").item(0).setTextContent(getIngestBusinessModuleUserName()); + doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestBusinessModuleUserPassword()); + + // uncomment cdata + String docAsString = docToString(doc); + docAsString = docAsString + .replace("", "-->", "]]>"); + + return docAsString; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java new file mode 100644 index 000000000..aa35c923b --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -0,0 +1,126 @@ +package com.kaltura.client.test.utils.ingestUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; + +public class IngestMppUtils extends BaseIngestUtils { + + // INGEST MPP PARAMS + static final String MPP_DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; + static final String MPP_DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; + static final String MPP_DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; + static final boolean MPP_DEFAULT_IS_ACTIVE_VALUE = true; + static final boolean MPP_DEFAULT_IS_RENEWABLE_VALUE = false; + static final int MPP_DEFAULT_GRACE_PERIOD_VALUE = 0; + + // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon + static final String MPP_DEFAULT_COUPON_GROUP_VALUE = + "\n" + + "01/05/2017 00:00:00\n" + + "31/12/2099 23:59:59\n" + + "100% unlimited\n" + + "\n" + + "\n" + + "01/05/2017 00:00:00\n" + + "31/05/2017 23:59:59\n" + + "Expired coupon group 1\n" + + ""; + + static final String MPP_DEFAULT_PRODUCT_CODES_VALUE = + "\n" + + "ProductCode1\n" + + "Google\n" + + "\n" + + "\n" + + "ProductCode2\n" + + "Apple\n" + + ""; + + public static String buildIngestMppXml(String action, String mppCode, boolean isActive, String title, String description, + String startDate, String endDate, String internalDiscount, String productCode, + boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, + String pricePlanCode2, String channel1, String channel2, String fileType1, + String fileType2, String couponGroup, String productCodes) { + + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder; + Document doc = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestMPP.xml"); + } catch (Exception e) { + e.printStackTrace(); + } + + // user and password + doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); + doc.getElementsByTagName("tem:password").item(0).setTextContent(getIngestBusinessModuleUserPassword()); + + // ingest + Element ingest = (Element) doc.getElementsByTagName("ingest").item(0); + ingest.setAttribute("id", mppCode); + + // multi price plan + Element mpp = (Element) ingest.getElementsByTagName("multi_price_plan").item(0); + mpp.setAttribute("code", mppCode); + mpp.setAttribute("action", action); + mpp.setAttribute("is_active", Boolean.toString(isActive)); + + // title + mpp.getElementsByTagName("title").item(0).setTextContent(title); + + // description + mpp.getElementsByTagName("description").item(0).setTextContent(description); + + // start date + mpp.getElementsByTagName("start_date").item(0).setTextContent(startDate); + + // end date + mpp.getElementsByTagName("end_date").item(0).setTextContent(endDate); + + // internal discount + mpp.getElementsByTagName("internal_discount").item(0).setTextContent(internalDiscount); + + // product code + mpp.getElementsByTagName("product_code").item(0).setTextContent(productCode); + + // is renewable + mpp.getElementsByTagName("is_renewable").item(0).setTextContent(Boolean.toString(isRenewable)); + + // grace period minutes + mpp.getElementsByTagName("grace_period_minutes").item(0).setTextContent(String.valueOf(gracePeriodMinute)); + + // price plan codes + mpp.getElementsByTagName("price_plan_code").item(0).setTextContent(pricePlanCode1); + mpp.getElementsByTagName("price_plan_code").item(1).setTextContent(pricePlanCode2); + + // channels + mpp.getElementsByTagName("channel").item(0).setTextContent(channel1); + mpp.getElementsByTagName("channel").item(1).setTextContent(channel2); + + // file types + mpp.getElementsByTagName("file_type").item(0).setTextContent(fileType1); + mpp.getElementsByTagName("file_type").item(1).setTextContent(fileType2); + + // subscription coupon group + mpp.getElementsByTagName("subscription_coupon_group").item(0).setTextContent(couponGroup); + + // product codes + mpp.getElementsByTagName("product_codes").item(0).setTextContent(productCodes); + + // uncomment cdata + String docAsString = docToString(doc); + docAsString = docAsString + .replace("", "-->", "]]>"); + + return docAsString; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java new file mode 100644 index 000000000..53dfefb1f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -0,0 +1,78 @@ +package com.kaltura.client.test.utils.ingestUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; + +public class IngestPpUtils extends BaseIngestUtils { + + // INGEST PP PARAMS + static final boolean PP_DEFAULT_IS_ACTIVE_VALUE = true; + static final boolean PP_DEFAULT_IS_RENEWABLE_VALUE = false; + static final int PP_DEFAULT_MAX_VIEWS_VALUE = 0; + static final int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; + + public static String buildIngestPpXml(String action, String ppCode, boolean isActive, String fullLifeCycle, String viewLifeCycle, + int maxViews, String price, String currency, String discount, boolean isRenewable, int recurringPeriods) { + + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder; + Document doc = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestPP.xml"); + } catch (Exception e) { + e.printStackTrace(); + } + + // user and password + doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); + doc.getElementsByTagName("tem:password").item(0).setTextContent(getIngestBusinessModuleUserPassword()); + + // ingest + Element ingest = (Element) doc.getElementsByTagName("ingest").item(0); + ingest.setAttribute("id", "reportIngestPricePlan"); + + // price plan + Element pp = (Element) ingest.getElementsByTagName("price_plan").item(0); + pp.setAttribute("code", ppCode); + pp.setAttribute("action", action); + pp.setAttribute("is_active", Boolean.toString(isActive)); + + // full life cycles + pp.getElementsByTagName("full_life_cycle").item(0).setTextContent(fullLifeCycle); + + // view life cycle + pp.getElementsByTagName("view_life_cycle").item(0).setTextContent(viewLifeCycle); + + // max views + pp.getElementsByTagName("max_views").item(0).setTextContent(String.valueOf(maxViews)); + + // price code + pp.getElementsByTagName("price").item(0).setTextContent(price); + pp.getElementsByTagName("currency").item(0).setTextContent(currency); + + // discount + pp.getElementsByTagName("discount").item(0).setTextContent(discount); + + // is renewable + pp.getElementsByTagName("is_renewable").item(0).setTextContent(Boolean.toString(isRenewable)); + + // recurring periods + pp.getElementsByTagName("recurring_periods").item(0).setTextContent(String.valueOf(recurringPeriods)); + + // uncomment cdata + String docAsString = docToString(doc); + docAsString = docAsString + .replace("", "-->", "]]>"); + + return docAsString; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java new file mode 100644 index 000000000..4d4c157b5 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -0,0 +1,76 @@ +package com.kaltura.client.test.utils.ingestUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; +import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; + +public class IngestPpvUtils extends BaseIngestUtils { + + public static String buildIngestPpvXml(String action, String ppvCode, boolean isActive, String description, String discount, + double price, String currency, String usageModule, boolean isSubscriptionOnly, + boolean isFirstDeviceLimitation, String productCode, String firstFileType, String secondFileType) { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder; + Document doc = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestPPV.xml"); + } catch (Exception e) { + e.printStackTrace(); + } + + // user and password + doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); + doc.getElementsByTagName("tem:password").item(0).setTextContent(getIngestBusinessModuleUserPassword()); + + // ingest + Element ingest = (Element) doc.getElementsByTagName("ingest").item(0); + ingest.setAttribute("id", ppvCode); + + // ppv + Element ppv = (Element) ingest.getElementsByTagName("ppv").item(0); + ppv.setAttribute("code", ppvCode); + ppv.setAttribute("action", action); + ppv.setAttribute("is_active", Boolean.toString(isActive)); + + // description + ppv.getElementsByTagName("description").item(0).setTextContent(description); + + // price code + ppv.getElementsByTagName("price").item(0).setTextContent(String.valueOf(price)); + ppv.getElementsByTagName("currency").item(0).setTextContent(currency); + + // usage module + ppv.getElementsByTagName("usage_module").item(0).setTextContent(usageModule); + + // discount + ppv.getElementsByTagName("discount").item(0).setTextContent(discount); + + // subscription only + ppv.getElementsByTagName("subscription_only").item(0).setTextContent(Boolean.toString(isSubscriptionOnly)); + + // first device limitation + ppv.getElementsByTagName("first_device_limitation").item(0).setTextContent(Boolean.toString(isFirstDeviceLimitation)); + + // product_code + ppv.getElementsByTagName("product_code").item(0).setTextContent(productCode); + + // file types + ppv.getElementsByTagName("file_type").item(0).setTextContent(firstFileType); + ppv.getElementsByTagName("file_type").item(1).setTextContent(secondFileType); + + // uncomment cdata + String docAsString = docToString(doc); + docAsString = docAsString + .replace("", "-->", "]]>"); + + return docAsString; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java index f5e6354ee..83837786c 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java @@ -22,8 +22,11 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.buildIngestVodXml; import static io.restassured.path.xml.XmlPath.from; +import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; public class IngestUtils extends BaseUtils { @@ -52,48 +55,6 @@ public class IngestUtils extends BaseUtils { private static String titleOfIngestedItem = ""; - // INGEST MPP PARAMS - private static boolean MPP_DEFAULT_IS_ACTIVE_VALUE = true; - private static String MPP_DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; - private static String MPP_DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; - private static String MPP_DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; - private static boolean MPP_DEFAULT_IS_RENEWABLE_VALUE = false; - private static int MPP_DEFAULT_GRACE_PERIOD_VALUE = 0; - - // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon - private static String MPP_DEFAULT_COUPON_GROUP_VALUE = - "\n" + - "01/05/2017 00:00:00\n" + - "31/12/2099 23:59:59\n" + - "100% unlimited\n" + - "\n" + - "\n" + - "01/05/2017 00:00:00\n" + - "31/05/2017 23:59:59\n" + - "Expired coupon group 1\n" + - ""; - - private static String MPP_DEFAULT_PRODUCT_CODES_VALUE = - "\n" + - "ProductCode1\n" + - "Google\n" + - "\n" + - "\n" + - "ProductCode2\n" + - "Apple\n" + - ""; - - // INGEST PP PARAMS - private static boolean PP_DEFAULT_IS_ACTIVE_VALUE = true; - private static int PP_DEFAULT_MAX_VIEWS_VALUE = 0; - private static boolean PP_DEFAULT_IS_RENEWABLE_VALUE = false; - private static int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; - - - public static List ingestEPG(String epgChannelName, Integer programCount) { - return ingestEPG(epgChannelName, Optional.of(programCount), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - } // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project public static List ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, @@ -103,8 +64,7 @@ public static List ingestEPG(String epgChannelName, Optional ingestEPG(String epgChannelName, Optional(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "\"http://tempuri.org/IService/IngestKalturaEpg\""); + String reqBody = "\n" + " \n" + " \n" + @@ -173,14 +131,18 @@ public static List ingestEPG(String epgChannelName, Optional\n" + " \n" + ""; - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); + + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestKalturaEpg") + .body(reqBody) + .when() + .post(url); Logger.getLogger(IngestUtils.class).debug(reqBody); Logger.getLogger(IngestUtils.class).debug(resp.asString()); + int epgChannelId = IngestFixtureData.getEpgChannelId(epgChannelName); // TODO: create method getting epoch value from String and pattern long epoch = 0L; @@ -211,6 +173,11 @@ public static List ingestEPG(String epgChannelName, Optional) (Object) ingestedProgrammes.results.getObjects(); } + public static List ingestEPG(String epgChannelName, Integer programCount) { + return ingestEPG(epgChannelName, Optional.of(programCount), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + } + private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { return () -> { ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null).setKs(ks); @@ -401,31 +368,22 @@ public static Subscription ingestMPP(Optional action, Optional m String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getIngestBusinessModuleUserName() + "" + - getIngestBusinessModuleUserPassword() + "" + - " \n" + - " \n" + - ""; - - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) + channel1Value, channel2Value, fileType1Value, fileType2Value, couponGroupValue, productCodesValue); + + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") + .body(reqBody) + .when() .post(url); Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); + Logger.getLogger(IngestUtils.class).debug("\n Response:!!! " + resp.asString()); String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); @@ -458,48 +416,6 @@ public static Subscription ingestMPP(Optional action, Optional m return subscription; } - private static String buildIngestMppXML(String action, String mppCode, boolean isActive, String title, String description, - String startDate, String endDate, String internalDiscount, String productCode, - boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, - String pricePlanCode2, String channel1, String channel2, String fileType1, - String fileType2, String couponGroup, String productCodes) { - return "\n" + - "\n" + - "\n" + - "\n" + - "" + title + "\n" + - "\n" + - "\n" + - "" + description + "" + - "\n" + - "" + startDate + "\n" + - "" + endDate + "\n" + - "" + internalDiscount + "\n" + - "\n" + - "" + productCode + "\n" + - "" + isRenewable + "\n" + - "\n" + - "" + gracePeriodMinute + "\n" + - "\n" + - "" + pricePlanCode1 + "\n" + - "" + pricePlanCode2 + "\n" + - "\n" + - "\n" + - "" + channel1 + "\n" + - "" + channel2 + "\n" + - "\n" + - "\n" + - "" + fileType1 + "\n" + - "" + fileType2 + "\n" + - "\n" + - "\n" + - "" + couponGroup + "\n" + - "" + productCodes + "\n" + - "\n" + - "\n" + - "\n"; - } - // ingest new PP /** @@ -543,27 +459,17 @@ public static PricePlan ingestPP(Optional action, Optional ppCod int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getIngestBusinessModuleUserName() + "" + - getIngestBusinessModuleUserPassword() + "" + - " \n" + - " \n" + - ""; - - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); + + String reqBody = IngestPpUtils.buildIngestPpXml(actionValue, ppCodeValue, isActiveValue, fullLifeCycleValue, + viewLifeCycleValue, maxViewsValue, priceValue, currencyValue, discountValue, isRenewableValue, recurringPeriodsValue); + + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") + .body(reqBody) + .when() + .post(url); Logger.getLogger(IngestUtils.class).debug(reqBody); Logger.getLogger(IngestUtils.class).debug(resp.asString()); @@ -596,28 +502,6 @@ public static PricePlan ingestPP(Optional action, Optional ppCod return pricePlan; } - private static String buildIngestPpXML(String action, String ppCode, boolean isActive, String fullLifeCycle, - String viewLifeCycle, int maxViews, String price, String currency, - String discount, boolean isRenewable, int recurringPeriods) { - String id = "reportIngestPricePlan" + action.substring(0, 1).toUpperCase() + action.substring(1); - return "\n" + - "\n" + - "\n" + - "" + fullLifeCycle + "\n" + - "" + viewLifeCycle + "\n" + - "" + maxViews + "\n" + - "\n" + - "" + price + "\n" + - "" + currency + "\n" + - "\n" + - "" + discount + "\n" + - "" + isRenewable + "\n" + - "" + recurringPeriods + "\n" + - "\n" + - "\n" + - "\n"; - } - /** * IMPORTANT: please delete inserted by that method items * @@ -643,9 +527,8 @@ private static String buildIngestPpXML(String action, String ppCode, boolean isA */ // ingest new PPV public static Ppv ingestPPV(Optional action, Optional ppvCode, Optional isActive, Optional description, - Optional discount, Optional price, Optional currency, - Optional usageModule, Optional isSubscriptionOnly, - Optional isFirstDeviceLimitation, Optional productCode, + Optional discount, Optional price, Optional currency, Optional usageModule, + Optional isSubscriptionOnly, Optional isFirstDeviceLimitation, Optional productCode, Optional firstFileType, Optional secondFileType) { String actionValue = action.orElse(INGEST_ACTION_INSERT); String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); @@ -664,30 +547,21 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O String secondFileTypeValue = secondFileType.orElse(getProperty(MOBILE_FILE_TYPE)); String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); - - String reqBody = "\n" + - " \n" + - " \n" + - " " + getIngestBusinessModuleUserName() + "" + - getIngestBusinessModuleUserPassword() + "" + - " \n" + - " \n" + - ""; + isFirstDeviceLimitationValue, productCodeValue, firstFileTypeValue, secondFileTypeValue); - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") + .body(reqBody) + .when() + .post(url); Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); + Logger.getLogger(IngestUtils.class).debug("\n Response!!!: " + resp.asString()); String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //System.out.println("ReportId = " + reportId); @@ -726,35 +600,6 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O return ppv; } - private static String buildIngestPpvXML(String action, String ppvCode, boolean isActive, String description, String discount, - double price, String currency, String usageModule, boolean isSubscriptionOnly, - boolean isFirstDeviceLimitation, String productCode, String firstFileType, - String secondFileType) { - return "\n" + - " \n" + - " \n" + - " \n" + - " " + description + "\n" + - " \n" + - " \n" + - " " + price + "\n" + - " " + currency + "\n" + - " \n" + - " " + usageModule + "\n" + - " " + discount + "\n" + - " \n" + - " " + isSubscriptionOnly + "\n" + - " " + isFirstDeviceLimitation + "\n" + - " " + productCode + "\n" + - " \n" + - " " + firstFileType + "\n" + - " " + secondFileType + "\n" + - " \n" + - " \n" + - " \n" + - "\n"; - } - /** * IMPORTANT: please delete inserted by that method items * @@ -809,26 +654,22 @@ public static MediaAsset ingestVOD(Optional action, Optional cog Map datesValue = dates.orElse(getDefaultDates()); // TODO: check if ingest url is the same for all ingest actions String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - HashMap headerMap = new HashMap<>(); - headerMap.put("Content-Type", "text/xml;charset=UTF-8"); - headerMap.put("SOAPAction", "http://tempuri.org/IService/IngestTvinciData"); - String reqBody = null; - try { - reqBody = buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, - catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); - } catch (Exception e) { - e.printStackTrace(); - } + String reqBody = buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, + catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); - io.restassured.response.Response resp = RestAssured.given() - .log().all() - .headers(headerMap) - .body(reqBody) - .post(url); + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestTvinciData") + .body(reqBody) + .when() + .post(url); // Logger.getLogger(IngestUtils.class).debug(reqBody); Logger.getLogger(IngestUtils.class).debug("Ingest response: \n" + resp.asString()); + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); String id; if (INGEST_ACTION_INSERT.equals(actionValue)) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 7a4bda936..620c2ae02 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -6,24 +6,15 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.StringWriter; -import java.io.Writer; import java.util.List; import java.util.Map; -import static com.kaltura.client.test.Properties.MOBILE_FILE_TYPE; -import static com.kaltura.client.test.Properties.WEB_FILE_TYPE; -import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.getIngestAssetUserName; import static com.kaltura.client.test.tests.BaseTest.getIngestAssetUserPassword; import static com.kaltura.client.test.utils.XmlUtils.asList; -public class IngestVodUtils { +public class IngestVodUtils extends BaseIngestUtils { public static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName, Map> tags, Map strings, @@ -162,30 +153,4 @@ private static Element generateAndAppendMetaNode(Document doc, Element rootEleme return meta; } - - private static String docToString(Document doc) { - try { - StringWriter sw = new StringWriter(); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - - transformer.transform(new DOMSource(doc), new StreamResult(sw)); - return sw.toString(); - } catch (Exception ex) { - throw new RuntimeException("Error converting to String", ex); - } - } - - private static void prettyPrint(Document doc) throws Exception { - Transformer tf = TransformerFactory.newInstance().newTransformer(); - tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - tf.setOutputProperty(OutputKeys.INDENT, "yes"); - Writer out = new StringWriter(); - tf.transform(new DOMSource(doc), new StreamResult(out)); - System.out.println(out.toString()); - } } diff --git a/src/test/resources/ingest_xml_templates/ingestEPG.xml b/src/test/resources/ingest_xml_templates/ingestEPG.xml new file mode 100644 index 000000000..5d75d4043 --- /dev/null +++ b/src/test/resources/ingest_xml_templates/ingestEPG.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + Program_20180617170200_ser18061717020028_seas1_e1 + 18061717020028_1_1 + 20180617170200 until 20180617173200 + 20180617170200 + eng + + season_num + 1 + + + Series_ID + 18061717020028 + + + Episode number + 1 + + + + Program_20180617173200_ser18061717020028_seas1_e2 + 18061717020028_1_2 + 20180617173200 until 20180617180200 + 20180617170200 + eng + + season_num + 1 + + + Series_ID + 18061717020028 + + + Episode number + 2 + + + + + + + + + + + diff --git a/src/test/resources/ingest_xml_templates/ingestMPP.xml b/src/test/resources/ingest_xml_templates/ingestMPP.xml new file mode 100644 index 000000000..8f5cfcd0a --- /dev/null +++ b/src/test/resources/ingest_xml_templates/ingestMPP.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + </titles> + <descriptions> + <description lang="eng"/> + </descriptions> + <start_date/> + <end_date/> + <internal_discount/> + <coupon_group/> + <product_code/> + <is_renewable/> + <priview_module/> + <grace_period_minutes/> + <price_plan_codes> + <price_plan_code/> + <price_plan_code/> + </price_plan_codes> + <channels> + <channel/> + <channel/> + </channels> + <file_types> + <file_type/> + <file_type/> + </file_types> + <order_number/> + <subscription_coupon_group/> + <product_codes> + <product_code/> + </product_codes> + </multi_price_plan> + </multi_price_plans> + </ingest> + <!--]]>--> + </tem:xml> + </tem:IngestBusinessModules> + </soapenv:Body> +</soapenv:Envelope> \ No newline at end of file diff --git a/src/test/resources/ingest_xml_templates/ingestPP.xml b/src/test/resources/ingest_xml_templates/ingestPP.xml new file mode 100644 index 000000000..fea426d7e --- /dev/null +++ b/src/test/resources/ingest_xml_templates/ingestPP.xml @@ -0,0 +1,30 @@ +<?xml version='1.0' encoding='utf-8'?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> + <soapenv:Header/> + <soapenv:Body> + <tem:IngestBusinessModules> + <tem:username/> + <tem:password/> + <tem:xml> + <!--<![CDATA[--> + <ingest> + <price_plans> + <price_plan> + <full_life_cycle/> + <view_life_cycle/> + <max_views/> + <price_code> + <price/> + <currency/> + </price_code> + <discount/> + <is_renewable/> + <recurring_periods/> + </price_plan> + </price_plans> + </ingest> + <!--]]>--> + </tem:xml> + </tem:IngestBusinessModules> + </soapenv:Body> +</soapenv:Envelope> \ No newline at end of file diff --git a/src/test/resources/ingest_xml_templates/ingestPPV.xml b/src/test/resources/ingest_xml_templates/ingestPPV.xml new file mode 100644 index 000000000..6c4fe4262 --- /dev/null +++ b/src/test/resources/ingest_xml_templates/ingestPPV.xml @@ -0,0 +1,39 @@ +<?xml version='1.0' encoding='utf-8'?> +<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:tem='http://tempuri.org/'> + <soapenv:Header/> + <soapenv:Body> + <tem:IngestBusinessModules> + <tem:username/> + <tem:password/> + <tem:xml> + <!--<![CDATA[--> + <ingest> + <ppvs> + <ppv> + <descriptions> + <description lang="eng"/> + </descriptions> + <price_code> + <price/> + <currency/> + </price_code> + <usage_module/> + <discount/> + <coupon_group/> + <subscription_only/> + <first_device_limitation/> + <product_code/> + <file_types> + <file_type/> + <file_type/> + </file_types> + </ppv> + </ppvs> + </ingest> + <!--]]>--> + </tem:xml> + </tem:IngestBusinessModules> + </soapenv:Body> +</soapenv:Envelope> + + From 25219e7a4eeabd7b01babbc0556911d197709772 Mon Sep 17 00:00:00 2001 From: "alon.basin" <alon.basin@kaltura.com> Date: Sun, 17 Jun 2018 17:29:09 +0300 Subject: [PATCH 357/605] no message --- src/test/resources/ingest_xml_templates/ingestEPG.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/resources/ingest_xml_templates/ingestEPG.xml b/src/test/resources/ingest_xml_templates/ingestEPG.xml index 5d75d4043..a2601352e 100644 --- a/src/test/resources/ingest_xml_templates/ingestEPG.xml +++ b/src/test/resources/ingest_xml_templates/ingestEPG.xml @@ -8,7 +8,6 @@ <passWord xmlns=""/> <data xmlns=""> <!--<![CDATA[--> - <?xml version="1.0" encoding="utf-8"?> <EpgChannels xmlns="http://tempuri.org/xmltv" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" From 5c2af37b10a50037ae522cde29f789617161e560 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" <michael.kondratiev@kaltura.com> Date: Mon, 18 Jun 2018 09:36:42 +0300 Subject: [PATCH 358/605] Transaction tests started --- .../TransactionHistoryListTests.java | 4 ++++ .../TransactionPurchaseTests.java | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index 082f93bdb..7cbfa80bf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -129,6 +129,7 @@ public void transactionHistoryPerHouseholdWithUserKs() { listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); + assertThat(listBillingTransactionResponse.results).isNotNull(); //Verify that two transactions were performed assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(3); assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(3); @@ -148,6 +149,7 @@ public void transactionHistoryPerUserWithUserKs() { listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); + assertThat(listBillingTransactionResponse.results).isNotNull(); //Verify that two transactions were performed assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(2); assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(2); @@ -167,6 +169,7 @@ public void transactionHistoryPerHouseholdWithMasterKs() { listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); + assertThat(listBillingTransactionResponse.results).isNotNull(); //Verify that two transactions were performed assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(3); assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(3); @@ -186,6 +189,7 @@ public void transactionHistoryPerUserWithMasterKs() { listBillingTransactionResponse = executor.executeSync(listTransactionHistoryBuilder); //No errors appeared at response assertThat(listBillingTransactionResponse.error).isNull(); + assertThat(listBillingTransactionResponse.results).isNotNull(); //Verify that one transaction was performed assertThat(listBillingTransactionResponse.results.getTotalCount()).isEqualTo(1); assertThat(listBillingTransactionResponse.results.getObjects().size()).isEqualTo(1); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java new file mode 100644 index 000000000..0f510adef --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -0,0 +1,20 @@ +package com.kaltura.client.test.tests.servicesTests.transactionTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.types.Household; +import com.kaltura.client.types.HouseholdUser; +import org.testng.annotations.Test; + +public class TransactionPurchaseTests extends BaseTest { + + + + @Test + private void purchaseDefaultPG() { + Household household = HouseholdUtils.createHousehold(1, 1, true); + HouseholdUser masterUser = + + } + +} From ca1f45d8654214d697d0c91fd9ae14bfe1af5435 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" <michael.kondratiev@kaltura.com> Date: Mon, 18 Jun 2018 09:38:43 +0300 Subject: [PATCH 359/605] transaction fix --- .../transactionTests/TransactionPurchaseTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index 0f510adef..2e6bd66bd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -3,7 +3,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.Household; -import com.kaltura.client.types.HouseholdUser; import org.testng.annotations.Test; public class TransactionPurchaseTests extends BaseTest { @@ -13,7 +12,7 @@ public class TransactionPurchaseTests extends BaseTest { @Test private void purchaseDefaultPG() { Household household = HouseholdUtils.createHousehold(1, 1, true); - HouseholdUser masterUser = +// HouseholdUser masterUser = } From 80bc5c96302a8345de962041b6134f562aa754a2 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" <maksim.superfin@kaltura.com> Date: Mon, 18 Jun 2018 12:31:54 +0300 Subject: [PATCH 360/605] Added json schema validation for LicensedUrl object --- .../EntitlementCancelTests.java | 17 +++++++-- src/test/resources/schemas/LicensedUrl.json | 35 +++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/schemas/LicensedUrl.json diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 2d0ea31ce..fc066c805 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -119,16 +119,23 @@ public void cancelWithInvalidSubscription() { @Severity(SeverityLevel.NORMAL) @Description("entitlement/action/cancel - cancel played subscription - error 3005") - @Test(enabled = false) // TODO: as not completed + @Test//(enabled = false) // TODO: as not completed public void cancelPlayedSubscription() { // create mpp having at least 1 media on its channel sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response<Channel> channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); sharedChannel.setId(channelResponse.results.getId()); + PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty()); + + /*pricePlan.setWaiverPeriod(1440); // TODO: update + pricePlan.setIsWaiverEnabled(false);*/ + Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); // set household @@ -140,7 +147,7 @@ public void cancelPlayedSubscription() { // get CDN code for media MediaFile mediaFile = getMediaFileByType(getSharedMediaAsset(), getProperty(WEB_FILE_TYPE)); - String cdnCode = mediaFile.getCdnCode(); + String cdnCode = mediaFile.getUrl(); // check license for play LicensedUrlMediaRequest licensedUrlRequest = new LicensedUrlMediaRequest(); @@ -173,6 +180,10 @@ public void cancelPlayedSubscription() { Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + //delete PP + IngestUtils.ingestPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(pricePlan.getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty()); } @AfterClass diff --git a/src/test/resources/schemas/LicensedUrl.json b/src/test/resources/schemas/LicensedUrl.json new file mode 100644 index 000000000..0e3250738 --- /dev/null +++ b/src/test/resources/schemas/LicensedUrl.json @@ -0,0 +1,35 @@ +{ + "$id": "LicensedUrl", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "mainUrl": { + "type": "string" + }, + "altUrl": { + "type": "string" + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaLicensedUrl" + ] + } + }, + "required": [ + "mainUrl", + "altUrl", + "objectType" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} \ No newline at end of file From 2684a82ee1b7bc3eef27daaef43c754f1ca072d2 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" <maksim.superfin@kaltura.com> Date: Mon, 18 Jun 2018 13:00:41 +0300 Subject: [PATCH 361/605] Completed test case cancelPlayedSubscription() --- .../EntitlementCancelTests.java | 15 +++----------- .../test/utils/dbUtils/DBConstants.java | 3 +++ .../client/test/utils/dbUtils/DBUtils.java | 20 +++++++++++++++++++ .../test/utils/dbUtils/IngestFixtureData.java | 2 +- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index fc066c805..8fb378408 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -9,6 +9,7 @@ import com.kaltura.client.services.LicensedUrlService.GetLicensedUrlBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -119,19 +120,14 @@ public void cancelWithInvalidSubscription() { @Severity(SeverityLevel.NORMAL) @Description("entitlement/action/cancel - cancel played subscription - error 3005") - @Test//(enabled = false) // TODO: as not completed + @Test public void cancelPlayedSubscription() { // create mpp having at least 1 media on its channel sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response<Channel> channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); sharedChannel.setId(channelResponse.results.getId()); - PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty()); - - /*pricePlan.setWaiverPeriod(1440); // TODO: update - pricePlan.setIsWaiverEnabled(false);*/ + PricePlan pricePlan = DBUtils.loadPPWithWaiver(); Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), @@ -171,7 +167,6 @@ public void cancelPlayedSubscription() { booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(masterKs)); assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3005).getCode()); - // TODO: 5/23/2018 complete test // delete household for cleanup executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); @@ -180,10 +175,6 @@ public void cancelPlayedSubscription() { Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); - //delete PP - IngestUtils.ingestPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(pricePlan.getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty()); } @AfterClass diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 62b8542b5..100d60bf6 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -92,6 +92,9 @@ public class DBConstants { "where [status]=1 and is_active=1\n" + "and group_id=? and internal_discount_id=? and pricing_id=?"; + static final String PRICE_PLAN_WITH_WAVER_SELECT = "SELECT TOP 1 * FROM [Pricing].[dbo].[usage_modules]\n" + + "WHERE group_id=? and WAIVER=1 AND WAIVER_PERIOD>0 and IS_ACTIVE=1 and [STATUS]=1"; + static final String PRICE_PLAN_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + "and view_life_cycle_min = 5\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 5c8a0823d..854c2b422 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -3,6 +3,7 @@ import com.google.common.base.Strings; import com.kaltura.client.Logger; import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.PricePlan; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; @@ -13,6 +14,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; +import static com.kaltura.client.test.utils.dbUtils.IngestFixtureData.loadFirstPricePlanFromJsonArray; import static org.assertj.core.api.Assertions.fail; public class DBUtils extends BaseUtils { @@ -303,6 +305,24 @@ private static PreparedStatement preparedStatementExecution(Connection conn, Str return pstm; } + public static PricePlan loadPPWithWaiver() { + Logger.getLogger(IngestFixtureData.class).debug("loadPPWithWaiver()"); + PricePlan pricePlan = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITH_WAVER_SELECT, true, partnerId); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return pricePlan; + } + + pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); + } + return pricePlan; + } + // private static void openConnection() { // SQLServerDataSource dataSource = getDataSource(); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index aee6811e3..8327f483f 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -94,7 +94,7 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl return pricePlan; } - private static PricePlan loadFirstPricePlanFromJsonArray(JSONArray jsonArray) { + static PricePlan loadFirstPricePlanFromJsonArray(JSONArray jsonArray) { PricePlan pricePlan = new PricePlan(); pricePlan.setId(jsonArray.getJSONObject(0).getLong(ID)); pricePlan.setName(jsonArray.getJSONObject(0).getString(NAME)); From 21a9c83929584b3f9adf461ff345d222a657332c Mon Sep 17 00:00:00 2001 From: "alon.basin" <alon.basin@kaltura.com> Date: Mon, 18 Jun 2018 14:19:03 +0300 Subject: [PATCH 362/605] ingest refactor --- .../kaltura/client/test/tests/BaseTest.java | 20 +- .../SearchAssetFilterTests.java | 13 +- .../AssetCommentListTests.java | 4 +- .../AssetHistoryCleanTests.java | 10 +- .../AssetHistoryListTests.java | 14 +- .../channelTests/ChannelAddTests.java | 19 +- .../EntitlementCancelTests.java | 20 +- .../EntitlementListTests.java | 8 +- .../ProductPriceListTests.java | 46 +- .../kaltura/client/test/utils/BaseUtils.java | 3 +- .../utils/ingestUtils/IngestEpgUtils.java | 187 +++++- .../utils/ingestUtils/IngestMppUtils.java | 126 +++- .../test/utils/ingestUtils/IngestPpUtils.java | 99 ++- .../utils/ingestUtils/IngestPpvUtils.java | 114 +++- .../test/utils/ingestUtils/IngestUtils.java | 568 +----------------- .../utils/ingestUtils/IngestVodUtils.java | 210 ++++++- .../ingest_xml_templates/ingestEPG.xml | 45 +- 17 files changed, 824 insertions(+), 682 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c9ccf5dc4..2b03cb383 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -13,7 +13,7 @@ import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.*; import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; @@ -139,7 +139,7 @@ public static PricePlan getSharedCommonPricePlan() { if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), EUR.getValue(), defaultDiscountPrice, defaultDiscountPercentValue); if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = IngestUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), + sharedCommonPricePlan = IngestPpUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), Optional.of(EUR.getValue()), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)), Optional.of(true), Optional.of(0)); @@ -161,7 +161,7 @@ public static Subscription getSharedCommonSubscription() { if (sharedCommonSubscription == null) { sharedCommonSubscription = IngestFixtureData.loadSharedCommonSubscription(getSharedCommonPricePlan()); if (sharedCommonSubscription == null) { - sharedCommonSubscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), + sharedCommonSubscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)), Optional.empty(), Optional.of(false), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.empty(), @@ -209,7 +209,7 @@ public static Ppv getSharedCommonPpv(){ if (sharedCommonPpv == null) { sharedCommonPpv = IngestFixtureData.loadSharedCommonPpv(getSharedCommonPricePlan()); if (sharedCommonPpv == null) { - sharedCommonPpv = IngestUtils.ingestPPV(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), + sharedCommonPpv = IngestPpvUtils.ingestPPV(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.empty(), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) discountPercentValue)), Optional.empty(), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.of(false), Optional.of(false), Optional.empty(), Optional.empty(), Optional.empty()); @@ -295,7 +295,7 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { - mediaAsset = IngestUtils.ingestVOD (Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + mediaAsset = IngestVodUtils.ingestVOD (Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -344,7 +344,7 @@ public static Subscription get5MinRenewableSubscription() { ingestVODIntoSubscription(fiveMinRenewableSubscription); } if (fiveMinRenewableSubscription == null) { - PricePlan pricePlan = IngestUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), + PricePlan pricePlan = IngestPpUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(EUR.getValue()), Optional.of(""), Optional.of(true), Optional.of(3)); @@ -356,7 +356,7 @@ public static Subscription get5MinRenewableSubscription() { Response<Channel> channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); channel.setId(channelResponse.results.getId()); - fiveMinRenewableSubscription = IngestUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), + fiveMinRenewableSubscription = IngestMppUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -397,11 +397,11 @@ private static void ingestVODIntoSubscription(Subscription subscription) { } if (name != null) { // ingest VOD by name - MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - IngestUtils.updateVODName(mediaAsset, name); + IngestVodUtils.updateVODName(mediaAsset, name); } if (tag != null) { // ingest VOD by tag @@ -409,7 +409,7 @@ private static void ingestVODIntoSubscription(Subscription subscription) { List<String> values = new ArrayList<>(); values.add(parameters[1].replaceAll("'", "")); tags.put(tag, values); - IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), + IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 034d45bc9..89f290630 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -8,6 +8,7 @@ import com.kaltura.client.test.utils.*; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -53,9 +54,9 @@ private void Asset_list_before_class() { list.add(tagValue); map.put(tagName, list); - asset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); - asset2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-100))); - asset3 = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-10))); + asset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); + asset2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-100))); + asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-10))); program = IngestUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestUtils.ingestEPG(epgChannelName2, 1).get(0); } @@ -212,9 +213,9 @@ private void OrderVodAssetsByViews() { @Description("Asset/action/list - VOD - order by NAME (DESC/ASC") @Test(enabled = false) private void OrderVodAssetsByName() { - IngestUtils.updateVODName(asset, "AAA"); - IngestUtils.updateVODName(asset2, "BBB"); - IngestUtils.updateVODName(asset3, "CCC"); + IngestVodUtils.updateVODName(asset, "AAA"); + IngestVodUtils.updateVODName(asset2, "BBB"); + IngestVodUtils.updateVODName(asset3, "CCC"); ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index ea9ae8dea..875cf057e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -5,7 +5,7 @@ import com.kaltura.client.services.AssetCommentService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; import com.kaltura.client.types.Household; @@ -45,7 +45,7 @@ private void checkCommentsOrder() { String subHeader = "subHeader"; String text = "A lot of text"; - Long assetId = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Long assetId = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(MOVIE_MEDIA_TYPE)), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()).getId(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index bce584a49..178083a82 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -8,16 +8,16 @@ import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; +import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; @@ -46,13 +46,13 @@ public class AssetHistoryCleanTests extends BaseTest { // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + movie = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + movie2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE); + episode = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index a9525075f..b7af7f060 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -7,7 +7,7 @@ import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -17,8 +17,10 @@ import java.util.ArrayList; import java.util.List; -import static com.kaltura.client.services.AssetHistoryService.*; -import static com.kaltura.client.services.BookmarkService.*; +import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; +import static com.kaltura.client.services.AssetHistoryService.list; +import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; +import static com.kaltura.client.services.BookmarkService.add; import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; @@ -45,13 +47,13 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { // Ingest first movie asset - movie = IngestUtils.ingestVOD( MOVIE_MEDIA_TYPE); + movie = IngestVodUtils.ingestVOD( MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); + movie2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestUtils.ingestVOD(EPISODE_MEDIA_TYPE); + episode = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index cb44cd0ea..88e6903ea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -7,7 +7,7 @@ import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.ChannelUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -18,8 +18,9 @@ import java.util.List; import java.util.Optional; -import static com.kaltura.client.services.AssetService.*; -import static com.kaltura.client.services.ChannelService.*; +import static com.kaltura.client.services.AssetService.ListAssetBuilder; +import static com.kaltura.client.services.ChannelService.AddChannelBuilder; +import static com.kaltura.client.services.ChannelService.DeleteChannelBuilder; import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -58,16 +59,16 @@ private void addChannel() { @Test private void checkOrderOfAssetsInChannel() { - String asset1Name = "Movie_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); - String asset2Name = "Episode_" + BaseUtils.getCurrentDataInFormat("yyMMddHHmmss"); + String asset1Name = "Movie_" + BaseUtils.getCurrentDateInFormat("yyMMddHHmmss"); + String asset2Name = "Episode_" + BaseUtils.getCurrentDateInFormat("yyMMddHHmmss"); // Ingest first asset - MediaAsset movieAsset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); - movieAsset = IngestUtils.updateVODName(movieAsset, asset1Name); + MediaAsset movieAsset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); + movieAsset = IngestVodUtils.updateVODName(movieAsset, asset1Name); // Ingest second asset - MediaAsset episodeAsset = IngestUtils.ingestVOD(MOVIE_MEDIA_TYPE); - episodeAsset = IngestUtils.updateVODName(episodeAsset, asset2Name); + MediaAsset episodeAsset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); + episodeAsset = IngestVodUtils.updateVODName(episodeAsset, asset2Name); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 2d0ea31ce..39dccb5ab 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -3,13 +3,19 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.*; -import com.kaltura.client.services.ChannelService.AddChannelBuilder; +import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; +import com.kaltura.client.services.ChannelService; +import com.kaltura.client.services.ChannelService.AddChannelBuilder; +import com.kaltura.client.services.EntitlementService; +import com.kaltura.client.services.LicensedUrlService; import com.kaltura.client.services.LicensedUrlService.GetLicensedUrlBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.*; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestMppUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -18,8 +24,10 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + import java.util.List; import java.util.Optional; + import static com.kaltura.client.services.EntitlementService.*; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; @@ -126,7 +134,7 @@ public void cancelPlayedSubscription() { AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response<Channel> channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); sharedChannel.setId(channelResponse.results.getId()); - Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -169,7 +177,7 @@ public void cancelPlayedSubscription() { // delete household for cleanup executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); //delete subscription - IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index e9047cc3c..9821e4561 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -9,8 +9,8 @@ import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -19,7 +19,9 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + import java.util.Optional; + import static com.kaltura.client.enums.EntitlementOrderBy.PURCHASE_DATE_ASC; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; @@ -194,7 +196,7 @@ public void entitlementListAfterForceCancel() { public void entitlementListWithPaging() { PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); - MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -236,7 +238,7 @@ public void entitlementListWithPaging() { forceCancelEntitlementBuilder = EntitlementService.forceCancel(mediaFileId, TransactionType.PPV); executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); // delete media - IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), + IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 8037c1ca5..62e2659ab 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -2,15 +2,19 @@ import com.kaltura.client.enums.*; import com.kaltura.client.services.*; +import com.kaltura.client.services.AssetService.ListAssetBuilder; import com.kaltura.client.services.ChannelService.AddChannelBuilder; import com.kaltura.client.services.ChannelService.DeleteChannelBuilder; -import com.kaltura.client.services.AssetService.ListAssetBuilder; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.*; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestMppUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -21,7 +25,9 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + import java.util.Optional; + import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; @@ -75,7 +81,7 @@ public void beforeClass() { sharedChannel.setIsActive(true); sharedChannel.setAssetTypes(null); - subscriptionWithMultiCurrenciesAndDiscountPercentage = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), + subscriptionWithMultiCurrenciesAndDiscountPercentage = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), @@ -213,7 +219,7 @@ public void subscriptionTest() { AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response<Channel> channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); sharedChannel.setId(channelResponse.results.getId()); - Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); @@ -280,7 +286,7 @@ public void subscriptionTest() { HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); //delete subscription - IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); @@ -295,7 +301,7 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response<Channel> channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); sharedChannel.setId(channelResponse.results.getId()); - Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); @@ -349,7 +355,7 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(Math.toIntExact(sharedChannel.getId())); executor.executeSync(deleteChannelBuilder.setKs(getManagerKs())); //delete subscription - IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); @@ -359,7 +365,7 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { @Description("productPrice/action/list - subscription - no specifed currency") @Test() public void productPriceSubscriptionNoSpecifiedCurrencyTest() { - Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -410,7 +416,7 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); //delete subscription - IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); @@ -475,7 +481,7 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLocaleTest() { // TODO: should we save it in Properties? double subPriceAfterDiscount = 4; // as price 5 and discount is 1 - Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_FIXED), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -525,7 +531,7 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); //delete subscription - IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); @@ -597,7 +603,7 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { // TODO: should we save it in Properties? double ppvPriceAfterDiscount = 33.3; // as price 37 ILS and discount is 10% - MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), @@ -642,7 +648,7 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); - IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), + IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), @@ -659,7 +665,7 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); - MediaAsset mediaAsset = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), + MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT), Optional.empty(), Optional.empty(), @@ -705,7 +711,7 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); - IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), + IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), @@ -718,7 +724,7 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { public void productPriceWithPassedPpvTest() { String ppvWithExpiredDate = ";;01/01/2017 00:00:00"; String ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate + PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS + ";;"; - MediaAsset mediaAssetWith2Ppv1Expired = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, + MediaAsset mediaAssetWith2Ppv1Expired = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -736,7 +742,7 @@ public void productPriceWithPassedPpvTest() { mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate; - mediaAssetWith2Ppv1Expired = IngestUtils.ingestVOD(Optional.empty(), Optional.empty(), true, + mediaAssetWith2Ppv1Expired = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -752,7 +758,7 @@ public void productPriceWithPassedPpvTest() { assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo( mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); // delete media - IngestUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAssetWith2Ppv1Expired.getName()), true, Optional.empty(), + IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAssetWith2Ppv1Expired.getName()), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), @@ -765,7 +771,7 @@ public void afterClass() { HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); // delete subscription - IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscriptionWithMultiCurrenciesAndDiscountPercentage.getName()), + IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscriptionWithMultiCurrenciesAndDiscountPercentage.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 4c0c4ea48..8f47aa2d4 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -7,7 +7,6 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import javax.annotation.Nullable; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -69,7 +68,7 @@ public static long getTimeInEpoch(int offSetInMinutes) { } // generate current data String in specified format - public static String getCurrentDataInFormat(String pattern) { + public static String getCurrentDateInFormat(String pattern) { return getOffsetDateInFormat(0, pattern); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index ec3ea4fb3..a5c91e4b4 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -1,21 +1,46 @@ package com.kaltura.client.test.utils.ingestUtils; import org.w3c.dom.Document; +import org.w3c.dom.Element; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; -import java.util.Optional; - -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; +import static com.kaltura.client.test.tests.BaseTest.*; public class IngestEpgUtils extends BaseIngestUtils { - public static String buildIngestEpgXml(String epgChannelName, Optional<Integer> programCount, Optional<String> firstProgramStartDate, - Optional<Integer> programDuration, Optional<String> programDurationPeriodName, - Optional<Boolean> isCridUnique4AllPrograms, Optional<Integer> seasonCount, - Optional<String> coguid, Optional<String> crid, Optional<String> seriesId) { + // TODO: think about ENUMS if we really need it here? should we create new ENUM class for it? where? + public static final String DURATION_PERIOD_DAYS = "days"; + public static final String DURATION_PERIOD_HOURS = "hours"; + public static final String DURATION_PERIOD_MINUTES = "minutes"; + public static final String DURATION_PERIOD_SECONDS = "seconds"; + + public static List<String> durationPeriodNames = new ArrayList<>(); + + static { + durationPeriodNames.add(DURATION_PERIOD_DAYS); + durationPeriodNames.add(DURATION_PERIOD_HOURS); + durationPeriodNames.add(DURATION_PERIOD_MINUTES); + durationPeriodNames.add(DURATION_PERIOD_SECONDS); + } + + // INGEST EPG PARAMS + public static final int EPG_DEFAULT_COUNT_OF_SEASONS = 1; + public static final int EPG_DEFAULT_COUNT_OF_PROGRAMMES = 2; + public static final int EPG_DEFAULT_PROGRAM_DURATION = 30; + public static final String EPG_DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; + + + public static String buildIngestEpgXml(String epgChannelName, int programsNum, String firstProgramStartDate, int programDuration, + String programDurationPeriodName, boolean isCridUnique4AllPrograms, int seasonsNum, + String coguid, String crid, String seriesId) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; @@ -32,6 +57,44 @@ public static String buildIngestEpgXml(String epgChannelName, Optional<Integer> doc.getElementsByTagName("userName").item(0).setTextContent(getIngestBusinessModuleUserName()); doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestBusinessModuleUserPassword()); + // EpgChannels + Element epgChannels = (Element) doc.getElementsByTagName("EpgChannels").item(0); + epgChannels.setAttribute("parent-group-id", String.valueOf(partnerId)); + epgChannels.setAttribute("group-id", String.valueOf(partnerId + 1)); + + // channel + Element channel = (Element) epgChannels.getElementsByTagName("channel").item(0); + channel.setAttribute("id", epgChannelName); + + // programme + String datePattern = "MM/yy/dd HH:mm:ss"; + SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); + Calendar startDate = Calendar.getInstance(); + try { + startDate.setTime(dateFormat.parse(firstProgramStartDate)); + } catch (ParseException e) { + e.printStackTrace(); + } + + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); + + int seasonId = 1; + while (seasonId < seasonsNum) { + int programId = 1; + while (programId < programsNum) { + Date endDate = loadEndDate(startDate.getTime(), programDuration, programDurationPeriodName); + + Element programmeNode = getProgrammeNode(doc, programId, df.format(startDate.getTime()), df.format(endDate), epgChannelName, + coguid, crid, "Program", df.format(Calendar.getInstance().getTime()), seriesId, + String.valueOf(seasonsNum), isCridUnique4AllPrograms); + epgChannels.appendChild(programmeNode); + + startDate.setTime(endDate); + programId++; + } + seasonId++; + } + // uncomment cdata String docAsString = docToString(doc); docAsString = docAsString @@ -40,4 +103,112 @@ public static String buildIngestEpgXml(String epgChannelName, Optional<Integer> return docAsString; } + + private static Element getProgrammeNode(Document doc, int idx, String startDate, String endDate, String channel, String coguid, String crid, String programNamePrefix, + String currentDate, String seriesId, String seasonNumber, boolean isCridUnique4AllPrograms) { + String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; + String cridValue = isCridUnique4AllPrograms ? crid + "_" + seasonNumber + "_" + idx : crid + "_" + idx; + + // programme + Element programme = doc.createElement("programme"); + programme.setAttribute("start", startDate); + programme.setAttribute("stop", endDate); + programme.setAttribute("channel", channel); + programme.setAttribute("external_id", coguid + "_" + seasonNumber + "_" + idx); + + // title + Element title = doc.createElement("title"); + title.setAttribute("lang", "eng"); + title.setTextContent(name); + programme.appendChild(title); + + // crid + Element cridElement = doc.createElement("crid"); + cridElement.setTextContent(cridValue); + programme.appendChild(cridElement); + + // desc + Element desc = doc.createElement("desc"); + desc.setAttribute("lang", "eng"); + desc.setTextContent(startDate + " until " + endDate); + programme.appendChild(desc); + + // date + Element date = doc.createElement("date"); + date.setTextContent(currentDate); + programme.appendChild(date); + + // language + Element lang = doc.createElement("language"); + lang.setAttribute("lang", "eng"); + lang.setTextContent("eng"); + programme.appendChild(lang); + + // season num meta + programme.appendChild(generateMetasNode(doc, "season_num", seasonNumber)); + + // series id meta + programme.appendChild(generateMetasNode(doc, "series_id", seriesId)); + + // episode num meta + programme.appendChild(generateMetasNode(doc, "episode_num", String.valueOf(idx))); + + return programme; + } + + private static Element generateMetasNode(Document doc, String metaTypeString, String metaValuesString) { + // metas node + Element metas = doc.createElement("metas"); + + // metaType + Element metaType = doc.createElement("MetaType"); + metaType.setTextContent(metaTypeString); + metas.appendChild(metaType); + + // metaValues + Element metaValues = doc.createElement("MetaValues"); + metaValues.setAttribute("lang", "eng"); + metaValues.setTextContent(metaValuesString); + metas.appendChild(metaValues); + + return metas; + } + + private static Element generateTagsNode(Document doc, String tagTypeString, String tagValuesString) { + // tags node + Element tags = doc.createElement("tags"); + + // TagType + Element tagType = doc.createElement("TagType"); + tagType.setTextContent(tagTypeString); + tags.appendChild(tagType); + + // TagValues + Element tagValues = doc.createElement("TagValues"); + tagValues.setAttribute("lang", "eng"); + tagValues.setTextContent(tagValuesString); + tags.appendChild(tagValues); + + return tags; + } + + static Date loadEndDate(Date startDate, int durationValue, String periodName) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + switch (periodName) { + case DURATION_PERIOD_DAYS: + calendar.add(Calendar.DATE, durationValue); + break; + case DURATION_PERIOD_HOURS: + calendar.add(Calendar.HOUR, durationValue); + break; + case DURATION_PERIOD_MINUTES: + calendar.add(Calendar.MINUTE, durationValue); + break; + case DURATION_PERIOD_SECONDS: + calendar.add(Calendar.SECOND, durationValue); + } + return calendar.getTime(); + } + } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index aa35c923b..cd53bdbc4 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -1,13 +1,25 @@ package com.kaltura.client.test.utils.ingestUtils; +import com.kaltura.client.Logger; +import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.types.Subscription; +import io.restassured.RestAssured; import org.w3c.dom.Document; import org.w3c.dom.Element; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import java.util.Optional; + +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; +import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static io.restassured.path.xml.XmlPath.from; public class IngestMppUtils extends BaseIngestUtils { @@ -42,7 +54,119 @@ public class IngestMppUtils extends BaseIngestUtils { "<verification_payment_gateway>Apple</verification_payment_gateway>\n" + "</product_code>"; - public static String buildIngestMppXml(String action, String mppCode, boolean isActive, String title, String description, + /** + * IMPORTANT: please delete inserted by that method items + * + * @param action - can be "insert" or "delete" ("update" looks like broken) + * @param mppCode - should have value in case "action" is "delete" + * @param isActive + * @param title + * @param description + * @param startDate + * @param endDate + * @param internalDiscount + * @param productCode + * @param isRenewable + * @param gracePeriodMinute + * @param pricePlanCode1 + * @param pricePlanCode2 + * @param channel1 + * @param channel2 + * @param fileType1 + * @param fileType2 + * @param couponGroup + * @param productCodes + * @return MPP data + * <p> + * !!!Only created by that method MPP can be deleted!!! + * <p> + * to delete existed MPP use corresponded action and value mpp.getName() as "mppCode" + * (where mpp is a variable that contains mpp data). + * <p> + * <p> + * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created by ingestPP method) + */ + // ingest new MPP + public static Subscription ingestMPP(Optional<String> action, Optional<String> mppCode, Optional<Boolean> isActive, Optional<String> title, + Optional<String> description, Optional<String> startDate, Optional<String> endDate, Optional<String> internalDiscount, + Optional<String> productCode, Optional<Boolean> isRenewable, Optional<Integer> gracePeriodMinute, + Optional<String> pricePlanCode1, Optional<String> pricePlanCode2, Optional<String> channel1, + Optional<String> channel2, Optional<String> fileType1, Optional<String> fileType2, Optional<String> couponGroup, + Optional<String> productCodes) { + String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); + String actionValue = action.orElse(INGEST_ACTION_INSERT); + boolean isActiveValue = isActive.orElse(MPP_DEFAULT_IS_ACTIVE_VALUE); + String titleValue = INGEST_ACTION_INSERT.equals(actionValue) ? mppCodeValue : title.orElse(mppCodeValue); + String descriptionValue = description.orElse(MPP_DEFAULT_DESCRIPTION_VALUE); + String startDateValue = startDate.orElse(MPP_DEFAULT_START_DATE_VALUE); + String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); + String defaultCurrencyOfDiscount4IngestMpp = "GBP"; + int defaultPercentageOfDiscount4IngestMpp = 100; + String internalDiscountValue = internalDiscount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); + String productCodeValue = productCode.orElse(""); + boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); + int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); + + String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); + String pricePlanCode2Value = pricePlanCode2.orElse(""); + String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); + String channel2Value = channel2.orElse(""); + String fileType1Value = fileType1.orElse(""); + String fileType2Value = fileType2.orElse(""); + String couponGroupValue = couponGroup.orElse(MPP_DEFAULT_COUPON_GROUP_VALUE); + String productCodesValue = productCodes.orElse(MPP_DEFAULT_PRODUCT_CODES_VALUE); + + + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + + String reqBody = IngestMppUtils.buildIngestMppXml(actionValue, mppCodeValue, isActiveValue, titleValue, + descriptionValue, startDateValue, endDateValue, internalDiscountValue, productCodeValue, + isRenewableValue, gracePeriodMinuteValue, pricePlanCode1Value, pricePlanCode2Value, + channel1Value, channel2Value, fileType1Value, fileType2Value, couponGroupValue, productCodesValue); + + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") + .body(reqBody) + .when() + .post(url); + + Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug("\n Response:!!! " + resp.asString()); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); + + url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); + + Subscription subscription = new Subscription(); + subscription.setId(id); + subscription.setName(titleValue); + subscription.setDescription(descriptionValue); + // TODO: complete COMMENTED IF NEEDED + //subscription.setStartDate(); + //subscription.setEndDate(); + //subscription.setDiscountModule(); + //subscription.setProductCodes(); + subscription.isRenewable(String.valueOf(isRenewableValue)); + subscription.setGracePeriodMinutes(gracePeriodMinuteValue); + //subscription.setPricePlanIds(); + //subscription.setChannels(); + //subscription.setFileTypes(); + //subscription.setCouponsGroups(); + return subscription; + } + + private static String buildIngestMppXml(String action, String mppCode, boolean isActive, String title, String description, String startDate, String endDate, String internalDiscount, String productCode, boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, String pricePlanCode2, String channel1, String channel2, String fileType1, diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 53dfefb1f..56bc5c446 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -1,13 +1,27 @@ package com.kaltura.client.test.utils.ingestUtils; +import com.kaltura.client.Logger; +import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.types.DiscountModule; +import com.kaltura.client.types.PricePlan; +import io.restassured.RestAssured; import org.w3c.dom.Document; import org.w3c.dom.Element; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import java.util.Optional; + +import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.IngestConstants.MAX_RANDOM_GENERATED_VALUE_4_INGEST; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; +import static com.kaltura.client.test.tests.enums.Currency.EUR; +import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static io.restassured.path.xml.XmlPath.from; public class IngestPpUtils extends BaseIngestUtils { @@ -17,7 +31,90 @@ public class IngestPpUtils extends BaseIngestUtils { static final int PP_DEFAULT_MAX_VIEWS_VALUE = 0; static final int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; - public static String buildIngestPpXml(String action, String ppCode, boolean isActive, String fullLifeCycle, String viewLifeCycle, + /** + * IMPORTANT: please delete inserted by that method items + * + * @param action - can be "insert", "update" and "delete" + * @param ppCode - should have value in case "action" one of {"update" and "delete"} + * @param isActive + * @param fullLifeCycle + * @param viewLifeCycle + * @param maxViews + * @param price + * @param currency + * @param discount + * @param isRenewable + * @param recurringPeriods + * @return PricePlan data + * <p> + * to update or delete existed price plan use corresponded action and value pricePlan.getName() as "ppCode" + * (where pricePlan is a variable that contains price plan data) + * <p> + * !!!Only created by that method PP can be deleted/updated!!! + */ + public static PricePlan ingestPP(Optional<String> action, Optional<String> ppCode, Optional<Boolean> isActive, + Optional<String> fullLifeCycle, Optional<String> viewLifeCycle, Optional<Integer> maxViews, + Optional<String> price, Optional<String> currency, Optional<String> discount, Optional<Boolean> isRenewable, + Optional<Integer> recurringPeriods) { + String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); + String actionValue = action.orElse(INGEST_ACTION_INSERT); + boolean isActiveValue = isActive.orElse(PP_DEFAULT_IS_ACTIVE_VALUE); + String fullLifeCycleValue = fullLifeCycle.orElse(FIVE_MINUTES_PERIOD); + String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); + int maxViewsValue = maxViews.orElse(PP_DEFAULT_MAX_VIEWS_VALUE); + String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT)); + String currencyValue = currency.orElse(EUR.getValue()); + int defaultPercentageOfDiscount4IngestMpp = 100; + DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount4IngestMpp); + String discountValue = discount.orElse(discountModule.toParams().get("code").toString()); + boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); + int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); + + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + + String reqBody = IngestPpUtils.buildIngestPpXml(actionValue, ppCodeValue, isActiveValue, fullLifeCycleValue, + viewLifeCycleValue, maxViewsValue, priceValue, currencyValue, discountValue, isRenewableValue, recurringPeriodsValue); + + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") + .body(reqBody) + .when() + .post(url); + + Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); + + url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); + //Logger.getLogger(IngestUtils.class).debug("ID: " + id); + + PricePlan pricePlan = new PricePlan(); + pricePlan.setId(Long.valueOf(id)); + pricePlan.setMaxViewsNumber(maxViewsValue); + pricePlan.setIsRenewable(isRenewableValue); + pricePlan.setRenewalsNumber(recurringPeriodsValue); + pricePlan.setName(ppCodeValue); + pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get("id").toString())); + // TODO: complete COMMENTED IF NEEDED + //pricePlan.setFullLifeCycle(); + //pricePlan.setViewLifeCycle(); + //pricePlan.setPriceDetailsId(); + return pricePlan; + } + + private static String buildIngestPpXml(String action, String ppCode, boolean isActive, String fullLifeCycle, String viewLifeCycle, int maxViews, String price, String currency, String discount, boolean isRenewable, int recurringPeriods) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 4d4c157b5..0a36da133 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -1,17 +1,129 @@ package com.kaltura.client.test.utils.ingestUtils; +import com.kaltura.client.Logger; +import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.types.*; +import io.restassured.RestAssured; import org.w3c.dom.Document; import org.w3c.dom.Element; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.IngestConstants.MAX_RANDOM_GENERATED_VALUE_4_INGEST; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; +import static com.kaltura.client.test.tests.enums.Currency.EUR; +import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static io.restassured.path.xml.XmlPath.from; public class IngestPpvUtils extends BaseIngestUtils { - public static String buildIngestPpvXml(String action, String ppvCode, boolean isActive, String description, String discount, + /** + * IMPORTANT: please delete inserted by that method items + * + * @param action - can be "insert", "update" and "delete" + * @param ppvCode - should have value in case "action" one of {"update" and "delete"} + * @param isActive + * @param description + * @param discount + * @param price + * @param currency + * @param usageModule + * @param isSubscriptionOnly + * @param isFirstDeviceLimitation + * @param productCode + * @param firstFileType + * @param secondFileType + * @return PPV data + * <p> + * to update or delete existed ppv use corresponded action and value ppv.getName() as "ppvCode" + * (where ppv is a variable that contains ppv data) + * <p> + * !!!Only created by that method PPV can be deleted/update!!! + */ + // ingest new PPV + public static Ppv ingestPPV(Optional<String> action, Optional<String> ppvCode, Optional<Boolean> isActive, Optional<String> description, + Optional<String> discount, Optional<Double> price, Optional<String> currency, Optional<String> usageModule, + Optional<Boolean> isSubscriptionOnly, Optional<Boolean> isFirstDeviceLimitation, Optional<String> productCode, + Optional<String> firstFileType, Optional<String> secondFileType) { + String actionValue = action.orElse(INGEST_ACTION_INSERT); + String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); + boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; + String descriptionValue = description.orElse("My ingest PPV"); + String defaultCurrencyOfDiscount4IngestPpv = "ILS"; + int defaultPercentageOfDiscount4IngestPpv = 50; + String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); + double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); + String currencyValue = currency.orElse(EUR.getValue()); + String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); + boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; + boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; + String productCodeValue = productCode.orElse(getProperty(DEFAULT_PRODUCT_CODE)); + String firstFileTypeValue = firstFileType.orElse(getProperty(WEB_FILE_TYPE)); + String secondFileTypeValue = secondFileType.orElse(getProperty(MOBILE_FILE_TYPE)); + + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + + String reqBody = IngestPpvUtils.buildIngestPpvXml(actionValue, ppvCodeValue, isActiveValue, descriptionValue, + discountValue, priceValue, currencyValue, usageModuleValue, isSubscriptionOnlyValue, + isFirstDeviceLimitationValue, productCodeValue, firstFileTypeValue, secondFileTypeValue); + + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") + .body(reqBody) + .when() + .post(url); + + Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug("\n Response!!!: " + resp.asString()); + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + //System.out.println("ReportId = " + reportId); + + url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = RestAssured.given() + .log().all() + .get(url); + + Logger.getLogger(IngestUtils.class).debug(resp.asString()); + Logger.getLogger(IngestUtils.class).debug(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + + String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); + + Ppv ppv = new Ppv(); + ppv.setId(id); + List<TranslationToken> descriptions = new ArrayList<>(); + TranslationToken translationToken = new TranslationToken(); + translationToken.setValue(descriptionValue); + descriptions.add(translationToken); + ppv.setDescriptions(descriptions); + PriceDetails priceDetails = new PriceDetails(); + Price priceObj = new Price(); + priceObj.setAmount(priceValue); + priceObj.setCurrency(currencyValue); + priceDetails.setPrice(priceObj); + ppv.setPrice(priceDetails); + UsageModule usageModuleObj = new UsageModule(); + usageModuleObj.setName(usageModuleValue); + ppv.setUsageModule(usageModuleObj); + ppv.setIsSubscriptionOnly(isSubscriptionOnlyValue); + ppv.setFirstDeviceLimitation(isFirstDeviceLimitationValue); + ppv.setProductCode(productCodeValue); + ppv.setName(ppvCodeValue); + + return ppv; + } + + private static String buildIngestPpvXml(String action, String ppvCode, boolean isActive, String description, String discount, double price, String currency, String usageModule, boolean isSubscriptionOnly, boolean isFirstDeviceLimitation, String productCode, String firstFileType, String secondFileType) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java index 83837786c..1b2fadb0d 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java @@ -2,60 +2,33 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.AssetService.GetAssetBuilder; import com.kaltura.client.services.AssetService.ListAssetBuilder; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.ProgramAsset; +import com.kaltura.client.types.SearchAssetFilter; import com.kaltura.client.utils.response.base.Response; import io.restassured.RestAssured; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.tests.enums.Currency.EUR; -import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestPpUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.buildIngestVodXml; -import static io.restassured.path.xml.XmlPath.from; -import static org.assertj.core.api.Assertions.assertThat; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; import static org.awaitility.Awaitility.await; public class IngestUtils extends BaseUtils { - // INGEST EPG PARAMS - // TODO: think about ENUMS if we really need it here? should we create new ENUM class for it? where? - public static final String DURATION_PERIOD_DAYS = "days"; - public static final String DURATION_PERIOD_HOURS = "hours"; - public static final String DURATION_PERIOD_MINUTES = "minutes"; - public static final String DURATION_PERIOD_SECONDS = "seconds"; - - // default values - public static final int EPG_DEFAULT_COUNT_OF_SEASONS = 1; - public static final int EPG_DEFAULT_COUNT_OF_PROGRAMMES = 2; - public static final int EPG_DEFAULT_PROGRAM_DURATION = 30; - public static final String EPG_DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; - - private static List<String> durationPeriodNames = new ArrayList<>(); - - static { - durationPeriodNames.add(DURATION_PERIOD_DAYS); - durationPeriodNames.add(DURATION_PERIOD_HOURS); - durationPeriodNames.add(DURATION_PERIOD_MINUTES); - durationPeriodNames.add(DURATION_PERIOD_SECONDS); - } - - private static String titleOfIngestedItem = ""; - - // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project public static List<ProgramAsset> ingestEPG(String epgChannelName, Optional<Integer> programCount, Optional<String> firstProgramStartDate, Optional<Integer> programDuration, Optional<String> programDurationPeriodName, @@ -67,11 +40,12 @@ public static List<ProgramAsset> ingestEPG(String epgChannelName, Optional<Integ Logger.getLogger(IngestUtils.class).error("Invalid programCount value " + programCount.get() + ". Should be bigger than 0"); return null; } + int seasonCountValue = seasonCount.orElse(EPG_DEFAULT_COUNT_OF_SEASONS); String datePattern = "MM/yy/dd HH:mm:ss"; SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); - String firstProgramStartDateValue = firstProgramStartDate.orElse(getCurrentDataInFormat(datePattern)); + String firstProgramStartDateValue = firstProgramStartDate.orElse(getCurrentDateInFormat(datePattern)); Calendar startDate = Calendar.getInstance(); try { startDate.setTime(dateFormat.parse(firstProgramStartDateValue)); @@ -93,11 +67,10 @@ public static List<ProgramAsset> ingestEPG(String epgChannelName, Optional<Integ } boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); - String coguidValue = coguid.orElseGet(() -> getCurrentDataInFormat("yyMMddHHmmssSS")); + String coguidValue = coguid.orElseGet(() -> getCurrentDateInFormat("yyMMddHHmmssSS")); String cridValue = crid.orElse(coguidValue); String seriesIdValue = seriesId.orElse(coguidValue); int seasonId = 1; - Date endDate; String output = ""; String oneProgrammOutput = ""; SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss"); @@ -105,7 +78,7 @@ public static List<ProgramAsset> ingestEPG(String epgChannelName, Optional<Integ while (seasonId <= seasonCountValue) { int idx = 1; while (idx <= programCountValue) { - endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); + Date endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); oneProgrammOutput = getProgrammeXML(idx, df2.format(startDate.getTime()), df2.format(endDate), epgChannelName, coguidValue, cridValue, "Program", df2.format(now), seriesIdValue, String.valueOf(seasonId), isCridUnique4AllProgramsValue); @@ -202,9 +175,7 @@ private static String getProgrammeXML(int idx, String startDate, String endDate, String programNamePrefix, String currentDate, String seriesId, String seasonNumber, boolean isCridUnique4AllPrograms) { String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; - if ("".equals(titleOfIngestedItem)) { - titleOfIngestedItem = name; - } + // TODO: complete to cover util from old project completely String CRID = "<crid>" + crid + "_" + idx + "</crid>"; if (isCridUnique4AllPrograms) { @@ -245,6 +216,7 @@ private static String getProgrammeXML(int idx, String startDate, String endDate, "<TagType>Season</TagType>" + "<TagValues lang=\"eng\">" + seasonNumber + "</TagValues>" + "</tags>" + + "<tags>" + "<TagType>Episode</TagType>" + "<TagValues lang=\"eng\">" + id + "</TagValues>" + @@ -282,514 +254,4 @@ private static String getProgrammeXML(int idx, String startDate, String endDate, "</programme>"; return output; } - - private static Date loadEndDate(Date startDate, int durationValue, String periodName) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(startDate); - switch (periodName) { - case DURATION_PERIOD_DAYS: - calendar.add(Calendar.DATE, durationValue); - break; - case DURATION_PERIOD_HOURS: - calendar.add(Calendar.HOUR, durationValue); - break; - case DURATION_PERIOD_MINUTES: - calendar.add(Calendar.MINUTE, durationValue); - break; - case DURATION_PERIOD_SECONDS: - calendar.add(Calendar.SECOND, durationValue); - } - return calendar.getTime(); - } - - /** - * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert" or "delete" ("update" looks like broken) - * @param mppCode - should have value in case "action" is "delete" - * @param isActive - * @param title - * @param description - * @param startDate - * @param endDate - * @param internalDiscount - * @param productCode - * @param isRenewable - * @param gracePeriodMinute - * @param pricePlanCode1 - * @param pricePlanCode2 - * @param channel1 - * @param channel2 - * @param fileType1 - * @param fileType2 - * @param couponGroup - * @param productCodes - * @return MPP data - * <p> - * !!!Only created by that method MPP can be deleted!!! - * <p> - * to delete existed MPP use corresponded action and value mpp.getName() as "mppCode" - * (where mpp is a variable that contains mpp data). - * <p> - * <p> - * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created by ingestPP method) - */ - // ingest new MPP - public static Subscription ingestMPP(Optional<String> action, Optional<String> mppCode, Optional<Boolean> isActive, - Optional<String> title, Optional<String> description, Optional<String> startDate, - Optional<String> endDate, Optional<String> internalDiscount, - Optional<String> productCode, Optional<Boolean> isRenewable, - Optional<Integer> gracePeriodMinute, Optional<String> pricePlanCode1, - Optional<String> pricePlanCode2, Optional<String> channel1, - Optional<String> channel2, Optional<String> fileType1, - Optional<String> fileType2, Optional<String> couponGroup, Optional<String> productCodes) { - String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); - String actionValue = action.orElse(INGEST_ACTION_INSERT); - boolean isActiveValue = isActive.orElse(MPP_DEFAULT_IS_ACTIVE_VALUE); - String titleValue = INGEST_ACTION_INSERT.equals(actionValue) ? mppCodeValue : title.orElse(mppCodeValue); - String descriptionValue = description.orElse(MPP_DEFAULT_DESCRIPTION_VALUE); - String startDateValue = startDate.orElse(MPP_DEFAULT_START_DATE_VALUE); - String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); - String defaultCurrencyOfDiscount4IngestMpp = "GBP"; - int defaultPercentageOfDiscount4IngestMpp = 100; - String internalDiscountValue = internalDiscount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); - String productCodeValue = productCode.orElse(""); - boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); - int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); - - String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); - String pricePlanCode2Value = pricePlanCode2.orElse(""); - String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); - String channel2Value = channel2.orElse(""); - String fileType1Value = fileType1.orElse(""); - String fileType2Value = fileType2.orElse(""); - String couponGroupValue = couponGroup.orElse(MPP_DEFAULT_COUPON_GROUP_VALUE); - String productCodesValue = productCodes.orElse(MPP_DEFAULT_PRODUCT_CODES_VALUE); - - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - - String reqBody = IngestMppUtils.buildIngestMppXml(actionValue, mppCodeValue, isActiveValue, titleValue, - descriptionValue, startDateValue, endDateValue, internalDiscountValue, productCodeValue, - isRenewableValue, gracePeriodMinuteValue, pricePlanCode1Value, pricePlanCode2Value, - channel1Value, channel2Value, fileType1Value, fileType2Value, couponGroupValue, productCodesValue); - - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") - .body(reqBody) - .when() - .post(url); - - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug("\n Response:!!! " + resp.asString()); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); - - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); - - Subscription subscription = new Subscription(); - subscription.setId(id); - subscription.setName(titleValue); - subscription.setDescription(descriptionValue); - // TODO: complete COMMENTED IF NEEDED - //subscription.setStartDate(); - //subscription.setEndDate(); - //subscription.setDiscountModule(); - //subscription.setProductCodes(); - subscription.isRenewable(String.valueOf(isRenewableValue)); - subscription.setGracePeriodMinutes(gracePeriodMinuteValue); - //subscription.setPricePlanIds(); - //subscription.setChannels(); - //subscription.setFileTypes(); - //subscription.setCouponsGroups(); - return subscription; - } - - // ingest new PP - - /** - * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert", "update" and "delete" - * @param ppCode - should have value in case "action" one of {"update" and "delete"} - * @param isActive - * @param fullLifeCycle - * @param viewLifeCycle - * @param maxViews - * @param price - * @param currency - * @param discount - * @param isRenewable - * @param recurringPeriods - * @return PricePlan data - * <p> - * to update or delete existed price plan use corresponded action and value pricePlan.getName() as "ppCode" - * (where pricePlan is a variable that contains price plan data) - * <p> - * !!!Only created by that method PP can be deleted/updated!!! - */ - public static PricePlan ingestPP(Optional<String> action, Optional<String> ppCode, Optional<Boolean> isActive, - Optional<String> fullLifeCycle, Optional<String> viewLifeCycle, Optional<Integer> maxViews, - Optional<String> price, Optional<String> currency, - Optional<String> discount, Optional<Boolean> isRenewable, - Optional<Integer> recurringPeriods) { - String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); - String actionValue = action.orElse(INGEST_ACTION_INSERT); - boolean isActiveValue = isActive.orElse(PP_DEFAULT_IS_ACTIVE_VALUE); - String fullLifeCycleValue = fullLifeCycle.orElse(FIVE_MINUTES_PERIOD); - String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); - int maxViewsValue = maxViews.orElse(PP_DEFAULT_MAX_VIEWS_VALUE); - String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT)); - String currencyValue = currency.orElse(EUR.getValue()); - int defaultPercentageOfDiscount4IngestMpp = 100; - DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount4IngestMpp); - String discountValue = discount.orElse(discountModule.toParams().get("code").toString()); - boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); - int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - - String reqBody = IngestPpUtils.buildIngestPpXml(actionValue, ppCodeValue, isActiveValue, fullLifeCycleValue, - viewLifeCycleValue, maxViewsValue, priceValue, currencyValue, discountValue, isRenewableValue, recurringPeriodsValue); - - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") - .body(reqBody) - .when() - .post(url); - - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); - - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); - //Logger.getLogger(IngestUtils.class).debug("ID: " + id); - - PricePlan pricePlan = new PricePlan(); - pricePlan.setId(Long.valueOf(id)); - pricePlan.setMaxViewsNumber(maxViewsValue); - pricePlan.setIsRenewable(isRenewableValue); - pricePlan.setRenewalsNumber(recurringPeriodsValue); - pricePlan.setName(ppCodeValue); - pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get("id").toString())); - // TODO: complete COMMENTED IF NEEDED - //pricePlan.setFullLifeCycle(); - //pricePlan.setViewLifeCycle(); - //pricePlan.setPriceDetailsId(); - return pricePlan; - } - - /** - * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert", "update" and "delete" - * @param ppvCode - should have value in case "action" one of {"update" and "delete"} - * @param isActive - * @param description - * @param discount - * @param price - * @param currency - * @param usageModule - * @param isSubscriptionOnly - * @param isFirstDeviceLimitation - * @param productCode - * @param firstFileType - * @param secondFileType - * @return PPV data - * <p> - * to update or delete existed ppv use corresponded action and value ppv.getName() as "ppvCode" - * (where ppv is a variable that contains ppv data) - * <p> - * !!!Only created by that method PPV can be deleted/update!!! - */ - // ingest new PPV - public static Ppv ingestPPV(Optional<String> action, Optional<String> ppvCode, Optional<Boolean> isActive, Optional<String> description, - Optional<String> discount, Optional<Double> price, Optional<String> currency, Optional<String> usageModule, - Optional<Boolean> isSubscriptionOnly, Optional<Boolean> isFirstDeviceLimitation, Optional<String> productCode, - Optional<String> firstFileType, Optional<String> secondFileType) { - String actionValue = action.orElse(INGEST_ACTION_INSERT); - String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); - boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; - String descriptionValue = description.orElse("My ingest PPV"); - String defaultCurrencyOfDiscount4IngestPpv = "ILS"; - int defaultPercentageOfDiscount4IngestPpv = 50; - String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); - double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); - String currencyValue = currency.orElse(EUR.getValue()); - String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); - boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; - boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; - String productCodeValue = productCode.orElse(getProperty(DEFAULT_PRODUCT_CODE)); - String firstFileTypeValue = firstFileType.orElse(getProperty(WEB_FILE_TYPE)); - String secondFileTypeValue = secondFileType.orElse(getProperty(MOBILE_FILE_TYPE)); - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - - String reqBody = IngestPpvUtils.buildIngestPpvXml(actionValue, ppvCodeValue, isActiveValue, descriptionValue, - discountValue, priceValue, currencyValue, usageModuleValue, isSubscriptionOnlyValue, - isFirstDeviceLimitationValue, productCodeValue, firstFileTypeValue, secondFileTypeValue); - - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") - .body(reqBody) - .when() - .post(url); - - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug("\n Response!!!: " + resp.asString()); - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //System.out.println("ReportId = " + reportId); - - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); - - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - Logger.getLogger(IngestUtils.class).debug(resp.asString().split(" = ")[1].replaceAll("\\.", "")); - - String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); - - Ppv ppv = new Ppv(); - ppv.setId(id); - List<TranslationToken> descriptions = new ArrayList<>(); - TranslationToken translationToken = new TranslationToken(); - translationToken.setValue(descriptionValue); - descriptions.add(translationToken); - ppv.setDescriptions(descriptions); - PriceDetails priceDetails = new PriceDetails(); - Price priceObj = new Price(); - priceObj.setAmount(priceValue); - priceObj.setCurrency(currencyValue); - priceDetails.setPrice(priceObj); - ppv.setPrice(priceDetails); - UsageModule usageModuleObj = new UsageModule(); - usageModuleObj.setName(usageModuleValue); - ppv.setUsageModule(usageModuleObj); - ppv.setIsSubscriptionOnly(isSubscriptionOnlyValue); - ppv.setFirstDeviceLimitation(isFirstDeviceLimitationValue); - ppv.setProductCode(productCodeValue); - ppv.setName(ppvCodeValue); - - return ppv; - } - - /** - * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert", "update" and "delete" - * @param coguid - should have value in case "action" one of {"update" and "delete"} - * @param isActive - * @param name - * @param thumbUrl - * @param description - * @param catalogStartDate - * @param catalogEndDate - * @param startDate - * @param endDate - * @param mediaType - * @param ppvWebName - * @param ppvMobileName - * @param tags - * @param strings - * @param numbers - * @param dates - * @return to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" - * (where vod is a variable that contains VOD data) - * <p> - * !!!Only created by that method VOD can be deleted/update!!! - */ - // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - public static MediaAsset ingestVOD(Optional<String> action, Optional<String> coguid, boolean isActive, Optional<String> name, Optional<String> thumbUrl, Optional<String> description, - Optional<String> catalogStartDate, Optional<String> catalogEndDate, Optional<String> startDate, Optional<String> endDate, Optional<String> mediaType, - Optional<String> ppvWebName, Optional<String> ppvMobileName, Optional<Map<String, List<String>>> tags, Optional<Map<String, String>> strings, - Optional<Map<String, Integer>> numbers, Optional<Map<String, String>> dates) { - String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; - String coguidDatePattern = "yyMMddHHmmssSS"; - String maxEndDateValue = "14/10/2099 17:00:00"; - String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value - int defaultDayOffset = -1; - - String actionValue = action.orElse(INGEST_ACTION_INSERT); - String coguidValue = coguid.orElse(getCurrentDataInFormat(coguidDatePattern)); - String nameValue = INGEST_ACTION_INSERT.equals(actionValue) ? coguidValue : name.orElse(coguidValue); - String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); - String descriptionValue = description.orElse("description of " + coguidValue); - String catalogStartDateValue = catalogStartDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); - String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); - String startDateValue = startDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); - String endDateValue = endDate.orElse(maxEndDateValue); - String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); - String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); - String ppvMobileNameValue = ppvMobileName.orElse(ppvModuleName); - Map<String, List<String>> tagsValue = tags.orElse(getDefaultTags()); - Map<String, String> stringsValue = strings.orElse(getDefaultStrings()); - Map<String, Integer> numbersValue = numbers.orElse(getDefaultNumbers()); - Map<String, String> datesValue = dates.orElse(getDefaultDates()); - // TODO: check if ingest url is the same for all ingest actions - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - - String reqBody = buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, - catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); - - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestTvinciData") - .body(reqBody) - .when() - .post(url); - -// Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug("Ingest response: \n" + resp.asString()); - assertThat(resp).isNotNull(); - assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); - - String id; - if (INGEST_ACTION_INSERT.equals(actionValue)) { - id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - } else { - id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); - } - - MediaAsset mediaAsset = new MediaAsset(); - mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id.trim())); - mediaAsset.setDescription(descriptionValue); - //mediaAsset.setStartDate(startDate); - //mediaAsset.setEndDate(endDate); - - if (!INGEST_ACTION_DELETE.equals(actionValue)) { - int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 90; - await() - .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) - .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(getAnonymousKs(), id, actionValue)); - - mediaAsset.setMediaFiles(executor.executeSync( - AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); - } - - // TODO: 4/15/2018 add log for ingest and index failures - return mediaAsset; - } - - // TODO: these values should be get in another way than now - private static Map<String, List<String>> getDefaultTags() { - Map<String, List<String>> tags = new HashMap<>(); - List<String> tagValues = new ArrayList<>(); - tagValues.add("Costa Rica;Israel"); - tags.put("Country", tagValues); - tagValues = new ArrayList<>(); - tagValues.add("GIH"); - tagValues.add("ABC"); - tagValues.add("DEF"); - tags.put("Genre", tagValues); - tagValues = new ArrayList<>(); - tagValues.add("Shay_Series"); - tags.put("Series name", tagValues); - tagValues = new ArrayList<>(); - tagValues.add("KSQL channel_573349"); - tags.put("Free", tagValues); - tagValues = new ArrayList<>(); - tags.put("Parental Rating", tagValues); - - return tags; - } - - // TODO: these values should be get in another way than now - private static Map<String, String> getDefaultStrings() { - Map<String, String> strings = new HashMap<>(); - strings.put("Synopsis", "syno pino sister"); - strings.put("meta_name", "meta_value"); - - return strings; - } - - // TODO: these values should be get in another way than now - private static Map<String, Integer> getDefaultNumbers() { - Map<String, Integer> doubles = new HashMap<>(); - doubles.put("Release year", 1900); - - return doubles; - } - - // TODO: these values should be get in another way than now - private static Map<String, String> getDefaultDates() { - Map<String, String> dates = new HashMap<>(); - dates.put("Life cycle start date", "23/03/2017 12:34:56"); - - return dates; - } - - private static Callable<Boolean> isDataReturned(String ks, String mediaId, String action) { - GetAssetBuilder getAssetBuilder = AssetService.get(mediaId, AssetReferenceType.MEDIA).setKs(ks); - if (INGEST_ACTION_DELETE.equals(action)) { - return () -> (executor.executeSync(getAssetBuilder).error != null); - } else { - return () -> (executor.executeSync(getAssetBuilder).error == null); - } - } - - // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestVOD(String mediaType, Map<String, List<String>> tags, String catalogStartDate) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(catalogStartDate), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), - Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; - } - - public static MediaAsset ingestVOD(String mediaType) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; - } - - public static MediaAsset updateVODName(MediaAsset asset, String name) { - MediaAsset mediaAsset = ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; - } - - public static ArrayList ingestBasicVODNumOfTimes(int numOfAssets, String mediaType) { - MediaAsset mediaAsset; - ArrayList<MediaAsset> assetList = new ArrayList<>(); - for (int i = 0; i < numOfAssets; i++) { - mediaAsset = ingestVOD(mediaType); - assetList.add(mediaAsset); - } - return assetList; - } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 620c2ae02..bea691065 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -1,22 +1,135 @@ package com.kaltura.client.test.utils.ingestUtils; +import com.kaltura.client.Logger; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.types.MediaAsset; +import io.restassured.RestAssured; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.getIngestAssetUserName; -import static com.kaltura.client.test.tests.BaseTest.getIngestAssetUserPassword; +import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; +import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; +import static com.kaltura.client.test.utils.BaseUtils.getOffsetDateInFormat; import static com.kaltura.client.test.utils.XmlUtils.asList; +import static io.restassured.path.xml.XmlPath.from; +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class IngestVodUtils extends BaseIngestUtils { - public static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, + /** + * IMPORTANT: please delete inserted by that method items + * + * @param action - can be "insert", "update" and "delete" + * @param coguid - should have value in case "action" one of {"update" and "delete"} + * @param isActive + * @param name + * @param thumbUrl + * @param description + * @param catalogStartDate + * @param catalogEndDate + * @param startDate + * @param endDate + * @param mediaType + * @param ppvWebName + * @param ppvMobileName + * @param tags + * @param strings + * @param numbers + * @param dates + * @return to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" + * (where vod is a variable that contains VOD data) + * <p> + * !!!Only created by that method VOD can be deleted/update!!! + */ + // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project + public static MediaAsset ingestVOD(Optional<String> action, Optional<String> coguid, boolean isActive, Optional<String> name, Optional<String> thumbUrl, Optional<String> description, + Optional<String> catalogStartDate, Optional<String> catalogEndDate, Optional<String> startDate, Optional<String> endDate, Optional<String> mediaType, + Optional<String> ppvWebName, Optional<String> ppvMobileName, Optional<Map<String, List<String>>> tags, Optional<Map<String, String>> strings, + Optional<Map<String, Integer>> numbers, Optional<Map<String, String>> dates) { + String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; + String coguidDatePattern = "yyMMddHHmmssSS"; + String maxEndDateValue = "14/10/2099 17:00:00"; + String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value + int defaultDayOffset = -1; + + String actionValue = action.orElse(INGEST_ACTION_INSERT); + String coguidValue = coguid.orElse(getCurrentDateInFormat(coguidDatePattern)); + String nameValue = INGEST_ACTION_INSERT.equals(actionValue) ? coguidValue : name.orElse(coguidValue); + String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); + String descriptionValue = description.orElse("description of " + coguidValue); + String catalogStartDateValue = catalogStartDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); + String startDateValue = startDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); + String endDateValue = endDate.orElse(maxEndDateValue); + String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); + String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); + String ppvMobileNameValue = ppvMobileName.orElse(ppvModuleName); + Map<String, List<String>> tagsValue = tags.orElse(getDefaultTags()); + Map<String, String> stringsValue = strings.orElse(getDefaultStrings()); + Map<String, Integer> numbersValue = numbers.orElse(getDefaultNumbers()); + Map<String, String> datesValue = dates.orElse(getDefaultDates()); + // TODO: check if ingest url is the same for all ingest actions + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + + String reqBody = buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, + catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); + + io.restassured.response.Response resp = RestAssured + .given() + .header("Content-Type", "text/xml;charset=UTF-8") + .header("SOAPAction", "http://tempuri.org/IService/IngestTvinciData") + .body(reqBody) + .when() + .post(url); + +// Logger.getLogger(IngestUtils.class).debug(reqBody); + Logger.getLogger(IngestUtils.class).debug("Ingest response: \n" + resp.asString()); + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); + + String id; + if (INGEST_ACTION_INSERT.equals(actionValue)) { + id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); + } else { + id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); + } + + MediaAsset mediaAsset = new MediaAsset(); + mediaAsset.setName(nameValue); + mediaAsset.setId(Long.valueOf(id.trim())); + mediaAsset.setDescription(descriptionValue); + //mediaAsset.setStartDate(startDate); + //mediaAsset.setEndDate(endDate); + + if (!INGEST_ACTION_DELETE.equals(actionValue)) { + int delayBetweenRetriesInSeconds = 3; + int maxTimeExpectingValidResponseInSeconds = 90; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(isDataReturned(getAnonymousKs(), id, actionValue)); + + mediaAsset.setMediaFiles(executor.executeSync( + AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); + } + + // TODO: 4/15/2018 add log for ingest and index failures + return mediaAsset; + } + + private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName, Map<String, List<String>> tags, Map<String, String> strings, Map<String, Integer> numbers, Map<String, String> dates) { @@ -153,4 +266,91 @@ private static Element generateAndAppendMetaNode(Document doc, Element rootEleme return meta; } + + // TODO: these values should be get in another way than now + private static Map<String, List<String>> getDefaultTags() { + Map<String, List<String>> tags = new HashMap<>(); + + List<String> tagValues = new ArrayList<>(); + tagValues.add("Costa Rica;Israel"); + tags.put("Country", tagValues); + + tagValues = new ArrayList<>(); + tagValues.add("GIH"); + tagValues.add("ABC"); + tagValues.add("DEF"); + tags.put("Genre", tagValues); + + tagValues = new ArrayList<>(); + tagValues.add("Shay_Series"); + tags.put("Series name", tagValues); + + tagValues = new ArrayList<>(); + tagValues.add("KSQL channel_573349"); + tags.put("Free", tagValues); + + tagValues = new ArrayList<>(); + tags.put("Parental Rating", tagValues); + + return tags; + } + + // TODO: these values should be get in another way than now + private static Map<String, String> getDefaultStrings() { + Map<String, String> strings = new HashMap<>(); + strings.put("Synopsis", "syno pino sister"); + strings.put("meta_name", "meta_value"); + + return strings; + } + + // TODO: these values should be get in another way than now + private static Map<String, Integer> getDefaultNumbers() { + Map<String, Integer> doubles = new HashMap<>(); + doubles.put("Release year", 1900); + + return doubles; + } + + // TODO: these values should be get in another way than now + private static Map<String, String> getDefaultDates() { + Map<String, String> dates = new HashMap<>(); + dates.put("Life cycle start date", "23/03/2017 12:34:56"); + + return dates; + } + + private static Callable<Boolean> isDataReturned(String ks, String mediaId, String action) { + AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(mediaId, AssetReferenceType.MEDIA).setKs(ks); + if (INGEST_ACTION_DELETE.equals(action)) { + return () -> (executor.executeSync(getAssetBuilder).error != null); + } else { + return () -> (executor.executeSync(getAssetBuilder).error == null); + } + } + + // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) + public static MediaAsset ingestVOD(String mediaType, Map<String, List<String>> tags, String catalogStartDate) { + MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(catalogStartDate), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), + Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); + + return mediaAsset; + } + + public static MediaAsset ingestVOD(String mediaType) { + MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + return mediaAsset; + } + + public static MediaAsset updateVODName(MediaAsset asset, String name) { + MediaAsset mediaAsset = ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + return mediaAsset; + } } diff --git a/src/test/resources/ingest_xml_templates/ingestEPG.xml b/src/test/resources/ingest_xml_templates/ingestEPG.xml index a2601352e..06bbeede8 100644 --- a/src/test/resources/ingest_xml_templates/ingestEPG.xml +++ b/src/test/resources/ingest_xml_templates/ingestEPG.xml @@ -11,53 +11,10 @@ <EpgChannels xmlns="http://tempuri.org/xmltv" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - parent-group-id="203" - group-id="204" main-lang="eng" updater-id="587"> - <channel id="Camilo_4"/> - <programme start="20180617170200" stop="20180617173200" channel="Camilo_4" - external_id="18061717020028_1_1"> - <title lang="eng">Program_20180617170200_ser18061717020028_seas1_e1 - 18061717020028_1_1 - 20180617170200 until 20180617173200 - 20180617170200 - eng - - season_num - 1 - - - Series_ID - 18061717020028 - - - Episode number - 1 - - - - Program_20180617173200_ser18061717020028_seas1_e2 - 18061717020028_1_2 - 20180617173200 until 20180617180200 - 20180617170200 - eng - - season_num - 1 - - - Series_ID - 18061717020028 - - - Episode number - 2 - - + - From 234400b60c20ea13ad22e7d09dc09679f82e1e5c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 19 Jun 2018 06:03:23 +0300 Subject: [PATCH 363/605] small refactoring done. --- .../EntitlementCancelTests.java | 68 ++++++++++++++++++- .../test/utils/dbUtils/DBConstants.java | 7 +- .../client/test/utils/dbUtils/DBUtils.java | 18 +++++ 3 files changed, 88 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 8fb378408..9ac3a2399 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -47,7 +47,7 @@ public void cancelTestBeforeClass() { subscriptionId = Integer.valueOf(getSharedCommonSubscription().getId()); // set household - testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); testSharedMasterUser = HouseholdUtils.getMasterUserFromHousehold(testSharedHousehold); playerData = new BookmarkPlayerData(); @@ -136,7 +136,6 @@ public void cancelPlayedSubscription() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - //HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); String masterKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); PurchaseUtils.purchaseSubscription(masterKs, Integer.valueOf(subscription.getId()), Optional.empty()); @@ -174,7 +173,70 @@ public void cancelPlayedSubscription() { IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + // delete channel + executor.executeSync(ChannelService.delete(Math.toIntExact(sharedChannel.getId())).setKs(getManagerKs())); + } + + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/cancel - cancel subscription in cancellation window - error 3001") + @Test(enabled = false) //TODO: as not completed + public void cancelSubscriptionInCancellationWindow() { +/* // create mpp having at least 1 media on its channel + sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); + Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + sharedChannel.setId(channelResponse.results.getId());*/ + PricePlan pricePlan = DBUtils.loadPPWithoutWaiver(); + + Subscription subscription = IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + // set household + /*Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + String masterKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid());*/ + String masterKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId()), null); + + PurchaseUtils.purchaseSubscription(masterKs, Integer.valueOf(subscription.getId()), Optional.empty()); + + /*// get CDN code for media + MediaFile mediaFile = getMediaFileByType(getSharedMediaAsset(), getProperty(WEB_FILE_TYPE)); + String cdnCode = mediaFile.getUrl(); + + // check license for play + LicensedUrlMediaRequest licensedUrlRequest = new LicensedUrlMediaRequest(); + licensedUrlRequest.setAssetId(String.valueOf(getSharedMediaAsset().getId())); + licensedUrlRequest.setContentId(mediaFile.getId()); + licensedUrlRequest.setBaseUrl(cdnCode); + GetLicensedUrlBuilder licensedUrlBuilder = LicensedUrlService.get(licensedUrlRequest); + Response urlResponse = executor.executeSync(licensedUrlBuilder.setKs(masterKs)); + assertThat(urlResponse.results).isNotNull(); + // play + playerData.setFileId(mediaFile.getId().longValue()); + bookmark.setPlayerData(playerData); + bookmark.setId(String.valueOf(getSharedMediaAsset().getId())); + AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); + Response booleanResponse = executor.executeSync(addBookmarkBuilder.setKs(masterKs)); + assertThat(booleanResponse.results.booleanValue()).isTrue();*/ + + // try cancel + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.valueOf(subscription.getId()), + TransactionType.SUBSCRIPTION); + Response booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(masterKs)); + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3001).getCode()); + + // delete household for cleanup + //executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); + //delete subscription + IngestUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + // delete channel + //executor.executeSync(ChannelService.delete(Math.toIntExact(sharedChannel.getId())).setKs(getManagerKs())); } @AfterClass diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 100d60bf6..99caeb0a7 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -93,7 +93,10 @@ public class DBConstants { "and group_id=? and internal_discount_id=? and pricing_id=?"; static final String PRICE_PLAN_WITH_WAVER_SELECT = "SELECT TOP 1 * FROM [Pricing].[dbo].[usage_modules]\n" + - "WHERE group_id=? and WAIVER=1 AND WAIVER_PERIOD>0 and IS_ACTIVE=1 and [STATUS]=1"; + "WHERE group_id=? AND WAIVER=1 AND WAIVER_PERIOD>0 AND IS_ACTIVE=1 AND [STATUS]=1"; + + static final String PRICE_PLAN_WITHOUT_WAVER_SELECT = "SELECT TOP 1 * FROM [Pricing].[dbo].[usage_modules]\n" + + "WHERE group_id=? AND WAIVER=0 AND IS_ACTIVE=1 AND [STATUS]=1"; static final String PRICE_PLAN_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + @@ -116,7 +119,7 @@ public class DBConstants { // TODO: not sure about um.num_of_rec_periods > 2 "um.is_renew=1 and ((um.num_of_rec_periods > 2) or (um.num_of_rec_periods = 0))\n" + "and s.is_recurring=1 and c.channel_type!=" + ChannelType.MANUAL_CHANNEL_TYPE.getValue() + " " + - "and s.group_id=? and s.is_active=1 and s.[status]=1 and s.[type]=0\n" + + "and s.group_id=? and s.is_active=1 and s.[status]=1 and s.[type]=0 and sc.is_active=1 and sc.[status]=1\n" + "order by s.create_date desc"; static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) SUBSCRIPTION_ID as " + SUB_ID + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 854c2b422..dfc3b4879 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -323,6 +323,24 @@ public static PricePlan loadPPWithWaiver() { return pricePlan; } + public static PricePlan loadPPWithoutWaiver() { + Logger.getLogger(IngestFixtureData.class).debug("loadPPWithoutWaiver()"); + PricePlan pricePlan = null; + + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITHOUT_WAVER_SELECT, true, partnerId); + if (Strings.isNullOrEmpty(jsonArray.toString())) { + return pricePlan; + } + + pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); + } catch (Exception e) { + e.printStackTrace(); + Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); + } + return pricePlan; + } + // private static void openConnection() { // SQLServerDataSource dataSource = getDataSource(); From 3c88886d1e09c46aa157f6307e814f5685e73733 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 20 Jun 2018 12:42:46 +0300 Subject: [PATCH 364/605] ingest refactor --- .../kaltura/client/test/IngestConstants.java | 29 -- .../kaltura/client/test/tests/BaseTest.java | 11 +- .../test/tests/enums/DurationPeriod.java | 41 +++ .../SearchAssetFilterTests.java | 51 ++-- .../AssetCommentAddTests.java | 10 +- .../AssetCommentListTests.java | 4 +- .../AssetHistoryCleanTests.java | 31 +-- .../AssetHistoryListTests.java | 26 +- .../channelTests/ChannelAddTests.java | 2 +- .../EntitlementCancelTests.java | 16 +- .../EntitlementGrantTests.java | 40 +-- .../EntitlementListTests.java | 12 +- .../householdTests/HouseholdAddTests.java | 4 +- .../householdTests/HouseholdDeleteTests.java | 8 +- .../householdTests/HouseholdGetTests.java | 8 +- .../householdTests/HouseholdPurgeTests.java | 8 +- .../HouseholdResetFrequencyTests.java | 12 +- .../householdTests/HouseholdResumeTests.java | 4 +- .../householdTests/HouseholdSuspendTests.java | 36 +-- .../householdTests/HouseholdUpdateTests.java | 12 +- .../ottUserTests/OttUserAddRoleTests.java | 2 +- .../ottUserTests/OttUserDeleteTests.java | 10 +- .../OttUserGetEncryptedUserIdTests.java | 2 +- .../ottUserTests/OttUserListTests.java | 10 +- .../ottUserTests/OttUserLoginTests.java | 4 +- .../ottUserTests/OttUserUpdateTests.java | 4 +- .../ProductPriceListTests.java | 44 +-- .../sessionTests/SessionGetTests.java | 4 +- .../sessionTests/SessionRevokeTests.java | 4 +- .../sessionTests/SessionSwitchUserTests.java | 114 ++++---- .../TransactionHistoryListTests.java | 4 +- .../kaltura/client/test/utils/AssetUtils.java | 6 +- .../kaltura/client/test/utils/BaseUtils.java | 4 +- .../client/test/utils/HouseholdUtils.java | 50 ++-- .../client/test/utils/OttUserUtils.java | 20 +- .../utils/ingestUtils/BaseIngestUtils.java | 53 +++- .../utils/ingestUtils/IngestEpgUtils.java | 208 +++++++++----- .../utils/ingestUtils/IngestMppUtils.java | 54 ++-- .../test/utils/ingestUtils/IngestPpUtils.java | 57 ++-- .../utils/ingestUtils/IngestPpvUtils.java | 47 ++-- .../test/utils/ingestUtils/IngestUtils.java | 257 ------------------ .../utils/ingestUtils/IngestVodUtils.java | 41 +-- 42 files changed, 601 insertions(+), 763 deletions(-) delete mode 100644 src/test/java/com/kaltura/client/test/IngestConstants.java create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java delete mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java diff --git a/src/test/java/com/kaltura/client/test/IngestConstants.java b/src/test/java/com/kaltura/client/test/IngestConstants.java deleted file mode 100644 index 221b82a0f..000000000 --- a/src/test/java/com/kaltura/client/test/IngestConstants.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.kaltura.client.test; - -public class IngestConstants { - - public static final String INGEST_ACTION_INSERT = "insert"; - public static final String INGEST_ACTION_UPDATE = "update"; - public static final String INGEST_ACTION_DELETE = "delete"; - - public static final Long MAX_RANDOM_GENERATED_VALUE_4_INGEST = 9999999999L; - public static final String INGEST_VOD_DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - - // life cycles periods - public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; - - // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts - public static final String MOVIE_MEDIA_TYPE = "Movie"; - public static final String EPISODE_MEDIA_TYPE = "Episode"; - public static final String LINEAR_MEDIA_TYPE = "Linear"; - - // PG adapter data - /*public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; - public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; - public static final String PG_DEFAULT_SHARED_SECRET = "123456"; - public static final int PG_DEFAULT_PENDING_INTERVAL = 0; - public static final int PG_DEFAULT_PENDING_RETRIES = 0; - public static final int PG_DEFAULT_RENEW_INTERVAL_MINUTES = 15; - public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; - public static final String PG_DEFAULT_PG_SETTINGS = "{}";*/ -} diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 2b03cb383..c1827c865 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -25,13 +25,13 @@ import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.OttUserService.login; -import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; import static com.kaltura.client.test.utils.SubscriptionUtils.getAssetsListBySubscription; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.FIVE_MINUTES_PERIOD; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -304,8 +304,7 @@ public static MediaAsset getSharedMediaAsset() { public static ProgramAsset getSharedEpgProgram() { if (epgProgram == null) { - epgProgram = IngestUtils.ingestEPG(epgChannelName, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty()).get(0); + epgProgram = IngestEpgUtils.ingestEPG(epgChannelName).get(0); } return (ProgramAsset) epgProgram; } @@ -439,7 +438,7 @@ public static Household getSharedHousehold() { if (sharedHousehold == null) { sharedHousehold = createHousehold(numOfUsers, numOfDevices, true); - List sharedHouseholdUsers = getUsersListFromHouseHold(sharedHousehold); + List sharedHouseholdUsers = getUsersList(sharedHousehold); for (HouseholdUser user : sharedHouseholdUsers) { if (user.getIsMaster() != null && user.getIsMaster()) { sharedMasterUser = user; @@ -449,7 +448,7 @@ public static Household getSharedHousehold() { } } - List sharedHouseholdDevices = getDevicesListFromHouseHold(sharedHousehold); + List sharedHouseholdDevices = getDevicesList(sharedHousehold); String sharedMasterUserName = getOttUserById(Integer.parseInt(sharedMasterUser.getUserId())).getUsername(); loginResponse = executor.executeSync(login(partnerId, sharedMasterUserName, defaultUserPassword,null,sharedHouseholdDevices.get(0).getUdid())); sharedMasterUserKs = loginResponse.results.getLoginSession().getKs(); diff --git a/src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java b/src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java new file mode 100644 index 000000000..5ceaab1dc --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum DurationPeriod implements EnumAsString { + DAYS("days"), + HOURS("hours"), + MINUTES("minutes"), + SECONDS("seconds"); + + private String value; + + DurationPeriod(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static DurationPeriod get(String value) { + if(value == null) { + return null; + } + + // goes over Currency defined values and compare the inner value with the given one: + for(DurationPeriod item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return Currency.values().length > 0 ? DurationPeriod.values()[0]: null; + } + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 89f290630..6ecbb4d85 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -3,11 +3,11 @@ import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.services.AssetService; - import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.*; +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -17,17 +17,16 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; -import static com.kaltura.client.services.AssetService.*; public class SearchAssetFilterTests extends BaseTest { @@ -57,13 +56,13 @@ private void Asset_list_before_class() { asset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); asset2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-100))); asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-10))); - program = IngestUtils.ingestEPG(epgChannelName, 1).get(0); - program2 = IngestUtils.ingestEPG(epgChannelName2, 1).get(0); + program = IngestEpgUtils.ingestEPG(epgChannelName, 1).get(0); + program2 = IngestEpgUtils.ingestEPG(epgChannelName2, 1).get(0); } // VOD @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - name equal query") + @Description("asset/action/list - VOD - name equal query") @Test private void listVodAssetsWithExactKsqlQuery() { ksqlQuery = "name = '" + asset.getName() + "'"; @@ -78,7 +77,7 @@ private void listVodAssetsWithExactKsqlQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - id equal query") + @Description("asset/action/list - VOD - id equal query") @Test private void listVodAssetsWithExactKsqlQuery2() { ksqlQuery = "media_id = '" + asset.getId() + "'"; @@ -93,7 +92,7 @@ private void listVodAssetsWithExactKsqlQuery2() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - OR query") + @Description("asset/action/list - VOD - OR query") @Test private void listVodAssetsWithOrQuery() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')"; @@ -109,7 +108,7 @@ private void listVodAssetsWithOrQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - AND query") + @Description("asset/action/list - VOD - AND query") @Test private void listVodAssetsWithAndQuery() { ksqlQuery = "(and media_id = '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; @@ -124,7 +123,7 @@ private void listVodAssetsWithAndQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - not query") + @Description("asset/action/list - VOD - not query") @Test private void listVodAssetsWithNotKsqlQuery() { ksqlQuery = "(and media_id != '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; @@ -139,7 +138,7 @@ private void listVodAssetsWithNotKsqlQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - like query") + @Description("asset/action/list - VOD - like query") @Test private void listVodAssetsWithLikeKsqlQuery() { ksqlQuery = "" + tagName + " ~ '" + tagValue + "'"; @@ -155,7 +154,7 @@ private void listVodAssetsWithLikeKsqlQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - start with query") + @Description("asset/action/list - VOD - start with query") @Test private void listVodAssetsWithStartWithKsqlQuery() { ksqlQuery = "" + tagName + " ^ '" + tagValue + "'"; @@ -165,13 +164,13 @@ private void listVodAssetsWithStartWithKsqlQuery() { .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); List assets = executor.executeSync(listAssetBuilder).results.getObjects(); - assertThat(assets).isNotNull(); + assertThat(assets).isNotNull().as("assets list"); assertThat(assets.size()).isEqualTo(2); assertThat(assets).extracting("id").contains(asset3.getId(), asset2.getId()).doesNotContain(asset.getId()); } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - filtered by type (Movie)") + @Description("asset/action/list - VOD - filtered by type (Movie)") @Test private void listVodAssetsFilteredByType() { ksqlQuery = "" + tagName + " = '" + tagValue + "'"; @@ -187,7 +186,7 @@ private void listVodAssetsFilteredByType() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - order by VIEWS") + @Description("asset/action/list - VOD - order by VIEWS") @Test private void OrderVodAssetsByViews() { AssetUtils.addViewsToAsset(asset.getId(), 3, AssetType.MEDIA); @@ -210,7 +209,7 @@ private void OrderVodAssetsByViews() { //TODO - Enable test after fixing updateVodName method @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - order by NAME (DESC/ASC") + @Description("asset/action/list - VOD - order by NAME (DESC/ASC") @Test(enabled = false) private void OrderVodAssetsByName() { IngestVodUtils.updateVODName(asset, "AAA"); @@ -240,7 +239,7 @@ private void OrderVodAssetsByName() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - order by LIKES") + @Description("asset/action/list - VOD - order by LIKES") @Test private void orderVodAssetsByLikes() { AssetUtils.addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); @@ -261,7 +260,7 @@ private void orderVodAssetsByLikes() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - order by (num of) VOTES and RATING") + @Description("asset/action/list - VOD - order by (num of) VOTES and RATING") @Test private void orderVodAssetsByVotesAndRating() { AssetUtils.addVotesToAsset(asset2.getId(), 2, AssetType.MEDIA, 1); @@ -292,7 +291,7 @@ private void orderVodAssetsByVotesAndRating() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - VOD - order by CATALOG START DATE") + @Description("asset/action/list - VOD - order by CATALOG START DATE") @Test private void orderVodAssetsByCatalogStartDate() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; @@ -318,7 +317,7 @@ private void orderVodAssetsByCatalogStartDate() { //TODO - add test for KalturaPersistedFilter in searchHistory class // EPG @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - EPG - name equal query") + @Description("asset/action/list - EPG - name equal query") @Test private void listEpgProgramWithExactKsqlQuery() { ksqlQuery = "name = '" + program.getName() + "'"; @@ -333,7 +332,7 @@ private void listEpgProgramWithExactKsqlQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - EPG - epg channel id equal query") + @Description("asset/action/list - EPG - epg channel id equal query") @Test private void listEpgProgramWithExactKsqlQuery2() { ksqlQuery = "epg_channel_id = '" + program.getEpgChannelId() + "'"; @@ -350,7 +349,7 @@ private void listEpgProgramWithExactKsqlQuery2() { @Severity(SeverityLevel.CRITICAL) - @Description("Asset/action/list - EPG - filter by epg channel id") + @Description("asset/action/list - EPG - filter by epg channel id") @Test private void listEpgProgramsFilteredByEpgChannel() { ksqlQuery = "(or name = '" + program.getName() + "' name = '" + program2.getName() + "')"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 749b83c5c..dc396e211 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -6,7 +6,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -14,7 +14,6 @@ import org.testng.annotations.Test; import java.util.List; -import java.util.Optional; import static com.kaltura.client.services.AssetCommentService.AddAssetCommentBuilder; import static com.kaltura.client.services.AssetCommentService.ListAssetCommentBuilder; @@ -38,7 +37,7 @@ private void add_tests_before_class() { int numOfUsers = 1; int numOfDevices = 1; household = createHousehold(numOfUsers, numOfDevices, false); - householdMasterUserKs = getHouseholdMasterUserKs(household,null); + householdMasterUserKs = getHouseholdMasterUserKs(household); } @Description("AssetComment/action/add - vod asset") @@ -51,7 +50,7 @@ private void addCommentForVod() { // AssetComment/action/add AddAssetCommentBuilder addAssetCommentBuilder = AssetCommentService.add(assetComment) - .setKs(getHouseholdMasterUserKs(household,null)); + .setKs(getHouseholdMasterUserKs(household)); Response assetCommentResponse = executor.executeSync(addAssetCommentBuilder); //Assertions for AssetComment/action/add @@ -91,8 +90,7 @@ private void addCommentForVod() { @Test private void addCommentForEPGProgram() { // Ingest EPG program - List epgPrograms = IngestUtils.ingestEPG("Shmulik_Series_1", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + List epgPrograms = IngestEpgUtils.ingestEPG("Shmulik_Series_1"); Long epgProgramId = epgPrograms.get(0).getId(); // Initialize assetComment object diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index 875cf057e..13698d44c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -18,9 +18,9 @@ import java.util.Optional; import static com.kaltura.client.services.AssetCommentService.ListAssetCommentBuilder; -import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; public class AssetCommentListTests extends BaseTest { @@ -33,7 +33,7 @@ private void asset_comment_listTests_before_class() { int numOfUsers = 1; int numOfDevices = 1; household = createHousehold(numOfUsers, numOfDevices, false); - householdMasterUserKs = getHouseholdMasterUserKs(household, null); + householdMasterUserKs = getHouseholdMasterUserKs(household); } @Description("AssetComment/action/list - check order by functionality") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 178083a82..75d8ac2b3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -19,12 +19,12 @@ import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; -import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.EPISODE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryCleanTests extends BaseTest { @@ -48,20 +48,21 @@ private void clean_tests_before_class() { // Ingest first movie asset movie = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); + // Ingest second movie asset movie2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); + // Ingest episode asset episode = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } - @Description("/assetHistory/action/clean - no filtering") + @Description("assetHistory/action/clean - no filtering") @Test private void cleanHistory() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -95,12 +96,11 @@ private void cleanHistory() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); } - @Description("/assetHistory/action/clean - filtered by asset id") + @Description("assetHistory/action/clean - filtered by asset id") @Test private void cleanSpecifcAssetHistory() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -131,12 +131,11 @@ private void cleanSpecifcAssetHistory() { assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); } - @Description("/assetHistory/action/clean - filtered by asset type") + @Description("assetHistory/action/clean - filtered by asset type") @Test private void cleanSpecifcAssetTypeHistory() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -169,12 +168,11 @@ private void cleanSpecifcAssetTypeHistory() { assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); } - @Description("/assetHistory/action/clean - filtered by asset finished") + @Description("assetHistory/action/clean - filtered by asset finished") @Test private void cleanAssetsAccordingToWatchStatusDone() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -206,12 +204,11 @@ private void cleanAssetsAccordingToWatchStatusDone() { assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); } - @Description("/assetHistory/action/clean - filtered by asset in progress") + @Description("assetHistory/action/clean - filtered by asset in progress") @Test private void cleanAssetsAccordingToWatchStatusProgress() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index b7af7f060..e4dfa1bd3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -4,9 +4,7 @@ import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.AssetHistoryUtils; -import com.kaltura.client.test.utils.AssetUtils; -import com.kaltura.client.test.utils.BookmarkUtils; +import com.kaltura.client.test.utils.*; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -21,14 +19,14 @@ import static com.kaltura.client.services.AssetHistoryService.list; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; -import static com.kaltura.client.test.IngestConstants.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { @@ -57,13 +55,14 @@ private void list_tests_before_class() { episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } - @Description("/AssetHistory/action/list - with no filter") + @Description("assetHistory/action/list - with no filter") @Test private void vodAssetHistory() { // Create HH with one user and one device Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -112,12 +111,11 @@ private void vodAssetHistory() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); } - @Description("/AssetHistory/action/list -filtered by movie asset id") + @Description("assetHistory/action/list - filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -165,12 +163,12 @@ private void vodAssetHistoryFilteredByAssetId() { assertThat(assetHistoryIdsList).containsOnly(movie2.getId(), episode.getId()); } - @Description("/AssetHistory/action/list -filtered by movie type id") + @Description("assetHistory/action/list -filtered by movie type id") @Test private void vodAssetHistoryFilteredByAssetType() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -195,12 +193,12 @@ private void vodAssetHistoryFilteredByAssetType() { assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); } - @Description("/AssetHistory/action/list -filtered by assets progress") + @Description("assetHistory/action/list -filtered by assets progress") @Test private void vodAssetHistoryFilteredByAssetProgress() { Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household, null); + String userKs = getHouseholdMasterUserKs(household); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 88e6903ea..f0aafdaca 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -21,8 +21,8 @@ import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.ChannelService.AddChannelBuilder; import static com.kaltura.client.services.ChannelService.DeleteChannelBuilder; -import static com.kaltura.client.test.IngestConstants.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; public class ChannelAddTests extends BaseTest { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 39dccb5ab..17f9a52b7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -30,10 +30,10 @@ import static com.kaltura.client.services.EntitlementService.*; import static com.kaltura.client.services.HouseholdService.delete; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.WEB_FILE_TYPE; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementCancelTests extends BaseTest { @@ -55,7 +55,7 @@ public void cancelTestBeforeClass() { // set household testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - testSharedMasterUser = HouseholdUtils.getMasterUserFromHousehold(testSharedHousehold); + testSharedMasterUser = HouseholdUtils.getMasterUser(testSharedHousehold); playerData = new BookmarkPlayerData(); playerData.setAction(BookmarkActionType.FIRST_PLAY); @@ -80,8 +80,8 @@ public void cancelTestBeforeClass() { public void cancelSubscription() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); // grant subscription GrantEntitlementBuilder grantEntitlementBuilder = grant(subscriptionId, TransactionType.SUBSCRIPTION, true, 0) @@ -117,7 +117,7 @@ public void cancelSubscription() { public void cancelWithInvalidSubscription() { // cancel subscription int invalidSubscriptionId = 1; - String userKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId()), null); + String userKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId())); CancelEntitlementBuilder cancelEntitlementBuilder = cancel(invalidSubscriptionId, TransactionType.SUBSCRIPTION); Response booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(userKs)); @@ -141,8 +141,8 @@ public void cancelPlayedSubscription() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - //HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + //HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); PurchaseUtils.purchaseSubscription(masterKs, Integer.valueOf(subscription.getId()), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index 68c4bf8a6..aab57591a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -57,8 +57,8 @@ private void grant_test_before_class() { private void grant_subscription_with_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // grant subscription - history = true @@ -90,7 +90,7 @@ private void grant_subscription_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); TransactionHistoryService.ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -102,7 +102,7 @@ private void grant_subscription_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -123,7 +123,7 @@ private void grant_subscription_with_history() { private void grant_subscription_without_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // grant subscription - history = true @@ -140,7 +140,7 @@ private void grant_subscription_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); TransactionHistoryService.ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); @@ -148,7 +148,7 @@ private void grant_subscription_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(0); @@ -165,8 +165,8 @@ private void grant_subscription_without_history() { private void grant_ppv_with_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // grant subscription - history = true GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) @@ -198,7 +198,7 @@ private void grant_ppv_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -210,7 +210,7 @@ private void grant_ppv_with_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -230,8 +230,8 @@ private void grant_ppv_with_history() { private void grant_ppv_without_history() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // grant subscription - history = true GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) @@ -248,7 +248,7 @@ private void grant_ppv_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.USER.getValue()); ListTransactionHistoryBuilder listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -260,7 +260,7 @@ private void grant_ppv_without_history() { transactionHistoryfilter.entityReferenceEqual(EntityReferenceBy.HOUSEHOLD.getValue()); listTransactionHistoryBuilder = TransactionHistoryService.list(transactionHistoryfilter, null) - .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null)); + .setKs(OttUserUtils.getKs(Integer.parseInt(user.getUserId()))); billingTransactionListResponse = executor.executeSync(listTransactionHistoryBuilder); assertThat(billingTransactionListResponse.results.getTotalCount()).isEqualTo(1); @@ -280,7 +280,7 @@ private void grant_ppv_with_wrong_id() { int productId = 1; // get user form test shared household - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(testSharedHousehold).get(0); // grant ppv with wrong id GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(productId, TransactionType.PPV, true, contentId) @@ -299,7 +299,7 @@ private void grant_ppv_with_wrong_id() { @Test private void grant_purchased_ppv() { // get user form test shared household - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(testSharedHousehold).get(0); // grant ppv - first time GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(ppvId, TransactionType.PPV, true, contentId) @@ -324,7 +324,7 @@ private void grant_purchased_ppv() { @Test private void grant_purchased_subscription() { // get user form test shared household - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(testSharedHousehold).get(0); // grant subscription - first time GrantEntitlementBuilder grantEntitlementBuilder = EntitlementService.grant(subscriptionId, TransactionType.SUBSCRIPTION, false, 0) @@ -357,7 +357,7 @@ private void grant_3023() { @Test(enabled = false) private void grant_ppv_with_invalid_contentId() { // get user form test shared household - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(testSharedHousehold).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(testSharedHousehold).get(0); // grant ppv with invalid content id int invalidContentId = 1; @@ -399,7 +399,7 @@ private void grant_ppv_user_not_in_domain() { private void grant_ppv_user_suspend() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // suspend household SuspendHouseholdBuilder suspendHouseholdBuilder = suspend(0) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index 9821e4561..33b892db2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -24,7 +24,7 @@ import static com.kaltura.client.enums.EntitlementOrderBy.PURCHASE_DATE_ASC; import static com.kaltura.client.services.HouseholdService.delete; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementListTests extends BaseTest { @@ -48,10 +48,10 @@ public void setUp() { filter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - regularUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); - regularUserId = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0).getUserId(); + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); + regularUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); + masterUserId = HouseholdUtils.getMasterUser(household).getUserId(); + regularUserId = HouseholdUtils.getRegularUsersList(household).get(0).getUserId(); } @Severity(SeverityLevel.NORMAL) @@ -59,7 +59,7 @@ public void setUp() { @Test public void entitlementListBeforePurchase() { Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - String masterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + String masterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); // subscription filter.setProductTypeEqual(TransactionType.SUBSCRIPTION); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdAddTests.java index 46d8243e9..fc26c4e8d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdAddTests.java @@ -29,7 +29,7 @@ private void household_addTests_beforeClass() { int numberOfUsersInHousehold = 1; int numberOfDevicesInHousehold = 1; household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + masterUser = HouseholdUtils.getMasterUser(household); } @Severity(SeverityLevel.NORMAL) @@ -42,7 +42,7 @@ private void add_with_exists_in_other_household_masterUser() { household.setDescription(masterUser.getUserId() + " Description"); // add household - String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); Response householdResponse = executor.executeSync(add(household).setKs(masterUserKs)); assertThat(householdResponse.results).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdDeleteTests.java index 7c1d1875b..f18d05a70 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdDeleteTests.java @@ -28,10 +28,10 @@ public class HouseholdDeleteTests extends BaseTest { private void delete_with_household_masterUser() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // delete household - String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); Response booleanResponse = executor.executeSync(delete().setKs(masterUserKs)); assertThat(booleanResponse.results.booleanValue()).isTrue(); @@ -49,10 +49,10 @@ private void delete_with_household_masterUser() { private void delete_with_household_regularUser() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // delete household - String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId())); Response booleanResponse = executor.executeSync(delete().setKs(userKs)); assertThat(booleanResponse.results).isNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdGetTests.java index 0e51c7c4c..7a6262650 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdGetTests.java @@ -34,8 +34,8 @@ private void household_getTests_beforeClass() { @Test private void get_with_masterUser_ks() { // get master user ks - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); // get household GetHouseholdBuilder getHouseholdBuilder = get() @@ -51,8 +51,8 @@ private void get_with_masterUser_ks() { @Test private void get_with_regularUser_ks() { // get regular user ks - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); - String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId())); // get household GetHouseholdBuilder getHouseholdBuilder = get() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java index 750f34c8f..2d15a6c95 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java @@ -28,10 +28,10 @@ private void household_purgeTests_beforeClass() { int numberOfUsersInHousehold = 1; int numberOfDevicesInHousehold = 1; household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); } @@ -46,7 +46,7 @@ private void purge() { // // delete devices until error 1014 return -// List devices = HouseholdUtils.getDevicesListFromHouseHold(household); +// List devices = HouseholdUtils.getDevicesList(household); // // executor.executeSync(delete(devices.get(1).getUdid()).setKs(masterUserKs)); // Response booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); @@ -64,7 +64,7 @@ private void purge() { // assertThat(booleanResponse.results.booleanValue()).isTrue(); // // // assert devices list size = 1 -// devices = HouseholdUtils.getDevicesListFromHouseHold(household); +// devices = HouseholdUtils.getDevicesList(household); // assertThat(devices.size()).isEqualTo(1); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java index 9c8333b42..ab39878ab 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResetFrequencyTests.java @@ -36,10 +36,10 @@ private void household_resetFrequencyTests_beforeClass() { int numberOfUsersInHousehold = 3; int numberOfDevicesInHousehold = 3; household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); } @@ -48,7 +48,7 @@ private void household_resetFrequencyTests_beforeClass() { @Test private void resetFrequency_household_devices() { // delete devices until error 1014 return - List devices = HouseholdUtils.getDevicesListFromHouseHold(household); + List devices = HouseholdUtils.getDevicesList(household); executor.executeSync(delete(devices.get(1).getUdid()).setKs(masterUserKs)); Response booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); @@ -66,7 +66,7 @@ private void resetFrequency_household_devices() { assertThat(booleanResponse.results.booleanValue()).isTrue(); // assert devices list size = 1 - devices = HouseholdUtils.getDevicesListFromHouseHold(household); + devices = HouseholdUtils.getDevicesList(household); assertThat(devices.size()).isEqualTo(1); } @@ -75,7 +75,7 @@ private void resetFrequency_household_devices() { @Test private void resetFrequency_household_users() { // delete users until error 1014 return - List users = HouseholdUtils.getRegularUsersListFromHouseHold(household); + List users = HouseholdUtils.getRegularUsersList(household); executor.executeSync(HouseholdUserService.delete(users.get(0).getUserId()).setKs(masterUserKs)); Response booleanResponse = executor.executeSync(HouseholdUserService.delete(users.get(1).getUserId()).setKs(masterUserKs)); @@ -93,7 +93,7 @@ private void resetFrequency_household_users() { assertThat(booleanResponse.results.booleanValue()).isTrue(); // assert regular users list size = 1 - users = HouseholdUtils.getRegularUsersListFromHouseHold(household); + users = HouseholdUtils.getRegularUsersList(household); assertThat(users.size()).isEqualTo(1); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java index 9d350e3f6..8687620f3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdResumeTests.java @@ -33,10 +33,10 @@ private void household_resumeTests_beforeClass() { int numberOfUsersInHousehold = 2; int numberOfDevicesInHousehold = 1; household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // set subscription diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index f5831c3a7..b5943e028 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -69,7 +69,7 @@ private void household_suspendTests_beforeClass() { private void suspend() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // suspend household SuspendHouseholdBuilder suspendHouseholdBuilder = HouseholdService.suspend() @@ -94,10 +94,10 @@ private void suspend() { private void suspend_with_masterUser_ks() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // suspend household @@ -116,7 +116,7 @@ private void suspend_with_masterUser_ks() { private void suspend_with_login_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // create role UserRole role = new UserRole(); @@ -154,10 +154,10 @@ private void suspend_with_login_role() { private void suspend_with_purchase_subscription_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role @@ -209,10 +209,10 @@ private void suspend_with_purchase_subscription_role() { private void suspend_with_cancel_subscription_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role @@ -256,10 +256,10 @@ private void suspend_with_cancel_subscription_role() { private void suspend_with_playback_subscription_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role @@ -308,10 +308,10 @@ private void suspend_with_playback_subscription_role() { private void suspend_with_purchase_ppv_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role @@ -358,10 +358,10 @@ private void suspend_with_purchase_ppv_role() { private void suspend_with_playback_ppv_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role @@ -419,10 +419,10 @@ private void suspend_with_renew_subscription_role_before_wait() { // set household householdSlowTest = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(householdSlowTest); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(householdSlowTest); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(householdSlowTest).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(householdSlowTest).get(0).getUdid(); masterUserKsSlowTest = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role @@ -512,10 +512,10 @@ private void suspend_with_renew_subscription_role_after_wait() { private void suspend_with_purchase_service_role() { // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); // create role diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java index 97a20dcc7..61b47cba6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdUpdateTests.java @@ -29,10 +29,10 @@ private void household_updateTests_beforeClass() { int numberOfUsersInHousehold = 2; int numberOfDevicesInHousehold = 1; household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); } @@ -87,8 +87,8 @@ private void update_with_regular_userKs() { updatedHousehold.setName(householdUpdatedDetails); updatedHousehold.setDescription(householdUpdatedDetails); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); - String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId())); updatedHousehold = executor.executeSync(update(updatedHousehold) .setKs(userKs)) @@ -109,8 +109,8 @@ private void update_with_empty_household() { String householdUpdatedDetails = "updated details with empty household"; Household updatedHousehold = new Household(); - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); - String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), null); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); + String userKs = OttUserUtils.getKs(Integer.parseInt(user.getUserId())); updatedHousehold = executor.executeSync(update(updatedHousehold) .setKs(userKs)) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java index 38304775a..8cd69e29a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java @@ -55,7 +55,7 @@ private void addRole() { int userId = Integer.parseInt(user.getId()); ListUserRoleBuilder listUserRoleBuilder = UserRoleService.list(filter) - .setKs(getKs(userId, null)); + .setKs(getKs(userId)); List userRoles = executor.executeSync(listUserRoleBuilder).results.getObjects(); // assert new added role is return diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java index 79df95e27..f909911d6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserDeleteTests.java @@ -19,8 +19,8 @@ import static com.kaltura.client.services.HouseholdService.DeleteHouseholdBuilder; import static com.kaltura.client.services.OttUserService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; -import static com.kaltura.client.test.utils.HouseholdUtils.getDefaultUserFromHousehold; -import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUserFromHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getDefaultUser; +import static com.kaltura.client.test.utils.HouseholdUtils.getMasterUser; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; import static org.assertj.core.api.Assertions.assertThat; @@ -68,7 +68,7 @@ private void delete() { @Test() private void delete_master_user() { // get household master user - HouseholdUser masterUser = getMasterUserFromHousehold(household); + HouseholdUser masterUser = getMasterUser(household); // try to delete master user and assert error deleteOttUserBuilder = OttUserService.delete() @@ -85,7 +85,7 @@ private void delete_master_user() { @Test() private void delete_default_user() { // get household default user - HouseholdUser defaultUser = getDefaultUserFromHousehold(household); + HouseholdUser defaultUser = getDefaultUser(household); // try to delete default user and assert error deleteOttUserBuilder = OttUserService.delete() @@ -120,7 +120,7 @@ private void delete_user_with_suspended_household() { Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); // get regular user - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // suspend household SuspendHouseholdBuilder suspendHouseholdBuilder = suspend() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java index 5fa00c874..16f9ef146 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserGetEncryptedUserIdTests.java @@ -44,7 +44,7 @@ private void getEncryptedUserId_with_superUserKs () { @Description("ottUser/action/getEncryptedUserId") @Test private void getEncryptedUserId() { - String userKs = getKs(Integer.parseInt(user.getId()), null); + String userKs = getKs(Integer.parseInt(user.getId())); GetEncryptedUserIdOttUserBuilder getEncryptedUserIdOttUserBuilder = OttUserService.getEncryptedUserId() .setKs(userKs); Response stringValueResponse = executor.executeSync(getEncryptedUserIdOttUserBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java index f181cf2ff..3ae5e639a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserListTests.java @@ -41,7 +41,7 @@ private void ottUser_list_tests_setup() { @Test private void list_with_masterUserKs() { // get master user from household - HouseholdUser masterUser = getMasterUserFromHousehold(household); + HouseholdUser masterUser = getMasterUser(household); // login master user String username = getOttUserById(Integer.parseInt(masterUser.getUserId())).getUsername(); @@ -64,7 +64,7 @@ private void list_with_masterUserKs() { @Test private void list_with_regularUserKs() { // get master user from household - HouseholdUser user = getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser user = getRegularUsersList(household).get(0); // login regular user String username = getOttUserById(Integer.parseInt(user.getUserId())).getUsername(); @@ -87,7 +87,7 @@ private void list_with_regularUserKs() { @Test private void list_with_id_filter() { // get users from household - List householdUsers = getUsersListFromHouseHold(household); + List householdUsers = getUsersList(household); // set user filter OTTUserFilter ottUserFilter = new OTTUserFilter(); @@ -110,7 +110,7 @@ private void list_with_id_filter() { @Test private void list_with_username_filter() { // get users from household - List householdUsers = getUsersListFromHouseHold(household); + List householdUsers = getUsersList(household); // set user filter OTTUserFilter ottUserFilter = new OTTUserFilter(); @@ -133,7 +133,7 @@ private void list_with_username_filter() { @Test private void list_with_invalid_filter() { // get users from household - List householdUsers = getUsersListFromHouseHold(household); + List householdUsers = getUsersList(household); // set invalid user filter OTTUserFilter ottUserFilter = new OTTUserFilter(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java index 44a1ca20a..defe0fafa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginTests.java @@ -102,7 +102,7 @@ private void login_with_suspended_user() { Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); // get regular user - HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // suspend household SuspendHouseholdBuilder suspendHouseholdBuilder = suspend() @@ -148,7 +148,7 @@ private void login_with_suspended_user() { // Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); // // // get regular user -// HouseholdUser user = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0); +// HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); // // // login user with invalid udid // String username = getOttUserById(Integer.parseInt(user.getUserId())).getUsername(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java index 5ef3c76e5..f7f2696df 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateTests.java @@ -33,8 +33,8 @@ private void ottUser_updateTests_beforeClass() { int numOfUsersInHousehold = 2; int numOfDevicesInHousehold = 1; Household household = HouseholdUtils.createHousehold(numOfUsersInHousehold, numOfDevicesInHousehold, true); - HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); - userKs = OttUserUtils.getKs(Integer.parseInt(householdUser.getUserId()), null); + HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); + userKs = OttUserUtils.getKs(Integer.parseInt(householdUser.getUserId())); // get ottUser user = executor.executeSync(get().setKs(userKs)).results; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 62e2659ab..8f6606e7e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -29,11 +29,11 @@ import java.util.Optional; import static com.kaltura.client.services.HouseholdService.delete; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_DELETE; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static org.assertj.core.api.Assertions.assertThat; public class ProductPriceListTests extends BaseTest { @@ -72,8 +72,8 @@ public void beforeClass() { int numberOfUsers = 2; int numberOfDevices = 1; household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - classMasterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); + classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); + classMasterUserId = HouseholdUtils.getMasterUser(household).getUserId(); sharedChannel = new Channel(); sharedChannel.setName(BaseUtils.getRandomValue("Channel_", 999999)); @@ -184,7 +184,7 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); ProductPriceFilter filter = new ProductPriceFilter(); filter.setSubscriptionIdIn(get5MinRenewableSubscription().getId()); @@ -192,7 +192,7 @@ public void productPriceSubscriptionAndPpvBeforePurchaseTest() { filter.setIsLowest(false); ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(filter); productPriceResponse = executor.executeSync(productPriceListBeforePurchase - .setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null))); + .setKs(OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())))); // should be 2 ss one item is subscription an another is media file assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(2); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); @@ -211,8 +211,8 @@ public void subscriptionTest() { int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - //HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + //HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); // create mpp with supporting of 1 type only and having at least 1 media on its channel sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); @@ -310,8 +310,8 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(String.valueOf(webHDFileOnlySubId)); @@ -374,8 +374,8 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(String.valueOf(subWithMultiCurrencyId)); @@ -433,8 +433,8 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); @@ -490,8 +490,8 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); @@ -548,8 +548,8 @@ public void productPriceSubscriptionWithPercentageDiscountAndNoSpecifiedCurrency int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setSubscriptionIdIn(String.valueOf(subWithDiscountAndCurrencyId)); @@ -598,8 +598,8 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); // TODO: should we save it in Properties? double ppvPriceAfterDiscount = 33.3; // as price 37 ILS and discount is 10% @@ -662,8 +662,8 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), null); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java index 447a77bcc..5d301bb58 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionGetTests.java @@ -22,8 +22,8 @@ public class SessionGetTests extends BaseTest { @Test private void getMasterUserSession() { Household household = HouseholdUtils.createHousehold(2, 1, false); - HouseholdUser user = HouseholdUtils.getMasterUserFromHousehold(household); - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); + HouseholdUser user = HouseholdUtils.getMasterUser(household); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); String session = OttUserUtils.getKs(Integer.parseInt(user.getUserId()), udid); GetSessionBuilder getSessionBuilder = SessionService.get(session).setKs(getAdministratorKs()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java index 69d2e1014..b583baeba 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionRevokeTests.java @@ -21,8 +21,8 @@ public class SessionRevokeTests extends BaseTest { @Test private void RevokeKs() { Household household = HouseholdUtils.createHousehold(2, 2, false); - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); - String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, null); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); + String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household); String masterUserKs2 = HouseholdUtils.getHouseholdMasterUserKs(household, udid); try { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java index 0a51e9dd3..824aadaf6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/sessionTests/SessionSwitchUserTests.java @@ -1,10 +1,10 @@ package com.kaltura.client.test.tests.servicesTests.sessionTests; import com.kaltura.client.enums.UserState; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.OttUserService; import com.kaltura.client.services.SessionService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.types.Household; import com.kaltura.client.types.LoginSession; @@ -12,123 +12,133 @@ import com.kaltura.client.types.Session; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.OttUserService.GetOttUserBuilder; -import static com.kaltura.client.services.SessionService.GetSessionBuilder; -import static com.kaltura.client.services.SessionService.SwitchUserSessionBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.HouseholdUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class SessionSwitchUserTests extends BaseTest { - //TODO - replace hardcoded user id - private String UserId = "1543798"; + private final int numOfUsers = 2; + private final int numOfDevices = 1; + + private String userId; private String userKs; @BeforeClass private void switchUser_tests_before_class() { - userKs = OttUserUtils.getKs(Integer.valueOf(UserId), null); + userId = executor.executeSync(OttUserService.register(partnerId, OttUserUtils.generateOttUser(), defaultUserPassword)) + .results.getId(); + userKs = OttUserUtils.getKs(Integer.valueOf(userId)); } - @Description("/session/action/switchUser") + @Severity(SeverityLevel.CRITICAL) + @Description("session/action/switchUser") @Test - private void SwitchUser() { - - Household household = HouseholdUtils.createHousehold(2, 1, false); - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); - String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); - String secondUserId = HouseholdUtils.getRegularUsersListFromHouseHold(household).get(0).getUserId(); + private void switchUser() { + Household household = createHousehold(numOfUsers, numOfDevices, false); + String udid = getDevicesList(household).get(0).getUdid(); + String masterUserId = getMasterUser(household).getUserId(); + String secondUserId = getRegularUsersList(household).get(0).getUserId(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUserId), udid); // Invoke session/action/switchUser - second user replace master user in the session - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(secondUserId).setKs(masterUserKs); - Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + Response loginSessionResponse = executor.executeSync(SessionService.switchUser(secondUserId) + .setKs(masterUserKs)); // Verify new session ks returned - assertThat(loginSessionResponse.results.getKs()).isNotEmpty(); + assertThat(loginSessionResponse.results).isNotNull(); String secondUserKs = loginSessionResponse.results.getKs(); + assertThat(secondUserKs).isNotEmpty(); ///----- After User was switched ------ - // Invoke OttUser/action/get - with master user (expired) ks - OttUserService.GetOttUserBuilder getOttUserBuilder = OttUserService.get().setKs(masterUserKs); - Response ottUserResponse = executor.executeSync(getOttUserBuilder); + Response ottUserResponse = executor.executeSync(OttUserService.get() + .setKs(masterUserKs)); // Verify master user ks is now expired (after the switch) assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500016).getCode()); // Invoke OttUser/action/get with second user new ks - GetOttUserBuilder getOttUserBuilder2 = OttUserService.get().setKs(secondUserKs); - Response ottUserResponse2 = executor.executeSync(getOttUserBuilder2); + ottUserResponse = executor.executeSync(OttUserService.get() + .setKs(secondUserKs)); // Verify second user id return in the response - assertThat(ottUserResponse2.results.getId()).isEqualTo(secondUserId); - assertThat(ottUserResponse2.results.getUserState()).isEqualTo(UserState.OK); - + assertThat(ottUserResponse.results.getId()).isEqualTo(secondUserId); + assertThat(ottUserResponse.results.getUserState()).isEqualTo(UserState.OK); // Invoke session/action/get - GetSessionBuilder getSessionBuilder = SessionService.get(secondUserKs).setKs(getAdministratorKs()); - Response getSessionResponse = executor.executeSync(getSessionBuilder); + Response getSessionResponse = executor.executeSync(SessionService.get(secondUserKs) + .setKs(getAdministratorKs())); // Verify second user id returned in the response assertThat(getSessionResponse.results.getUserId()).isEqualTo(secondUserId); assertThat(getSessionResponse.results.getUdid()).isEqualTo(udid); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } + @Severity(SeverityLevel.MINOR) @Description("/session/action/switchUser - user switch to himself") @Test - private void SwitchUserToHimself() { - Household household = HouseholdUtils.createHousehold(2, 1, false); - String udid = HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid(); - String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); - String masterUserId = HouseholdUtils.getMasterUserFromHousehold(household).getUserId(); + private void switchUserToHimself() { + Household household = createHousehold(numOfUsers, numOfDevices, false); + String udid = getDevicesList(household).get(0).getUdid(); + String masterUserId = getMasterUser(household).getUserId(); + String masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUserId), udid); // Invoke session/action/switchUser - Should return an error (user can't switched to himself - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(masterUserId).setKs(masterUserKs); - Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + Response loginSessionResponse = executor.executeSync(SessionService.switchUser(masterUserId) + .setKs(masterUserKs)); // Verify exception returned assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1).getCode()); + // TODO: 6/19/2018 need to open a bug on error 1 + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } + @Severity(SeverityLevel.MINOR) @Description("/session/action/switchUser - switch to inactive user") - @Test - private void SwitchInactiveUser() { - + @Test(enabled = false) + private void switchToInactiveUser() { //TODO - replace hardcoded user id String inactiveUserId = "1543797"; - String UserKs = OttUserUtils.getKs(Integer.valueOf(UserId), null); - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(inactiveUserId).setKs(UserKs); - Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + Response loginSessionResponse = executor.executeSync(SessionService.switchUser(inactiveUserId) + .setKs(userKs)); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2016).getCode()); } + @Severity(SeverityLevel.MINOR) @Description("/session/action/switchUser - switch to user from another HH") @Test private void switchToUserFromAnotherHousehold() { + Household household1 = createHousehold(numOfUsers, numOfDevices, false); + String masterUserKs1 = getHouseholdMasterUserKs(household1); - //TODO - replace hardcoded user id - String userIdFromHousehold1 = "1543798"; - String Use1rKs = OttUserUtils.getKs(Integer.valueOf(userIdFromHousehold1), null); + Household household2 = createHousehold(numOfUsers, numOfDevices, false); + String masterUserId2 = getMasterUser(household2).getUserId(); - //TODO - replace hardcoded user id - String userIdFromHousehold2 = "638731"; - - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(userIdFromHousehold2).setKs(Use1rKs); - Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + Response loginSessionResponse = executor.executeSync(SessionService.switchUser(masterUserId2) + .setKs(masterUserKs1)); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } - - @Description("/session/action/switchUser - No user id to switch provided") + @Severity(SeverityLevel.MINOR) + @Description("session/action/switchUser - No user id to switch provided") @Test private void switchToUserWithoutUserId() { - SwitchUserSessionBuilder switchUserSessionBuilder = SessionService.switchUser(null).setKs(userKs); - Response loginSessionResponse = executor.executeSync(switchUserSessionBuilder); + Response loginSessionResponse = executor.executeSync(SessionService.switchUser(null) + .setKs(userKs)); assertThat(loginSessionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500053).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index 7cbfa80bf..ce72f2aae 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -64,9 +64,9 @@ public void transactionHistortTestSetup(){ Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); //Login with master to first device - masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); //Login with user to second device - userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); + userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(1).getUdid()); //All transactions per household - empty transactionHistoryFilter.setEntityReferenceEqual(EntityReferenceBy.HOUSEHOLD); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index ed1ea4748..ae787eac8 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -92,7 +92,7 @@ public static void addViewsToAsset(Long assetId, int numOfActions, AssetType ass } else { for (int i = 0; i < numOfActions; i++) { Household household = HouseholdUtils.createHousehold(1, 1, false); - HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0), assetType, BookmarkActionType.FIRST_PLAY); @@ -112,7 +112,7 @@ public static void addLikesToAsset(Long assetId, int numOfActions, AssetType ass } else { for (int i = 0; i < numOfActions; i++) { Household household = HouseholdUtils.createHousehold(1, 1, false); - HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); SocialAction socialAction = SocialUtils.getSocialAction(SocialActionType.LIKE, null, assetId, assetType, null); AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialAction) .setKs(BaseTest.getOperatorKs()) @@ -130,7 +130,7 @@ public static void addVotesToAsset(Long assetId, int numOfActions, AssetType ass } else { for (int i = 0; i < numOfActions; i++) { Household household = HouseholdUtils.createHousehold(1, 1, false); - HouseholdUser householdUser = HouseholdUtils.getMasterUserFromHousehold(household); + HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); SocialActionRate socialActionRate = SocialUtils.getSocialActionRate(SocialActionType.RATE, null, assetId, assetType, null, rate); AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialActionRate) .setKs(BaseTest.getOperatorKs()) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 8f47aa2d4..58ac873a8 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -37,8 +37,7 @@ public static String getOffsetDateInFormat(int offsetDay, String pattern) { // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) public static String getTimeInDate(int offSetInMinutes, String timeZone) { - TimeZone theTimeZone; - theTimeZone = TimeZone.getTimeZone(timeZone); + TimeZone theTimeZone = TimeZone.getTimeZone(timeZone); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); dateFormat.setTimeZone(theTimeZone); Date dNow = new Date(); @@ -55,7 +54,6 @@ public static String getTimeInDate(int offSetInMinutes) { return getTimeInDate(offSetInMinutes,"israel"); } - // Get epoch time in seconds according to off set parameter provided (in minutes) public static long getTimeInEpoch(int offSetInMinutes) { //DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 8a13d0c8d..e76648adc 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -1,22 +1,24 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Logger; -import com.kaltura.client.services.*; +import com.kaltura.client.services.HouseholdDeviceService; +import com.kaltura.client.services.HouseholdPaymentGatewayService; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Random; -import static com.kaltura.client.services.HouseholdDeviceService.*; -import static com.kaltura.client.services.HouseholdPaymentGatewayService.*; +import static com.kaltura.client.services.HouseholdDeviceService.AddHouseholdDeviceBuilder; +import static com.kaltura.client.services.HouseholdDeviceService.ListHouseholdDeviceBuilder; +import static com.kaltura.client.services.HouseholdPaymentGatewayService.SetChargeIDHouseholdPaymentGatewayBuilder; +import static com.kaltura.client.services.HouseholdService.AddHouseholdBuilder; import static com.kaltura.client.services.HouseholdUserService.*; +import static com.kaltura.client.services.HouseholdUserService.list; import static com.kaltura.client.services.OttUserService.*; -import static com.kaltura.client.services.HouseholdService.*; import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.tests.BaseTest.getAdministratorKs; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; public class HouseholdUtils extends BaseUtils { @@ -95,7 +97,7 @@ public static HouseholdDevice generateHouseholdDevice() { } // get users list from given household - public static List getDevicesListFromHouseHold(Household household) { + public static List getDevicesList(Household household) { HouseholdDeviceFilter filter = new HouseholdDeviceFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); @@ -109,7 +111,7 @@ public static List getDevicesListFromHouseHold(Household househ } // get users list from given household - public static List getUsersListFromHouseHold(Household household) { + public static List getUsersList(Household household) { HouseholdUserFilter filter = new HouseholdUserFilter(); filter.setHouseholdIdEqual(Math.toIntExact(household.getId())); @@ -121,8 +123,8 @@ public static List getUsersListFromHouseHold(Household household) } // get master user from given household - public static HouseholdUser getMasterUserFromHousehold(Household household) { - List users = getUsersListFromHouseHold(household); + public static HouseholdUser getMasterUser(Household household) { + List users = getUsersList(household); for (HouseholdUser user : users) { if (user.getIsMaster() != null && user.getIsMaster()) { @@ -135,8 +137,8 @@ public static HouseholdUser getMasterUserFromHousehold(Household household) { } // get default user from given household - public static HouseholdUser getDefaultUserFromHousehold(Household household) { - List users = getUsersListFromHouseHold(household); + public static HouseholdUser getDefaultUser(Household household) { + List users = getUsersList(household); for (HouseholdUser user : users) { if (user.getIsDefault() != null && user.getIsDefault()) { @@ -149,8 +151,8 @@ public static HouseholdUser getDefaultUserFromHousehold(Household household) { } // get regular users list from given household - public static List getRegularUsersListFromHouseHold(Household household) { - List users = getUsersListFromHouseHold(household); + public static List getRegularUsersList(Household household) { + List users = getUsersList(household); List usersToRemove = new ArrayList<>(); for (HouseholdUser user : users) { @@ -166,14 +168,26 @@ public static List getRegularUsersListFromHouseHold(Household hou } // Get master KS by providing household object - public static String getHouseholdMasterUserKs(Household household, @Nullable String udid) { - HouseholdUser masterUser = getMasterUserFromHousehold(household); + public static String getHouseholdMasterUserKs(Household household) { + HouseholdUser masterUser = getMasterUser(household); + return OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); + } + + // Get regular user KS by providing household object + public static String getHouseholdUserKs(Household household) { + HouseholdUser user = getRegularUsersList(household).get(0); + return OttUserUtils.getKs(Integer.parseInt(user.getUserId())); + } + + // Get master KS by providing household object + public static String getHouseholdMasterUserKs(Household household, String udid) { + HouseholdUser masterUser = getMasterUser(household); return OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); } // Get regular user KS by providing household object - public static String getHouseholdUserKs(Household household, @Nullable String udid) { - HouseholdUser user = getRegularUsersListFromHouseHold(household).get(0); + public static String getHouseholdUserKs(Household household, String udid) { + HouseholdUser user = getRegularUsersList(household).get(0); return OttUserUtils.getKs(Integer.parseInt(user.getUserId()), udid); } } diff --git a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java index 056be3cce..61a079739 100644 --- a/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/OttUserUtils.java @@ -6,12 +6,12 @@ import com.kaltura.client.types.StringValue; import com.kaltura.client.utils.response.base.Response; -import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; import java.util.Random; -import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.services.OttUserService.GetOttUserBuilder; +import static com.kaltura.client.services.OttUserService.LoginOttUserBuilder; import static com.kaltura.client.test.tests.BaseTest.*; public class OttUserUtils extends BaseUtils { @@ -49,13 +49,21 @@ public static OTTUser getOttUserById(int userId) { return userResponse.results; } - public static String getKs(int userId, @Nullable String udid) { + public static String getKs(int userId) { OTTUser ottUser = getOttUserById(userId); - //OttUser/action/login + // ottUser/action/login + LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, ottUser.getUsername(), defaultUserPassword, null, null); + Response loginResponse = executor.executeSync(loginOttUserBuilder); + + return loginResponse.results.getLoginSession().getKs(); + } + + public static String getKs(int userId, String udid) { + OTTUser ottUser = getOttUserById(userId); + + // ottUser/action/login LoginOttUserBuilder loginOttUserBuilder = OttUserService.login(partnerId, ottUser.getUsername(), defaultUserPassword, null, udid); - loginOttUserBuilder.setKs(null); - loginOttUserBuilder.setUserId(userId); Response loginResponse = executor.executeSync(loginOttUserBuilder); return loginResponse.results.getLoginSession().getKs(); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index fdb2195b6..4973773b9 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -1,7 +1,10 @@ package com.kaltura.client.test.utils.ingestUtils; +import io.restassured.http.Header; import org.w3c.dom.Document; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -12,9 +15,55 @@ public class BaseIngestUtils { + static final Header contentTypeXml = new Header("Content-Type", "text/xml;charset=UTF-8"); + static final Header soapActionIngestTvinciData = new Header("SOAPAction", "http://tempuri.org/IService/IngestTvinciData"); + static final Header soapActionIngestBusinessModules = new Header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); + static final Header soapActionIngestKalturaEpg = new Header("SOAPAction", "http://tempuri.org/IService/IngestKalturaEpg"); + public static final String INGEST_ACTION_INSERT = "insert"; + public static final String INGEST_ACTION_UPDATE = "update"; + public static final String INGEST_ACTION_DELETE = "delete"; - public static String docToString(Document doc) { + static final Long MAX_RANDOM_VALUE = 9999999999L; + static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + + // life cycles periods + public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; + + // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts + public static final String MOVIE_MEDIA_TYPE = "Movie"; + public static final String EPISODE_MEDIA_TYPE = "Episode"; + public static final String LINEAR_MEDIA_TYPE = "Linear"; + + /* + // PG adapter data + public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; + public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; + public static final String PG_DEFAULT_SHARED_SECRET = "123456"; + public static final int PG_DEFAULT_PENDING_INTERVAL = 0; + public static final int PG_DEFAULT_PENDING_RETRIES = 0; + public static final int PG_DEFAULT_RENEW_INTERVAL_MINUTES = 15; + public static final int PG_DEFAULT_RENEW_START_MINUTES =-5; + public static final String PG_DEFAULT_PG_SETTINGS = "{}"; + */ + + + static Document getDocument(String uri) { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder; + Document doc = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + doc = docBuilder.parse(uri); + } catch (Exception e) { + e.printStackTrace(); + } + + return doc; + } + + static String docToString(Document doc) { try { StringWriter sw = new StringWriter(); TransformerFactory tf = TransformerFactory.newInstance(); @@ -31,7 +80,7 @@ public static String docToString(Document doc) { } } - public static void prettyPrint(Document doc) throws Exception { + static void prettyPrint(Document doc) throws Exception { Transformer tf = TransformerFactory.newInstance().newTransformer(); tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); tf.setOutputProperty(OutputKeys.INDENT, "yes"); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index a5c91e4b4..93048e7a6 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -1,57 +1,127 @@ package com.kaltura.client.test.utils.ingestUtils; +import com.kaltura.client.Logger; +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.test.tests.enums.DurationPeriod; +import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.types.Asset; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.ProgramAsset; +import com.kaltura.client.types.SearchAssetFilter; +import com.kaltura.client.utils.response.base.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Optional; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; +import static io.restassured.RestAssured.given; +import static org.awaitility.Awaitility.await; public class IngestEpgUtils extends BaseIngestUtils { - // TODO: think about ENUMS if we really need it here? should we create new ENUM class for it? where? - public static final String DURATION_PERIOD_DAYS = "days"; - public static final String DURATION_PERIOD_HOURS = "hours"; - public static final String DURATION_PERIOD_MINUTES = "minutes"; - public static final String DURATION_PERIOD_SECONDS = "seconds"; - - public static List durationPeriodNames = new ArrayList<>(); - - static { - durationPeriodNames.add(DURATION_PERIOD_DAYS); - durationPeriodNames.add(DURATION_PERIOD_HOURS); - durationPeriodNames.add(DURATION_PERIOD_MINUTES); - durationPeriodNames.add(DURATION_PERIOD_SECONDS); + // INGEST EPG PARAMS + static final int EPG_DEFAULT_COUNT_OF_SEASONS = 2; + static final int EPG_DEFAULT_COUNT_OF_PROGRAMMES = 2; + static final int EPG_DEFAULT_PROGRAM_DURATION = 30; + + + // ingest new EPG (Programmes) + public static List ingstEPG(String epgChannelName, Optional programCount, Optional startDate, + Optional programDuration, Optional programDurationPeriod, + Optional isCridUnique4AllPrograms, Optional seasonCount, + Optional coguid, Optional crid, Optional seriesId, + Optional thumb, Optional programNamePrefix) { + + // TODO: complete one-by-one needed fields to cover util ingest_epg from old project + int programCountValue = programCount.orElse(EPG_DEFAULT_COUNT_OF_PROGRAMMES); + int seasonCountValue = seasonCount.orElse(EPG_DEFAULT_COUNT_OF_SEASONS); + Calendar startDateValue = startDate.orElse(Calendar.getInstance()); + int programDurationValue = programDuration.orElse(EPG_DEFAULT_PROGRAM_DURATION); + DurationPeriod programDurationPeriodValue = programDurationPeriod.orElse(DurationPeriod.MINUTES); + boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); + String coguidValue = coguid.orElseGet(() -> getCurrentDateInFormat("yyMMddHHmmssSS")); + String cridValue = crid.orElse(coguidValue); + String seriesIdValue = seriesId.orElse(coguidValue); + String thumbValue = thumb.orElse(DEFAULT_THUMB); + String programNamePrefixValue = programNamePrefix.orElse("Program"); + + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + + String reqBody1 = IngestEpgUtils.buildIngestEpgXml(epgChannelName, programCountValue, startDateValue, programDurationValue, + programDurationPeriodValue, isCridUnique4AllProgramsValue, seasonCountValue, coguidValue, cridValue, seriesIdValue, + thumbValue, programNamePrefixValue); + + io.restassured.response.Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestKalturaEpg) + .body(reqBody1) + .when() + .post(url); + + Logger.getLogger(IngestEpgUtils.class).debug(reqBody1); + Logger.getLogger(IngestEpgUtils.class).debug(resp.asString()); + + // TODO: 6/20/2018 add response assertion + + int epgChannelId = IngestFixtureData.getEpgChannelId(epgChannelName); + // TODO: create method getting epoch value from String and pattern + Date firstProgramStartDateAsDate = startDateValue.getTime(); + long epoch = firstProgramStartDateAsDate.getTime() / 1000; // 1000 milliseconds in 1 second + + String firstProgramStartDateEpoch = String.valueOf(epoch); + + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); + assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + + int delayBetweenRetriesInSeconds = 5; + int maxTimeExpectingValidResponseInSeconds = 90; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue * seasonCountValue)); + + Response> ingestedProgrammes = executor.executeSync( + AssetService.list(assetFilter, null).setKs(getAnonymousKs())); + + // TODO: complete Asset.json at least for programs + + return (List) (Object) ingestedProgrammes.results.getObjects(); } - // INGEST EPG PARAMS - public static final int EPG_DEFAULT_COUNT_OF_SEASONS = 1; - public static final int EPG_DEFAULT_COUNT_OF_PROGRAMMES = 2; - public static final int EPG_DEFAULT_PROGRAM_DURATION = 30; - public static final String EPG_DEFAULT_PROGRAM_DURATION_PERIOD_NAME = DURATION_PERIOD_MINUTES; + private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { + return () -> { + AssetService.ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null).setKs(ks); + return executor.executeSync(listAssetBuilder).error == null && + executor.executeSync(listAssetBuilder).results.getTotalCount() == totalCount; + }; + } + public static List ingestEPG(String epgChannelName, Integer programCount) { + Optional o = Optional.empty(); + return ingstEPG(epgChannelName, Optional.of(programCount), o, o, o, o, o, o, o, o, o, o); + } - public static String buildIngestEpgXml(String epgChannelName, int programsNum, String firstProgramStartDate, int programDuration, - String programDurationPeriodName, boolean isCridUnique4AllPrograms, int seasonsNum, - String coguid, String crid, String seriesId) { + public static List ingestEPG(String epgChannelName) { + Optional o = Optional.empty(); + return ingstEPG(epgChannelName, o, o, o, o, o, o, o, o, o, o, o); + } - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder; - Document doc = null; - - try { - docBuilder = docFactory.newDocumentBuilder(); - doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestEPG.xml"); - } catch (Exception e) { - e.printStackTrace(); - } + private static String buildIngestEpgXml(String epgChannelName, int episodesNum, Calendar startDate, int programDuration, + DurationPeriod programDurationPeriod, boolean isCridUnique4AllPrograms, int seasonsNum, + String coguid, String crid, String seriesId, String thumb, String programNamePrefix) { + Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestEPG.xml"); // user and password doc.getElementsByTagName("userName").item(0).setTextContent(getIngestBusinessModuleUserName()); @@ -67,32 +137,25 @@ public static String buildIngestEpgXml(String epgChannelName, int programsNum, S channel.setAttribute("id", epgChannelName); // programme - String datePattern = "MM/yy/dd HH:mm:ss"; - SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); - Calendar startDate = Calendar.getInstance(); - try { - startDate.setTime(dateFormat.parse(firstProgramStartDate)); - } catch (ParseException e) { - e.printStackTrace(); - } - SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); - int seasonId = 1; - while (seasonId < seasonsNum) { - int programId = 1; - while (programId < programsNum) { - Date endDate = loadEndDate(startDate.getTime(), programDuration, programDurationPeriodName); - - Element programmeNode = getProgrammeNode(doc, programId, df.format(startDate.getTime()), df.format(endDate), epgChannelName, - coguid, crid, "Program", df.format(Calendar.getInstance().getTime()), seriesId, - String.valueOf(seasonsNum), isCridUnique4AllPrograms); + int seasonNum = 1; + while (seasonNum <= seasonsNum) { + int episodeNum = 1; + while (episodeNum <= episodesNum) { + Date endDate = loadEndDate(startDate.getTime(), programDuration, programDurationPeriod); + String startDateFormatted = df.format(startDate.getTime()); + String endDateFormatted = df.format(endDate.getTime()); + String nowDateFormatted = df.format(Calendar.getInstance().getTime()); + + Element programmeNode = getProgrammeNode(doc, episodeNum, startDateFormatted, endDateFormatted, epgChannelName, + coguid, crid, programNamePrefix, nowDateFormatted, seriesId, seasonNum, isCridUnique4AllPrograms, thumb); epgChannels.appendChild(programmeNode); startDate.setTime(endDate); - programId++; + episodeNum++; } - seasonId++; + seasonNum++; } // uncomment cdata @@ -104,17 +167,18 @@ public static String buildIngestEpgXml(String epgChannelName, int programsNum, S return docAsString; } - private static Element getProgrammeNode(Document doc, int idx, String startDate, String endDate, String channel, String coguid, String crid, String programNamePrefix, - String currentDate, String seriesId, String seasonNumber, boolean isCridUnique4AllPrograms) { - String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; - String cridValue = isCridUnique4AllPrograms ? crid + "_" + seasonNumber + "_" + idx : crid + "_" + idx; + private static Element getProgrammeNode(Document doc, int episodeNumber, String startDate, String endDate, String channel, String coguid, String crid, + String programNamePrefix, String currentDate, String seriesId, int seasonNumber, boolean isCridUnique4AllPrograms, + String thumb) { + String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + episodeNumber; + String cridValue = isCridUnique4AllPrograms ? crid + "_" + seasonNumber + "_" + episodeNumber : crid + "_" + episodeNumber; // programme Element programme = doc.createElement("programme"); programme.setAttribute("start", startDate); programme.setAttribute("stop", endDate); programme.setAttribute("channel", channel); - programme.setAttribute("external_id", coguid + "_" + seasonNumber + "_" + idx); + programme.setAttribute("external_id", coguid + "_" + seasonNumber + "_" + episodeNumber); // title Element title = doc.createElement("title"); @@ -144,14 +208,21 @@ private static Element getProgrammeNode(Document doc, int idx, String startDate, lang.setTextContent("eng"); programme.appendChild(lang); + // icon + Element icon = doc.createElement("icon"); + icon.setAttribute("ratio", "16:9"); + icon.setAttribute("src", thumb); + // season num meta - programme.appendChild(generateMetasNode(doc, "season_num", seasonNumber)); + programme.appendChild(generateMetasNode(doc, "season_num", String.valueOf(seasonNumber))); // series id meta programme.appendChild(generateMetasNode(doc, "series_id", seriesId)); // episode num meta - programme.appendChild(generateMetasNode(doc, "episode_num", String.valueOf(idx))); + programme.appendChild(generateMetasNode(doc, "episode_num", String.valueOf(episodeNumber))); + + // TODO: 6/19/2018 add missing parameters according to needed tests return programme; } @@ -192,23 +263,22 @@ private static Element generateTagsNode(Document doc, String tagTypeString, Stri return tags; } - static Date loadEndDate(Date startDate, int durationValue, String periodName) { + static Date loadEndDate(Date startDate, int durationValue, DurationPeriod durationPeriod) { Calendar calendar = Calendar.getInstance(); calendar.setTime(startDate); - switch (periodName) { - case DURATION_PERIOD_DAYS: + switch (durationPeriod) { + case DAYS: calendar.add(Calendar.DATE, durationValue); break; - case DURATION_PERIOD_HOURS: + case HOURS: calendar.add(Calendar.HOUR, durationValue); break; - case DURATION_PERIOD_MINUTES: + case MINUTES: calendar.add(Calendar.MINUTE, durationValue); break; - case DURATION_PERIOD_SECONDS: + case SECONDS: calendar.add(Calendar.SECOND, durationValue); } return calendar.getTime(); } - } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index cd53bdbc4..77a76c268 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -3,22 +3,17 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.Subscription; -import io.restassured.RestAssured; +import io.restassured.response.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import java.util.Optional; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.Properties.PARTNER_ID; -import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; public class IngestMppUtils extends BaseIngestUtils { @@ -106,7 +101,6 @@ public static Subscription ingestMPP(Optional action, Optional m String productCodeValue = productCode.orElse(""); boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); - String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); String pricePlanCode2Value = pricePlanCode2.orElse(""); String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); @@ -124,27 +118,29 @@ public static Subscription ingestMPP(Optional action, Optional m isRenewableValue, gracePeriodMinuteValue, pricePlanCode1Value, pricePlanCode2Value, channel1Value, channel2Value, fileType1Value, fileType2Value, couponGroupValue, productCodesValue); - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") - .body(reqBody) + Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestBusinessModules) + .body(reqBody) .when() - .post(url); + .post(url); + + Logger.getLogger(IngestMppUtils.class).debug(reqBody); + Logger.getLogger(IngestMppUtils.class).debug("\n Response: " + resp.asString()); - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug("\n Response:!!! " + resp.asString()); + // TODO: 6/20/2018 add response assertion +// assertThat(from(resp.asString()) +// .get("").toString()) +// .isEqualTo("OK"); String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); + resp = given().get(url); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); @@ -152,13 +148,13 @@ public static Subscription ingestMPP(Optional action, Optional m subscription.setId(id); subscription.setName(titleValue); subscription.setDescription(descriptionValue); + subscription.isRenewable(String.valueOf(isRenewableValue)); + subscription.setGracePeriodMinutes(gracePeriodMinuteValue); // TODO: complete COMMENTED IF NEEDED //subscription.setStartDate(); //subscription.setEndDate(); //subscription.setDiscountModule(); //subscription.setProductCodes(); - subscription.isRenewable(String.valueOf(isRenewableValue)); - subscription.setGracePeriodMinutes(gracePeriodMinuteValue); //subscription.setPricePlanIds(); //subscription.setChannels(); //subscription.setFileTypes(); @@ -171,17 +167,7 @@ private static String buildIngestMppXml(String action, String mppCode, boolean i boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, String pricePlanCode2, String channel1, String channel2, String fileType1, String fileType2, String couponGroup, String productCodes) { - - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder; - Document doc = null; - - try { - docBuilder = docFactory.newDocumentBuilder(); - doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestMPP.xml"); - } catch (Exception e) { - e.printStackTrace(); - } + Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestMPP.xml"); // user and password doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 56bc5c446..a4a22dc2e 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -4,23 +4,18 @@ import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.DiscountModule; import com.kaltura.client.types.PricePlan; -import io.restassured.RestAssured; +import io.restassured.response.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import java.util.Optional; -import static com.kaltura.client.test.IngestConstants.FIVE_MINUTES_PERIOD; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; -import static com.kaltura.client.test.IngestConstants.MAX_RANDOM_GENERATED_VALUE_4_INGEST; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; public class IngestPpUtils extends BaseIngestUtils { @@ -52,11 +47,10 @@ public class IngestPpUtils extends BaseIngestUtils { *

* !!!Only created by that method PP can be deleted/updated!!! */ - public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, - Optional fullLifeCycle, Optional viewLifeCycle, Optional maxViews, - Optional price, Optional currency, Optional discount, Optional isRenewable, - Optional recurringPeriods) { - String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); + public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, Optional fullLifeCycle, + Optional viewLifeCycle, Optional maxViews, Optional price, Optional currency, + Optional discount, Optional isRenewable, Optional recurringPeriods) { + String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_VALUE)); String actionValue = action.orElse(INGEST_ACTION_INSERT); boolean isActiveValue = isActive.orElse(PP_DEFAULT_IS_ACTIVE_VALUE); String fullLifeCycleValue = fullLifeCycle.orElse(FIVE_MINUTES_PERIOD); @@ -75,30 +69,27 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String reqBody = IngestPpUtils.buildIngestPpXml(actionValue, ppCodeValue, isActiveValue, fullLifeCycleValue, viewLifeCycleValue, maxViewsValue, priceValue, currencyValue, discountValue, isRenewableValue, recurringPeriodsValue); - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") - .body(reqBody) + Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestBusinessModules) + .body(reqBody) .when() - .post(url); + .post(url); - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); + Logger.getLogger(IngestPpUtils.class).debug(reqBody); + Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); + // TODO: 6/20/2018 add response assertion + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); + resp = given().get(url); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - //System.out.println(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); - //Logger.getLogger(IngestUtils.class).debug("ID: " + id); PricePlan pricePlan = new PricePlan(); pricePlan.setId(Long.valueOf(id)); @@ -116,17 +107,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod private static String buildIngestPpXml(String action, String ppCode, boolean isActive, String fullLifeCycle, String viewLifeCycle, int maxViews, String price, String currency, String discount, boolean isRenewable, int recurringPeriods) { - - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder; - Document doc = null; - - try { - docBuilder = docFactory.newDocumentBuilder(); - doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestPP.xml"); - } catch (Exception e) { - e.printStackTrace(); - } + Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestPP.xml"); // user and password doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 0a36da133..d6159dab6 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -3,24 +3,20 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; -import io.restassured.RestAssured; +import io.restassured.response.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import java.util.ArrayList; import java.util.List; import java.util.Optional; -import static com.kaltura.client.test.IngestConstants.INGEST_ACTION_INSERT; -import static com.kaltura.client.test.IngestConstants.MAX_RANDOM_GENERATED_VALUE_4_INGEST; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; public class IngestPpvUtils extends BaseIngestUtils { @@ -54,7 +50,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O Optional isSubscriptionOnly, Optional isFirstDeviceLimitation, Optional productCode, Optional firstFileType, Optional secondFileType) { String actionValue = action.orElse(INGEST_ACTION_INSERT); - String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_GENERATED_VALUE_4_INGEST)); + String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_VALUE)); boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; String descriptionValue = description.orElse("My ingest PPV"); String defaultCurrencyOfDiscount4IngestPpv = "ILS"; @@ -75,27 +71,27 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O discountValue, priceValue, currencyValue, usageModuleValue, isSubscriptionOnlyValue, isFirstDeviceLimitationValue, productCodeValue, firstFileTypeValue, secondFileTypeValue); - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules") - .body(reqBody) + Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestBusinessModules) + .body(reqBody) .when() - .post(url); + .post(url); + + Logger.getLogger(IngestPpvUtils.class).debug(reqBody); + Logger.getLogger(IngestPpvUtils.class).debug("\n Response: " + resp.asString()); - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug("\n Response!!!: " + resp.asString()); + // TODO: 6/20/2018 add response assertion String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //System.out.println("ReportId = " + reportId); url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = RestAssured.given() - .log().all() - .get(url); + resp = given().get(url); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - Logger.getLogger(IngestUtils.class).debug(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + Logger.getLogger(IngestPpvUtils.class).debug(resp.asString()); + Logger.getLogger(IngestPpvUtils.class).debug(resp.asString().split(" = ")[1].replaceAll("\\.", "")); String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); @@ -126,16 +122,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O private static String buildIngestPpvXml(String action, String ppvCode, boolean isActive, String description, String discount, double price, String currency, String usageModule, boolean isSubscriptionOnly, boolean isFirstDeviceLimitation, String productCode, String firstFileType, String secondFileType) { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder; - Document doc = null; - - try { - docBuilder = docFactory.newDocumentBuilder(); - doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestPPV.xml"); - } catch (Exception e) { - e.printStackTrace(); - } + Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestPPV.xml"); // user and password doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java deleted file mode 100644 index 1b2fadb0d..000000000 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestUtils.java +++ /dev/null @@ -1,257 +0,0 @@ -package com.kaltura.client.test.utils.ingestUtils; - -import com.kaltura.client.Logger; -import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.AssetService.ListAssetBuilder; -import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; -import com.kaltura.client.types.Asset; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.ProgramAsset; -import com.kaltura.client.types.SearchAssetFilter; -import com.kaltura.client.utils.response.base.Response; -import io.restassured.RestAssured; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; -import static org.awaitility.Awaitility.await; - -public class IngestUtils extends BaseUtils { - - // ingest new EPG (Programmes) // TODO: complete one-by-one needed fields to cover util ingest_epg from old project - public static List ingestEPG(String epgChannelName, Optional programCount, Optional firstProgramStartDate, - Optional programDuration, Optional programDurationPeriodName, - Optional isCridUnique4AllPrograms, Optional seasonCount, - Optional coguid, Optional crid, Optional seriesId) { - - int programCountValue = programCount.orElse(EPG_DEFAULT_COUNT_OF_PROGRAMMES); - if (programCountValue <= 0) { - Logger.getLogger(IngestUtils.class).error("Invalid programCount value " + programCount.get() + ". Should be bigger than 0"); - return null; - } - - int seasonCountValue = seasonCount.orElse(EPG_DEFAULT_COUNT_OF_SEASONS); - - String datePattern = "MM/yy/dd HH:mm:ss"; - SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); - String firstProgramStartDateValue = firstProgramStartDate.orElse(getCurrentDateInFormat(datePattern)); - Calendar startDate = Calendar.getInstance(); - try { - startDate.setTime(dateFormat.parse(firstProgramStartDateValue)); - } catch (ParseException e) { - e.printStackTrace(); - } - - int programDurationValue = programDuration.orElse(EPG_DEFAULT_PROGRAM_DURATION); - if (programDurationValue <= 0) { - Logger.getLogger(IngestUtils.class).error("Invalid programDuration value " + programDuration.get() + - ". Should be bigger than 0"); - return null; - } - String programDurationPeriodNameValue = programDurationPeriodName.orElse(EPG_DEFAULT_PROGRAM_DURATION_PERIOD_NAME); - if (!durationPeriodNames.contains(programDurationPeriodNameValue)) { - Logger.getLogger(IngestUtils.class).error("Invalid programDurationPeriodName value " + programDurationPeriodName.get() + - ". Should be one from " + durationPeriodNames); - return null; - } - boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); - - String coguidValue = coguid.orElseGet(() -> getCurrentDateInFormat("yyMMddHHmmssSS")); - String cridValue = crid.orElse(coguidValue); - String seriesIdValue = seriesId.orElse(coguidValue); - int seasonId = 1; - String output = ""; - String oneProgrammOutput = ""; - SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss"); - Date now = Calendar.getInstance().getTime(); - while (seasonId <= seasonCountValue) { - int idx = 1; - while (idx <= programCountValue) { - Date endDate = loadEndDate(startDate.getTime(), programDurationValue, programDurationPeriodNameValue); - oneProgrammOutput = getProgrammeXML(idx, df2.format(startDate.getTime()), df2.format(endDate), - epgChannelName, coguidValue, cridValue, "Program", df2.format(now), - seriesIdValue, String.valueOf(seasonId), isCridUnique4AllProgramsValue); - startDate.setTime(endDate); - output = output + oneProgrammOutput; - idx = idx + 1; - } - seasonId = seasonId + 1; - } - String epgChannelIngestXml = getChannelXML(partnerId, epgChannelName, output); - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - - String reqBody = "\n" + - " \n" + - " \n" + - " " + - " " + - " " + getIngestAssetUserName() + "" + getIngestAssetUserPassword() + "" + - epgChannelIngestXml + "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestKalturaEpg") - .body(reqBody) - .when() - .post(url); - - Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug(resp.asString()); - - int epgChannelId = IngestFixtureData.getEpgChannelId(epgChannelName); - // TODO: create method getting epoch value from String and pattern - long epoch = 0L; - try { - Date firstProgramStartDateAsDate = dateFormat.parse(firstProgramStartDateValue); - epoch = firstProgramStartDateAsDate.getTime() / 1000; // 1000 milliseconds in 1 second - } catch (ParseException e) { - e.printStackTrace(); - } - String firstProgramStartDateEpoch = String.valueOf(epoch); - - SearchAssetFilter assetFilter = new SearchAssetFilter(); - assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); - assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); - - int delayBetweenRetriesInSeconds = 3; - int maxTimeExpectingValidResponseInSeconds = 90; - await() - .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) - .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue * seasonCountValue)); - - Response> ingestedProgrammes = executor.executeSync( - AssetService.list(assetFilter, null).setKs(getAnonymousKs())); - - // TODO: complete Asset.json at least for programs - - return (List) (Object) ingestedProgrammes.results.getObjects(); - } - - public static List ingestEPG(String epgChannelName, Integer programCount) { - return ingestEPG(epgChannelName, Optional.of(programCount), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - } - - private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { - return () -> { - ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null).setKs(ks); - return executor.executeSync(listAssetBuilder).error == null && - executor.executeSync(listAssetBuilder).results.getTotalCount() == totalCount; - }; - } - - private static String getChannelXML(int partnerId, String epgChannelName, String programsXml) { - return " " + - "" + - "" + - programsXml + - "" + - "]]>"; - } - - // generate XML for ingest of 1 program - private static String getProgrammeXML(int idx, String startDate, String endDate, String channel, String coguid, String crid, - String programNamePrefix, String currentDate, String seriesId, String seasonNumber, - boolean isCridUnique4AllPrograms) { - String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + idx; - - // TODO: complete to cover util from old project completely - String CRID = "" + crid + "_" + idx + ""; - if (isCridUnique4AllPrograms) { - CRID = "" + crid + "_" + seasonNumber + "_" + idx + ""; - } - String output = - "" + - "" + name + "" + - CRID + - "" + startDate + " until " + endDate + "" + - "" + currentDate + "" + - "eng" + - //"" + - //"" + enableCDVR + "" + - //"" + enableCatchUp + ""+ - //"" + enableStartOver + "" + - //"" + enableTrickPlay + "" + - //"" + - //"" + metaName + "" + - //"" + metaValue + "" + - //"" + - "" + - // TODO: that meta should be added into property file - "season_num" + - "" + seasonNumber + "" + - "" + - "" + - // TODO: that meta should be added into property file - "Series_ID" + - "" + seriesId + "" + - "" + - "" + - // TODO: that meta should be added into property file - "Episode number" + - "" + idx + "" + - "" + - /* "" + - "Season" + - "" + seasonNumber + "" + - "" + - - "" + - "Episode" + - "" + id + "" + - "" + - */ - //"" + - //"Country" + - //"Israel" + - //"" + - //"" + - //"YEAR" + - //"2015" + - //"" + - //"" + - //"Genre" + - //"" + genre + "" + - //"" + - //"" + - //"Actors" + - //"Shay" + - //"Ortal" + - //"" + - //"" + - //"" + tagName + "" + - //"" + tagValue + "" + - //"" + - //"" + - //"" + parentalFieldName + "" + - //"" + parentalValue + "" + - //"" + - //"" + - //"" + parentalFieldName + "" + - //"" + parentalValue2 + "" + - //"" + - ""; - return output; - } -} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index bea691065..58a257a4a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -4,24 +4,21 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.types.MediaAsset; -import io.restassured.RestAssured; +import io.restassured.response.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.IngestConstants.*; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static com.kaltura.client.test.utils.BaseUtils.getOffsetDateInFormat; import static com.kaltura.client.test.utils.XmlUtils.asList; +import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -67,7 +64,7 @@ public static MediaAsset ingestVOD(Optional action, Optional cog String actionValue = action.orElse(INGEST_ACTION_INSERT); String coguidValue = coguid.orElse(getCurrentDateInFormat(coguidDatePattern)); String nameValue = INGEST_ACTION_INSERT.equals(actionValue) ? coguidValue : name.orElse(coguidValue); - String thumbUrlValue = thumbUrl.orElse(INGEST_VOD_DEFAULT_THUMB); + String thumbUrlValue = thumbUrl.orElse(DEFAULT_THUMB); String descriptionValue = description.orElse("description of " + coguidValue); String catalogStartDateValue = catalogStartDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); @@ -80,22 +77,24 @@ public static MediaAsset ingestVOD(Optional action, Optional cog Map stringsValue = strings.orElse(getDefaultStrings()); Map numbersValue = numbers.orElse(getDefaultNumbers()); Map datesValue = dates.orElse(getDefaultDates()); + // TODO: check if ingest url is the same for all ingest actions String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; String reqBody = buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); - io.restassured.response.Response resp = RestAssured - .given() - .header("Content-Type", "text/xml;charset=UTF-8") - .header("SOAPAction", "http://tempuri.org/IService/IngestTvinciData") - .body(reqBody) + Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestTvinciData) + .body(reqBody) .when() - .post(url); + .post(url); + + Logger.getLogger(IngestVodUtils.class).debug(reqBody); + Logger.getLogger(IngestVodUtils.class).debug("Ingest response: \n" + resp.asString()); -// Logger.getLogger(IngestUtils.class).debug(reqBody); - Logger.getLogger(IngestUtils.class).debug("Ingest response: \n" + resp.asString()); assertThat(resp).isNotNull(); assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); @@ -114,7 +113,7 @@ public static MediaAsset ingestVOD(Optional action, Optional cog //mediaAsset.setEndDate(endDate); if (!INGEST_ACTION_DELETE.equals(actionValue)) { - int delayBetweenRetriesInSeconds = 3; + int delayBetweenRetriesInSeconds = 5; int maxTimeExpectingValidResponseInSeconds = 90; await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) @@ -132,17 +131,7 @@ public static MediaAsset ingestVOD(Optional action, Optional cog private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName, Map> tags, Map strings, Map numbers, Map dates) { - - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder; - Document doc = null; - - try { - docBuilder = docFactory.newDocumentBuilder(); - doc = docBuilder.parse("src/test/resources/ingest_xml_templates/ingestVOD.xml"); - } catch (Exception e) { - e.printStackTrace(); - } + Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password doc.getElementsByTagName("userName").item(0).setTextContent(getIngestAssetUserName()); From fbe234398ebb3d5ece8f81092ee6b98fd772679c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 20 Jun 2018 13:00:09 +0300 Subject: [PATCH 365/605] Added properties and updated pom for tasks with logs processing --- pom.xml | 7 +++++++ src/test/java/com/kaltura/client/test/Properties.java | 8 ++++++++ src/test/resources/test.template.properties | 11 ++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 191e382e7..9943f3f91 100644 --- a/pom.xml +++ b/pom.xml @@ -207,6 +207,13 @@ commons-dbutils 1.7 + + + org.apache.commons + commons-vfs2 + 2.2 + + diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index a72f540ab..ecf374219 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -68,6 +68,14 @@ public class Properties { // product codes public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; + // processing apps logs from remote connection + public static final String PHOENIX_SERVER_DOMAIN_NAME = "phoenix_server_domain_name"; + public static final String PHOENIX_SERVER_USER_NAME = "phoenix_server_user_name"; + public static final String PHOENIX_SERVER_PASSWORD = "phoenix_server_password"; + public static final String PHOENIX_SERVER_LOGS_DIRECTORY = "phoenix_server_logs_directory"; + public static final String PHOENIX_SERVER_LOG_FILE_NAME = "phoenix_server_logs_file_name"; + public static final String PHOENIX_SERVER_LOGS_LOCAL_PATH = "phoenix_server_logs_local_path"; + public static String getProperty(String propertyKey) { if (resourceBundle == null) { resourceBundle = ResourceBundle.getBundle("test"); diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index b7c7bb4a1..5c77f8b67 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -4,6 +4,7 @@ api_version=@API_VERSION@ partner_id=@PARTNER_ID@ ingest_base_url=@INGEST_BASE_URL@ ingest_report_url=@INGEST_REPORT_URL@ +default_timeout_in_sec=@DEFAULT_TIMEOUT_IN_SEC@ # DB SQL Properties db_url=@DB_URL@ @@ -32,4 +33,12 @@ default_product_code=@DEFAULT_PRODUCT_CODE@ # media types ids movie_media_type_id=@MOVIE_MEDIA_TYPE_ID@ -episode_media_type_id=@EPISODE_MEDIA_TYPE_ID@ \ No newline at end of file +episode_media_type_id=@EPISODE_MEDIA_TYPE_ID@ + +# Phoenix logs remote access +phoenix_server_domain_name=@PHOENIX_SERVER_DOMAIN_NAME@ +phoenix_server_user_name=@PHOENIX_SERVER_USER_NAME@ +phoenix_server_password=@PHOENIX_SERVER_PASSWORD@ +phoenix_server_logs_directory=@PHOENIX_SERVER_LOGS_DIRECTORY@ +phoenix_server_logs_file_name=@PHOENIX_SERVER_LOGS_FILE_NAME@ +phoenix_server_logs_local_path=@PHOENIX_SERVER_LOGS_LOCAL_PATH@ \ No newline at end of file From daebde53c7f4163821e38d801291d20b93c3c13e Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 20 Jun 2018 13:30:33 +0300 Subject: [PATCH 366/605] transaction tests --- .../com/kaltura/client/test/Properties.java | 3 + .../test/TestAPIOkRequestsExecutor.java | 3 +- .../TransactionPurchaseTests.java | 106 +++++++++++++++++- src/test/resources/schemas/ListResponse.json | 6 +- .../schemas/PaymentGatewayProfile.json | 43 +++++++ 5 files changed, 154 insertions(+), 7 deletions(-) create mode 100644 src/test/resources/schemas/PaymentGatewayProfile.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index a72f540ab..7a5adc5ab 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -39,6 +39,9 @@ public class Properties { public static final String PRICE_CODE_AMOUNT = "price_code_amount"; // 4.99 public static final String COMMON_PRICE_CODE_AMOUNT = "5"; // TODO: should we document it as requirement? + // maximum objects at list response for validating JSON schema + public static final int MAX_OBJECTS_AT_LIST_RESPONSE = 20; + // price plans // INGEST doesn't allow create PP with multi-currencies // TODO: should we document it as requirement? price plan having few locales (EUR + few others) with different prices diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 24077d34a..857ed4568 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -14,6 +14,7 @@ import java.util.concurrent.atomic.AtomicBoolean; +import static com.kaltura.client.test.Properties.MAX_OBJECTS_AT_LIST_RESPONSE; import static com.kaltura.client.test.tests.BaseTest.LOG_HEADERS; import static com.kaltura.client.test.tests.BaseTest.client; import static com.kaltura.client.utils.ErrorElement.*; @@ -63,7 +64,7 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request // if returned list without objects scheme should not be checked if (s2.equals("ListResponse")) { com.kaltura.client.utils.response.base.Response listResponse = response; - if (listResponse.results.getTotalCount() == 0) { + if (listResponse.results.getTotalCount() == 0 || listResponse.results.getTotalCount() > MAX_OBJECTS_AT_LIST_RESPONSE) { return responseElement; } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index 2e6bd66bd..b735dea04 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -1,19 +1,115 @@ package com.kaltura.client.test.tests.servicesTests.transactionTests; +import com.kaltura.client.enums.PurchaseStatus; +import com.kaltura.client.enums.TransactionAdapterStatus; +import com.kaltura.client.enums.TransactionType; +import com.kaltura.client.services.ProductPriceService; +import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; +import com.kaltura.client.services.TransactionService; +import com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.types.Household; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.within; + public class TransactionPurchaseTests extends BaseTest { + private int numberOfUsersInDomain = 2; + private int numberOfDevicesInDomain = 2; + private Response> listResponse; + private Household household; + private String masterUserKs; + private String userKs; + + + + @BeforeClass (enabled = false) + public void beforeClass(){ + // Prepare household with users and devices + household = HouseholdUtils.createHousehold(numberOfUsersInDomain, numberOfDevicesInDomain, false); + HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); + userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); - @Test - private void purchaseDefaultPG() { - Household household = HouseholdUtils.createHousehold(1, 1, true); -// HouseholdUser masterUser = + PaymentGatewayProfile paymentGatewayProfile = new PaymentGatewayProfile(); + } + @Test(enabled = false) + private void purchasePpvWithDefaultPG() { + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setFileIdIn(getSharedWebMediaFile().getId().toString()); + ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter).setKs(masterUserKs); + listResponse = executor.executeSync(listProductPriceBuilder); + assertThat(listResponse.results).isNotNull(); + PpvPrice productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); + assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.PPV); + purchase.setProductId(Integer.valueOf(productPricePpv.getPpvModuleId())); + purchase.setContentId(getSharedWebMediaFile().getId()); + purchase.setCurrency(productPricePpv.getPrice().getCurrency()); + purchase.setPrice(productPricePpv.getPrice().getAmount()); + + PurchaseTransactionBuilder purchaseTransactionBuilder = TransactionService.purchase(purchase).setKs(masterUserKs); + Response purchaseTransaction = executor.executeSync(purchaseTransactionBuilder); + Transaction purchasePpv = purchaseTransaction.results; + assertThat(purchasePpv).isNotNull(); + assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)getTimeInEpoch(0), within(15)); + assertThat(purchasePpv.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(purchasePpv.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(purchasePpv.getFailReasonCode()).isEqualTo(0); + assertThat(purchasePpv.getRelatedObjects()).isNull(); + + listResponse = executor.executeSync(listProductPriceBuilder); + assertThat(listResponse.results).isNotNull(); + productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); + assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + } + + @Test (enabled = false) + private void purchaseSubscriptionWithDefaultPG() { + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId().toString()); + ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter).setKs(masterUserKs); + listResponse = executor.executeSync(listProductPriceBuilder); + assertThat(listResponse.results).isNotNull(); + PpvPrice productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); + assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.PPV); + purchase.setProductId(Integer.valueOf(productPricePpv.getPpvModuleId())); + purchase.setContentId(getSharedWebMediaFile().getId()); + purchase.setCurrency(productPricePpv.getPrice().getCurrency()); + purchase.setPrice(productPricePpv.getPrice().getAmount()); + + PurchaseTransactionBuilder purchaseTransactionBuilder = TransactionService.purchase(purchase).setKs(masterUserKs); + Response purchaseTransaction = executor.executeSync(purchaseTransactionBuilder); + Transaction purchasePpv = purchaseTransaction.results; + assertThat(purchasePpv).isNotNull(); + assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)getTimeInEpoch(0), within(15)); + assertThat(purchasePpv.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(purchasePpv.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(purchasePpv.getFailReasonCode()).isEqualTo(0); + assertThat(purchasePpv.getRelatedObjects()).isNull(); + + listResponse = executor.executeSync(listProductPriceBuilder); + assertThat(listResponse.results).isNotNull(); + productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); + assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + } } diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 82f0cd45d..092993465 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -44,6 +44,9 @@ }, { "$ref": "Subscription.json#/definitions/Subscription" + }, + { + "$ref": "PaymentGatewayProfile.json#/definitions/PaymentGatewayProfile" } ] } @@ -66,7 +69,8 @@ "KalturaAssetCommentListResponse", "KalturaAssetHistoryListResponse", "KalturaUserRoleListResponse", - "KalturaSubscriptionListResponse" + "KalturaSubscriptionListResponse", + "KalturaPaymentGatewayProfileListResponse" ] } }, diff --git a/src/test/resources/schemas/PaymentGatewayProfile.json b/src/test/resources/schemas/PaymentGatewayProfile.json new file mode 100644 index 000000000..7fa72748a --- /dev/null +++ b/src/test/resources/schemas/PaymentGatewayProfile.json @@ -0,0 +1,43 @@ +{ + "$id": "PaymentGatewayProfile", + "definitions": { + "PaymentGatewayProfile": { + "type": "object", + "properties": { + "isActive": {"type": "integer", "minimum": 0}, + "adapterUrl": {"type": "string", "minLength": 0}, + "transactUrl": {"type": "string", "minLength": 0}, + "statusUrl": {"type": "string","minLength": 0}, + "renewUrl": {"type": "string","minLength": 0}, + "paymentGatewaySettings": {"type": "object"}, + "externalIdentifier": {"type": "string","minLength": 0}, + "pendingInterval": {"type": "integer","minimum": 0}, + "pendingRetries": {"type": "integer","minimum": 0}, + "sharedSecret": {"type": "string","minLength": 0}, + "renewIntervalMinutes": {"type": "integer","minimum": 0}, + "renewStartMinutes": {"type": "integer","minimum": 0}, + "externalVerification": {"type": "boolean"}, + "id": {"type": "integer","minimum": 0}, + "name": {"type": "string","minLength": 0}, + "isDefault": {"type": "boolean"}, + "paymentMethods": {"type": "array"}, + "objectType": {"type": "string","minLength": 0} + }, + "required": ["isActive", "adapterUrl", "transactUrl", "statusUrl","renewUrl","paymentGatewaySettings","externalIdentifier","pendingInterval","pendingRetries","sharedSecret", + "renewIntervalMinutes","renewStartMinutes","externalVerification","id","name","isDefault","paymentMethods","objectType"] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/PaymentGatewayProfile" + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} \ No newline at end of file From 61d1709fc9b015a763e568e6d0e7f98e6d96bb6e Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 20 Jun 2018 14:03:45 +0300 Subject: [PATCH 367/605] fixes of setters --- .../kaltura/client/test/tests/BaseTest.java | 12 ++++++------ .../EntitlementCancelTests.java | 10 ++++++---- .../ProductPriceListTests.java | 18 +++++++++++------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index c1827c865..5b3951383 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -353,12 +353,12 @@ public static Subscription get5MinRenewableSubscription() { channel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(channel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); - channel.setId(channelResponse.results.getId()); - - fiveMinRenewableSubscription = IngestMppUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), - Optional.of(channel.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + if (channelResponse.results != null && channelResponse.results.getName() != null) { + fiveMinRenewableSubscription = IngestMppUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), + Optional.of(channelResponse.results.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + } } } return fiveMinRenewableSubscription; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index cda3310b9..fd4b3d842 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -134,12 +134,14 @@ public void cancelPlayedSubscription() { sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); - sharedChannel.setId(channelResponse.results.getId()); + assertThat(channelResponse.results).isNotNull(); + Channel channel = channelResponse.results; + assertThat(channel.getName()).isNotNull(); PricePlan pricePlan = DBUtils.loadPPWithWaiver(); Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.of(channel.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); // set household @@ -181,10 +183,10 @@ public void cancelPlayedSubscription() { //delete subscription IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); // delete channel - executor.executeSync(ChannelService.delete(Math.toIntExact(sharedChannel.getId())).setKs(getManagerKs())); + executor.executeSync(ChannelService.delete(Math.toIntExact(channel.getId())).setKs(getManagerKs())); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 8f6606e7e..af9050e42 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -218,10 +218,12 @@ public void subscriptionTest() { sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); - sharedChannel.setId(channelResponse.results.getId()); + assertThat(channelResponse.results).isNotNull(); + Channel channel = channelResponse.results; + assertThat(channel.getName()).isNotNull(); Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementSubsFilter, null); @@ -288,7 +290,7 @@ public void subscriptionTest() { //delete subscription IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } @@ -300,10 +302,12 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); - sharedChannel.setId(channelResponse.results.getId()); + assertThat(channelResponse.results).isNotNull(); + Channel channel = channelResponse.results; + assertThat(channel.getName()).isNotNull(); Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); int webHDFileOnlySubId = Integer.valueOf(subscription.getId()); @@ -352,12 +356,12 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); // delete channel - DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(Math.toIntExact(sharedChannel.getId())); + DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(Math.toIntExact(channel.getId())); executor.executeSync(deleteChannelBuilder.setKs(getManagerKs())); //delete subscription IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), + Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); } From 01e2c612674fd086c6b47045223d92d43e23bcb6 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 20 Jun 2018 14:10:05 +0300 Subject: [PATCH 368/605] transaction disable till project will build successfully --- .../transactionTests/TransactionPurchaseTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index b735dea04..ce4ef3938 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -33,9 +33,9 @@ public class TransactionPurchaseTests extends BaseTest { public void beforeClass(){ // Prepare household with users and devices household = HouseholdUtils.createHousehold(numberOfUsersInDomain, numberOfDevicesInDomain, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); - masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); - userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); +// HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); +// masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); +// userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); PaymentGatewayProfile paymentGatewayProfile = new PaymentGatewayProfile(); From 2aac7ae1d3811e0cf4322add8bafed9fd549bfb3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 20 Jun 2018 14:42:46 +0300 Subject: [PATCH 369/605] UserRoleUtil fix --- src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java b/src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java index 65eb7f354..410aa74b9 100644 --- a/src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/UserRoleUtils.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.utils; import com.kaltura.client.types.UserRole; + import java.util.Random; public class UserRoleUtils extends BaseUtils { @@ -13,9 +14,7 @@ public static UserRole generateUserRole() { long roleId = r.nextInt(max - low) + low; UserRole userRole = new UserRole(); - userRole.setId(roleId); userRole.setName(String.valueOf(roleId)); - return userRole; } } From 9796402a2ddd943b574b87bb4184426952223371 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 20 Jun 2018 15:05:01 +0300 Subject: [PATCH 370/605] fixed utils --- .../test/utils/dbUtils/IngestFixtureData.java | 61 ++++++++----------- .../test/utils/ingestUtils/IngestPpUtils.java | 30 ++++----- .../utils/ingestUtils/IngestPpvUtils.java | 35 +++-------- .../utils/ingestUtils/IngestVodUtils.java | 14 ++--- 4 files changed, 50 insertions(+), 90 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 8327f483f..902140f31 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -1,46 +1,47 @@ package com.kaltura.client.test.utils.dbUtils; import com.google.common.base.Strings; -import com.google.common.base.Verify; +import static com.kaltura.client.test.tests.BaseTest.*; import com.kaltura.client.Logger; import com.kaltura.client.enums.SubscriptionDependencyType; -import com.kaltura.client.services.SubscriptionService; -import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.SubscriptionUtils; +import com.kaltura.client.services.ChannelService; +import com.kaltura.client.services.ChannelService.GetChannelBuilder; +import com.kaltura.client.services.PriceDetailsService; +import com.kaltura.client.services.PriceDetailsService.ListPriceDetailsBuilder; +import com.kaltura.client.services.PricePlanService; +import com.kaltura.client.services.PricePlanService.ListPricePlanBuilder; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.json.JSONArray; import java.sql.SQLException; - import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; import static com.kaltura.client.test.tests.BaseTest.partnerId; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; import static com.kaltura.client.test.utils.dbUtils.DBUtils.ERROR_MESSAGE; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getJsonArrayFromQueryResult; -public class IngestFixtureData { +public class IngestFixtureData extends BaseUtils { public static PriceDetails loadPriceCode(Double priceAmount, String currency) { Logger.getLogger(IngestFixtureData.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); - PriceDetails result = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_CODE_SELECT, true, partnerId, priceAmount, currency); if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; + return null; } - result = new PriceDetails(); - result.setName(jsonArray.getJSONObject(0).getString(CODE)); - result.setId(jsonArray.getJSONObject(0).getInt(ID)); - Price price = new Price(); - price.setCurrency(currency); - price.setAmount(priceAmount); - result.setPrice(price); + PriceDetailsFilter filter = new PriceDetailsFilter(); + filter.setIdIn(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + ListPriceDetailsBuilder priceDetailsBuilder = PriceDetailsService.list(filter); + Response> priceDetailsListResponse = executor.executeSync(priceDetailsBuilder.setKs(getOperatorKs())); + + return priceDetailsListResponse.results.getObjects().get(0); } catch (Exception e) { e.printStackTrace(); Logger.getLogger(IngestFixtureData.class).error("discount code can't be null"); } - return result; + return null; } @@ -95,18 +96,12 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl } static PricePlan loadFirstPricePlanFromJsonArray(JSONArray jsonArray) { - PricePlan pricePlan = new PricePlan(); - pricePlan.setId(jsonArray.getJSONObject(0).getLong(ID)); - pricePlan.setName(jsonArray.getJSONObject(0).getString(NAME)); - pricePlan.setViewLifeCycle(jsonArray.getJSONObject(0).getInt(VIEW_LIFE_CYCLE_MINUTES)); - pricePlan.setFullLifeCycle(jsonArray.getJSONObject(0).getInt(FULL_LIFE_CYCLE_MINUTES)); - pricePlan.setMaxViewsNumber(jsonArray.getJSONObject(0).getInt(MAX_VIEWS_COUNT)); - pricePlan.setDiscountId(jsonArray.getJSONObject(0).getLong(INT_DISCOUNT_ID)); - pricePlan.setPriceDetailsId(jsonArray.getJSONObject(0).getLong(PRICING_ID)); - pricePlan.setIsRenewable(0 == jsonArray.getJSONObject(0).getInt(IS_RENEWED)); - pricePlan.setRenewalsNumber(jsonArray.getJSONObject(0).getInt(NUMBER_OF_REC_PERIODS)); - - return pricePlan; + PricePlanFilter filter = new PricePlanFilter(); + filter.setIdIn(String.valueOf(jsonArray.getJSONObject(0).getLong(ID))); + ListPricePlanBuilder pricePlanBuilder = PricePlanService.list(filter); + com.kaltura.client.utils.response.base.Response> pricePlanListResponse = + executor.executeSync(pricePlanBuilder.setKs(getOperatorKs())); + return pricePlanListResponse.results.getObjects().get(0); } public static PricePlan load5MinRenewablePricePlan() { @@ -315,13 +310,9 @@ public static Channel getChannel(int id) { return channel; } - channel = new Channel(); - channel.setId(jsonArray.getJSONObject(0).getLong(ID)); - channel.setName(jsonArray.getJSONObject(0).getString(NAME)); - // logic if FILTER_EXPRESSION is not null so we have KSQL channel, otherwise we have automatic channel - channel.setFilterExpression(jsonArray.getJSONObject(0).getString(FILTER_EXPRESSION)); - channel.setToken(CHANNEL_TYPE, String.valueOf(jsonArray.getJSONObject(0).getInt(CHANNEL_TYPE))); - // TODO: add more data in case it needed + GetChannelBuilder getChannelBuilder = ChannelService.get(jsonArray.getJSONObject(0).getInt(ID)); + Response channelResponse = executor.executeSync(getChannelBuilder.setKs(getOperatorKs())); + channel = channelResponse.results; } catch (Exception e) { e.printStackTrace(); Logger.getLogger(IngestFixtureData.class).error("channel data can't be null"); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index a4a22dc2e..1124483c6 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -1,18 +1,18 @@ package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.Logger; +import com.kaltura.client.services.PricePlanService; +import com.kaltura.client.services.PricePlanService.ListPricePlanBuilder; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.DiscountModule; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.PricePlan; -import io.restassured.response.Response; +import com.kaltura.client.types.PricePlanFilter; import org.w3c.dom.Document; import org.w3c.dom.Element; - import java.util.Optional; - import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; +import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; @@ -69,7 +69,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String reqBody = IngestPpUtils.buildIngestPpXml(actionValue, ppCodeValue, isActiveValue, fullLifeCycleValue, viewLifeCycleValue, maxViewsValue, priceValue, currencyValue, discountValue, isRenewableValue, recurringPeriodsValue); - Response resp = + io.restassured.response.Response resp = given() .header(contentTypeXml) .header(soapActionIngestBusinessModules) @@ -91,18 +91,12 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); - PricePlan pricePlan = new PricePlan(); - pricePlan.setId(Long.valueOf(id)); - pricePlan.setMaxViewsNumber(maxViewsValue); - pricePlan.setIsRenewable(isRenewableValue); - pricePlan.setRenewalsNumber(recurringPeriodsValue); - pricePlan.setName(ppCodeValue); - pricePlan.setDiscountId(Long.valueOf(discountModule.toParams().get("id").toString())); - // TODO: complete COMMENTED IF NEEDED - //pricePlan.setFullLifeCycle(); - //pricePlan.setViewLifeCycle(); - //pricePlan.setPriceDetailsId(); - return pricePlan; + PricePlanFilter filter = new PricePlanFilter(); + filter.setIdIn(id); + ListPricePlanBuilder pricePlanBuilder = PricePlanService.list(filter); + com.kaltura.client.utils.response.base.Response> pricePlanListResponse = + executor.executeSync(pricePlanBuilder.setKs(getOperatorKs())); + return pricePlanListResponse.results.getObjects().get(0); } private static String buildIngestPpXml(String action, String ppCode, boolean isActive, String fullLifeCycle, String viewLifeCycle, diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index d6159dab6..369b01275 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -1,19 +1,16 @@ package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.Logger; +import com.kaltura.client.services.PpvService; +import com.kaltura.client.services.PpvService.GetPpvBuilder; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import io.restassured.response.Response; import org.w3c.dom.Document; import org.w3c.dom.Element; - -import java.util.ArrayList; -import java.util.List; import java.util.Optional; - import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; +import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; @@ -95,28 +92,10 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); - Ppv ppv = new Ppv(); - ppv.setId(id); - List descriptions = new ArrayList<>(); - TranslationToken translationToken = new TranslationToken(); - translationToken.setValue(descriptionValue); - descriptions.add(translationToken); - ppv.setDescriptions(descriptions); - PriceDetails priceDetails = new PriceDetails(); - Price priceObj = new Price(); - priceObj.setAmount(priceValue); - priceObj.setCurrency(currencyValue); - priceDetails.setPrice(priceObj); - ppv.setPrice(priceDetails); - UsageModule usageModuleObj = new UsageModule(); - usageModuleObj.setName(usageModuleValue); - ppv.setUsageModule(usageModuleObj); - ppv.setIsSubscriptionOnly(isSubscriptionOnlyValue); - ppv.setFirstDeviceLimitation(isFirstDeviceLimitationValue); - ppv.setProductCode(productCodeValue); - ppv.setName(ppvCodeValue); - - return ppv; + GetPpvBuilder getPpvBuilder = PpvService.get(Long.valueOf(id)); + com.kaltura.client.utils.response.base.Response ppvResponse = executor.executeSync(getPpvBuilder.setKs(getOperatorKs())); + + return ppvResponse.results; } private static String buildIngestPpvXml(String action, String ppvCode, boolean isActive, String description, String discount, diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 58a257a4a..e57ebf281 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -3,6 +3,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; import org.w3c.dom.Document; @@ -105,12 +106,8 @@ public static MediaAsset ingestVOD(Optional action, Optional cog id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); } - MediaAsset mediaAsset = new MediaAsset(); - mediaAsset.setName(nameValue); - mediaAsset.setId(Long.valueOf(id.trim())); - mediaAsset.setDescription(descriptionValue); - //mediaAsset.setStartDate(startDate); - //mediaAsset.setEndDate(endDate); + AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(id.trim(), AssetReferenceType.MEDIA); + com.kaltura.client.utils.response.base.Response assetResponse = executor.executeSync(getAssetBuilder.setKs(getAnonymousKs())); if (!INGEST_ACTION_DELETE.equals(actionValue)) { int delayBetweenRetriesInSeconds = 5; @@ -120,12 +117,11 @@ public static MediaAsset ingestVOD(Optional action, Optional cog .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(isDataReturned(getAnonymousKs(), id, actionValue)); - mediaAsset.setMediaFiles(executor.executeSync( - AssetService.get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs())).results.getMediaFiles()); + return (MediaAsset) assetResponse.results; } // TODO: 4/15/2018 add log for ingest and index failures - return mediaAsset; + return null; } private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, From ec1767880f2c819c97ba2f783e6ac9131f6ca242 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 20 Jun 2018 16:37:51 +0300 Subject: [PATCH 371/605] OttUser Fix --- .../servicesTests/ottUserTests/OttUserAddRoleTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java index 8cd69e29a..dc7b058ca 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserAddRoleTests.java @@ -40,10 +40,12 @@ private void addRole() { // add role AddUserRoleBuilder addUserRoleBuilder = add(userRole) .setKs(getAdministratorKs()); - executor.executeSync(addUserRoleBuilder); + Response userRoleResponse = executor.executeSync(addUserRoleBuilder); + assertThat(userRoleResponse.results).isNotNull(); + UserRole userRoleResult = userRoleResponse.results; // add role to user - AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(userRole.getId()) + AddRoleOttUserBuilder addRoleOttUserBuilder = OttUserService.addRole(userRoleResult.getId()) .setKs(getAdministratorKs()) .setUserId(Integer.valueOf(user.getId())); Response booleanResponse = executor.executeSync(addRoleOttUserBuilder); @@ -64,7 +66,7 @@ private void addRole() { userRolesIds.add(ur.getId()); } - assertThat(userRolesIds).contains(userRole.getId()); + assertThat(userRolesIds).contains(userRoleResult.getId()); // cleanup - delete role // TODO: 5/14/2018 finish test after when reletead bug will be fixed From 94ce24167f77cc668545ec90b7b1430161b30354 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 20 Jun 2018 22:52:03 +0300 Subject: [PATCH 372/605] fixing ingestVOD return null and missing schemas --- .../test/TestAPIOkRequestsExecutor.java | 30 +++--- .../SearchAssetFilterTests.java | 2 +- .../EntitlementGrantTests.java | 2 + .../kaltura/client/test/utils/AssetUtils.java | 26 +++--- .../utils/ingestUtils/IngestVodUtils.java | 15 +-- src/test/resources/schemas/ListResponse.json | 10 +- src/test/resources/schemas/PriceDetails.json | 35 +++++++ src/test/resources/schemas/PricePlan.json | 92 +++++++++++++++++++ 8 files changed, 178 insertions(+), 34 deletions(-) create mode 100644 src/test/resources/schemas/PriceDetails.json create mode 100644 src/test/resources/schemas/PricePlan.json diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 857ed4568..d9f8c373b 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -28,11 +28,21 @@ // public class TestAPIOkRequestsExecutor extends APIOkRequestsExecutor { - public static final String TAG = "TestAPIOkRequestsExecutor"; - private static ILogger logger = Logger.getLogger(TAG); + private static final String TAG = "TestAPIOkRequestsExecutor"; + private static ILogger logger = Logger.getLogger(TAG); private static TestAPIOkRequestsExecutor executor; + private final int[] genericErrors = { + ConnectionError.getCode(), + BadRequestError.getCode(), + GeneralError.getCode(), + NotFound.getCode(), + LoadError.getCode(), + ServiceUnavailableError.getCode(), + SessionError.getCode() + }; + private TestAPIOkRequestsExecutor() { } @@ -61,10 +71,11 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request String s2 = response.results.getClass().getSimpleName(); String s3 = ".json"; - // if returned list without objects scheme should not be checked + // if returned list empty or greater than 'MAX_OBJECTS_AT_LIST_RESPONSE' skip schema validation if (s2.equals("ListResponse")) { com.kaltura.client.utils.response.base.Response listResponse = response; - if (listResponse.results.getTotalCount() == 0 || listResponse.results.getTotalCount() > MAX_OBJECTS_AT_LIST_RESPONSE) { + if (listResponse.results.getTotalCount() == 0 || + listResponse.results.getTotalCount() > MAX_OBJECTS_AT_LIST_RESPONSE) { return responseElement; } } @@ -104,19 +115,10 @@ public Response exec(RequestBuilder requestBuilder) { APIException error = response.error; if (error != null) { - int[] genericErrors = { - ConnectionError.getCode(), - BadRequestError.getCode(), - GeneralError.getCode(), - NotFound.getCode(), - LoadError.getCode(), - ServiceUnavailableError.getCode(), - SessionError.getCode() - }; - int errorCode = Integer.parseInt(error.getCode()); if (Ints.asList(genericErrors).contains(errorCode)) { logger.error(error.getMessage() + " : " + error.getCode()); + try { throw error; } catch (APIException e) { e.printStackTrace(); } } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 6ecbb4d85..e3a1313ea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -164,7 +164,7 @@ private void listVodAssetsWithStartWithKsqlQuery() { .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); List assets = executor.executeSync(listAssetBuilder).results.getObjects(); - assertThat(assets).isNotNull().as("assets list"); + assertThat(assets).as("assets list").isNotNull(); assertThat(assets.size()).isEqualTo(2); assertThat(assets).extracting("id").contains(asset3.getId(), asset2.getId()).doesNotContain(asset.getId()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index aab57591a..af8e24f9e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -173,6 +173,7 @@ private void grant_ppv_with_history() { .setUserId(Integer.valueOf(user.getUserId())) .setKs(getAdministratorKs()); Response booleanResponse = executor.executeSync(grantEntitlementBuilder); + assertThat(booleanResponse).isNotNull(); assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); @@ -238,6 +239,7 @@ private void grant_ppv_without_history() { .setUserId(Integer.valueOf(user.getUserId())) .setKs(getAdministratorKs()); Response booleanResponse = executor.executeSync(grantEntitlementBuilder); + assertThat(booleanResponse).isNotNull(); assertThat(booleanResponse.results.booleanValue()).isEqualTo(true); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index ae787eac8..6d4fc6f16 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -14,16 +14,18 @@ import com.kaltura.client.utils.response.base.Response; import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; -import static com.kaltura.client.services.SocialActionService.*; -import static com.kaltura.client.services.BookmarkService.*; -import static com.kaltura.client.services.AssetService.*; -import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.services.AssetService.GetAssetBuilder; +import static com.kaltura.client.services.AssetService.ListAssetBuilder; +import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; +import static com.kaltura.client.services.SocialActionService.AddSocialActionBuilder; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.executor; +import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; +import static org.assertj.core.api.Assertions.assertThat; public class AssetUtils extends BaseUtils { @@ -56,7 +58,6 @@ public static ChannelFilter getChannelFilter(int idEqual, Optional ksql, } public static List getAssetFileIds(String assetId) { - AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); GetAssetBuilder getAssetBuilder = AssetService.get(assetId, assetReferenceType); @@ -64,13 +65,16 @@ public static List getAssetFileIds(String assetId) { Response assetResponse = executor.executeSync(getAssetBuilder); List mediaFiles = assetResponse.results.getMediaFiles(); + assertThat(mediaFiles.size()).as("media files list").isGreaterThan(0); - List fileIdsList = new ArrayList<>(); - for (MediaFile mediaFile : mediaFiles) { - fileIdsList.add(mediaFile.getId()); - } +// List fileIdsList = new ArrayList<>(); +// for (MediaFile mediaFile : mediaFiles) { +// fileIdsList.add(mediaFile.getId()); +// } +// +// return fileIdsList; - return fileIdsList; + return mediaFiles.stream().map(MediaFile::getId).collect(Collectors.toList()); } public static List getAssetsByType(String typeIn) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index e57ebf281..43fddd603 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -2,8 +2,6 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.services.AssetService; -import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; import org.w3c.dom.Document; @@ -14,6 +12,8 @@ import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; +import static com.kaltura.client.services.AssetService.GetAssetBuilder; +import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; @@ -106,9 +106,6 @@ public static MediaAsset ingestVOD(Optional action, Optional cog id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); } - AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(id.trim(), AssetReferenceType.MEDIA); - com.kaltura.client.utils.response.base.Response assetResponse = executor.executeSync(getAssetBuilder.setKs(getAnonymousKs())); - if (!INGEST_ACTION_DELETE.equals(actionValue)) { int delayBetweenRetriesInSeconds = 5; int maxTimeExpectingValidResponseInSeconds = 90; @@ -117,10 +114,14 @@ public static MediaAsset ingestVOD(Optional action, Optional cog .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(isDataReturned(getAnonymousKs(), id, actionValue)); - return (MediaAsset) assetResponse.results; + + return (MediaAsset) executor.executeSync(get(id, AssetReferenceType.MEDIA) + .setKs(getAnonymousKs())) + .results; } // TODO: 4/15/2018 add log for ingest and index failures + return null; } @@ -306,7 +307,7 @@ private static Map getDefaultDates() { } private static Callable isDataReturned(String ks, String mediaId, String action) { - AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(mediaId, AssetReferenceType.MEDIA).setKs(ks); + GetAssetBuilder getAssetBuilder = get(mediaId, AssetReferenceType.MEDIA).setKs(ks); if (INGEST_ACTION_DELETE.equals(action)) { return () -> (executor.executeSync(getAssetBuilder).error != null); } else { diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 092993465..1c949f9cb 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -47,6 +47,12 @@ }, { "$ref": "PaymentGatewayProfile.json#/definitions/PaymentGatewayProfile" + }, + { + "$ref": "PriceDetails.json#/definitions/PriceDetails" + }, + { + "$ref": "PricePlan.json#/definitions/PricePlan" } ] } @@ -70,7 +76,9 @@ "KalturaAssetHistoryListResponse", "KalturaUserRoleListResponse", "KalturaSubscriptionListResponse", - "KalturaPaymentGatewayProfileListResponse" + "KalturaPaymentGatewayProfileListResponse", + "KalturaPriceDetailsListResponse", + "KalturaPricePlanListResponse" ] } }, diff --git a/src/test/resources/schemas/PriceDetails.json b/src/test/resources/schemas/PriceDetails.json new file mode 100644 index 000000000..25e9aa97e --- /dev/null +++ b/src/test/resources/schemas/PriceDetails.json @@ -0,0 +1,35 @@ +{ + "$id": "PriceDetails", + "definitions": { + "PriceDetails": { + "type": "object", + "properties": { + "id": {"type": "integer", "minimum": 0}, + "name": {"type": "string", "minLength": 0}, + "multiCurrencyPrice": { + "type": "array", + "items": { + "type": "object", + "properties": { + "amount": {"type": "integer", "minimum": 0}, + "currency": {"type": "string", "minLength": 0}, + "currencySign": {"type": "string", "minLength": 0}, + "objectType": {"type": "string", "enum": ["KalturaPriceDetails"]} + }, + "required": ["amount", "currency", "currencySign", "objectType"] + } + }, + "objectType": {"type": "string", "minLength": 0} + }, + "required": ["id", "name", "multiCurrencyPrice"] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/PriceDetails" + }, + "executionTime": {"type": "number"} + }, + "required": ["result", "executionTime"] +} \ No newline at end of file diff --git a/src/test/resources/schemas/PricePlan.json b/src/test/resources/schemas/PricePlan.json new file mode 100644 index 000000000..ac495ae12 --- /dev/null +++ b/src/test/resources/schemas/PricePlan.json @@ -0,0 +1,92 @@ +{ + "$id": "PricePlan", + "definitions": { + "PricePlan": { + "type": "object", + "properties": { + "isRenewable": { + "type": "boolean" + }, + "renewalsNumber": { + "type": "integer", + "minimum": 0 + }, + "discountId": { + "type": "integer", + "minimum": 0 + }, + "priceDetailsId": { + "type": "integer", + "minimum": 0 + }, + "id": { + "type": "integer", + "minimum": 0 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "maxViewsNumber": { + "type": "integer", + "minimum": 0 + }, + "viewLifeCycle": { + "type": "integer", + "minimum": 0 + }, + "fullLifeCycle": { + "type": "integer", + "minimum": 0 + }, + "couponId": { + "type": "integer", + "minimum": 0 + }, + "waiverPeriod": { + "type": "integer", + "minimum": 0 + }, + "isWaiverEnabled": { + "type": "boolean" + }, + "isOfflinePlayback": { + "type": "boolean" + }, + "objectType": { + "type": "string", + "enum": ["KalturaPricePlan"] + } + }, + "required": [ + "isRenewable", + "renewalsNumber", + "discountId", + "priceDetailsId", + "id", + "name", + "maxViewsNumber", + "viewLifeCycle", + "fullLifeCycle", + "couponId", + "waiverPeriod", + "isWaiverEnabled", + "isOfflinePlayback", + "objectType" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/PricePlan" + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} \ No newline at end of file From c592740eb014745be2fe206fbe53b2299f5f92c8 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 21 Jun 2018 04:03:59 +0300 Subject: [PATCH 373/605] addition for log monitoring task --- .../com/kaltura/client/test/Properties.java | 1 + .../client/test/TestAPIOkRequestsExecutor.java | 18 ++++++++++++++++++ src/test/resources/test.template.properties | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index ce885f786..2db9224e3 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -78,6 +78,7 @@ public class Properties { public static final String PHOENIX_SERVER_LOGS_DIRECTORY = "phoenix_server_logs_directory"; public static final String PHOENIX_SERVER_LOG_FILE_NAME = "phoenix_server_logs_file_name"; public static final String PHOENIX_SERVER_LOGS_LOCAL_PATH = "phoenix_server_logs_local_path"; + public static final String REGRESSION_LOGS_LOCAL_PATH = "regression_logs_local_path"; public static String getProperty(String propertyKey) { if (resourceBundle == null) { diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 857ed4568..f652ab575 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -12,9 +12,12 @@ import com.kaltura.client.utils.response.base.Response; import com.kaltura.client.utils.response.base.ResponseElement; +import java.io.*; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.test.Properties.MAX_OBJECTS_AT_LIST_RESPONSE; +import static com.kaltura.client.test.Properties.REGRESSION_LOGS_LOCAL_PATH; +import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.LOG_HEADERS; import static com.kaltura.client.test.tests.BaseTest.client; import static com.kaltura.client.utils.ErrorElement.*; @@ -77,11 +80,26 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request assertThat(responseElement.getResponse(), matchesJsonSchemaInClasspath(schema)); /*date = new Date(); System.out.println("AFTER VALIDATION: " + formatter.format(date));*/ + + String serviceMethod = action.getUrl().split("service")[1]; + String kalturaSession = okhttpResponse.headers().get("X-Kaltura-Session"); + write2LogFile(serviceMethod, kalturaSession); } } return responseElement; } + private void write2LogFile(String serviceMethod, String kalturaSession) { + try(FileWriter fw = new FileWriter(getProperty(REGRESSION_LOGS_LOCAL_PATH), true); + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter out = new PrintWriter(bw)) + { + out.println(serviceMethod + " " + kalturaSession); + } catch (IOException e) { + e.printStackTrace(); + } + } + public Response executeSync(RequestBuilder requestBuilder) { SyncExecutor syncExecutor = new SyncExecutor<>(); return syncExecutor.exec(requestBuilder); diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index 5c77f8b67..7ee6403f4 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -41,4 +41,5 @@ phoenix_server_user_name=@PHOENIX_SERVER_USER_NAME@ phoenix_server_password=@PHOENIX_SERVER_PASSWORD@ phoenix_server_logs_directory=@PHOENIX_SERVER_LOGS_DIRECTORY@ phoenix_server_logs_file_name=@PHOENIX_SERVER_LOGS_FILE_NAME@ -phoenix_server_logs_local_path=@PHOENIX_SERVER_LOGS_LOCAL_PATH@ \ No newline at end of file +phoenix_server_logs_local_path=@PHOENIX_SERVER_LOGS_LOCAL_PATH@ +regression_logs_local_path=@REGRESSION_LOGS_LOCAL_PATH@ \ No newline at end of file From 299ce7d68e1f979d7ad1021141df32d270579b4e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 21 Jun 2018 10:56:44 +0300 Subject: [PATCH 374/605] fixed part of failed regression tests --- .../kaltura/client/test/tests/BaseTest.java | 25 ++++++++++++++++--- .../test/utils/dbUtils/DBConstants.java | 11 +++++--- .../test/utils/dbUtils/IngestFixtureData.java | 13 +++------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 5b3951383..59267d427 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -78,6 +78,9 @@ public class BaseTest { // shared ingested PP private static PricePlan sharedCommonPricePlan; + // shared discount module for shared PP + private static DiscountModule sharedCommonDiscountModule; + // shared ingested subscription private static Subscription sharedCommonSubscription; @@ -134,20 +137,34 @@ public void baseTest_beforeMethod(Method method) { * @return common shared Price Plan with mentioned parameters */ public static PricePlan getSharedCommonPricePlan() { - double defaultDiscountPrice = 0.0; - double defaultDiscountPercentValue = 100.0; if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), EUR.getValue(), defaultDiscountPrice, defaultDiscountPercentValue); + sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), EUR.getValue(), getSharedCommonDiscount()); if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestPpUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), - Optional.of(EUR.getValue()), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)), + Optional.of(EUR.getValue()), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), getSharedCommonDiscount().getPercent().intValue())), Optional.of(true), Optional.of(0)); } } return sharedCommonPricePlan; } + /** + * Regression requires existing of Price Plan with specific parameters. + * One of them: + * Discount percent should be equal 100% + * Can't work in case proper Discount and PriceCode aren't found in DB + * + * @return common shared Discount Module with mentioned parameters + */ + public static DiscountModule getSharedCommonDiscount() { + double defaultDiscountPrice = 0.0; + double defaultDiscountPercentValue = 100.0; + if (sharedCommonDiscountModule == null) { + sharedCommonDiscountModule = IngestFixtureData.loadDiscount(defaultDiscountPrice, defaultDiscountPercentValue); + } + return sharedCommonDiscountModule; + } /** * Regression requires existing of MPP with specific parameters. * Price Plan should be as for method public static PricePlan getSharedCommonPricePlan() diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 99caeb0a7..be7bb987d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -106,10 +106,13 @@ public class DBConstants { "and ((num_of_rec_periods > 2) or (num_of_rec_periods = 0))\n" + // TODO: do we really want it "num_of_rec_periods > 2"? "and group_id=?"; - static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions]\n" + - "where [status]=1 and is_active=1\n" + - "and group_id=? and usage_module_code=? and discount_module_code=?\n" + - "order by create_date"; + static final String SUBSCRIPTION_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions] s with(nolock)\n" + + "join [Pricing].[dbo].[subscriptions_channels] sc with(nolock) on (sc.subscription_id=s.id)\n" + + "join [TVinci].[dbo].[channels] c with(nolock) on (c.id=sc.channel_id)\n" + + "where s.[status]=1 and s.is_active=1\n" + + "and s.group_id=? and s.usage_module_code=? and s.discount_module_code=? and c.channel_type!=" + + ChannelType.MANUAL_CHANNEL_TYPE.getValue() + " and sc.is_active=1 and sc.[status]=1\n" + + "order by s.create_date"; static final String SUBSCRIPTION_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[subscriptions] s with(nolock)\n" + "join [Pricing].[dbo].[usage_modules] um with(nolock) on (s.usage_module_code=um.id)\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 902140f31..e25e53c99 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -64,9 +64,9 @@ public static DiscountModule loadDiscount(Double discountPrice, Double discountP return result; } - public static PricePlan loadPricePlan(Double priceAmount, String currency, Double discountPrice, Double discountPercent) { + public static PricePlan loadPricePlan(Double priceAmount, String currency, DiscountModule discountModule) { Logger.getLogger(IngestFixtureData.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency + - " discountPrice = " + discountPrice + " discountPercent = " + discountPercent); + " discountPercent = " + discountModule.getPercent()); PricePlan pricePlan = null; @@ -76,11 +76,6 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Doubl return pricePlan; } - DiscountModule discountModule = loadDiscount(discountPrice, discountPercent); - if (discountModule == null) { - return pricePlan; - } - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_SELECT, true, partnerId, Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()); if (Strings.isNullOrEmpty(jsonArray.toString())) { @@ -129,7 +124,7 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { Subscription subscription = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_SELECT, true, partnerId, - pricePlan.getId(), pricePlan.getDiscountId()); + pricePlan.getId(), getSharedCommonDiscount().toParams().get("id")); if (Strings.isNullOrEmpty(jsonArray.toString())) { return subscription; } @@ -155,7 +150,7 @@ public static Collection loadSharedCommonCollection(PricePlan pricePlan) { Collection collection = null; try { JSONArray jsonArray = getJsonArrayFromQueryResult(COLLECTION_SELECT, true, partnerId, - pricePlan.getDiscountId(), pricePlan.getPriceDetailsId(), pricePlan.getId()); + getSharedCommonDiscount().toParams().get("id"), pricePlan.getPriceDetailsId(), pricePlan.getId()); if (Strings.isNullOrEmpty(jsonArray.toString())) { return collection; } From 8b6523c70dd736c3fc7abfab6809ca6a4f377133 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 21 Jun 2018 15:19:09 +0300 Subject: [PATCH 375/605] increased readTimeout for grant methods --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 59267d427..8f6519dd4 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -109,6 +109,7 @@ public void baseTest_beforeSuite() { config = new Configuration(); config.setEndpoint(getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION)); config.setAcceptGzipEncoding(false); + config.setReadTimeout(Integer.valueOf(getProperty(DEFAULT_TIMEOUT_IN_SEC))*1000); // set client client = new Client(config); From 919d6295c216b74e1ba5581774d27458c0f57244 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 21 Jun 2018 15:40:30 +0300 Subject: [PATCH 376/605] Fix searchAssertFilterTests --- .../test/TestAPIOkRequestsExecutor.java | 3 +- .../SearchAssetFilterTests.java | 221 +++++++++--------- .../kaltura/client/test/utils/AssetUtils.java | 53 +++-- .../client/test/utils/SubscriptionUtils.java | 10 +- .../test/utils/dbUtils/IngestFixtureData.java | 7 +- .../utils/ingestUtils/IngestVodUtils.java | 12 +- 6 files changed, 163 insertions(+), 143 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 8de3c4490..2a6576d9f 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -103,8 +103,7 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request private void write2LogFile(String serviceMethod, String kalturaSession) { try(FileWriter fw = new FileWriter(getProperty(REGRESSION_LOGS_LOCAL_PATH), true); BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) - { + PrintWriter out = new PrintWriter(bw)) { out.println(serviceMethod + " " + kalturaSession); } catch (IOException e) { e.printStackTrace(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index e3a1313ea..40c67dc0b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -2,10 +2,7 @@ import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; -import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.AssetUtils; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; @@ -14,6 +11,7 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.json.JSONArray; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,40 +20,48 @@ import java.util.List; import static com.kaltura.client.services.AssetService.ListAssetBuilder; +import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; +import static com.kaltura.client.test.utils.AssetUtils.*; +import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static org.assertj.core.api.Assertions.assertThat; public class SearchAssetFilterTests extends BaseTest { + private final String tagName = "Genre"; + private MediaAsset asset; private MediaAsset asset2; private MediaAsset asset3; - private ProgramAsset program; private ProgramAsset program2; - private String ksqlQuery; - private AssetFilter assetFilter = null; - private ListAssetBuilder listAssetBuilder = null; - private HashMap> map = new HashMap<>(); - private ArrayList list = new ArrayList<>(); - private String tagName = "Genre"; - private String tagValue = BaseUtils.getRandomValue(tagName + "_", 999999); - private String epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); - private String epgChannelName2 = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(1).getString("name"); + private AssetFilter assetFilter; + private String tagValue; @BeforeClass - private void Asset_list_before_class() { + private void asset_list_before_class() { // Get asset from shared asset method + tagValue = getRandomValue(tagName + "_", 999999); + + ArrayList list = new ArrayList<>(); list.add(tagValue); + + HashMap> map = new HashMap<>(); map.put(tagName, list); + JSONArray ja = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray(); + String epgChannelName = ja.getJSONObject(0).getString("name"); + String epgChannelName2 = ja.getJSONObject(1).getString("name"); + asset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); - asset2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-100))); - asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, String.valueOf(BaseUtils.getTimeInDate(-10))); + asset2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, getTimeInDate(-100)); + asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, getTimeInDate(-10)); program = IngestEpgUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestEpgUtils.ingestEPG(epgChannelName2, 1).get(0); } @@ -66,12 +72,11 @@ private void Asset_list_before_class() { @Test private void listVodAssetsWithExactKsqlQuery() { ksqlQuery = "name = '" + asset.getName() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); } @@ -81,12 +86,11 @@ private void listVodAssetsWithExactKsqlQuery() { @Test private void listVodAssetsWithExactKsqlQuery2() { ksqlQuery = "media_id = '" + asset.getId() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); } @@ -96,12 +100,11 @@ private void listVodAssetsWithExactKsqlQuery2() { @Test private void listVodAssetsWithOrQuery() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(2); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset.getId()); @@ -112,12 +115,11 @@ private void listVodAssetsWithOrQuery() { @Test private void listVodAssetsWithAndQuery() { ksqlQuery = "(and media_id = '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); } @@ -127,12 +129,11 @@ private void listVodAssetsWithAndQuery() { @Test private void listVodAssetsWithNotKsqlQuery() { ksqlQuery = "(and media_id != '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); } @@ -142,11 +143,12 @@ private void listVodAssetsWithNotKsqlQuery() { @Test private void listVodAssetsWithLikeKsqlQuery() { ksqlQuery = "" + tagName + " ~ '" + tagValue + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - List assets = executor.executeSync(listAssetBuilder).results.getObjects(); + assetFilter = getSearchAssetFilter(ksqlQuery); + + List assets = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())) + .results + .getObjects(); assertThat(assets).isNotNull(); assertThat(assets.size()).isEqualTo(2); @@ -158,11 +160,12 @@ private void listVodAssetsWithLikeKsqlQuery() { @Test private void listVodAssetsWithStartWithKsqlQuery() { ksqlQuery = "" + tagName + " ^ '" + tagValue + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - List assets = executor.executeSync(listAssetBuilder).results.getObjects(); + assetFilter = getSearchAssetFilter(ksqlQuery); + + List assets = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())) + .results + .getObjects(); assertThat(assets).as("assets list").isNotNull(); assertThat(assets.size()).isEqualTo(2); @@ -174,11 +177,10 @@ private void listVodAssetsWithStartWithKsqlQuery() { @Test private void listVodAssetsFilteredByType() { ksqlQuery = "" + tagName + " = '" + tagValue + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, getProperty(MOVIE_MEDIA_TYPE_ID), null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); - Response> assetListResponse = executor.executeSync(listAssetBuilder); + assetFilter = getSearchAssetFilter(ksqlQuery, null, getProperty(MOVIE_MEDIA_TYPE_ID), null, null, null, null); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); assertThat(assetListResponse.results).isNotNull(); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); @@ -188,19 +190,17 @@ private void listVodAssetsFilteredByType() { @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - order by VIEWS") @Test - private void OrderVodAssetsByViews() { - AssetUtils.addViewsToAsset(asset.getId(), 3, AssetType.MEDIA); - AssetUtils.addViewsToAsset(asset2.getId(), 2, AssetType.MEDIA); - AssetUtils.addViewsToAsset(asset3.getId(), 1, AssetType.MEDIA); - + private void orderVodAssetsByViews() { + addViewsToAsset(asset.getId(), 3, AssetType.MEDIA); + addViewsToAsset(asset2.getId(), 2, AssetType.MEDIA); + addViewsToAsset(asset3.getId(), 1, AssetType.MEDIA); ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); @@ -211,28 +211,27 @@ private void OrderVodAssetsByViews() { @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - order by NAME (DESC/ASC") @Test(enabled = false) - private void OrderVodAssetsByName() { + private void orderVodAssetsByName() { IngestVodUtils.updateVODName(asset, "AAA"); IngestVodUtils.updateVODName(asset2, "BBB"); IngestVodUtils.updateVODName(asset3, "CCC"); ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); - - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); + ListAssetBuilder listAssetBuilder = list(assetFilter) + .setKs(getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); - - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); + listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); @@ -242,17 +241,16 @@ private void OrderVodAssetsByName() { @Description("asset/action/list - VOD - order by LIKES") @Test private void orderVodAssetsByLikes() { - AssetUtils.addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); - AssetUtils.addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); - AssetUtils.addLikesToAsset(asset.getId(), 1, AssetType.MEDIA); + addLikesToAsset(asset3.getId(), 3, AssetType.MEDIA); + addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); + addLikesToAsset(asset.getId(), 1, AssetType.MEDIA); ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); @@ -263,14 +261,15 @@ private void orderVodAssetsByLikes() { @Description("asset/action/list - VOD - order by (num of) VOTES and RATING") @Test private void orderVodAssetsByVotesAndRating() { - AssetUtils.addVotesToAsset(asset2.getId(), 2, AssetType.MEDIA, 1); - AssetUtils.addVotesToAsset(asset3.getId(), 1, AssetType.MEDIA, 5); + addVotesToAsset(asset2.getId(), 2, AssetType.MEDIA, 1); + addVotesToAsset(asset3.getId(), 1, AssetType.MEDIA, 5); // Order by number of votes (highest to lowest) ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); + + ListAssetBuilder listAssetBuilder = list(assetFilter) + .setKs(getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); @@ -279,9 +278,9 @@ private void orderVodAssetsByVotesAndRating() { assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); // Order by Ratings (highest to lowest) - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); + + listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); @@ -295,20 +294,22 @@ private void orderVodAssetsByVotesAndRating() { @Test private void orderVodAssetsByCatalogStartDate() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); + ListAssetBuilder listAssetBuilder = list(assetFilter) + .setKs(getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset3.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_ASC.getValue()); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_ASC.getValue()); + + listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); @@ -321,12 +322,11 @@ private void orderVodAssetsByCatalogStartDate() { @Test private void listEpgProgramWithExactKsqlQuery() { ksqlQuery = "name = '" + program.getName() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, "0", null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, null, "0", null, null, null, null); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program.getId()); } @@ -336,14 +336,14 @@ private void listEpgProgramWithExactKsqlQuery() { @Test private void listEpgProgramWithExactKsqlQuery2() { ksqlQuery = "epg_channel_id = '" + program.getEpgChannelId() + "'"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, null, null, null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery); - List epgPrograms = executor.executeSync(listAssetBuilder).results.getObjects(); - assertThat(epgPrograms.size()).isGreaterThan(1); + List epgPrograms = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())) + .results + .getObjects(); + assertThat(epgPrograms.size()).isGreaterThan(1); assertThat(epgPrograms).extracting("epgChannelId").contains(program.getEpgChannelId()); } @@ -353,12 +353,11 @@ private void listEpgProgramWithExactKsqlQuery2() { @Test private void listEpgProgramsFilteredByEpgChannel() { ksqlQuery = "(or name = '" + program.getName() + "' name = '" + program2.getName() + "')"; - assetFilter = AssetUtils.getSearchAssetFilter(ksqlQuery, program2.getEpgChannelId().toString(), "0", null, null, - null, null); - listAssetBuilder = AssetService.list(assetFilter, null) - .setKs(BaseTest.SharedHousehold.getSharedMasterUserKs()); + assetFilter = getSearchAssetFilter(ksqlQuery, program2.getEpgChannelId().toString(), "0", null, null, null, null); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); - Response> assetListResponse = executor.executeSync(listAssetBuilder); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(program2.getId()); } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 6d4fc6f16..93deac285 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -7,9 +7,7 @@ import com.kaltura.client.enums.SocialActionType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.BookmarkService; -import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.SocialActionService; -import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -21,6 +19,7 @@ import static com.kaltura.client.services.AssetService.GetAssetBuilder; import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; +import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.SocialActionService.AddSocialActionBuilder; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.executor; @@ -30,10 +29,9 @@ public class AssetUtils extends BaseUtils { - + // TODO: 6/21/2018 Use Optional instead of nullable public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nullable String idIn, @Nullable String typeIn, - @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, - String orderBy) { + @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); searchAssetFilter.setKSql(ksql); searchAssetFilter.setIdIn(idIn); @@ -46,6 +44,13 @@ public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nul return searchAssetFilter; } + public static SearchAssetFilter getSearchAssetFilter(String ksql) { + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(ksql); + + return searchAssetFilter; + } + public static ChannelFilter getChannelFilter(int idEqual, Optional ksql, Optional dynamicOrderBy, Optional orderBy) { ChannelFilter channelFilter = new ChannelFilter(); channelFilter.setIdEqual(idEqual); @@ -79,9 +84,11 @@ public static List getAssetFileIds(String assetId) { public static List getAssetsByType(String typeIn) { AssetFilter assetFilter = getSearchAssetFilter(null, null, typeIn, null, null, null, null); + FilterPager filterPager = new FilterPager(); filterPager.setPageSize(20); filterPager.setPageIndex(1); + ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, filterPager) .setKs(getSharedMasterUserKs()); Response> assetResponse = executor.executeSync(listAssetBuilder); @@ -95,17 +102,25 @@ public static void addViewsToAsset(Long assetId, int numOfActions, AssetType ass Logger.getLogger("Value must be equal or greater than 0"); } else { for (int i = 0; i < numOfActions; i++) { - Household household = HouseholdUtils.createHousehold(1, 1, false); + int j = 1; + Household household = HouseholdUtils.createHousehold(j, j, false); HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); - Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), + + Bookmark bookmark = BookmarkUtils.addBookmark( + 0, + String.valueOf(assetId), AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0), - assetType, BookmarkActionType.FIRST_PLAY); + assetType, + BookmarkActionType.FIRST_PLAY + ); + AddBookmarkBuilder bookmarkBuilder = BookmarkService.add(bookmark) .setKs(getOperatorKs()) .setUserId(Integer.valueOf(householdUser.getUserId())); executor.executeSync(bookmarkBuilder); - HouseholdService.delete(Math.toIntExact(household.getId())); + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } } } @@ -115,15 +130,19 @@ public static void addLikesToAsset(Long assetId, int numOfActions, AssetType ass Logger.getLogger("Value must be equal or greater than 0"); } else { for (int i = 0; i < numOfActions; i++) { - Household household = HouseholdUtils.createHousehold(1, 1, false); + int j = 1; + Household household = HouseholdUtils.createHousehold(j, j, false); HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); + SocialAction socialAction = SocialUtils.getSocialAction(SocialActionType.LIKE, null, assetId, assetType, null); + AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialAction) - .setKs(BaseTest.getOperatorKs()) + .setKs(getOperatorKs()) .setUserId(Integer.valueOf(householdUser.getUserId())); executor.executeSync(addSocialActionBuilder); - HouseholdService.delete(Math.toIntExact(household.getId())); + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } } } @@ -133,15 +152,19 @@ public static void addVotesToAsset(Long assetId, int numOfActions, AssetType ass Logger.getLogger("Value must be equal or greater than 0"); } else { for (int i = 0; i < numOfActions; i++) { - Household household = HouseholdUtils.createHousehold(1, 1, false); + int j = 1; + Household household = HouseholdUtils.createHousehold(j, j, false); HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); + SocialActionRate socialActionRate = SocialUtils.getSocialActionRate(SocialActionType.RATE, null, assetId, assetType, null, rate); + AddSocialActionBuilder addSocialActionBuilder = SocialActionService.add(socialActionRate) - .setKs(BaseTest.getOperatorKs()) + .setKs(getOperatorKs()) .setUserId(Integer.valueOf(householdUser.getUserId())); executor.executeSync(addSocialActionBuilder); - HouseholdService.delete(Math.toIntExact(household.getId())); + // cleanup - delete household + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); } } } diff --git a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java index 8ccc3928d..f2d6b96e9 100644 --- a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java @@ -5,14 +5,16 @@ import com.kaltura.client.services.AssetService; import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; -import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.ChannelType; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; + import java.util.ArrayList; import java.util.List; import java.util.Optional; + +import static com.kaltura.client.test.tests.BaseTest.executor; import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; public class SubscriptionUtils extends BaseUtils { @@ -31,9 +33,9 @@ public static List getAssetsListBySubscription(int subscriptionId, Option pager.setPageSize(numOfPages.get()); pager.setPageIndex(1); - assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter, pager).setKs(getOperatorKs())); + assetListResponse = executor.executeSync(AssetService.list(filter, pager).setKs(getOperatorKs())); } else { - assetListResponse = BaseTest.executor.executeSync(AssetService.list(filter).setKs(getOperatorKs())); + assetListResponse = executor.executeSync(AssetService.list(filter).setKs(getOperatorKs())); } List assets = assetListResponse.results.getObjects(); @@ -73,7 +75,7 @@ public static List getChannelsListBySubscription(String subscriptio SubscriptionFilter filter = new SubscriptionFilter(); filter.setSubscriptionIdIn(subscriptionId); ListSubscriptionBuilder listSubscriptionBuilder = SubscriptionService.list(filter); - Response> listResponse = BaseTest.executor.executeSync(listSubscriptionBuilder.setKs(getOperatorKs())); + Response> listResponse = executor.executeSync(listSubscriptionBuilder.setKs(getOperatorKs())); Verify.verify(listResponse.results.getObjects().get(0).getChannels().size() > 0); return listResponse.results.getObjects().get(0).getChannels(); } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index e25e53c99..58a671fcd 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.utils.dbUtils; import com.google.common.base.Strings; -import static com.kaltura.client.test.tests.BaseTest.*; import com.kaltura.client.Logger; import com.kaltura.client.enums.SubscriptionDependencyType; import com.kaltura.client.services.ChannelService; @@ -14,9 +13,10 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.json.JSONArray; + import java.sql.SQLException; -import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; -import static com.kaltura.client.test.tests.BaseTest.partnerId; + +import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; import static com.kaltura.client.test.utils.dbUtils.DBUtils.ERROR_MESSAGE; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getJsonArrayFromQueryResult; @@ -44,7 +44,6 @@ public static PriceDetails loadPriceCode(Double priceAmount, String currency) { return null; } - public static DiscountModule loadDiscount(Double discountPrice, Double discountPercent) { Logger.getLogger(IngestFixtureData.class).debug("loadDiscount(): discountPrice = " + discountPrice + " discountPercent = " + discountPercent); DiscountModule result = null; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 43fddd603..45fe2f586 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -207,12 +207,12 @@ private static String buildIngestVodXml(String action, String coguid, boolean is Element metasElement = (Element) media.getElementsByTagName("metas").item(0); for (Map.Entry> entry : tags.entrySet()) { // meta node - generateAndAppendMetaNode(doc, metasElement, entry.getKey()); + Element metaElement = generateAndAppendMetaNode(doc, metasElement, entry.getKey()); if (entry.getValue() != null) { // container node for (String s : entry.getValue()) { Element container = doc.createElement("container"); - metasElement.appendChild(container); + metaElement.appendChild(container); // value node Element value = doc.createElement("value"); @@ -333,10 +333,8 @@ public static MediaAsset ingestVOD(String mediaType) { } public static MediaAsset updateVODName(MediaAsset asset, String name) { - MediaAsset mediaAsset = ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; + Optional o = Optional.empty(); + return ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), + o, o, o, o, o, o, o, o, o, o, o, o, o); } } From 1bef415652195f6ffe411acb9121a72ba9ab502e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 24 Jun 2018 15:17:01 +0300 Subject: [PATCH 377/605] updated to use preparedStatement logic --- .../com/kaltura/client/test/utils/dbUtils/DBConstants.java | 4 ++-- .../kaltura/client/test/utils/dbUtils/IngestFixtureData.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index be7bb987d..688184dfb 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -39,11 +39,11 @@ public class DBConstants { static final String CHANNEL_EXPRESSION_SELECT = "select t.tag_type_id as tag_name, t.value as tag_value\n" + "from [TVinci].[dbo].[tags] t, [TVinci].[dbo].[channel_tags] ct\n" + - "where ct.status=1 and t.status=1 and ct.channel_id=%d and ct.tag_id=t.id"; + "where ct.status=1 and t.status=1 and ct.channel_id=? and ct.tag_id=t.id"; static final String CHANNEL_SELECT = "select *\n" + "from [TVinci].[dbo].[channels]\n" + - "where id=%d"; + "where id=?"; static final String CHECK_IS_ACTIVATION_USERS_NEEDED = "select [IS_ACTIVATION_NEEDED]\n" + "from [Users].[dbo].[groups_parameters]\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 58a671fcd..edf539ad9 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -299,7 +299,7 @@ public static Channel getChannel(int id) { Channel channel = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHANNEL_SELECT, id), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_SELECT, true, id); if (Strings.isNullOrEmpty(jsonArray.toString())) { return channel; } @@ -319,7 +319,7 @@ public static String getAutomaticChannelExpression(int channelId) { String result = null; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(CHANNEL_EXPRESSION_SELECT, channelId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_EXPRESSION_SELECT, true, channelId); if (Strings.isNullOrEmpty(jsonArray.toString())) { return result; } From f27a30855a26d4021f67fec988a218574ac60c28 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Sun, 24 Jun 2018 17:29:27 +0300 Subject: [PATCH 378/605] Added md documintation file for SearchAssetFilterTests class --- .../SearchAssetFilterTests.md | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/test/resources/Tests documentation/SearchAssetFilterTests.md diff --git a/src/test/resources/Tests documentation/SearchAssetFilterTests.md b/src/test/resources/Tests documentation/SearchAssetFilterTests.md new file mode 100644 index 000000000..bff3a69a7 --- /dev/null +++ b/src/test/resources/Tests documentation/SearchAssetFilterTests.md @@ -0,0 +1,76 @@ +asset/action/list with KalturaSearchAssetFilter + +Inherited from KalturaPersistedFilter +------------------------------------- +* Should be tested in /searchhistory/action/list tests +name - Name for the persisted filter. +If empty, no action will be done. If has value, the filter will be saved and persisted in user's search history. + +Inherited from KalturaAssetFilter +--------------------------------- +1. dynamicOrderBy + * order by meta + * META_ASC (TODO) + * META_DESC (TODO) + +Inherited from KalturaBaseSearchAssetFilter +------------------------------------------- +2. Filter by KSQL - Search assets using various dynamic criteria +* by asset name +* by tag value +* by meta value (TODO) + +* By reserved keys + * media_id + * epg_id (EPG TODO) + * epg_channel_id (TODO) + * asset start date (TODO) + * asset end date (TODO) + * asset_type - valid values: + * media + * epg + * recording + * geo_block - only valid value is "true": When enabled, only assets that are not restricted to the user by geo-block rules will return (TODO) + * parental_rules - only valid value is "true": When enabled, only assets that the user doesn't need to provide PIN code will return (TODO) + * user_interests - only valid value is "true". When enabled, only assets that the user defined as his interests (by tags and metas) (TODO) + * entitled_assets - valid values: + * free - gets only free to watch assets(TODO) + * entitled - only those that the user is implicitly entitled to watch (TODO) + * "both" + +* Logical conjunction + * or + * and + +* Comparison operators + * For numeric fields: + * = (TODO) + * > (TODO) + * < (TODO) + * >= (edge case) + * <= (edge case) + * : (in)(edge case) + + * For alpha numeric fields: + * Any word starts with(^) + * phrase starts with(^=)(edge case) + * not (!=) + * like (~) + * Not like (!~)(edge case) + * Exists (+)(edge case) + * Not exists (!+)(edge case) + + +* limitations + * search values - 20 characters (TODO) + * entire filter - 2048 characters (Edge case) + + +KalturaSearchAssetFilter +---------------------------- +3. Filter by asset type (typeIn) - DEPRECATED (use KalturaBaseSearchAssetFilter kSql) + * specific asset type + * list of assets types (TODO) + + + From c1770dcb6cc1c82f99d0f6844e13fca74a0b00dc Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 25 Jun 2018 10:44:28 +0300 Subject: [PATCH 379/605] household purge tests --- .../kaltura/client/test/tests/BaseTest.java | 13 +- .../householdTests/HouseholdPurgeTests.java | 121 +++++-- .../OttUserLoginWithPinTests.java | 2 +- .../test/utils/dbUtils/DBConstants.java | 5 + .../client/test/utils/dbUtils/DBUtils.java | 307 +++++------------- .../test/utils/dbUtils/IngestFixtureData.java | 1 + src/test/resources/WORK_PLAN.md | 2 +- 7 files changed, 183 insertions(+), 268 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 8f6519dd4..6c3b86434 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -56,16 +56,15 @@ public class BaseTest { private static String administratorKs, operatorKs, managerKs, anonymousKs; // shared ingest users data - private static String ingestAssetUserUsername, ingestAssetUserPassword, ingestBusinessModuleUserUsername, - ingestBusinessModuleUserPassword; + private static String ingestAssetUserUsername, ingestAssetUserPassword, ingestBusinessModuleUserUsername, ingestBusinessModuleUserPassword; // shared VOD private static MediaAsset mediaAsset; - // TODO - dynamic - private static String epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); + // shared channel name + private static String epgChannelName; - //Shared EPG program + // shared EPG program private static Asset epgProgram; // shared files @@ -102,7 +101,6 @@ public class BaseTest { Shared Test Params - end ================================================================================*/ - @BeforeSuite public void baseTest_beforeSuite() { // set configuration @@ -120,6 +118,9 @@ public void baseTest_beforeSuite() { // set shared common params partnerId = Integer.parseInt(getProperty(PARTNER_ID)); defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); + + // TODO - dynamic + epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); } @BeforeMethod diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java index 2d15a6c95..eab61f8c7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java @@ -1,76 +1,125 @@ package com.kaltura.client.test.tests.servicesTests.householdTests; -import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.OttUserUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.Household; import com.kaltura.client.types.HouseholdUser; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.json.JSONObject; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.services.HouseholdService.purge; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class HouseholdPurgeTests extends BaseTest { - private Household household; - private HouseholdUser masterUser; - private String masterUserKs; +// private Household household; +// private HouseholdUser masterUser; +// private String masterUserKs; @BeforeClass private void household_purgeTests_beforeClass() { + + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/purge - active household") + @Test() + private void purge_active_household() { // set household int numberOfUsersInHousehold = 1; int numberOfDevicesInHousehold = 1; - household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - masterUser = HouseholdUtils.getMasterUser(household); + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); - // set masterUserKs - String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); - masterUserKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId()), udid); - } + // assert relevant statuses in db before purge + JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("status")).as("household purge status").isEqualTo(1); - @Severity(SeverityLevel.CRITICAL) - @Description("household/action/purge") - @Test(enabled = false) - private void purge() { - Response booleanResponse = executor.executeSync(HouseholdService.purge(Math.toIntExact(household.getId())) + JSONObject userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(1); + + // purge + Response booleanResponse = executor.executeSync(purge(Math.toIntExact(household.getId())) .setKs(getOperatorKs())); assertThat(booleanResponse.results.booleanValue()).isTrue(); - System.out.println(household.getId()); + // assert relevant statuses in db after purge + householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("status")).as("purge status").isEqualTo(2); + + userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(1); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); + + // delete household after purge + booleanResponse = executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1006).getCode()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/purge - deleted household") + @Test() + private void purge_deleted_household() { + // set household + int numberOfUsersInHousehold = 1; + int numberOfDevicesInHousehold = 1; + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + + // delete household before purge + executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + + // assert relevant statuses in db before purge + JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("status")).as("household purge status").isEqualTo(2); -// // delete devices until error 1014 return -// List devices = HouseholdUtils.getDevicesList(household); + JSONObject userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); // -// executor.executeSync(delete(devices.get(1).getUdid()).setKs(masterUserKs)); -// Response booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); -// assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(1014).getCode()); +// // purge +// Response booleanResponse = executor.executeSync(HouseholdService.purge(Math.toIntExact(household.getId())) +// .setKs(getOperatorKs())); +// assertThat(booleanResponse.results.booleanValue()).isTrue(); // -// // reset frequency for household devices -// Response householdResponse = executor.executeSync(resetFrequency(HouseholdFrequencyType.DEVICES) -// .setKs(getOperatorKs()) -// .setUserId(Integer.valueOf(masterUser.getUserId()))); -// assertThat(householdResponse.error).isNull(); -// assertThat(householdResponse.results.getId()).isEqualTo(household.getId()); +// // assert relevant statuses in db after purge +// householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); +// assertThat(householdJO.getInt("status")).as("purge status").isEqualTo(2); // -// // delete additional device to verify frequency was reset -// booleanResponse = executor.executeSync(delete(devices.get(2).getUdid()).setKs(masterUserKs)); -// assertThat(booleanResponse.results.booleanValue()).isTrue(); +// userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); +// assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(1); +// assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); // -// // assert devices list size = 1 -// devices = HouseholdUtils.getDevicesList(household); -// assertThat(devices.size()).isEqualTo(1); +// // delete household after purge +// booleanResponse = executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); +// assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1006).getCode()); + } + + @Severity(SeverityLevel.MINOR) + @Description("household/action/purge - with not exists household") + @Test() + private void purge_with_not_exists_household() { + // purge + int invalidHouseholdId = -1; + Response booleanResponse = executor.executeSync(purge(invalidHouseholdId) + .setKs(getOperatorKs())); + + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1006).getCode()); } @AfterClass private void household_purgeTests_afterClass() { - // delete household - executor.executeSync(HouseholdService.delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index 901d50c84..0ece3279f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -105,7 +105,7 @@ private void loginWithPin_with_expired_pinCode_after() { .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(() -> { - long expire = userLoginPinResponse.results.getExpirationTime() + 70; + long expire = userLoginPinResponse.results.getExpirationTime() + 120; long now = BaseUtils.getTimeInEpoch(0); return now > expire; }); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index be7bb987d..f36e863e3 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -180,6 +180,11 @@ public class DBConstants { static final String UNACTIVE_ASSET_ID_SELECT = "SELECT top 1 [id] FROM [TVinci].[dbo].[media] where group_id = ? and status = 2"; + static final String HOUSEHOLD_BY_ID_SELECT = "SELECT * from [Users].[dbo].[domains] where group_id = ? and ID = ?"; + + static final String USER_BY_ID_SELECT = "SELECT * from [Users].[dbo].[users] where group_id = ? and ID = ?"; + + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index dfc3b4879..3b2fdf605 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.utils.dbUtils; -import com.google.common.base.Strings; import com.kaltura.client.Logger; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.PricePlan; @@ -10,6 +9,7 @@ import org.json.JSONObject; import java.sql.*; +import java.util.Arrays; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.partnerId; @@ -19,168 +19,11 @@ public class DBUtils extends BaseUtils { + static final String ERROR_MESSAGE = "*** no data found ***"; + private static boolean isActivationNeeded = false; private static boolean isActivationNeededWasLoaded = false; - static final String ERROR_MESSAGE = "No results found"; - - public static boolean isActivationOfUsersNeeded() { - Logger.getLogger(DBUtils.class).debug("isActivationOfUsersNeeded()"); - if (isActivationNeededWasLoaded) { - return isActivationNeeded; - } - int result = -1; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(CHECK_IS_ACTIVATION_USERS_NEEDED, false, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); - return false; - } - - result = jsonArray.getJSONObject(0).getInt(IS_ACTIVATION_NEEDED); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error(IS_ACTIVATION_NEEDED + " can't be null"); - } - isActivationNeeded = result == 1; - isActivationNeededWasLoaded = true; - - return isActivationNeeded; - } - - public static String getUserData(String userRole) { - Logger.getLogger(DBUtils.class).debug("getUserData(): userRole = " + userRole); - - String sqlQuery = USER_BY_ROLE_SELECT; - if (isActivationOfUsersNeeded()) { - sqlQuery += AND_ACTIVE_STATUS; - } - String userdData = ""; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(sqlQuery, false, userRole, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); - return null; - } - - userdData = jsonArray.getJSONObject(0).getString(USERNAME) + ":" + - jsonArray.getJSONObject(0).getString(PASSWORD); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("username/password can't be null"); - } - - return userdData; - } - - public static String getActivationToken(String username) { - Logger.getLogger(DBUtils.class).debug("getActivationToken(): username = " + username); - String activationToken = null; - - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(ACTIVATION_TOKEN_SELECT, false, username); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); - return null; - } - - activationToken = jsonArray.getJSONObject(0).getString(ACTIVATION_TOKEN); - } catch (Exception e) { - e.printStackTrace(); - } - - return activationToken; - } - - public static String getResetPasswordToken(String username) { - String resetPasswordToken = null; - - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(RESET_PASSWORD_TOKEN_SELECT, false, username); - resetPasswordToken = jsonArray.getJSONObject(0).getString(CP_TOKEN); - } catch (Exception e) { - e.printStackTrace(); - } - - return resetPasswordToken; - } - - // Get epg channel name and linear asset id json array - public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { - JSONArray jsonArray = null; - try { - jsonArray = getJsonArrayFromQueryResult(ASSET_ID_SELECT, false, Integer.valueOf(getProperty(PARTNER_ID)) + 1); - if (jsonArray == null || jsonArray.length() <= 0) { - Logger.getLogger("Response is empty"); - } - } catch (Exception e) { - e.printStackTrace(); - } - return jsonArray; - } - - // Get un active asset from DB (status = 2) - public static int getUnActiveAsset() { - int assetId = 0; - - try { - assetId = getJsonArrayFromQueryResult(UNACTIVE_ASSET_ID_SELECT, false, Integer.valueOf(getProperty(PARTNER_ID)) + 1).getJSONObject(0).getInt("id"); - } catch (Exception e) { - e.printStackTrace(); - } - - return assetId; - } - - public static int getSubscriptionWithPremiumService() { - int subscriptionId = 0; - - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, false, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return subscriptionId; - } - - subscriptionId = jsonArray.getJSONObject(0).getInt(SUB_ID); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(DBUtils.class).error("data about premium services can't be null"); - } - - return subscriptionId; - } - - // Return json array from DB -// static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed) { -// SQLServerDataSource dataSource = getDataSource(); -// Connection conn = null; -// Statement stam = null; -// ResultSet rs = null; -// -// JSONArray jsonArray = null; -// -// try { -// conn = dataSource.getConnection(); -// stam = conn.createStatement(); -// rs = stam.executeQuery(query); -// -// if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { -// jsonArray = buildJsonArrayFromQueryResult(rs); -// Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); -// } else { -// Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// DbUtils.closeQuietly(rs); -// DbUtils.closeQuietly(stam); -// DbUtils.closeQuietly(conn); -// } -// -// return jsonArray; -// } - private static JSONArray buildJsonArrayFromQueryResult(ResultSet rs) throws SQLException { JSONArray jsonArray = new JSONArray(); ResultSetMetaData rsmd = rs.getMetaData(); @@ -227,7 +70,7 @@ private static JSONArray buildJsonArrayFromQueryResult(ResultSet rs) throws SQLE return jsonArray; } - private static SQLServerDataSource getDataSource(){ + private static SQLServerDataSource getDataSource() { SQLServerDataSource dataSource = new SQLServerDataSource(); dataSource.setUser(getProperty(DB_USER)); dataSource.setPassword(getProperty(DB_PASSWORD)); @@ -238,9 +81,8 @@ private static SQLServerDataSource getDataSource(){ return dataSource; } - // Return json array from DB - static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed, Object... args) { + static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed, Object... queryParams) { SQLServerDataSource dataSource = getDataSource(); Connection conn = null; PreparedStatement pstm = null; @@ -249,19 +91,20 @@ static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultA try { conn = dataSource.getConnection(); - if (args.length >0) { - pstm = preparedStatementExecution(conn, query, args); - } - else { + if (queryParams.length > 0) { + pstm = preparedStatementExecution(conn, query, queryParams); + } else { pstm = conn.prepareStatement(query); } + rs = pstm.executeQuery(); if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { jsonArray = buildJsonArrayFromQueryResult(rs); Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); } else { - Logger.getLogger(DBUtils.class).error(ERROR_MESSAGE); + // TODO: 6/25/2018 move query log once we'll have private repo + fail(ERROR_MESSAGE + "\nquery: " + query + "\nparams: " + Arrays.deepToString(queryParams)); } } catch (SQLException e) { e.printStackTrace(); @@ -279,88 +122,104 @@ private static PreparedStatement preparedStatementExecution(Connection conn, Str try { pstm = conn.prepareStatement(query); for (int i = 0; i < args.length; i++) { - switch(args[i].getClass().getSimpleName()){ + switch (args[i].getClass().getSimpleName()) { case "String": - pstm.setString(i+1, (String) args[i]); + pstm.setString(i + 1, (String) args[i]); break; case "Integer": - pstm.setInt(i+1, (int) args[i]); + pstm.setInt(i + 1, (int) args[i]); break; case "Double": - pstm.setDouble(i+1, (double) args[i]); + pstm.setDouble(i + 1, (double) args[i]); break; case "Long": - pstm.setLong(i+1, (long) args[i]); + pstm.setLong(i + 1, (long) args[i]); break; default: - Logger.getLogger(DBUtils.class).error("No valid type found!"); fail("No valid type found!"); break; } } - - } catch (SQLException e){ + } catch (SQLException e) { e.printStackTrace(); } return pstm; } - public static PricePlan loadPPWithWaiver() { - Logger.getLogger(IngestFixtureData.class).debug("loadPPWithWaiver()"); - PricePlan pricePlan = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITH_WAVER_SELECT, true, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return pricePlan; - } + // queries + public static boolean isActivationOfUsersNeeded() { + if (isActivationNeededWasLoaded) { + return isActivationNeeded; + } - pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); + JSONArray jsonArray = getJsonArrayFromQueryResult(CHECK_IS_ACTIVATION_USERS_NEEDED, false, partnerId); + int result = jsonArray.getJSONObject(0).getInt(IS_ACTIVATION_NEEDED); + + isActivationNeeded = result == 1; + isActivationNeededWasLoaded = true; + + return isActivationNeeded; + } + + public static String getUserData(String userRole) { + String sqlQuery = USER_BY_ROLE_SELECT; + + if (isActivationOfUsersNeeded()) { + sqlQuery += AND_ACTIVE_STATUS; } - return pricePlan; + + JSONArray jsonArray = getJsonArrayFromQueryResult(sqlQuery, false, userRole, partnerId); + return jsonArray.getJSONObject(0).getString(USERNAME) + ":" + jsonArray.getJSONObject(0).getString(PASSWORD); } - public static PricePlan loadPPWithoutWaiver() { - Logger.getLogger(IngestFixtureData.class).debug("loadPPWithoutWaiver()"); - PricePlan pricePlan = null; + public static String getActivationToken(String username) { + return getJsonArrayFromQueryResult(ACTIVATION_TOKEN_SELECT, false, username) + .getJSONObject(0) + .getString(ACTIVATION_TOKEN); + } - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITHOUT_WAVER_SELECT, true, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return pricePlan; - } + public static String getResetPasswordToken(String username) { + return getJsonArrayFromQueryResult(RESET_PASSWORD_TOKEN_SELECT, false, username) + .getJSONObject(0) + .getString(CP_TOKEN); + } - pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); - } - return pricePlan; + // Get epg channel name and linear asset id json array + public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { + return getJsonArrayFromQueryResult(ASSET_ID_SELECT, false, partnerId + 1); + } + + // Get un active asset from DB (status = 2) + public static int getUnActiveAsset() { + return getJsonArrayFromQueryResult(UNACTIVE_ASSET_ID_SELECT, false, partnerId + 1) + .getJSONObject(0) + .getInt("id"); + } + + public static int getSubscriptionWithPremiumService() { + return getJsonArrayFromQueryResult(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, false, partnerId) + .getJSONObject(0) + .getInt(SUB_ID); } + public static PricePlan loadPPWithWaiver() { + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITH_WAVER_SELECT, true, partnerId); + return loadFirstPricePlanFromJsonArray(jsonArray); + } + + public static PricePlan loadPPWithoutWaiver() { + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITHOUT_WAVER_SELECT, true, partnerId); + return loadFirstPricePlanFromJsonArray(jsonArray); + } + + public static JSONObject getHouseholdById(int householdId) { + return getJsonArrayFromQueryResult(HOUSEHOLD_BY_ID_SELECT, false, partnerId, householdId) + .getJSONObject(0); + } -// private static void openConnection() { -// SQLServerDataSource dataSource = getDataSource(); -// -// try { -// conn = dataSource.getConnection(); -// stam = conn.createStatement(); -// } catch (SQLException e) { -// e.printStackTrace(); -// } -// } -// -// static void closeConnection() { -// DbUtils.closeQuietly(rs); -// DbUtils.closeQuietly(stam); -// DbUtils.closeQuietly(conn); -// } - -// static void prepareCall(String sql) throws SQLException { -// openConnection(); -// cStmt = conn.prepareCall(sql); -// } + public static JSONObject getUserById(int userId) { + return getJsonArrayFromQueryResult(USER_BY_ID_SELECT, false, partnerId, userId) + .getJSONObject(0); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 58a671fcd..1398937ea 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -23,6 +23,7 @@ public class IngestFixtureData extends BaseUtils { + // TODO: 6/25/2018 Max please update methods by removing try catch and if statements (see example in DBUtils class) public static PriceDetails loadPriceCode(Double priceAmount, String currency) { Logger.getLogger(IngestFixtureData.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); try { diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 0d3f5ec22..9dc660a27 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -44,7 +44,7 @@ Migrate features tests from ReadyAPI | favorite | | | followTvSeries | | | homeNetwork | | -| household | Alon - in progress, actions: add - done, delete - done, get - done, suspend - done, resume - done, resetFrequency - done, update, purge | +| household | Alon - in progress, actions: purge | | householdDevice | | | householdLimitations | | | householdPaymentGateway | | From 7bf436cb8d0839818224d77640d3b2291a1de9df Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 25 Jun 2018 12:36:37 +0300 Subject: [PATCH 380/605] household purge tests --- .../householdTests/HouseholdPurgeTests.java | 247 +++++++++++++++--- src/test/resources/WORK_PLAN.md | 2 +- 2 files changed, 210 insertions(+), 39 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java index eab61f8c7..30470d6f2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java @@ -1,5 +1,8 @@ package com.kaltura.client.test.tests.servicesTests.householdTests; +import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.services.HouseholdUserService; +import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; @@ -10,8 +13,6 @@ import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.json.JSONObject; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.HouseholdService.delete; @@ -21,28 +22,22 @@ public class HouseholdPurgeTests extends BaseTest { -// private Household household; -// private HouseholdUser masterUser; -// private String masterUserKs; + private final int numberOfUsersInHousehold = 1; + private final int numberOfDevicesInHousehold = 1; - @BeforeClass - private void household_purgeTests_beforeClass() { - - } @Severity(SeverityLevel.CRITICAL) @Description("household/action/purge - active household") @Test() private void purge_active_household() { // set household - int numberOfUsersInHousehold = 1; - int numberOfDevicesInHousehold = 1; Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // assert relevant statuses in db before purge JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); - assertThat(householdJO.getInt("status")).as("household purge status").isEqualTo(1); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(0); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(1); JSONObject userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); @@ -55,7 +50,8 @@ private void purge_active_household() { // assert relevant statuses in db after purge householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); - assertThat(householdJO.getInt("status")).as("purge status").isEqualTo(2); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(1); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(1); @@ -71,8 +67,6 @@ private void purge_active_household() { @Test() private void purge_deleted_household() { // set household - int numberOfUsersInHousehold = 1; - int numberOfDevicesInHousehold = 1; Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); @@ -81,28 +75,210 @@ private void purge_deleted_household() { // assert relevant statuses in db before purge JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); - assertThat(householdJO.getInt("status")).as("household purge status").isEqualTo(2); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(0); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); JSONObject userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); -// -// // purge -// Response booleanResponse = executor.executeSync(HouseholdService.purge(Math.toIntExact(household.getId())) -// .setKs(getOperatorKs())); -// assertThat(booleanResponse.results.booleanValue()).isTrue(); -// -// // assert relevant statuses in db after purge -// householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); -// assertThat(householdJO.getInt("status")).as("purge status").isEqualTo(2); -// -// userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); -// assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(1); -// assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); -// -// // delete household after purge -// booleanResponse = executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); -// assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1006).getCode()); + + // purge + Response booleanResponse = executor.executeSync(purge(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert relevant statuses in db after purge + householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(1); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); + + userJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(1); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); + + // delete household after purge + booleanResponse = executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1006).getCode()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/purge - after deleting user") + @Test() + private void purge_after_delete_user() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); + + // delete user before purge + executor.executeSync(OttUserService.delete() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(user.getUserId()))); + + // assert relevant statuses in db before purge + JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(0); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(1); + + JSONObject masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(0); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(1); + + JSONObject userJO = DBUtils.getUserById(Integer.parseInt(user.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); + + // purge + Response booleanResponse = executor.executeSync(purge(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert relevant statuses in db after purge + householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(1); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); + + masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(1); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(2); + + userJO = DBUtils.getUserById(Integer.parseInt(user.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/purge - after removing user from household") + @Test() + private void purge_after_remove_user_from_household() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); + + // remove user from household before purge + executor.executeSync(HouseholdUserService.delete(user.getUserId()) + .setKs(getOperatorKs())); + + // assert relevant statuses in db before purge + JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(0); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(1); + + JSONObject masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(0); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(1); + + JSONObject userJO = DBUtils.getUserById(Integer.parseInt(user.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(1); + + // purge + Response booleanResponse = executor.executeSync(purge(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert relevant statuses in db after purge + householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(1); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); + + masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(1); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(2); + + userJO = DBUtils.getUserById(Integer.parseInt(user.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(1); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/purge - on suspended household") + @Test() + private void purge_on_suspended_household() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + + // suspend household before purge + executor.executeSync(HouseholdService.suspend() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(masterUser.getUserId()))); + + // assert relevant statuses in db before purge + JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(0); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(1); + assertThat(householdJO.getInt("is_suspended")).as("household suspend status").isEqualTo(1); + + JSONObject masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(0); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(1); + + // purge + Response booleanResponse = executor.executeSync(purge(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert relevant statuses in db after purge + householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(1); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); + assertThat(householdJO.getInt("is_suspended")).as("household suspend status").isEqualTo(1); + + masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(1); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(2); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("household/action/purge - after deleting user and household") + @Test() + private void purge_after_delete_user_and_household() { + // set household + Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); + HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); + + // delete user before purge + executor.executeSync(OttUserService.delete() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(user.getUserId()))); + + // delete household before purge + executor.executeSync(HouseholdService.delete(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + + // assert relevant statuses in db before purge + JSONObject householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(0); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); + + JSONObject masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(0); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(2); + + JSONObject userJO = DBUtils.getUserById(Integer.parseInt(user.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(0); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); + + // purge + Response booleanResponse = executor.executeSync(purge(Math.toIntExact(household.getId())) + .setKs(getOperatorKs())); + assertThat(booleanResponse.results.booleanValue()).isTrue(); + + // assert relevant statuses in db after purge + householdJO = DBUtils.getHouseholdById(Math.toIntExact(household.getId())); + assertThat(householdJO.getInt("purge")).as("household purge status").isEqualTo(1); + assertThat(householdJO.getInt("status")).as("household delete status").isEqualTo(2); + + masterUserJO = DBUtils.getUserById(Integer.parseInt(masterUser.getUserId())); + assertThat(masterUserJO.getInt("purge")).as("master user purge status").isEqualTo(1); + assertThat(masterUserJO.getInt("status")).as("master user delete status").isEqualTo(2); + + userJO = DBUtils.getUserById(Integer.parseInt(user.getUserId())); + assertThat(userJO.getInt("purge")).as("user purge status").isEqualTo(1); + assertThat(userJO.getInt("status")).as("user delete status").isEqualTo(2); } @Severity(SeverityLevel.MINOR) @@ -117,9 +293,4 @@ private void purge_with_not_exists_household() { assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(1006).getCode()); } - - @AfterClass - private void household_purgeTests_afterClass() { - - } } diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 9dc660a27..e05616bae 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -44,7 +44,7 @@ Migrate features tests from ReadyAPI | favorite | | | followTvSeries | | | homeNetwork | | -| household | Alon - in progress, actions: purge | +| household | Done | | householdDevice | | | householdLimitations | | | householdPaymentGateway | | From a49f2d991ca9cf29f0a10cc2ac8ef6e101479f01 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 25 Jun 2018 14:39:56 +0300 Subject: [PATCH 381/605] Removed useless parameter boolean isNullResultAllowed and useless calls of Strings.isNullOrEmpty(jsonArray.toString())) { --- .../client/test/utils/dbUtils/DBUtils.java | 35 +- .../test/utils/dbUtils/IngestFixtureData.java | 320 +++++------------- 2 files changed, 106 insertions(+), 249 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 3b2fdf605..3f811b209 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -6,6 +6,7 @@ import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import java.sql.*; @@ -82,7 +83,7 @@ private static SQLServerDataSource getDataSource() { } // Return json array from DB - static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultAllowed, Object... queryParams) { + static JSONArray getJsonArrayFromQueryResult(String query, Object... queryParams) { SQLServerDataSource dataSource = getDataSource(); Connection conn = null; PreparedStatement pstm = null; @@ -99,7 +100,7 @@ static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultA rs = pstm.executeQuery(); - if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { + if (rs != null && rs.isBeforeFirst()) { jsonArray = buildJsonArrayFromQueryResult(rs); Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); } else { @@ -153,7 +154,7 @@ public static boolean isActivationOfUsersNeeded() { return isActivationNeeded; } - JSONArray jsonArray = getJsonArrayFromQueryResult(CHECK_IS_ACTIVATION_USERS_NEEDED, false, partnerId); + JSONArray jsonArray = getJsonArrayFromQueryResult(CHECK_IS_ACTIVATION_USERS_NEEDED, partnerId); int result = jsonArray.getJSONObject(0).getInt(IS_ACTIVATION_NEEDED); isActivationNeeded = result == 1; @@ -169,57 +170,61 @@ public static String getUserData(String userRole) { sqlQuery += AND_ACTIVE_STATUS; } - JSONArray jsonArray = getJsonArrayFromQueryResult(sqlQuery, false, userRole, partnerId); + JSONArray jsonArray = getJsonArrayFromQueryResult(sqlQuery, userRole, partnerId); return jsonArray.getJSONObject(0).getString(USERNAME) + ":" + jsonArray.getJSONObject(0).getString(PASSWORD); } public static String getActivationToken(String username) { - return getJsonArrayFromQueryResult(ACTIVATION_TOKEN_SELECT, false, username) + return getJsonArrayFromQueryResult(ACTIVATION_TOKEN_SELECT, username) .getJSONObject(0) .getString(ACTIVATION_TOKEN); } public static String getResetPasswordToken(String username) { - return getJsonArrayFromQueryResult(RESET_PASSWORD_TOKEN_SELECT, false, username) - .getJSONObject(0) - .getString(CP_TOKEN); + try { + return getJsonArrayFromQueryResult(RESET_PASSWORD_TOKEN_SELECT, username) + .getJSONObject(0) + .getString(CP_TOKEN); + } catch (JSONException e) { + return null; + } } // Get epg channel name and linear asset id json array public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { - return getJsonArrayFromQueryResult(ASSET_ID_SELECT, false, partnerId + 1); + return getJsonArrayFromQueryResult(ASSET_ID_SELECT, partnerId + 1); } // Get un active asset from DB (status = 2) public static int getUnActiveAsset() { - return getJsonArrayFromQueryResult(UNACTIVE_ASSET_ID_SELECT, false, partnerId + 1) + return getJsonArrayFromQueryResult(UNACTIVE_ASSET_ID_SELECT, partnerId + 1) .getJSONObject(0) .getInt("id"); } public static int getSubscriptionWithPremiumService() { - return getJsonArrayFromQueryResult(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, false, partnerId) + return getJsonArrayFromQueryResult(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, partnerId) .getJSONObject(0) .getInt(SUB_ID); } public static PricePlan loadPPWithWaiver() { - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITH_WAVER_SELECT, true, partnerId); + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITH_WAVER_SELECT, partnerId); return loadFirstPricePlanFromJsonArray(jsonArray); } public static PricePlan loadPPWithoutWaiver() { - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITHOUT_WAVER_SELECT, true, partnerId); + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_WITHOUT_WAVER_SELECT, partnerId); return loadFirstPricePlanFromJsonArray(jsonArray); } public static JSONObject getHouseholdById(int householdId) { - return getJsonArrayFromQueryResult(HOUSEHOLD_BY_ID_SELECT, false, partnerId, householdId) + return getJsonArrayFromQueryResult(HOUSEHOLD_BY_ID_SELECT, partnerId, householdId) .getJSONObject(0); } public static JSONObject getUserById(int userId) { - return getJsonArrayFromQueryResult(USER_BY_ID_SELECT, false, partnerId, userId) + return getJsonArrayFromQueryResult(USER_BY_ID_SELECT, partnerId, userId) .getJSONObject(0); } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 95f182e74..b3021b788 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.utils.dbUtils; -import com.google.common.base.Strings; import com.kaltura.client.Logger; import com.kaltura.client.enums.SubscriptionDependencyType; import com.kaltura.client.services.ChannelService; @@ -13,54 +12,33 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.json.JSONArray; - -import java.sql.SQLException; - import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.ERROR_MESSAGE; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getJsonArrayFromQueryResult; public class IngestFixtureData extends BaseUtils { - // TODO: 6/25/2018 Max please update methods by removing try catch and if statements (see example in DBUtils class) public static PriceDetails loadPriceCode(Double priceAmount, String currency) { Logger.getLogger(IngestFixtureData.class).debug("loadPriceCode(): priceAmount = " + priceAmount + " currency = " + currency); - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_CODE_SELECT, true, partnerId, priceAmount, currency); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return null; - } - - PriceDetailsFilter filter = new PriceDetailsFilter(); - filter.setIdIn(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - ListPriceDetailsBuilder priceDetailsBuilder = PriceDetailsService.list(filter); - Response> priceDetailsListResponse = executor.executeSync(priceDetailsBuilder.setKs(getOperatorKs())); - - return priceDetailsListResponse.results.getObjects().get(0); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("discount code can't be null"); - } - return null; + + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_CODE_SELECT, partnerId, priceAmount, currency); + PriceDetailsFilter filter = new PriceDetailsFilter(); + filter.setIdIn(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + ListPriceDetailsBuilder priceDetailsBuilder = PriceDetailsService.list(filter); + Response> priceDetailsListResponse = executor.executeSync(priceDetailsBuilder.setKs(getOperatorKs())); + + return priceDetailsListResponse.results.getObjects().get(0); } public static DiscountModule loadDiscount(Double discountPrice, Double discountPercent) { Logger.getLogger(IngestFixtureData.class).debug("loadDiscount(): discountPrice = " + discountPrice + " discountPercent = " + discountPercent); - DiscountModule result = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, true, partnerId, discountPrice, discountPercent); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; - } - result = new DiscountModule(); - result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - result.setToken(NAME, jsonArray.getJSONObject(0).getString(CODE)); - result.setPercent(discountPercent); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("discount code can't be null"); - } + + JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PRICE_AND_PERCENT_SELECT, partnerId, discountPrice, discountPercent); + DiscountModule result = new DiscountModule(); + result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + result.setToken(NAME, jsonArray.getJSONObject(0).getString(CODE)); + result.setPercent(discountPercent); + return result; } @@ -68,26 +46,11 @@ public static PricePlan loadPricePlan(Double priceAmount, String currency, Disco Logger.getLogger(IngestFixtureData.class).debug("loadPricePlan(): priceAmount = " + priceAmount + " currency = " + currency + " discountPercent = " + discountModule.getPercent()); - PricePlan pricePlan = null; - - try { - PriceDetails priceCode = loadPriceCode(priceAmount, currency); - if (priceCode == null) { - return pricePlan; - } - - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_SELECT, true, partnerId, - Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return pricePlan; - } - - pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); - } - return pricePlan; + PriceDetails priceCode = loadPriceCode(priceAmount, currency); + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_SELECT, partnerId, + Integer.valueOf(discountModule.toParams().get("id").toString()), priceCode.getId()); + + return loadFirstPricePlanFromJsonArray(jsonArray); } static PricePlan loadFirstPricePlanFromJsonArray(JSONArray jsonArray) { @@ -102,44 +65,24 @@ static PricePlan loadFirstPricePlanFromJsonArray(JSONArray jsonArray) { public static PricePlan load5MinRenewablePricePlan() { Logger.getLogger(IngestFixtureData.class).debug("load5MinRenewablePricePlan()"); - PricePlan pricePlan = null; + JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_5_MIN_RENEW_SELECT, partnerId); - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(PRICE_PLAN_5_MIN_RENEW_SELECT, true, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return pricePlan; - } - - pricePlan = loadFirstPricePlanFromJsonArray(jsonArray); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("price plan data can't be null"); - } - return pricePlan; + return loadFirstPricePlanFromJsonArray(jsonArray); } public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { Logger.getLogger(IngestFixtureData.class).debug("loadSharedCommonSubscription(): pricePlan id = " + pricePlan.getId()); - Subscription subscription = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_SELECT, true, partnerId, - pricePlan.getId(), getSharedCommonDiscount().toParams().get("id")); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return subscription; - } - - subscription = new Subscription(); - subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); - subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); - subscription.setIsRenewable(false); - subscription.setDependencyType(SubscriptionDependencyType.BASE); - // TODO: add more data in case it needed - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("subscription data can't be null"); - } + JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_SELECT, partnerId, + pricePlan.getId(), getSharedCommonDiscount().toParams().get("id")); + + Subscription subscription = new Subscription(); + subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); + subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); + subscription.setIsRenewable(false); + subscription.setDependencyType(SubscriptionDependencyType.BASE); + return subscription; } @@ -147,190 +90,99 @@ public static Collection loadSharedCommonCollection(PricePlan pricePlan) { Logger.getLogger(IngestFixtureData.class).debug("loadSharedCommonCollection(): price_id = " + pricePlan.getPriceDetailsId() + "discount_id = " + pricePlan.getDiscountId() + "usage_module_id = " + pricePlan.getId()); - Collection collection = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(COLLECTION_SELECT, true, partnerId, - getSharedCommonDiscount().toParams().get("id"), pricePlan.getPriceDetailsId(), pricePlan.getId()); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return collection; - } - - collection = new Collection(); - collection.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - collection.setName(jsonArray.getJSONObject(0).getString(NAME)); - // TODO: add more data in case it needed - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("collection data can't be null"); - } + JSONArray jsonArray = getJsonArrayFromQueryResult(COLLECTION_SELECT, partnerId, + getSharedCommonDiscount().toParams().get("id"), pricePlan.getPriceDetailsId(), pricePlan.getId()); + Collection collection = new Collection(); + collection.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + collection.setName(jsonArray.getJSONObject(0).getString(NAME)); + // TODO: add more data in case it needed return collection; } public static String getDiscount(String currency, int percent) { Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): currency = " + currency + " percent = " + percent); - String code = ""; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT_AND_CURRENCY, false, currency, percent, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return null; - } - - code = jsonArray.getJSONObject(0).getString(CODE); - if ("".equals(code)) { - throw new SQLException(); - } - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error(CODE + " can't be null"); - } - - return code; + + JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, partnerId); + + return jsonArray.getJSONObject(0).getString(CODE); } public static DiscountModule getDiscount(int percent) { Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): percent = " + percent); - DiscountModule result = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT, false, - percent, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return null; - } - - result = new DiscountModule(); - result.setPercent((double) percent); - if ("".equals(result.toParams().get(CODE))) { - throw new SQLException(); - } - result.setToken(CODE, jsonArray.getJSONObject(0).getString(CODE)); - result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error(CODE + " can't be null"); - } + + JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT, + percent, partnerId); + DiscountModule result = new DiscountModule(); + result.setPercent((double) percent); + result.setToken(CODE, jsonArray.getJSONObject(0).getString(CODE)); + result.setToken(ID, String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + return result; } public static int getEpgChannelId(String channelName) { Logger.getLogger(IngestFixtureData.class).debug("getEpgChannelId(): channelName = " + channelName); - int epgChannelId = -1; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(EPG_CHANNEL_ID_SELECT, false, partnerId + 1, channelName); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - Logger.getLogger(IngestFixtureData.class).error(ERROR_MESSAGE); - return epgChannelId; - } - epgChannelId = jsonArray.getJSONObject(0).getInt("id"); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("epgChannelId can't be null"); - } + + JSONArray jsonArray = getJsonArrayFromQueryResult(EPG_CHANNEL_ID_SELECT, partnerId + 1, channelName); + int epgChannelId = jsonArray.getJSONObject(0).getInt("id"); return epgChannelId; } public static String getIngestItemUserData(int accountId) { Logger.getLogger(IngestFixtureData.class).debug("getIngestItemUserData(): accountId = " + accountId); - String result = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(INGEST_ITEMS_DATA_SELECT, false, accountId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; - } - - result = jsonArray.getJSONObject(0).getString(USERNAME) + ":" + - jsonArray.getJSONObject(0).getString(PASSWORD); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("data about ingest business module user can't be null"); - } - return result; + JSONArray jsonArray = getJsonArrayFromQueryResult(INGEST_ITEMS_DATA_SELECT, accountId); + + return jsonArray.getJSONObject(0).getString(USERNAME) + ":" + + jsonArray.getJSONObject(0).getString(PASSWORD); } public static Ppv loadSharedCommonPpv(PricePlan pricePlan) { Logger.getLogger(IngestFixtureData.class).debug("loadSharedCommonPpv(): pricePlan id = " + pricePlan.getId()); - Ppv ppv = null; - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(PPV_SELECT_BY_PRICE_PLAN, true, partnerId, - pricePlan.getId()); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return ppv; - } - - ppv = new Ppv(); - ppv.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - ppv.setName(jsonArray.getJSONObject(0).getString(NAME)); - ppv.setIsSubscriptionOnly(jsonArray.getJSONObject(0).getInt(SUBSCRIPTION_ONLY) == 0); - // TODO: add more data in case it needed - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("Ppv data can't be null"); - } + JSONArray jsonArray = getJsonArrayFromQueryResult(PPV_SELECT_BY_PRICE_PLAN, partnerId, + pricePlan.getId()); + Ppv ppv = new Ppv(); + ppv.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + ppv.setName(jsonArray.getJSONObject(0).getString(NAME)); + ppv.setIsSubscriptionOnly(jsonArray.getJSONObject(0).getInt(SUBSCRIPTION_ONLY) == 0); + // TODO: add more data in case it needed + return ppv; } public static Subscription loadShared5MinutesRenewableSubscription() { Logger.getLogger(IngestFixtureData.class).debug("loadShared5MinutesRenewableSubscription()"); - Subscription subscription = null; - - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_5_MIN_RENEW_SELECT, true, partnerId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return subscription; - } - - subscription = new Subscription(); - subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID)).trim()); - subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); - subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); - subscription.setIsRenewable(false); - subscription.setDependencyType(SubscriptionDependencyType.BASE); - // TODO: add more data in case it needed - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("subscription data can't be null"); - } + + JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_5_MIN_RENEW_SELECT, partnerId); + Subscription subscription = new Subscription(); + subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID)).trim()); + subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); + subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); + subscription.setIsRenewable(false); + subscription.setDependencyType(SubscriptionDependencyType.BASE); + // TODO: add more data in case it needed + return subscription; } public static Channel getChannel(int id) { Logger.getLogger(IngestFixtureData.class).debug("getChannel(): id = " + id); - Channel channel = null; - - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_SELECT, true, id); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return channel; - } - - GetChannelBuilder getChannelBuilder = ChannelService.get(jsonArray.getJSONObject(0).getInt(ID)); - Response channelResponse = executor.executeSync(getChannelBuilder.setKs(getOperatorKs())); - channel = channelResponse.results; - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("channel data can't be null"); - } - return channel; + + JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_SELECT, id); + GetChannelBuilder getChannelBuilder = ChannelService.get(jsonArray.getJSONObject(0).getInt(ID)); + Response channelResponse = executor.executeSync(getChannelBuilder.setKs(getOperatorKs())); + + return channelResponse.results; } public static String getAutomaticChannelExpression(int channelId) { Logger.getLogger(IngestFixtureData.class).debug("getAutomaticChannelExpression(): channelId = " + channelId); - String result = null; - - try { - JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_EXPRESSION_SELECT, true, channelId); - if (Strings.isNullOrEmpty(jsonArray.toString())) { - return result; - } - - result = jsonArray.getJSONObject(0).getString(TAG_TYPE) + ":" + - jsonArray.getJSONObject(0).getString(TAG_VALUE); - } catch (Exception e) { - e.printStackTrace(); - Logger.getLogger(IngestFixtureData.class).error("channel tags data can't be null"); - } - return result; + + JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_EXPRESSION_SELECT, channelId); + + return jsonArray.getJSONObject(0).getString(TAG_TYPE) + ":" + + jsonArray.getJSONObject(0).getString(TAG_VALUE); } } From facf61ebbdb887cc3e3cd4df4c6bb57d68203ac0 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 25 Jun 2018 17:01:36 +0300 Subject: [PATCH 382/605] Updated SearchAssetFilterTests md file --- .../SearchAssetFilterTests.java | 2 +- .../SearchAssetFilterTests.md | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 40c67dc0b..b71a6e01c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -207,7 +207,6 @@ private void orderVodAssetsByViews() { assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); } - //TODO - Enable test after fixing updateVodName method @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - order by NAME (DESC/ASC") @Test(enabled = false) @@ -316,6 +315,7 @@ private void orderVodAssetsByCatalogStartDate() { } //TODO - add test for KalturaPersistedFilter in searchHistory class + // EPG @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - EPG - name equal query") diff --git a/src/test/resources/Tests documentation/SearchAssetFilterTests.md b/src/test/resources/Tests documentation/SearchAssetFilterTests.md index bff3a69a7..8fb55374e 100644 --- a/src/test/resources/Tests documentation/SearchAssetFilterTests.md +++ b/src/test/resources/Tests documentation/SearchAssetFilterTests.md @@ -1,5 +1,19 @@ asset/action/list with KalturaSearchAssetFilter +Inherited from KalturaFilter +---------------------------- +1. OrderBy: + * VIEWS_DESC + * NAME_ASC + * NAME_DESC + * LIKES_DESC + * VOTES_DESC + * RATINGS_DESC + * START_DATE_DESC + * START_DATE_ASC + * RELEVANCY_DESC (edge case) + + Inherited from KalturaPersistedFilter ------------------------------------- * Should be tested in /searchhistory/action/list tests @@ -8,14 +22,14 @@ If empty, no action will be done. If has value, the filter will be saved and per Inherited from KalturaAssetFilter --------------------------------- -1. dynamicOrderBy +2. dynamicOrderBy * order by meta - * META_ASC (TODO) - * META_DESC (TODO) + * META_ASC (BEO-5254) + * META_DESC (BEO-5254) Inherited from KalturaBaseSearchAssetFilter ------------------------------------------- -2. Filter by KSQL - Search assets using various dynamic criteria +3. Filter by KSQL - Search assets using various dynamic criteria * by asset name * by tag value * by meta value (TODO) @@ -68,7 +82,7 @@ Inherited from KalturaBaseSearchAssetFilter KalturaSearchAssetFilter ---------------------------- -3. Filter by asset type (typeIn) - DEPRECATED (use KalturaBaseSearchAssetFilter kSql) +4. Filter by asset type (typeIn) - DEPRECATED (use KalturaBaseSearchAssetFilter kSql) * specific asset type * list of assets types (TODO) From 7d186c6337682006c9eab382244ff76ab24fdc45 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 25 Jun 2018 17:02:05 +0300 Subject: [PATCH 383/605] Smal tweak in inget vod overloded methods --- .../utils/ingestUtils/IngestVodUtils.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 45fe2f586..9932154a5 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -87,11 +87,11 @@ public static MediaAsset ingestVOD(Optional action, Optional cog Response resp = given() - .header(contentTypeXml) - .header(soapActionIngestTvinciData) - .body(reqBody) - .when() - .post(url); + .header(contentTypeXml) + .header(soapActionIngestTvinciData) + .body(reqBody) + .when() + .post(url); Logger.getLogger(IngestVodUtils.class).debug(reqBody); Logger.getLogger(IngestVodUtils.class).debug("Ingest response: \n" + resp.asString()); @@ -126,8 +126,8 @@ public static MediaAsset ingestVOD(Optional action, Optional cog } private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, - String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName, Map> tags, Map strings, - Map numbers, Map dates) { + String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName, Map> tags, Map strings, + Map numbers, Map dates) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password @@ -316,20 +316,16 @@ private static Callable isDataReturned(String ks, String mediaId, Strin } // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestVOD(String mediaType, Map> tags, String catalogStartDate) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), + public static MediaAsset ingestVOD(String mediaType, Map> tags, Map stringMetas, String catalogStartDate) { + return ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(catalogStartDate), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), - Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; + Optional.of(tags), Optional.of(stringMetas), Optional.empty(), Optional.empty()); } public static MediaAsset ingestVOD(String mediaType) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), + return ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; } public static MediaAsset updateVODName(MediaAsset asset, String name) { From 102296292cf96abc30eda46a0f3e7f42c829b866 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 25 Jun 2018 17:02:23 +0300 Subject: [PATCH 384/605] Added new test to SearchAssetFilterTests class --- .../SearchAssetFilterTests.java | 88 +++++++++++++++---- 1 file changed, 69 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index b71a6e01c..09471d2ae 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -2,6 +2,7 @@ import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; @@ -9,6 +10,7 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.json.JSONArray; @@ -33,16 +35,19 @@ public class SearchAssetFilterTests extends BaseTest { - private final String tagName = "Genre"; - private MediaAsset asset; private MediaAsset asset2; private MediaAsset asset3; private ProgramAsset program; private ProgramAsset program2; + private final String tagName = "Genre"; + private String tagValue; + private final String metaName = "synopsis"; + private String metaValue1 = "A" + getRandomValue("_", 999999); + private String metaValue2 = "B" + getRandomValue("_", 999999); private String ksqlQuery; private AssetFilter assetFilter; - private String tagValue; + @BeforeClass private void asset_list_before_class() { @@ -52,23 +57,31 @@ private void asset_list_before_class() { ArrayList list = new ArrayList<>(); list.add(tagValue); - HashMap> map = new HashMap<>(); - map.put(tagName, list); + HashMap> tagMap = new HashMap<>(); + tagMap.put(tagName, list); + + HashMap stringMetaMap1 = new HashMap<>(); + stringMetaMap1.put(metaName, metaValue1); + + HashMap stringMetaMap2 = new HashMap<>(); + stringMetaMap2.put(metaName, metaValue2); JSONArray ja = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray(); String epgChannelName = ja.getJSONObject(0).getString("name"); String epgChannelName2 = ja.getJSONObject(1).getString("name"); asset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); - asset2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, getTimeInDate(-100)); - asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, getTimeInDate(-10)); + asset2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE, tagMap, stringMetaMap1, getTimeInDate(-100)); + asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, tagMap, stringMetaMap2, getTimeInDate(-10)); program = IngestEpgUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestEpgUtils.ingestEPG(epgChannelName2, 1).get(0); } - // VOD + // Filter by KSQL + // ********************* + @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - VOD - name equal query") + @Description("asset/action/list - VOD - filter by asset name") @Test private void listVodAssetsWithExactKsqlQuery() { ksqlQuery = "name = '" + asset.getName() + "'"; @@ -82,9 +95,9 @@ private void listVodAssetsWithExactKsqlQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - VOD - id equal query") + @Description("Reserved key: asset/action/list - VOD - filter by media_id") @Test - private void listVodAssetsWithExactKsqlQuery2() { + private void listVodAssetsByMediaId() { ksqlQuery = "media_id = '" + asset.getId() + "'"; assetFilter = getSearchAssetFilter(ksqlQuery); @@ -96,7 +109,22 @@ private void listVodAssetsWithExactKsqlQuery2() { } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - VOD - OR query") + @Description("asset/action/list - VOD - filter by meta") + @Test + private void listVodAssetsByMeta() { + ksqlQuery = "" + metaName + " = '" + metaValue1 + "'"; + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); + } + + + @Severity(SeverityLevel.CRITICAL) + @Description("Logical conjunction: asset/action/list - VOD - OR query") @Test private void listVodAssetsWithOrQuery() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')"; @@ -111,7 +139,7 @@ private void listVodAssetsWithOrQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - VOD - AND query") + @Description("Logical conjunction: asset/action/list - VOD - AND query") @Test private void listVodAssetsWithAndQuery() { ksqlQuery = "(and media_id = '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; @@ -125,7 +153,7 @@ private void listVodAssetsWithAndQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - VOD - not query") + @Description("Alpha numeric field: asset/action/list - VOD - not query") @Test private void listVodAssetsWithNotKsqlQuery() { ksqlQuery = "(and media_id != '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; @@ -139,7 +167,7 @@ private void listVodAssetsWithNotKsqlQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - VOD - like query") + @Description("Alpha numeric field: asset/action/list - VOD - like query") @Test private void listVodAssetsWithLikeKsqlQuery() { ksqlQuery = "" + tagName + " ~ '" + tagValue + "'"; @@ -156,7 +184,7 @@ private void listVodAssetsWithLikeKsqlQuery() { } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - VOD - start with query") + @Description("Alpha numeric field: asset/action/list - VOD - start with query") @Test private void listVodAssetsWithStartWithKsqlQuery() { ksqlQuery = "" + tagName + " ^ '" + tagValue + "'"; @@ -176,8 +204,8 @@ private void listVodAssetsWithStartWithKsqlQuery() { @Description("asset/action/list - VOD - filtered by type (Movie)") @Test private void listVodAssetsFilteredByType() { - ksqlQuery = "" + tagName + " = '" + tagValue + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, getProperty(MOVIE_MEDIA_TYPE_ID), null, null, null, null); + ksqlQuery = "(and " + tagName + " = '" + tagValue + "' asset_type = '" + getProperty(MOVIE_MEDIA_TYPE_ID) + "')"; + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, null); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -267,7 +295,7 @@ private void orderVodAssetsByVotesAndRating() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); - ListAssetBuilder listAssetBuilder = list(assetFilter) + ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); @@ -314,9 +342,31 @@ private void orderVodAssetsByCatalogStartDate() { assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); } + @Issue("BEO-5254") + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - VOD - dynamicOrderBy meta (ASC/DESC") + @Test(enabled = false) + + private void dynamicOrderByMeta() { + ksqlQuery = "(and (or media_id = '" + asset2.getId() + "' media_id = '" + asset3.getId() + "') asset_type = '" + getProperty(MOVIE_MEDIA_TYPE_ID) + "')"; + DynamicOrderBy dynamicOrderBy = new DynamicOrderBy(); + dynamicOrderBy.setName(metaName); + dynamicOrderBy.setOrderBy(MetaTagOrderBy.META_ASC); + assetFilter = getSearchAssetFilter(ksqlQuery, null, null, dynamicOrderBy, null, null, null); + + ListAssetBuilder listAssetBuilder = list(assetFilter) + .setKs(getSharedMasterUserKs()); + Response> assetListResponse = executor.executeSync(listAssetBuilder); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(2); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); + assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset3.getId()); + } + + //TODO - add test for KalturaPersistedFilter in searchHistory class // EPG + // *************************************************** @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - EPG - name equal query") @Test From 64b550890cf5e1741193a109770f38e13df874fe Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 25 Jun 2018 17:37:32 +0300 Subject: [PATCH 385/605] Updated SearchAssetFilterTests.md file --- .../Tests documentation/SearchAssetFilterTests.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/resources/Tests documentation/SearchAssetFilterTests.md b/src/test/resources/Tests documentation/SearchAssetFilterTests.md index 8fb55374e..743789fcf 100644 --- a/src/test/resources/Tests documentation/SearchAssetFilterTests.md +++ b/src/test/resources/Tests documentation/SearchAssetFilterTests.md @@ -32,7 +32,7 @@ Inherited from KalturaBaseSearchAssetFilter 3. Filter by KSQL - Search assets using various dynamic criteria * by asset name * by tag value -* by meta value (TODO) +* by meta value * By reserved keys * media_id @@ -41,9 +41,10 @@ Inherited from KalturaBaseSearchAssetFilter * asset start date (TODO) * asset end date (TODO) * asset_type - valid values: - * media - * epg - * recording + * media (TODO) + * epg (TODO) + * recording (TODO) + * asset type id * geo_block - only valid value is "true": When enabled, only assets that are not restricted to the user by geo-block rules will return (TODO) * parental_rules - only valid value is "true": When enabled, only assets that the user doesn't need to provide PIN code will return (TODO) * user_interests - only valid value is "true". When enabled, only assets that the user defined as his interests (by tags and metas) (TODO) From 57afdd9bad1b359e0b0be21d17e9f881229514e5 Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Tue, 26 Jun 2018 16:49:27 +0300 Subject: [PATCH 386/605] Add additonal test to class "SearchAssetFilterTests" --- .../SearchAssetFilterTests.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 09471d2ae..d6d077b5f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -4,6 +4,8 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; @@ -20,6 +22,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Optional; import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.AssetService.list; @@ -47,6 +50,7 @@ public class SearchAssetFilterTests extends BaseTest { private String metaValue2 = "B" + getRandomValue("_", 999999); private String ksqlQuery; private AssetFilter assetFilter; + String masterUserKs; @BeforeClass @@ -75,15 +79,36 @@ private void asset_list_before_class() { asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, tagMap, stringMetaMap2, getTimeInDate(-10)); program = IngestEpgUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestEpgUtils.ingestEPG(epgChannelName2, 1).get(0); + + Household household = HouseholdUtils.createHousehold(1, 1, true); + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household); + + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(asset.getId().intValue()), Optional.empty(), Optional.empty()); + } // Filter by KSQL // ********************* + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - VOD - filter by entitled asset") + @Test + private void listVodAssetsByEntitled() { + ksqlQuery = "(and (or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "') entitled_assets = 'entitled')"; + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(masterUserKs)); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + } + + @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - filter by asset name") @Test - private void listVodAssetsWithExactKsqlQuery() { + private void listVodAssetsByAssetName() { ksqlQuery = "name = '" + asset.getName() + "'"; assetFilter = getSearchAssetFilter(ksqlQuery); @@ -112,7 +137,7 @@ private void listVodAssetsByMediaId() { @Description("asset/action/list - VOD - filter by meta") @Test private void listVodAssetsByMeta() { - ksqlQuery = "" + metaName + " = '" + metaValue1 + "'"; + ksqlQuery = "" + metaName + " = '" + metaValue1 + "'"; assetFilter = getSearchAssetFilter(ksqlQuery); Response> assetListResponse = executor.executeSync(list(assetFilter) @@ -370,7 +395,7 @@ private void dynamicOrderByMeta() { @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - EPG - name equal query") @Test - private void listEpgProgramWithExactKsqlQuery() { + private void listEpgProgramByNamr() { ksqlQuery = "name = '" + program.getName() + "'"; assetFilter = getSearchAssetFilter(ksqlQuery, null, "0", null, null, null, null); @@ -384,7 +409,7 @@ private void listEpgProgramWithExactKsqlQuery() { @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - EPG - epg channel id equal query") @Test - private void listEpgProgramWithExactKsqlQuery2() { + private void listEpgProgramByChannelId() { ksqlQuery = "epg_channel_id = '" + program.getEpgChannelId() + "'"; assetFilter = getSearchAssetFilter(ksqlQuery); From 84cef99681057d230ed0c532d615822555877aab Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 27 Jun 2018 09:44:17 +0300 Subject: [PATCH 387/605] Update SearchAssetFilterTests.md file --- .../resources/Tests documentation/SearchAssetFilterTests.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/Tests documentation/SearchAssetFilterTests.md b/src/test/resources/Tests documentation/SearchAssetFilterTests.md index 743789fcf..d66c39079 100644 --- a/src/test/resources/Tests documentation/SearchAssetFilterTests.md +++ b/src/test/resources/Tests documentation/SearchAssetFilterTests.md @@ -36,8 +36,8 @@ Inherited from KalturaBaseSearchAssetFilter * By reserved keys * media_id - * epg_id (EPG TODO) - * epg_channel_id (TODO) + * epg_id + * epg_channel_id * asset start date (TODO) * asset end date (TODO) * asset_type - valid values: @@ -85,7 +85,7 @@ KalturaSearchAssetFilter ---------------------------- 4. Filter by asset type (typeIn) - DEPRECATED (use KalturaBaseSearchAssetFilter kSql) * specific asset type - * list of assets types (TODO) + * list of assets types From 0d0c8490de7a87e9b7502827f7a0c07ad605c9cc Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Wed, 27 Jun 2018 15:57:55 +0300 Subject: [PATCH 388/605] Added new test to class - "SearchAssetFilterTests" --- .../SearchAssetFilterTests.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index d6d077b5f..b2076fb26 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -46,11 +46,12 @@ public class SearchAssetFilterTests extends BaseTest { private final String tagName = "Genre"; private String tagValue; private final String metaName = "synopsis"; + private final String metaName2 = "Short title"; private String metaValue1 = "A" + getRandomValue("_", 999999); private String metaValue2 = "B" + getRandomValue("_", 999999); private String ksqlQuery; private AssetFilter assetFilter; - String masterUserKs; + private String masterUserKs; @BeforeClass @@ -66,6 +67,7 @@ private void asset_list_before_class() { HashMap stringMetaMap1 = new HashMap<>(); stringMetaMap1.put(metaName, metaValue1); + stringMetaMap1.put(metaName2, metaValue1); HashMap stringMetaMap2 = new HashMap<>(); stringMetaMap2.put(metaName, metaValue2); @@ -90,6 +92,8 @@ private void asset_list_before_class() { // Filter by KSQL // ********************* + // TODO: 27/06/2018 - Add test that filter by Geo block after Alon will refactor the ingest util + @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - filter by entitled asset") @Test @@ -191,6 +195,21 @@ private void listVodAssetsWithNotKsqlQuery() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); } + + @Severity(SeverityLevel.CRITICAL) + @Description("Alpha numeric field: asset/action/list - VOD - with existing meta value (+)") + @Test + private void listVodAssetsWithExistingMetaValue() { + ksqlQuery = "(and (or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')" + metaName2 + "+''" + " )"; + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getSharedMasterUserKs())); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset2.getId()); + } + @Severity(SeverityLevel.CRITICAL) @Description("Alpha numeric field: asset/action/list - VOD - like query") @Test @@ -395,7 +414,7 @@ private void dynamicOrderByMeta() { @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - EPG - name equal query") @Test - private void listEpgProgramByNamr() { + private void listEpgProgramByName() { ksqlQuery = "name = '" + program.getName() + "'"; assetFilter = getSearchAssetFilter(ksqlQuery, null, "0", null, null, null, null); From 9dacedd5528098fb7e3089f2e96252c18d8b6c7b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 27 Jun 2018 16:31:24 +0300 Subject: [PATCH 389/605] added VodData wrapper object --- pom.xml | 9 +- .../kaltura/client/test/tests/BaseTest.java | 25 +-- .../SearchAssetFilterTests.java | 36 +++- .../AssetCommentListTests.java | 12 +- .../AssetHistoryCleanTests.java | 24 ++- .../AssetHistoryListTests.java | 26 ++- .../channelTests/ChannelAddTests.java | 21 +- .../EntitlementListTests.java | 22 +- .../OttUserResetPasswordTests.java | 1 - .../OttUserUpdateDynamicDataTests.java | 101 ++++++++- .../ProductPriceListTests.java | 77 ++++--- .../client/test/utils/HouseholdUtils.java | 3 +- .../client/test/utils/dbUtils/DBUtils.java | 12 +- .../utils/ingestUtils/IngestEpgUtils.java | 2 +- .../utils/ingestUtils/IngestVodUtils.java | 193 +++++++++--------- src/test/resources/WORK_PLAN.md | 2 +- 16 files changed, 370 insertions(+), 196 deletions(-) diff --git a/pom.xml b/pom.xml index 30350ab9d..23afd89b8 100644 --- a/pom.xml +++ b/pom.xml @@ -214,13 +214,20 @@ commons-dbutils 1.7 - + org.apache.commons commons-vfs2 2.2 + + org.projectlombok + lombok + 1.18.0 + provided + + diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 6c3b86434..f912c0ad8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -32,6 +32,7 @@ import static com.kaltura.client.test.utils.SubscriptionUtils.getAssetsListBySubscription; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.awaitility.Awaitility.setDefaultTimeout; public class BaseTest { @@ -314,9 +315,8 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { - mediaAsset = IngestVodUtils.ingestVOD (Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + VodData vodData = VodData.builder(INGEST_ACTION_INSERT).build(); + mediaAsset = ingestVOD (vodData); } return mediaAsset; } @@ -415,11 +415,10 @@ private static void ingestVODIntoSubscription(Subscription subscription) { } if (name != null) { // ingest VOD by name - MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); - IngestVodUtils.updateVODName(mediaAsset, name); + VodData vodData = VodData.builder(INGEST_ACTION_INSERT).build(); + MediaAsset mediaAsset = ingestVOD(vodData); + + updateVodName(mediaAsset, name); } if (tag != null) { // ingest VOD by tag @@ -427,10 +426,12 @@ private static void ingestVODIntoSubscription(Subscription subscription) { List values = new ArrayList<>(); values.add(parameters[1].replaceAll("'", "")); tags.put(tag, values); - IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(tags), Optional.empty(), - Optional.empty(), Optional.empty()); + + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .tags(tags) + .build(); + + ingestVOD(vodData); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 40c67dc0b..d73774ac1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -28,7 +27,9 @@ import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class SearchAssetFilterTests extends BaseTest { @@ -59,9 +60,28 @@ private void asset_list_before_class() { String epgChannelName = ja.getJSONObject(0).getString("name"); String epgChannelName2 = ja.getJSONObject(1).getString("name"); - asset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); - asset2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE, map, getTimeInDate(-100)); - asset3 = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE, map, getTimeInDate(-10)); + // ingest asset 1 + VodData vodData1 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .build(); + asset = ingestVOD(vodData1); + + // ingest asset 2 + VodData vodData2 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .catalogStartDate(getTimeInDate(-100)) + .tags(map) + .build(); + asset2 = ingestVOD(vodData2); + + // ingest asset 3 + VodData vodData3 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(EPISODE_MEDIA_TYPE) + .catalogStartDate(getTimeInDate(-10)) + .tags(map) + .build(); + asset3 = ingestVOD(vodData3); + program = IngestEpgUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestEpgUtils.ingestEPG(epgChannelName2, 1).get(0); } @@ -212,9 +232,9 @@ private void orderVodAssetsByViews() { @Description("asset/action/list - VOD - order by NAME (DESC/ASC") @Test(enabled = false) private void orderVodAssetsByName() { - IngestVodUtils.updateVODName(asset, "AAA"); - IngestVodUtils.updateVODName(asset2, "BBB"); - IngestVodUtils.updateVODName(asset3, "CCC"); + updateVodName(asset, "AAA"); + updateVodName(asset2, "BBB"); + updateVodName(asset3, "CCC"); ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); @@ -268,7 +288,7 @@ private void orderVodAssetsByVotesAndRating() { ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); - ListAssetBuilder listAssetBuilder = list(assetFilter) + ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); Response> assetListResponse = executor.executeSync(listAssetBuilder); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index 13698d44c..1fcacd948 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.services.AssetCommentService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; import com.kaltura.client.types.Household; @@ -15,12 +14,11 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.services.AssetCommentService.ListAssetCommentBuilder; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class AssetCommentListTests extends BaseTest { @@ -45,9 +43,11 @@ private void checkCommentsOrder() { String subHeader = "subHeader"; String text = "A lot of text"; - Long assetId = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(String.valueOf(MOVIE_MEDIA_TYPE)), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty()).getId(); + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .build(); + + Long assetId = ingestVOD(vodData).getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 75d8ac2b3..97744e103 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -8,7 +8,6 @@ import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -23,8 +22,9 @@ import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryCleanTests extends BaseTest { @@ -46,15 +46,27 @@ public class AssetHistoryCleanTests extends BaseTest { // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { // Ingest first movie asset - movie = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .build(); + + movie = ingestVOD(vodData); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - movie2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); + VodData vodData2 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .build(); + + movie2 = ingestVOD(vodData2); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE); + VodData vodData3 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(EPISODE_MEDIA_TYPE) + .build(); + + episode = ingestVOD(vodData3); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index e4dfa1bd3..20ae6bf5e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.enums.WatchStatus; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.*; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -25,8 +24,9 @@ import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { @@ -45,13 +45,27 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { // Ingest first movie asset - movie = IngestVodUtils.ingestVOD( MOVIE_MEDIA_TYPE); + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .build(); + + movie = ingestVOD(vodData); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); + // Ingest second movie asset - movie2 = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); + VodData vodData2 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .build(); + + movie2 = ingestVOD(vodData2); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); + // Ingest episode asset - episode = IngestVodUtils.ingestVOD(EPISODE_MEDIA_TYPE); + VodData vodData3 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(EPISODE_MEDIA_TYPE) + .build(); + + episode = ingestVOD(vodData3); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index f0aafdaca..e3fac1bd8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -7,7 +7,6 @@ import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.ChannelUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -22,7 +21,10 @@ import static com.kaltura.client.services.ChannelService.AddChannelBuilder; import static com.kaltura.client.services.ChannelService.DeleteChannelBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class ChannelAddTests extends BaseTest { @@ -58,17 +60,24 @@ private void addChannel() { @Description("channel/action/add - order by NAME_DESC") @Test private void checkOrderOfAssetsInChannel() { - String asset1Name = "Movie_" + BaseUtils.getCurrentDateInFormat("yyMMddHHmmss"); String asset2Name = "Episode_" + BaseUtils.getCurrentDateInFormat("yyMMddHHmmss"); // Ingest first asset - MediaAsset movieAsset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); - movieAsset = IngestVodUtils.updateVODName(movieAsset, asset1Name); + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(MOVIE_MEDIA_TYPE) + .build(); + + MediaAsset movieAsset = ingestVOD(vodData); + movieAsset = updateVodName(movieAsset, asset1Name); // Ingest second asset - MediaAsset episodeAsset = IngestVodUtils.ingestVOD(MOVIE_MEDIA_TYPE); - episodeAsset = IngestVodUtils.updateVODName(episodeAsset, asset2Name); + VodData vodData1 = VodData.builder(INGEST_ACTION_INSERT) + .mediaType(EPISODE_MEDIA_TYPE) + .build(); + + MediaAsset episodeAsset = ingestVOD(vodData1); + episodeAsset = updateVodName(episodeAsset, asset2Name); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index 33b892db2..d2e5deee2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -10,7 +10,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.PurchaseUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -25,6 +24,9 @@ import static com.kaltura.client.enums.EntitlementOrderBy.PURCHASE_DATE_ASC; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementListTests extends BaseTest { @@ -196,10 +198,10 @@ public void entitlementListAfterForceCancel() { public void entitlementListWithPaging() { PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); - MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + + VodData vodData = VodData.builder(INGEST_ACTION_INSERT).build(); + MediaAsset mediaAsset = ingestVOD(vodData); + int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(mediaAsset.getId())), Optional.of(mediaFileId), Optional.empty()); @@ -237,11 +239,13 @@ public void entitlementListWithPaging() { executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); forceCancelEntitlementBuilder = EntitlementService.forceCancel(mediaFileId, TransactionType.PPV); executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); + // delete media - IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + vodData + .setAction(INGEST_ACTION_DELETE) + .setName(mediaAsset.getName()); + + ingestVOD(vodData); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java index 5838e408c..e01eac159 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResetPasswordTests.java @@ -20,7 +20,6 @@ public class OttUserResetPasswordTests extends BaseTest { - @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resetPassword - resetPassword") @Test() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java index 5f638e4ea..5dfbffd50 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserUpdateDynamicDataTests.java @@ -1,10 +1,11 @@ package com.kaltura.client.test.tests.servicesTests.ottUserTests; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.OTTUser; -import com.kaltura.client.types.OTTUserDynamicData; -import com.kaltura.client.types.StringValue; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; @@ -26,8 +27,8 @@ private void updateDynamicData() { OTTUser user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; // set dynamic data - String keyString = "key1"; - String valueString = "value1"; + String keyString = BaseUtils.getRandomString(); + String valueString = BaseUtils.getRandomString(); StringValue value = new StringValue(); value.setValue(valueString); @@ -43,7 +44,97 @@ private void updateDynamicData() { assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo(keyString); assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo(valueString); + // get user + Response ottUserResponse = executor.executeSync(OttUserService.get() + .setKs(getOperatorKs()) + .setUserId(Integer.valueOf(user.getId()))); + + // assert get user data + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results.getDynamicData()).isNotNull(); + assertThat(ottUserResponse.results.getDynamicData().get(keyString).getValue()).isEqualTo(valueString); + // cleanup executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); } + + @Severity(SeverityLevel.CRITICAL) + @Description("ottUser/action/updateDynamicData - with masterUser ks") + @Test + private void updateDynamicData_with_masterUser_ks() { + // set household + int numOfUsers = 1; + int numOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, false); + String masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household); + + // set dynamic data + String keyString = BaseUtils.getRandomString(); + String valueString = BaseUtils.getRandomString(); + + StringValue value = new StringValue(); + value.setValue(valueString); + + // update user dynamic data + Response ottUserDynamicDataResponse = + executor.executeSync(OttUserService.updateDynamicData(keyString, value) + .setKs(masterUserKs)); + + // assert new dynamic data + assertThat(ottUserDynamicDataResponse.error).isNull(); + assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo(keyString); + assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo(valueString); + + // get user + Response ottUserResponse = executor.executeSync(OttUserService.get() + .setKs(masterUserKs)); + + // assert get user data + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results.getDynamicData()).isNotNull(); + assertThat(ottUserResponse.results.getDynamicData().get(keyString).getValue()).isEqualTo(valueString); + + // cleanup + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + } + + @Severity(SeverityLevel.NORMAL) + @Description("ottUser/action/updateDynamicData - with user ks") + @Test + private void updateDynamicData_with_user_ks() { + // set household + int numOfUsers = 1; + int numOfDevices = 1; + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, false); + String userKs = HouseholdUtils.getHouseholdUserKs(household); + + // set dynamic data + String keyString = BaseUtils.getRandomString(); + String valueString = BaseUtils.getRandomString(); + + StringValue value = new StringValue(); + value.setValue(valueString); + + // update user dynamic data + Response ottUserDynamicDataResponse = + executor.executeSync(OttUserService.updateDynamicData(keyString, value) + .setKs(userKs)); + + // assert new dynamic data + assertThat(ottUserDynamicDataResponse.error).isNull(); + assertThat(ottUserDynamicDataResponse.results.getKey()).isEqualTo(keyString); + assertThat(ottUserDynamicDataResponse.results.getValue().getValue()).isEqualTo(valueString); + + // get user + Response ottUserResponse = executor.executeSync(OttUserService.get() + .setKs(userKs)); + + // assert get user data + assertThat(ottUserResponse.error).isNull(); + assertThat(ottUserResponse.results.getDynamicData()).isNotNull(); + assertThat(ottUserResponse.results.getDynamicData().get(keyString).getValue()).isEqualTo(valueString); + + // cleanup + executor.executeSync(HouseholdService.delete().setKs(userKs)); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index af9050e42..627843d68 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -14,7 +14,6 @@ import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.test.utils.ingestUtils.IngestMppUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -34,6 +33,8 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; import static org.assertj.core.api.Assertions.assertThat; public class ProductPriceListTests extends BaseTest { @@ -607,11 +608,13 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { // TODO: should we save it in Properties? double ppvPriceAfterDiscount = 33.3; // as price 37 ILS and discount is 10% - MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), - Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) + .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) + .build(); + MediaAsset mediaAsset = ingestVOD(vodData); + int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); @@ -652,11 +655,11 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); - IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), - Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + + vodData + .setAction(INGEST_ACTION_DELETE) + .setCoguid(mediaAsset.getName()); + ingestVOD(vodData); } @Severity(SeverityLevel.NORMAL) @@ -669,11 +672,12 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); - MediaAsset mediaAsset = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT), - Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) + .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) + .build(); + MediaAsset mediaAsset = ingestVOD(vodData); + int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); double ppvPriceAfterDiscount = 2; // as price 5 ILS and discount is 3 @@ -715,11 +719,11 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); - IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAsset.getName()), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), - Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + + vodData + .setAction(INGEST_ACTION_DELETE) + .setCoguid(mediaAsset.getName()); + ingestVOD(vodData); } @Severity(SeverityLevel.NORMAL) @@ -728,10 +732,11 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { public void productPriceWithPassedPpvTest() { String ppvWithExpiredDate = ";;01/01/2017 00:00:00"; String ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate + PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS + ";;"; - MediaAsset mediaAssetWith2Ppv1Expired = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + .ppvMobileName(ppvMobileModule) + .build(); + MediaAsset mediaAssetWith2Ppv1Expired = ingestVOD(vodData); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); @@ -746,10 +751,11 @@ public void productPriceWithPassedPpvTest() { mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate; - mediaAssetWith2Ppv1Expired = IngestVodUtils.ingestVOD(Optional.empty(), Optional.empty(), true, - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(ppvMobileModule), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + VodData vodData1 = VodData.builder(INGEST_ACTION_INSERT) + .ppvMobileName(ppvMobileModule) + .build(); + mediaAssetWith2Ppv1Expired = ingestVOD(vodData1); + ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); productPriceListBeforePurchase = ProductPriceService.list(ppFilter); @@ -761,12 +767,15 @@ public void productPriceWithPassedPpvTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()).isEqualTo(0); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo( mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); + // delete media - IngestVodUtils.ingestVOD(Optional.of(INGEST_ACTION_DELETE), Optional.of(mediaAssetWith2Ppv1Expired.getName()), true, Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), - Optional.of(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + vodData + .setAction(INGEST_ACTION_DELETE) + .setCoguid(mediaAssetWith2Ppv1Expired.getName()) + .setPpvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) + .setPpvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS); + + ingestVOD(vodData); } @AfterClass diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index e76648adc..7c22734ea 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -75,7 +75,8 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO if (isPreparePG) { // TODO: there should be added logic with getting and using default PG currently it all hardcoded //HouseholdPaymentGateway/action/setChargeId - SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService.setChargeID("0110151474255957105", "1234") + SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService + .setChargeID("0110151474255957105", "1234") .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getId())); executor.executeSync(setChargeIDHouseholdPaymentGatewayBuilder); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 3b2fdf605..20bac99f9 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -6,6 +6,7 @@ import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import java.sql.*; @@ -101,6 +102,7 @@ static JSONArray getJsonArrayFromQueryResult(String query, boolean isNullResultA if (rs != null && rs.isBeforeFirst() || isNullResultAllowed) { jsonArray = buildJsonArrayFromQueryResult(rs); + Logger.getLogger(DBUtils.class).debug("query: " + query + "\nparams: " + Arrays.deepToString(queryParams)); Logger.getLogger(DBUtils.class).debug("DB jsonArray: " + jsonArray.toString()); } else { // TODO: 6/25/2018 move query log once we'll have private repo @@ -180,9 +182,13 @@ public static String getActivationToken(String username) { } public static String getResetPasswordToken(String username) { - return getJsonArrayFromQueryResult(RESET_PASSWORD_TOKEN_SELECT, false, username) - .getJSONObject(0) - .getString(CP_TOKEN); + try { + return getJsonArrayFromQueryResult(RESET_PASSWORD_TOKEN_SELECT, false, username) + .getJSONObject(0) + .getString(CP_TOKEN); + } catch (JSONException e) { + return null; + } } // Get epg channel name and linear asset id json array diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 93048e7a6..6bda4ec71 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -86,7 +86,7 @@ public static List ingstEPG(String epgChannelName, Optional= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); int delayBetweenRetriesInSeconds = 5; - int maxTimeExpectingValidResponseInSeconds = 90; + int maxTimeExpectingValidResponseInSeconds = 120; await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 45fe2f586..ddcfca9b7 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -4,11 +4,19 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Data; +import lombok.Setter; +import lombok.experimental.Accessors; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @@ -26,64 +34,63 @@ public class IngestVodUtils extends BaseIngestUtils { + private static final String coguidDatePattern = "yyMMddHHmmssSS"; + + @Builder(builderMethodName = "hiddenBuilder") + @Accessors(chain = true) + @Data + public static class VodData { + private static final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value + private static final String endDateValue = "14/10/2099 17:00:00"; + private static final String datePattern = "dd/MM/yyyy hh:mm:ss"; + + private String action; +// @Setter(AccessLevel.NONE) + private String coguid; +// @Setter(AccessLevel.NONE) + private String name; + @Setter(AccessLevel.NONE) private String description; + + @Builder.Default private boolean isActive = true; + @Builder.Default private String thumbUrl = DEFAULT_THUMB; + @Builder.Default private String catalogStartDate = getOffsetDateInFormat(-1, datePattern); + @Builder.Default private String catalogEndDate = endDateValue; + @Builder.Default private String startDate = getOffsetDateInFormat(-1, datePattern); + @Builder.Default private String endDate = endDateValue; + @Builder.Default private String mediaType = MOVIE_MEDIA_TYPE; + @Builder.Default private String ppvWebName = ppvModuleName; + @Builder.Default private String ppvMobileName = ppvModuleName; + @Builder.Default private String geoBlockRule = ""; + + @Builder.Default private Map> tags = getDefaultTags(); + @Builder.Default private Map strings = getDefaultStrings(); + @Builder.Default private Map dates = getDefaultDates(); + @Builder.Default private Map numbers = getDefaultNumbers(); + + public static VodDataBuilder builder(String action) { + return hiddenBuilder().action(action); + } + } + /** * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert", "update" and "delete" - * @param coguid - should have value in case "action" one of {"update" and "delete"} - * @param isActive - * @param name - * @param thumbUrl - * @param description - * @param catalogStartDate - * @param catalogEndDate - * @param startDate - * @param endDate - * @param mediaType - * @param ppvWebName - * @param ppvMobileName - * @param tags - * @param strings - * @param numbers - * @param dates * @return to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" * (where vod is a variable that contains VOD data) - *

* !!!Only created by that method VOD can be deleted/update!!! */ - // ingest new VOD (Media) // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - public static MediaAsset ingestVOD(Optional action, Optional coguid, boolean isActive, Optional name, Optional thumbUrl, Optional description, - Optional catalogStartDate, Optional catalogEndDate, Optional startDate, Optional endDate, Optional mediaType, - Optional ppvWebName, Optional ppvMobileName, Optional>> tags, Optional> strings, - Optional> numbers, Optional> dates) { - String startEndDatePattern = "dd/MM/yyyy hh:mm:ss"; - String coguidDatePattern = "yyMMddHHmmssSS"; - String maxEndDateValue = "14/10/2099 17:00:00"; - String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value - int defaultDayOffset = -1; - - String actionValue = action.orElse(INGEST_ACTION_INSERT); - String coguidValue = coguid.orElse(getCurrentDateInFormat(coguidDatePattern)); - String nameValue = INGEST_ACTION_INSERT.equals(actionValue) ? coguidValue : name.orElse(coguidValue); - String thumbUrlValue = thumbUrl.orElse(DEFAULT_THUMB); - String descriptionValue = description.orElse("description of " + coguidValue); - String catalogStartDateValue = catalogStartDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); - String catalogEndDateValue = catalogEndDate.orElse(maxEndDateValue); - String startDateValue = startDate.orElse(getOffsetDateInFormat(defaultDayOffset, startEndDatePattern)); - String endDateValue = endDate.orElse(maxEndDateValue); - String mediaTypeValue = mediaType.orElse(MOVIE_MEDIA_TYPE); - String ppvWebNameValue = ppvWebName.orElse(ppvModuleName); - String ppvMobileNameValue = ppvMobileName.orElse(ppvModuleName); - Map> tagsValue = tags.orElse(getDefaultTags()); - Map stringsValue = strings.orElse(getDefaultStrings()); - Map numbersValue = numbers.orElse(getDefaultNumbers()); - Map datesValue = dates.orElse(getDefaultDates()); + // ingest new VOD (Media) + public static MediaAsset ingestVOD(VodData vodData) { + // TODO: complete one-by-one needed fields to cover util ingest_vod from old project // TODO: check if ingest url is the same for all ingest actions + String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - String reqBody = buildIngestVodXml(actionValue, coguidValue, isActive, nameValue, thumbUrlValue, descriptionValue, catalogStartDateValue, - catalogEndDateValue, startDateValue, endDateValue, mediaTypeValue, ppvWebNameValue, ppvMobileNameValue, tagsValue, stringsValue, numbersValue, datesValue); + vodData.coguid = getCurrentDateInFormat(coguidDatePattern); + vodData.name = vodData.getCoguid(); + vodData.description = "description of " + vodData.getCoguid(); + + String reqBody = buildIngestVodXml(vodData); Response resp = given() @@ -100,19 +107,19 @@ public static MediaAsset ingestVOD(Optional action, Optional cog assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); String id; - if (INGEST_ACTION_INSERT.equals(actionValue)) { + if (INGEST_ACTION_INSERT.equals(vodData.getAction())) { id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); } else { id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); } - if (!INGEST_ACTION_DELETE.equals(actionValue)) { + if (!INGEST_ACTION_DELETE.equals(vodData.getAction())) { int delayBetweenRetriesInSeconds = 5; - int maxTimeExpectingValidResponseInSeconds = 90; + int maxTimeExpectingValidResponseInSeconds = 120; await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(getAnonymousKs(), id, actionValue)); + .until(isDataReturned(getAnonymousKs(), id, vodData.getAction())); return (MediaAsset) executor.executeSync(get(id, AssetReferenceType.MEDIA) @@ -121,13 +128,10 @@ public static MediaAsset ingestVOD(Optional action, Optional cog } // TODO: 4/15/2018 add log for ingest and index failures - return null; } - private static String buildIngestVodXml(String action, String coguid, boolean isActive, String name, String thumbUrl, String description, String catalogStartDate, String catalogEndDate, - String startDate, String endDate, String mediaType, String ppvWebName, String ppvMobileName, Map> tags, Map strings, - Map numbers, Map dates) { + private static String buildIngestVodXml(VodData vodData) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password @@ -140,43 +144,46 @@ private static String buildIngestVodXml(String action, String coguid, boolean is // media Element media = (Element) doc.getElementsByTagName("media").item(0); - media.setAttribute("co_guid", coguid); - media.setAttribute("entry_id", "entry_" + coguid); - media.setAttribute("action", action); - media.setAttribute("is_active", Boolean.toString(isActive)); + media.setAttribute("co_guid", vodData.getCoguid()); + media.setAttribute("entry_id", "entry_" + vodData.getCoguid()); + media.setAttribute("action", vodData.getAction()); + media.setAttribute("is_active", Boolean.toString(vodData.isActive())); // name Element nameElement = (Element) media.getElementsByTagName("name").item(0); - nameElement.getElementsByTagName("value").item(0).setTextContent(name); + nameElement.getElementsByTagName("value").item(0).setTextContent(vodData.getName()); // thumb Element thumb = (Element) media.getElementsByTagName("thumb").item(0); - thumb.setAttribute("url", thumbUrl); + thumb.setAttribute("url", vodData.getThumbUrl()); // description Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); - descriptionElement.getElementsByTagName("value").item(0).setTextContent(description); + descriptionElement.getElementsByTagName("value").item(0).setTextContent(vodData.getDescription()); // dates Element datesElement = (Element) media.getElementsByTagName("dates").item(0); - datesElement.getElementsByTagName("catalog_start").item(0).setTextContent(catalogStartDate); - datesElement.getElementsByTagName("start").item(0).setTextContent(startDate); - datesElement.getElementsByTagName("catalog_end").item(0).setTextContent(catalogEndDate); - datesElement.getElementsByTagName("end").item(0).setTextContent(endDate); + datesElement.getElementsByTagName("catalog_start").item(0).setTextContent(vodData.getCatalogStartDate()); + datesElement.getElementsByTagName("start").item(0).setTextContent(vodData.getStartDate()); + datesElement.getElementsByTagName("catalog_end").item(0).setTextContent(vodData.getCatalogEndDate()); + datesElement.getElementsByTagName("end").item(0).setTextContent(vodData.getEndDate()); // pic_ratios Element picRatios = (Element) media.getElementsByTagName("pic_ratios").item(0); for (Node n : asList(picRatios.getElementsByTagName("ratio"))) { Element e = (Element) n; - e.setAttribute("thumb", thumbUrl); + e.setAttribute("thumb", vodData.getThumbUrl()); } // media type - media.getElementsByTagName("media_type").item(0).setTextContent(mediaType); + media.getElementsByTagName("media_type").item(0).setTextContent(vodData.getMediaType()); + + // geo block rule + media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.getGeoBlockRule()); // strings Element stringsElement = (Element) media.getElementsByTagName("strings").item(0); - for (Map.Entry entry : strings.entrySet()) { + for (Map.Entry entry : vodData.getStrings().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, stringsElement, entry.getKey()); @@ -189,7 +196,7 @@ private static String buildIngestVodXml(String action, String coguid, boolean is // doubles Element doublesElement = (Element) media.getElementsByTagName("doubles").item(0); - for (Map.Entry entry : numbers.entrySet()) { + for (Map.Entry entry : vodData.getNumbers().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, doublesElement, entry.getKey()); meta.setTextContent(String.valueOf(entry.getValue())); @@ -197,7 +204,7 @@ private static String buildIngestVodXml(String action, String coguid, boolean is // dates Element datesMetaElement = (Element) media.getElementsByTagName("dates").item(1); - for (Map.Entry entry : dates.entrySet()) { + for (Map.Entry entry : vodData.getDates().entrySet()) { // meta node Element metaElement = generateAndAppendMetaNode(doc, datesMetaElement, entry.getKey()); metaElement.setTextContent(entry.getValue()); @@ -205,7 +212,7 @@ private static String buildIngestVodXml(String action, String coguid, boolean is // metas Element metasElement = (Element) media.getElementsByTagName("metas").item(0); - for (Map.Entry> entry : tags.entrySet()) { + for (Map.Entry> entry : vodData.getTags().entrySet()) { // meta node Element metaElement = generateAndAppendMetaNode(doc, metasElement, entry.getKey()); if (entry.getValue() != null) { @@ -226,13 +233,13 @@ private static String buildIngestVodXml(String action, String coguid, boolean is // file types Element file1 = (Element) media.getElementsByTagName("file").item(0); file1.setAttribute("type", getProperty(WEB_FILE_TYPE)); - file1.setAttribute("co_guid", "web_" + coguid); - file1.setAttribute("PPV_MODULE", ppvWebName); + file1.setAttribute("co_guid", "web_" + vodData.getCoguid()); + file1.setAttribute("PPV_MODULE", vodData.getPpvWebName()); Element file2 = (Element) media.getElementsByTagName("file").item(1); file2.setAttribute("type", getProperty(MOBILE_FILE_TYPE)); - file2.setAttribute("co_guid", "ipad_" + coguid); - file2.setAttribute("PPV_MODULE", ppvMobileName); + file2.setAttribute("co_guid", "ipad_" + vodData.getCoguid()); + file2.setAttribute("PPV_MODULE", vodData.getPpvMobileName()); // uncomment cdata String docAsString = docToString(doc); @@ -315,26 +322,20 @@ private static Callable isDataReturned(String ks, String mediaId, Strin } } - // Provide only media type (mandatory) and media name (Optional - if not provided will generate a name) - public static MediaAsset ingestVOD(String mediaType, Map> tags, String catalogStartDate) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(catalogStartDate), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), - Optional.of(tags), Optional.empty(), Optional.empty(), Optional.empty()); - - return mediaAsset; - } - - public static MediaAsset ingestVOD(String mediaType) { - MediaAsset mediaAsset = ingestVOD(Optional.empty(), Optional.empty(), true, Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(mediaType), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + public static MediaAsset updateVodName(MediaAsset asset, String name) { + VodData vodData = VodData.builder(INGEST_ACTION_UPDATE) + .coguid(asset.getName()) + .name(name) + .build(); - return mediaAsset; + return ingestVOD(vodData); } - public static MediaAsset updateVODName(MediaAsset asset, String name) { - Optional o = Optional.empty(); - return ingestVOD(Optional.of(INGEST_ACTION_UPDATE), Optional.of(asset.getName()), true, Optional.of(name), - o, o, o, o, o, o, o, o, o, o, o, o, o); + public static void deleteVod(String coGuid) { + VodData vodData = VodData.builder(INGEST_ACTION_DELETE) + .coguid(coGuid) + .build(); + ingestVOD(vodData); + //]]> } } diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index e05616bae..69c452d16 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -175,6 +175,6 @@ Migrate features tests from ReadyAPI | 4.8 - Watched content should not be displayed in recommendations [BEO-4823] | | | 4.8 - Scheduling rule for business model change[BEO-4221] | | | 4.8 - Coupons Updates[BEO-4901] | | -| 4.8.2 - GDPR - create scripts that delete the deleted and purged HH[BEO-5010] | | +| 4.8.2 - GDPR - create scripts that delete the deleted and purged HH[BEO-5010] | Tests moved to HouseholdPurgeTests | | 4.8.2 - Multi-Geo Asset Availability Windowing | | | 4.8.2 - Master user can hide part of the linear channel[BEO-4765] | | \ No newline at end of file From 980e1b089e5857c90261f3dfad75401c1946ef47 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 28 Jun 2018 13:34:54 +0300 Subject: [PATCH 390/605] add ingestVod insert, delete and update methods --- .../utils/ingestUtils/BaseIngestUtils.java | 20 +- .../utils/ingestUtils/IngestVodUtils.java | 359 ++++++++++++------ 2 files changed, 253 insertions(+), 126 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 4973773b9..b9889f22d 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -15,17 +15,20 @@ public class BaseIngestUtils { + // urls static final Header contentTypeXml = new Header("Content-Type", "text/xml;charset=UTF-8"); static final Header soapActionIngestTvinciData = new Header("SOAPAction", "http://tempuri.org/IService/IngestTvinciData"); static final Header soapActionIngestBusinessModules = new Header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); static final Header soapActionIngestKalturaEpg = new Header("SOAPAction", "http://tempuri.org/IService/IngestKalturaEpg"); + // actions public static final String INGEST_ACTION_INSERT = "insert"; public static final String INGEST_ACTION_UPDATE = "update"; public static final String INGEST_ACTION_DELETE = "delete"; - static final Long MAX_RANDOM_VALUE = 9999999999L; - static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + // wait configuration + static final int delayBetweenRetriesInSeconds = 5; + static final int maxTimeExpectingValidResponseInSeconds = 120; // life cycles periods public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; @@ -35,6 +38,10 @@ public class BaseIngestUtils { public static final String EPISODE_MEDIA_TYPE = "Episode"; public static final String LINEAR_MEDIA_TYPE = "Linear"; + // data + static final Long MAX_RANDOM_VALUE = 9999999999L; + static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + /* // PG adapter data public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; @@ -47,7 +54,6 @@ public class BaseIngestUtils { public static final String PG_DEFAULT_PG_SETTINGS = "{}"; */ - static Document getDocument(String uri) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; @@ -88,4 +94,12 @@ static void prettyPrint(Document doc) throws Exception { tf.transform(new DOMSource(doc), new StreamResult(out)); System.out.println(out.toString()); } + + static String uncommentCdata(String docAsString) { + docAsString = docAsString + .replace("", "-->", "]]>"); + + return docAsString; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index ddcfca9b7..147787e15 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; import lombok.AccessLevel; @@ -20,6 +21,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; +import static com.google.common.base.Verify.verify; import static com.kaltura.client.services.AssetService.GetAssetBuilder; import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.test.Properties.*; @@ -34,104 +36,196 @@ public class IngestVodUtils extends BaseIngestUtils { - private static final String coguidDatePattern = "yyMMddHHmmssSS"; + private static final String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult."; + private static final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; + private static final String ingestAssetIdPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus.InternalAssetId"; - @Builder(builderMethodName = "hiddenBuilder") + + @Builder(builderMethodName = "hiddenBuilder") //builderMethodName = "hiddenBuilder" @Accessors(chain = true) + // @NoArgsConstructor @Data public static class VodData { - private static final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value - private static final String endDateValue = "14/10/2099 17:00:00"; - private static final String datePattern = "dd/MM/yyyy hh:mm:ss"; - - private String action; -// @Setter(AccessLevel.NONE) + //@Setter(AccessLevel.NONE) private String coguid; -// @Setter(AccessLevel.NONE) + // @Setter(AccessLevel.NONE) private String name; - @Setter(AccessLevel.NONE) private String description; - - @Builder.Default private boolean isActive = true; - @Builder.Default private String thumbUrl = DEFAULT_THUMB; - @Builder.Default private String catalogStartDate = getOffsetDateInFormat(-1, datePattern); - @Builder.Default private String catalogEndDate = endDateValue; - @Builder.Default private String startDate = getOffsetDateInFormat(-1, datePattern); - @Builder.Default private String endDate = endDateValue; - @Builder.Default private String mediaType = MOVIE_MEDIA_TYPE; - @Builder.Default private String ppvWebName = ppvModuleName; - @Builder.Default private String ppvMobileName = ppvModuleName; - @Builder.Default private String geoBlockRule = ""; - - @Builder.Default private Map> tags = getDefaultTags(); - @Builder.Default private Map strings = getDefaultStrings(); - @Builder.Default private Map dates = getDefaultDates(); - @Builder.Default private Map numbers = getDefaultNumbers(); + @Setter(AccessLevel.NONE) + private String description; + /// + private String action; + /// + @Builder.Default + private boolean isActive = true; + + private String thumbUrl; + private String catalogStartDate; + private String catalogEndDate; + private String startDate; + private String endDate; + private String mediaType; + private String ppvWebName; + private String ppvMobileName; + private String geoBlockRule; + + private Map> tags; + private Map strings; + private Map dates; + private Map numbers; public static VodDataBuilder builder(String action) { - return hiddenBuilder().action(action); + return hiddenBuilder(); } } /** - * IMPORTANT: please delete inserted by that method items - * @return to update or delete existed VOD use corresponded action and value vod.getName() as "coguid" - * (where vod is a variable that contains VOD data) - * !!!Only created by that method VOD can be deleted/update!!! + * IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" */ - // ingest new VOD (Media) - public static MediaAsset ingestVOD(VodData vodData) { - - // TODO: complete one-by-one needed fields to cover util ingest_vod from old project - // TODO: check if ingest url is the same for all ingest actions - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + public static MediaAsset insertVod(VodData vodData) { + final String coguidDatePattern = "yyMMddHHmmssSS"; + final String datePattern = "dd/MM/yyyy hh:mm:ss"; + final String endDateValue = "14/10/2099 17:00:00"; + final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value vodData.coguid = getCurrentDateInFormat(coguidDatePattern); - vodData.name = vodData.getCoguid(); - vodData.description = "description of " + vodData.getCoguid(); + vodData.name = vodData.coguid; - String reqBody = buildIngestVodXml(vodData); + if (vodData.thumbUrl == null) { + vodData.thumbUrl = DEFAULT_THUMB; + } + if (vodData.catalogStartDate == null) { + vodData.catalogStartDate = getOffsetDateInFormat(-1, datePattern); + } + if (vodData.catalogEndDate == null) { + vodData.catalogEndDate = endDateValue; + } + if (vodData.startDate == null) { + vodData.startDate = getOffsetDateInFormat(-1, datePattern); + } + if (vodData.endDate == null) { + vodData.endDate = endDateValue; + } + if (vodData.mediaType == null) { + vodData.mediaType = MOVIE_MEDIA_TYPE; + } + if (vodData.ppvWebName == null) { + vodData.ppvWebName = ppvModuleName; + } + if (vodData.ppvMobileName == null) { + vodData.ppvMobileName = ppvModuleName; + } + if (vodData.tags == null) { + vodData.tags = getDefaultTags(); + } + if (vodData.strings == null) { + vodData.strings = getDefaultStrings(); + } + if (vodData.dates == null) { + vodData.dates = getDefaultDates(); + } + if (vodData.numbers == null) { + vodData.numbers = getDefaultNumbers(); + } - Response resp = - given() - .header(contentTypeXml) - .header(soapActionIngestTvinciData) - .body(reqBody) - .when() - .post(url); + String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); - Logger.getLogger(IngestVodUtils.class).debug(reqBody); - Logger.getLogger(IngestVodUtils.class).debug("Ingest response: \n" + resp.asString()); + Response resp = executeIngestVodRequest(reqBody); + String id = from(resp.asString()).get(ingestAssetIdPath).toString(); - assertThat(resp).isNotNull(); - assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); + GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> (executor.executeSync(getAssetBuilder).error == null)); - String id; - if (INGEST_ACTION_INSERT.equals(vodData.getAction())) { - id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); - } else { - id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); - } + Asset asset = executor.executeSync(getAssetBuilder).results; + verify(asset.getId().toString().equals(id)); + return (MediaAsset) asset; + } - if (!INGEST_ACTION_DELETE.equals(vodData.getAction())) { - int delayBetweenRetriesInSeconds = 5; - int maxTimeExpectingValidResponseInSeconds = 120; - await() - .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) - .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(getAnonymousKs(), id, vodData.getAction())); + public static MediaAsset updateVod(String coguid, VodData vodData) { + vodData.coguid = coguid; + String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_UPDATE); + Response resp = executeIngestVodRequest(reqBody); + String id = from(resp.asString()).get(ingestAssetIdPath).toString(); - return (MediaAsset) executor.executeSync(get(id, AssetReferenceType.MEDIA) - .setKs(getAnonymousKs())) - .results; - } + GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> (executor.executeSync(getAssetBuilder).error == null)); + + Asset asset = executor.executeSync(getAssetBuilder).results; + verify(asset.getId().toString().equals(id)); + return (MediaAsset) asset; + } + + public static void deleteVod(String coguid) { + VodData vodData = VodData.builder("1").build(); + vodData.coguid = coguid; + String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_DELETE); + + Response resp = executeIngestVodRequest(reqBody); + assertThat(from(resp.asString()).getInt(ingestAssetIdPath)).isEqualTo(0); + } + + // ingest new VOD (Media) + public static MediaAsset ingestVOD(VodData vodData) { +// +// // TODO: complete one-by-one needed fields to cover util ingest_vod from old project +// // TODO: check if ingest url is the same for all ingest actions +// +// String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; +// +// vodData.coguid = getCurrentDateInFormat(coguidDatePattern); +// vodData.name = vodData.getCoguid(); +// vodData.description = "description of " + vodData.getCoguid(); +// +// String reqBody = buildIngestVodXml(vodData); +// +// Response resp = +// given() +// .header(contentTypeXml) +// .header(soapActionIngestTvinciData) +// .body(reqBody) +// .when() +// .post(url); +// +// Logger.getLogger(IngestVodUtils.class).debug(reqBody); +// Logger.getLogger(IngestVodUtils.class).debug("Ingest response: \n" + resp.asString()); +// +// assertThat(resp).isNotNull(); +// assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); +// +// String id; +// if (INGEST_ACTION_INSERT.equals(vodData.getAction())) { +// id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); +// } else { +// id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); +// } +// +// if (!INGEST_ACTION_DELETE.equals(vodData.getAction())) { +// int delayBetweenRetriesInSeconds = 5; +// int maxTimeExpectingValidResponseInSeconds = 120; +// await() +// .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) +// .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) +// .until(isDataReturned(getAnonymousKs(), id, vodData.getAction())); +// +// +// return (MediaAsset) executor.executeSync(get(id, AssetReferenceType.MEDIA) +// .setKs(getAnonymousKs())) +// .results; +// } // TODO: 4/15/2018 add log for ingest and index failures return null; } - private static String buildIngestVodXml(VodData vodData) { + private static String buildIngestVodXml(VodData vodData, String action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password @@ -146,9 +240,13 @@ private static String buildIngestVodXml(VodData vodData) { Element media = (Element) doc.getElementsByTagName("media").item(0); media.setAttribute("co_guid", vodData.getCoguid()); media.setAttribute("entry_id", "entry_" + vodData.getCoguid()); - media.setAttribute("action", vodData.getAction()); + media.setAttribute("action", action); media.setAttribute("is_active", Boolean.toString(vodData.isActive())); + if (action.equals(INGEST_ACTION_DELETE)) { + return uncommentCdata(docToString(doc)); + } + // name Element nameElement = (Element) media.getElementsByTagName("name").item(0); nameElement.getElementsByTagName("value").item(0).setTextContent(vodData.getName()); @@ -182,50 +280,58 @@ private static String buildIngestVodXml(VodData vodData) { media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.getGeoBlockRule()); // strings - Element stringsElement = (Element) media.getElementsByTagName("strings").item(0); - for (Map.Entry entry : vodData.getStrings().entrySet()) { - // meta node - Element meta = generateAndAppendMetaNode(doc, stringsElement, entry.getKey()); - - // value node - Element value = doc.createElement("value"); - value.setAttribute("lang", "eng"); - value.setTextContent(entry.getValue()); - meta.appendChild(value); + if (vodData.getStrings() != null) { + Element stringsElement = (Element) media.getElementsByTagName("strings").item(0); + for (Map.Entry entry : vodData.getStrings().entrySet()) { + // meta node + Element meta = generateAndAppendMetaNode(doc, stringsElement, entry.getKey()); + + // value node + Element value = doc.createElement("value"); + value.setAttribute("lang", "eng"); + value.setTextContent(entry.getValue()); + meta.appendChild(value); + } } // doubles - Element doublesElement = (Element) media.getElementsByTagName("doubles").item(0); - for (Map.Entry entry : vodData.getNumbers().entrySet()) { - // meta node - Element meta = generateAndAppendMetaNode(doc, doublesElement, entry.getKey()); - meta.setTextContent(String.valueOf(entry.getValue())); + if (vodData.getNumbers() != null) { + Element doublesElement = (Element) media.getElementsByTagName("doubles").item(0); + for (Map.Entry entry : vodData.getNumbers().entrySet()) { + // meta node + Element meta = generateAndAppendMetaNode(doc, doublesElement, entry.getKey()); + meta.setTextContent(String.valueOf(entry.getValue())); + } } // dates - Element datesMetaElement = (Element) media.getElementsByTagName("dates").item(1); - for (Map.Entry entry : vodData.getDates().entrySet()) { - // meta node - Element metaElement = generateAndAppendMetaNode(doc, datesMetaElement, entry.getKey()); - metaElement.setTextContent(entry.getValue()); + if (vodData.getDates() != null) { + Element datesMetaElement = (Element) media.getElementsByTagName("dates").item(1); + for (Map.Entry entry : vodData.getDates().entrySet()) { + // meta node + Element metaElement = generateAndAppendMetaNode(doc, datesMetaElement, entry.getKey()); + metaElement.setTextContent(entry.getValue()); + } } // metas - Element metasElement = (Element) media.getElementsByTagName("metas").item(0); - for (Map.Entry> entry : vodData.getTags().entrySet()) { - // meta node - Element metaElement = generateAndAppendMetaNode(doc, metasElement, entry.getKey()); - if (entry.getValue() != null) { - // container node - for (String s : entry.getValue()) { - Element container = doc.createElement("container"); - metaElement.appendChild(container); - - // value node - Element value = doc.createElement("value"); - value.setTextContent(s); - value.setAttribute("lang", "eng"); - container.appendChild(value); + if (vodData.getTags() != null) { + Element metasElement = (Element) media.getElementsByTagName("metas").item(0); + for (Map.Entry> entry : vodData.getTags().entrySet()) { + // meta node + Element metaElement = generateAndAppendMetaNode(doc, metasElement, entry.getKey()); + if (entry.getValue() != null) { + // container node + for (String s : entry.getValue()) { + Element container = doc.createElement("container"); + metaElement.appendChild(container); + + // value node + Element value = doc.createElement("value"); + value.setTextContent(s); + value.setAttribute("lang", "eng"); + container.appendChild(value); + } } } } @@ -243,11 +349,8 @@ private static String buildIngestVodXml(VodData vodData) { // uncomment cdata String docAsString = docToString(doc); - docAsString = docAsString - .replace("", "-->", "]]>"); - return docAsString; + return uncommentCdata(docAsString); } private static Element generateAndAppendMetaNode(Document doc, Element rootElement, String name) { @@ -313,6 +416,23 @@ private static Map getDefaultDates() { return dates; } + private static Response executeIngestVodRequest(String reqBody) { + Response resp = given() + .header(contentTypeXml) + .header(soapActionIngestTvinciData) + .body(reqBody) + .when() + .post(url); + + Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); + Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); + + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); + + return resp; + } + private static Callable isDataReturned(String ks, String mediaId, String action) { GetAssetBuilder getAssetBuilder = get(mediaId, AssetReferenceType.MEDIA).setKs(ks); if (INGEST_ACTION_DELETE.equals(action)) { @@ -323,19 +443,12 @@ private static Callable isDataReturned(String ks, String mediaId, Strin } public static MediaAsset updateVodName(MediaAsset asset, String name) { - VodData vodData = VodData.builder(INGEST_ACTION_UPDATE) - .coguid(asset.getName()) - .name(name) - .build(); - - return ingestVOD(vodData); - } - - public static void deleteVod(String coGuid) { - VodData vodData = VodData.builder(INGEST_ACTION_DELETE) - .coguid(coGuid) - .build(); - ingestVOD(vodData); - //]]> +// VodData vodData = VodData.builder(INGEST_ACTION_UPDATE) +// .coguid(asset.getName()) +// .name(name) +// .build(); +// +// return ingestVOD(vodData); + return null; } } From b57e00138a2ffec26122598969b5e3ed91455fa6 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 28 Jun 2018 15:15:48 +0300 Subject: [PATCH 391/605] Updated INGEST_ITEMS_DATA_SELECT --- .../java/com/kaltura/client/test/utils/dbUtils/DBConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index cee92ec6b..e4c418d9c 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -76,7 +76,7 @@ public class DBConstants { static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + "from [Tvinci].[dbo].[groups_passwords]\n" + - "where [group_id]=? order by UPDATE_DATE DESC"; + "where [group_id]=? and is_active=1 and [status]=1 order by UPDATE_DATE DESC"; static final String PPV_SELECT_BY_PRICE_PLAN = "select top 1 * from [Pricing].[dbo].[ppv_modules]\n" + "where [status]=1 and is_active=1\n" + From 0fb5d4668ff52c3ebd220ed37d58d84c8341afc1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 28 Jun 2018 17:49:21 +0300 Subject: [PATCH 392/605] finish refactor ingestVodUtils and added support for virtual vod --- .../kaltura/client/test/tests/BaseTest.java | 36 ++- .../SearchAssetFilterTests.java | 35 +-- .../AssetCommentListTests.java | 8 +- .../AssetHistoryCleanTests.java | 26 +- .../AssetHistoryListTests.java | 28 +- .../channelTests/ChannelAddTests.java | 21 +- .../EntitlementListTests.java | 15 +- .../ProductPriceListTests.java | 51 ++-- .../utils/ingestUtils/BaseIngestUtils.java | 3 +- .../utils/ingestUtils/IngestVodUtils.java | 249 +++++------------- 10 files changed, 176 insertions(+), 296 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index f912c0ad8..a68f61a74 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -274,6 +274,24 @@ public static String getIngestAssetUserPassword() { return ingestAssetUserPassword; } + public static String getIngestVirualAssetUserName() { + if (ingestAssetUserUsername == null) { + String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 2); + ingestAssetUserUsername = userInfo.split(":")[0]; + ingestAssetUserPassword = userInfo.split(":")[1]; + } + return ingestAssetUserUsername; + } + + public static String getIngestVirualAssetUserPassword() { + if (ingestAssetUserPassword == null) { + String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 2); + ingestAssetUserUsername = userInfo.split(":")[0]; + ingestAssetUserPassword = userInfo.split(":")[1]; + } + return ingestAssetUserPassword; + } + // getters for shared params public static String getAdministratorKs() { if (administratorKs == null) { @@ -315,8 +333,8 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { - VodData vodData = VodData.builder(INGEST_ACTION_INSERT).build(); - mediaAsset = ingestVOD (vodData); + VodData vodData = new VodData(); + mediaAsset = insertVod(vodData); } return mediaAsset; } @@ -415,10 +433,11 @@ private static void ingestVODIntoSubscription(Subscription subscription) { } if (name != null) { // ingest VOD by name - VodData vodData = VodData.builder(INGEST_ACTION_INSERT).build(); - MediaAsset mediaAsset = ingestVOD(vodData); + VodData vodData = new VodData(); + MediaAsset mediaAsset = insertVod(vodData); - updateVodName(mediaAsset, name); + vodData.name(name); + updateVod(mediaAsset.getName(), vodData); } if (tag != null) { // ingest VOD by tag @@ -427,11 +446,8 @@ private static void ingestVODIntoSubscription(Subscription subscription) { values.add(parameters[1].replaceAll("'", "")); tags.put(tag, values); - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) - .tags(tags) - .build(); - - ingestVOD(vodData); + VodData vodData = new VodData().tags(tags); + insertVod(vodData); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index d73774ac1..a571454e3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -27,7 +27,6 @@ import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -61,26 +60,23 @@ private void asset_list_before_class() { String epgChannelName2 = ja.getJSONObject(1).getString("name"); // ingest asset 1 - VodData vodData1 = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(MOVIE_MEDIA_TYPE) - .build(); - asset = ingestVOD(vodData1); + VodData vodData1 = new VodData() + .mediaType(MOVIE_MEDIA_TYPE); + asset = insertVod(vodData1); // ingest asset 2 - VodData vodData2 = VodData.builder(INGEST_ACTION_INSERT) + VodData vodData2 = new VodData() .mediaType(MOVIE_MEDIA_TYPE) .catalogStartDate(getTimeInDate(-100)) - .tags(map) - .build(); - asset2 = ingestVOD(vodData2); + .tags(map); + asset2 = insertVod(vodData2); // ingest asset 3 - VodData vodData3 = VodData.builder(INGEST_ACTION_INSERT) + VodData vodData3 = new VodData() .mediaType(EPISODE_MEDIA_TYPE) .catalogStartDate(getTimeInDate(-10)) - .tags(map) - .build(); - asset3 = ingestVOD(vodData3); + .tags(map); + asset3 = insertVod(vodData3); program = IngestEpgUtils.ingestEPG(epgChannelName, 1).get(0); program2 = IngestEpgUtils.ingestEPG(epgChannelName2, 1).get(0); @@ -230,11 +226,16 @@ private void orderVodAssetsByViews() { //TODO - Enable test after fixing updateVodName method @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - order by NAME (DESC/ASC") - @Test(enabled = false) + @Test(enabled = true) private void orderVodAssetsByName() { - updateVodName(asset, "AAA"); - updateVodName(asset2, "BBB"); - updateVodName(asset3, "CCC"); + VodData vodData = new VodData().name("AAA"); + updateVod(asset.getName(), vodData); + + vodData.name("BBB"); + updateVod(asset2.getName(), vodData); + + vodData.name("CCC"); + updateVod(asset3.getName(), vodData); ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index 1fcacd948..edfa75c45 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -43,11 +43,9 @@ private void checkCommentsOrder() { String subHeader = "subHeader"; String text = "A lot of text"; - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(MOVIE_MEDIA_TYPE) - .build(); - - Long assetId = ingestVOD(vodData).getId(); + VodData vodData = new VodData() + .mediaType(MOVIE_MEDIA_TYPE); + Long assetId = insertVod(vodData).getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 97744e103..159658be2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -22,9 +22,10 @@ import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryCleanTests extends BaseTest { @@ -46,27 +47,24 @@ public class AssetHistoryCleanTests extends BaseTest { // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { // Ingest first movie asset - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(MOVIE_MEDIA_TYPE) - .build(); + VodData vodData = new VodData() + .mediaType(MOVIE_MEDIA_TYPE); - movie = ingestVOD(vodData); + movie = insertVod(vodData); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - VodData vodData2 = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(MOVIE_MEDIA_TYPE) - .build(); + VodData vodData2 = new VodData() + .mediaType(MOVIE_MEDIA_TYPE); - movie2 = ingestVOD(vodData2); + movie2 = insertVod(vodData2); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - VodData vodData3 = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(EPISODE_MEDIA_TYPE) - .build(); + VodData vodData3 = new VodData() + .mediaType(EPISODE_MEDIA_TYPE); - episode = ingestVOD(vodData3); + episode = insertVod(vodData3); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 20ae6bf5e..b6d0303af 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -24,9 +24,10 @@ import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { @@ -45,27 +46,22 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { // Ingest first movie asset - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(MOVIE_MEDIA_TYPE) - .build(); - - movie = ingestVOD(vodData); + VodData vodData = new VodData() + .mediaType(MOVIE_MEDIA_TYPE); + movie = insertVod(vodData); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset - VodData vodData2 = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(MOVIE_MEDIA_TYPE) - .build(); - - movie2 = ingestVOD(vodData2); + VodData vodData2 = new VodData() + .mediaType(MOVIE_MEDIA_TYPE); + movie2 = insertVod(vodData2); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - VodData vodData3 = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(EPISODE_MEDIA_TYPE) - .build(); + VodData vodData3 = new VodData() + .mediaType(EPISODE_MEDIA_TYPE); - episode = ingestVOD(vodData3); + episode = insertVod(vodData3); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index e3fac1bd8..b4ed545ff 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -22,7 +22,6 @@ import static com.kaltura.client.services.ChannelService.DeleteChannelBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -64,20 +63,16 @@ private void checkOrderOfAssetsInChannel() { String asset2Name = "Episode_" + BaseUtils.getCurrentDateInFormat("yyMMddHHmmss"); // Ingest first asset - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(MOVIE_MEDIA_TYPE) - .build(); - - MediaAsset movieAsset = ingestVOD(vodData); - movieAsset = updateVodName(movieAsset, asset1Name); + VodData vodData = new VodData() + .name(asset1Name) + .mediaType(MOVIE_MEDIA_TYPE); + MediaAsset movieAsset = insertVod(vodData); // Ingest second asset - VodData vodData1 = VodData.builder(INGEST_ACTION_INSERT) - .mediaType(EPISODE_MEDIA_TYPE) - .build(); - - MediaAsset episodeAsset = ingestVOD(vodData1); - episodeAsset = updateVodName(episodeAsset, asset2Name); + VodData vodData1 = new VodData() + .name(asset2Name) + .mediaType(EPISODE_MEDIA_TYPE); + MediaAsset episodeAsset = insertVod(vodData1); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index d2e5deee2..0957df3bb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -23,10 +23,7 @@ import static com.kaltura.client.enums.EntitlementOrderBy.PURCHASE_DATE_ASC; import static com.kaltura.client.services.HouseholdService.delete; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementListTests extends BaseTest { @@ -199,8 +196,8 @@ public void entitlementListWithPaging() { PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(getSharedMediaAsset().getId())), Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); - VodData vodData = VodData.builder(INGEST_ACTION_INSERT).build(); - MediaAsset mediaAsset = ingestVOD(vodData); + VodData vodData = new VodData(); + MediaAsset mediaAsset = insertVod(vodData); int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(mediaAsset.getId())), @@ -241,11 +238,7 @@ public void entitlementListWithPaging() { executor.executeSync(forceCancelEntitlementBuilder.setKs(getOperatorKs()).setUserId(Integer.valueOf(masterUserId))); // delete media - vodData - .setAction(INGEST_ACTION_DELETE) - .setName(mediaAsset.getName()); - - ingestVOD(vodData); + deleteVod(mediaAsset.getName()); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 627843d68..458a04ae4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -33,8 +33,7 @@ import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestVOD; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class ProductPriceListTests extends BaseTest { @@ -609,11 +608,10 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { // TODO: should we save it in Properties? double ppvPriceAfterDiscount = 33.3; // as price 37 ILS and discount is 10% - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + VodData vodData = new VodData() .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) - .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) - .build(); - MediaAsset mediaAsset = ingestVOD(vodData); + .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS); + MediaAsset mediaAsset = insertVod(vodData); int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); @@ -656,10 +654,8 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); - vodData - .setAction(INGEST_ACTION_DELETE) - .setCoguid(mediaAsset.getName()); - ingestVOD(vodData); + // delete media + deleteVod(mediaAsset.getName()); } @Severity(SeverityLevel.NORMAL) @@ -672,11 +668,10 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) + VodData vodData = new VodData() .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) - .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) - .build(); - MediaAsset mediaAsset = ingestVOD(vodData); + .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS); + MediaAsset mediaAsset = insertVod(vodData); int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); @@ -720,10 +715,8 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); - vodData - .setAction(INGEST_ACTION_DELETE) - .setCoguid(mediaAsset.getName()); - ingestVOD(vodData); + // delete media + deleteVod(mediaAsset.getName()); } @Severity(SeverityLevel.NORMAL) @@ -733,10 +726,9 @@ public void productPriceWithPassedPpvTest() { String ppvWithExpiredDate = ";;01/01/2017 00:00:00"; String ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate + PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS + ";;"; - VodData vodData = VodData.builder(INGEST_ACTION_INSERT) - .ppvMobileName(ppvMobileModule) - .build(); - MediaAsset mediaAssetWith2Ppv1Expired = ingestVOD(vodData); + VodData vodData = new VodData() + .ppvMobileName(ppvMobileModule); + MediaAsset mediaAssetWith2Ppv1Expired = insertVod(vodData); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); @@ -751,10 +743,9 @@ public void productPriceWithPassedPpvTest() { mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate; - VodData vodData1 = VodData.builder(INGEST_ACTION_INSERT) - .ppvMobileName(ppvMobileModule) - .build(); - mediaAssetWith2Ppv1Expired = ingestVOD(vodData1); + VodData vodData1 = new VodData() + .ppvMobileName(ppvMobileModule); + mediaAssetWith2Ppv1Expired = insertVod(vodData1); ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); @@ -769,13 +760,7 @@ public void productPriceWithPassedPpvTest() { mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId()); // delete media - vodData - .setAction(INGEST_ACTION_DELETE) - .setCoguid(mediaAssetWith2Ppv1Expired.getName()) - .setPpvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) - .setPpvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS); - - ingestVOD(vodData); + deleteVod(mediaAssetWith2Ppv1Expired.getName()); } @AfterClass diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index b9889f22d..9730842da 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -35,6 +35,7 @@ public class BaseIngestUtils { // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts public static final String MOVIE_MEDIA_TYPE = "Movie"; + public static final String SERIES_MEDIA_TYPE = "Series"; public static final String EPISODE_MEDIA_TYPE = "Episode"; public static final String LINEAR_MEDIA_TYPE = "Linear"; @@ -95,7 +96,7 @@ static void prettyPrint(Document doc) throws Exception { System.out.println(out.toString()); } - static String uncommentCdata(String docAsString) { + static String uncommentCdataSection(String docAsString) { docAsString = docAsString .replace("", "-->", "]]>"); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 147787e15..8e4c74042 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -6,7 +6,6 @@ import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; import lombok.AccessLevel; -import lombok.Builder; import lombok.Data; import lombok.Setter; import lombok.experimental.Accessors; @@ -18,7 +17,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import static com.google.common.base.Verify.verify; @@ -35,30 +33,23 @@ import static org.awaitility.Awaitility.await; public class IngestVodUtils extends BaseIngestUtils { - private static final String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult."; private static final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; private static final String ingestAssetIdPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus.InternalAssetId"; - @Builder(builderMethodName = "hiddenBuilder") //builderMethodName = "hiddenBuilder" - @Accessors(chain = true) - // @NoArgsConstructor + @Accessors(fluent = true) @Data public static class VodData { - //@Setter(AccessLevel.NONE) - private String coguid; - // @Setter(AccessLevel.NONE) - private String name; - @Setter(AccessLevel.NONE) - private String description; - /// - private String action; - /// - @Builder.Default + @Setter(AccessLevel.NONE) private String coguid; + private boolean isActive = true; + private boolean isVirtual = false; +// @Setter(AccessLevel.NONE) + private String name; + private String description; private String thumbUrl; private String catalogStartDate; private String catalogEndDate; @@ -73,61 +64,33 @@ public static class VodData { private Map strings; private Map dates; private Map numbers; - - public static VodDataBuilder builder(String action) { - return hiddenBuilder(); - } } - /** - * IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" - */ + /** IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" **/ public static MediaAsset insertVod(VodData vodData) { final String coguidDatePattern = "yyMMddHHmmssSS"; final String datePattern = "dd/MM/yyyy hh:mm:ss"; + final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); final String endDateValue = "14/10/2099 17:00:00"; final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value vodData.coguid = getCurrentDateInFormat(coguidDatePattern); - vodData.name = vodData.coguid; - if (vodData.thumbUrl == null) { - vodData.thumbUrl = DEFAULT_THUMB; - } - if (vodData.catalogStartDate == null) { - vodData.catalogStartDate = getOffsetDateInFormat(-1, datePattern); - } - if (vodData.catalogEndDate == null) { - vodData.catalogEndDate = endDateValue; - } - if (vodData.startDate == null) { - vodData.startDate = getOffsetDateInFormat(-1, datePattern); - } - if (vodData.endDate == null) { - vodData.endDate = endDateValue; - } - if (vodData.mediaType == null) { - vodData.mediaType = MOVIE_MEDIA_TYPE; - } - if (vodData.ppvWebName == null) { - vodData.ppvWebName = ppvModuleName; - } - if (vodData.ppvMobileName == null) { - vodData.ppvMobileName = ppvModuleName; - } - if (vodData.tags == null) { - vodData.tags = getDefaultTags(); - } - if (vodData.strings == null) { - vodData.strings = getDefaultStrings(); - } - if (vodData.dates == null) { - vodData.dates = getDefaultDates(); - } - if (vodData.numbers == null) { - vodData.numbers = getDefaultNumbers(); - } + if (vodData.name == null) { vodData.name = vodData.coguid; } + if (vodData.description == null) { vodData.description = "description of " + vodData.coguid; } + if (vodData.thumbUrl == null) { vodData.thumbUrl = DEFAULT_THUMB; } + if (vodData.catalogStartDate == null) { vodData.catalogStartDate = offsetDateValue; } + if (vodData.catalogEndDate == null) { vodData.catalogEndDate = endDateValue; } + if (vodData.startDate == null) { vodData.startDate = offsetDateValue; } + if (vodData.endDate == null) { vodData.endDate = endDateValue; } + if (vodData.mediaType == null) { vodData.mediaType = MOVIE_MEDIA_TYPE; } + if (vodData.ppvWebName == null) { vodData.ppvWebName = ppvModuleName; } + if (vodData.ppvMobileName == null) { vodData.ppvMobileName = ppvModuleName; } + if (vodData.tags == null) { vodData.tags = getDefaultTags(); } + if (vodData.strings == null) { vodData.strings = getDefaultStrings(); } + if (vodData.dates == null) { vodData.dates = getDefaultDates(); } + if (vodData.numbers == null) { vodData.numbers = getDefaultNumbers(); } String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); @@ -164,7 +127,7 @@ public static MediaAsset updateVod(String coguid, VodData vodData) { } public static void deleteVod(String coguid) { - VodData vodData = VodData.builder("1").build(); + VodData vodData = new VodData(); vodData.coguid = coguid; String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_DELETE); @@ -172,65 +135,35 @@ public static void deleteVod(String coguid) { assertThat(from(resp.asString()).getInt(ingestAssetIdPath)).isEqualTo(0); } - // ingest new VOD (Media) - public static MediaAsset ingestVOD(VodData vodData) { -// -// // TODO: complete one-by-one needed fields to cover util ingest_vod from old project -// // TODO: check if ingest url is the same for all ingest actions -// -// String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; -// -// vodData.coguid = getCurrentDateInFormat(coguidDatePattern); -// vodData.name = vodData.getCoguid(); -// vodData.description = "description of " + vodData.getCoguid(); -// -// String reqBody = buildIngestVodXml(vodData); -// -// Response resp = -// given() -// .header(contentTypeXml) -// .header(soapActionIngestTvinciData) -// .body(reqBody) -// .when() -// .post(url); -// -// Logger.getLogger(IngestVodUtils.class).debug(reqBody); -// Logger.getLogger(IngestVodUtils.class).debug("Ingest response: \n" + resp.asString()); -// -// assertThat(resp).isNotNull(); -// assertThat(from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.IngestStatus.Message").toString()).isEqualTo("OK"); -// -// String id; -// if (INGEST_ACTION_INSERT.equals(vodData.getAction())) { -// id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus.InternalAssetId").toString(); -// } else { -// id = from(resp.asString()).get("Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.tvmID").toString(); -// } -// -// if (!INGEST_ACTION_DELETE.equals(vodData.getAction())) { -// int delayBetweenRetriesInSeconds = 5; -// int maxTimeExpectingValidResponseInSeconds = 120; -// await() -// .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) -// .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) -// .until(isDataReturned(getAnonymousKs(), id, vodData.getAction())); -// -// -// return (MediaAsset) executor.executeSync(get(id, AssetReferenceType.MEDIA) -// .setKs(getAnonymousKs())) -// .results; -// } - - // TODO: 4/15/2018 add log for ingest and index failures - return null; + // private methods + private static Response executeIngestVodRequest(String reqBody) { + Response resp = given() + .header(contentTypeXml) + .header(soapActionIngestTvinciData) + .body(reqBody) + .when() + .post(url); + + Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); + Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); + + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); + + return resp; } private static String buildIngestVodXml(VodData vodData, String action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password - doc.getElementsByTagName("userName").item(0).setTextContent(getIngestAssetUserName()); - doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestAssetUserPassword()); + if (vodData.isVirtual()) { + doc.getElementsByTagName("userName").item(0).setTextContent(getIngestVirualAssetUserName()); + doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestVirualAssetUserPassword()); + } else { + doc.getElementsByTagName("userName").item(0).setTextContent(getIngestAssetUserName()); + doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestAssetUserPassword()); + } // // add CDATA section // CDATASection cdata = doc.createCDATASection(""); @@ -238,51 +171,51 @@ private static String buildIngestVodXml(VodData vodData, String action) { // media Element media = (Element) doc.getElementsByTagName("media").item(0); - media.setAttribute("co_guid", vodData.getCoguid()); - media.setAttribute("entry_id", "entry_" + vodData.getCoguid()); + media.setAttribute("co_guid", vodData.coguid()); + media.setAttribute("entry_id", "entry_" + vodData.coguid()); media.setAttribute("action", action); media.setAttribute("is_active", Boolean.toString(vodData.isActive())); if (action.equals(INGEST_ACTION_DELETE)) { - return uncommentCdata(docToString(doc)); + return uncommentCdataSection(docToString(doc)); } // name Element nameElement = (Element) media.getElementsByTagName("name").item(0); - nameElement.getElementsByTagName("value").item(0).setTextContent(vodData.getName()); + nameElement.getElementsByTagName("value").item(0).setTextContent(vodData.name()); // thumb Element thumb = (Element) media.getElementsByTagName("thumb").item(0); - thumb.setAttribute("url", vodData.getThumbUrl()); + thumb.setAttribute("url", vodData.thumbUrl()); // description Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); - descriptionElement.getElementsByTagName("value").item(0).setTextContent(vodData.getDescription()); + descriptionElement.getElementsByTagName("value").item(0).setTextContent(vodData.description()); // dates Element datesElement = (Element) media.getElementsByTagName("dates").item(0); - datesElement.getElementsByTagName("catalog_start").item(0).setTextContent(vodData.getCatalogStartDate()); - datesElement.getElementsByTagName("start").item(0).setTextContent(vodData.getStartDate()); - datesElement.getElementsByTagName("catalog_end").item(0).setTextContent(vodData.getCatalogEndDate()); - datesElement.getElementsByTagName("end").item(0).setTextContent(vodData.getEndDate()); + datesElement.getElementsByTagName("catalog_start").item(0).setTextContent(vodData.catalogStartDate()); + datesElement.getElementsByTagName("start").item(0).setTextContent(vodData.startDate()); + datesElement.getElementsByTagName("catalog_end").item(0).setTextContent(vodData.catalogEndDate()); + datesElement.getElementsByTagName("end").item(0).setTextContent(vodData.endDate()); // pic_ratios Element picRatios = (Element) media.getElementsByTagName("pic_ratios").item(0); for (Node n : asList(picRatios.getElementsByTagName("ratio"))) { Element e = (Element) n; - e.setAttribute("thumb", vodData.getThumbUrl()); + e.setAttribute("thumb", vodData.thumbUrl()); } // media type - media.getElementsByTagName("media_type").item(0).setTextContent(vodData.getMediaType()); + media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType()); // geo block rule - media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.getGeoBlockRule()); + media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.geoBlockRule()); // strings - if (vodData.getStrings() != null) { + if (vodData.strings() != null) { Element stringsElement = (Element) media.getElementsByTagName("strings").item(0); - for (Map.Entry entry : vodData.getStrings().entrySet()) { + for (Map.Entry entry : vodData.strings().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, stringsElement, entry.getKey()); @@ -295,9 +228,9 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // doubles - if (vodData.getNumbers() != null) { + if (vodData.numbers() != null) { Element doublesElement = (Element) media.getElementsByTagName("doubles").item(0); - for (Map.Entry entry : vodData.getNumbers().entrySet()) { + for (Map.Entry entry : vodData.numbers().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, doublesElement, entry.getKey()); meta.setTextContent(String.valueOf(entry.getValue())); @@ -305,9 +238,9 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // dates - if (vodData.getDates() != null) { + if (vodData.dates() != null) { Element datesMetaElement = (Element) media.getElementsByTagName("dates").item(1); - for (Map.Entry entry : vodData.getDates().entrySet()) { + for (Map.Entry entry : vodData.dates().entrySet()) { // meta node Element metaElement = generateAndAppendMetaNode(doc, datesMetaElement, entry.getKey()); metaElement.setTextContent(entry.getValue()); @@ -315,9 +248,9 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // metas - if (vodData.getTags() != null) { + if (vodData.tags() != null) { Element metasElement = (Element) media.getElementsByTagName("metas").item(0); - for (Map.Entry> entry : vodData.getTags().entrySet()) { + for (Map.Entry> entry : vodData.tags().entrySet()) { // meta node Element metaElement = generateAndAppendMetaNode(doc, metasElement, entry.getKey()); if (entry.getValue() != null) { @@ -339,18 +272,18 @@ private static String buildIngestVodXml(VodData vodData, String action) { // file types Element file1 = (Element) media.getElementsByTagName("file").item(0); file1.setAttribute("type", getProperty(WEB_FILE_TYPE)); - file1.setAttribute("co_guid", "web_" + vodData.getCoguid()); - file1.setAttribute("PPV_MODULE", vodData.getPpvWebName()); + file1.setAttribute("co_guid", "web_" + vodData.coguid()); + file1.setAttribute("PPV_MODULE", vodData.ppvWebName()); Element file2 = (Element) media.getElementsByTagName("file").item(1); file2.setAttribute("type", getProperty(MOBILE_FILE_TYPE)); - file2.setAttribute("co_guid", "ipad_" + vodData.getCoguid()); - file2.setAttribute("PPV_MODULE", vodData.getPpvMobileName()); + file2.setAttribute("co_guid", "ipad_" + vodData.coguid()); + file2.setAttribute("PPV_MODULE", vodData.ppvMobileName()); // uncomment cdata String docAsString = docToString(doc); - return uncommentCdata(docAsString); + return uncommentCdataSection(docAsString); } private static Element generateAndAppendMetaNode(Document doc, Element rootElement, String name) { @@ -415,40 +348,4 @@ private static Map getDefaultDates() { return dates; } - - private static Response executeIngestVodRequest(String reqBody) { - Response resp = given() - .header(contentTypeXml) - .header(soapActionIngestTvinciData) - .body(reqBody) - .when() - .post(url); - - Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); - Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); - - assertThat(resp).isNotNull(); - assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); - - return resp; - } - - private static Callable isDataReturned(String ks, String mediaId, String action) { - GetAssetBuilder getAssetBuilder = get(mediaId, AssetReferenceType.MEDIA).setKs(ks); - if (INGEST_ACTION_DELETE.equals(action)) { - return () -> (executor.executeSync(getAssetBuilder).error != null); - } else { - return () -> (executor.executeSync(getAssetBuilder).error == null); - } - } - - public static MediaAsset updateVodName(MediaAsset asset, String name) { -// VodData vodData = VodData.builder(INGEST_ACTION_UPDATE) -// .coguid(asset.getName()) -// .name(name) -// .build(); -// -// return ingestVOD(vodData); - return null; - } } From 6a289958f70560199700343716b7bb9a8f709a8f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 1 Jul 2018 07:48:00 +0300 Subject: [PATCH 393/605] Updated query to get PRICE_PLAN_WITHOUT_WAVER_SELECT --- .../java/com/kaltura/client/test/utils/dbUtils/DBConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index e4c418d9c..2af6cfb30 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -96,7 +96,7 @@ public class DBConstants { "WHERE group_id=? AND WAIVER=1 AND WAIVER_PERIOD>0 AND IS_ACTIVE=1 AND [STATUS]=1"; static final String PRICE_PLAN_WITHOUT_WAVER_SELECT = "SELECT TOP 1 * FROM [Pricing].[dbo].[usage_modules]\n" + - "WHERE group_id=? AND WAIVER=0 AND IS_ACTIVE=1 AND [STATUS]=1"; + "WHERE group_id=? AND WAIVER=0 AND IS_ACTIVE=1 AND [STATUS]=1 AND EXT_DISCOUNT_ID IS NOT NULL AND INTERNAL_DISCOUNT_ID IS NOT NULL"; static final String PRICE_PLAN_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + From 6073876035989d1ff618a32882b6d0c1e5566f4c Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Sun, 1 Jul 2018 16:37:59 +0300 Subject: [PATCH 394/605] Updated SearchAssetFilterTests.md file --- .../resources/Tests documentation/SearchAssetFilterTests.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/Tests documentation/SearchAssetFilterTests.md b/src/test/resources/Tests documentation/SearchAssetFilterTests.md index d66c39079..620ef47cd 100644 --- a/src/test/resources/Tests documentation/SearchAssetFilterTests.md +++ b/src/test/resources/Tests documentation/SearchAssetFilterTests.md @@ -50,7 +50,7 @@ Inherited from KalturaBaseSearchAssetFilter * user_interests - only valid value is "true". When enabled, only assets that the user defined as his interests (by tags and metas) (TODO) * entitled_assets - valid values: * free - gets only free to watch assets(TODO) - * entitled - only those that the user is implicitly entitled to watch (TODO) + * entitled - only those that the user is implicitly entitled to watch * "both" * Logical conjunction @@ -72,7 +72,7 @@ Inherited from KalturaBaseSearchAssetFilter * not (!=) * like (~) * Not like (!~)(edge case) - * Exists (+)(edge case) + * Exists (+) * Not exists (!+)(edge case) From 248168025ab7957a998bcaef2f0d4bee6c919834 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 1 Jul 2018 16:40:36 +0300 Subject: [PATCH 395/605] add EpgData object to ingest EPG util --- .../kaltura/client/test/tests/BaseTest.java | 15 +- .../SearchAssetFilterTests.java | 10 +- .../AssetCommentAddTests.java | 5 +- .../kaltura/client/test/utils/AssetUtils.java | 5 + .../utils/ingestUtils/BaseIngestUtils.java | 7 + .../utils/ingestUtils/IngestEpgUtils.java | 210 +++++++++--------- .../test/utils/ingestUtils/IngestPpUtils.java | 6 +- .../utils/ingestUtils/IngestPpvUtils.java | 6 +- .../utils/ingestUtils/IngestVodUtils.java | 3 +- src/test/resources/schemas/Asset.json | 5 +- 10 files changed, 146 insertions(+), 126 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index a68f61a74..a12938fcd 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -32,6 +32,8 @@ import static com.kaltura.client.test.utils.SubscriptionUtils.getAssetsListBySubscription; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.FIVE_MINUTES_PERIOD; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.awaitility.Awaitility.setDefaultTimeout; @@ -119,9 +121,6 @@ public void baseTest_beforeSuite() { // set shared common params partnerId = Integer.parseInt(getProperty(PARTNER_ID)); defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); - - // TODO - dynamic - epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); } @BeforeMethod @@ -168,6 +167,7 @@ public static DiscountModule getSharedCommonDiscount() { } return sharedCommonDiscountModule; } + /** * Regression requires existing of MPP with specific parameters. * Price Plan should be as for method public static PricePlan getSharedCommonPricePlan() @@ -339,9 +339,16 @@ public static MediaAsset getSharedMediaAsset() { return mediaAsset; } + public static String getSharedEpgChannelName() { + if (epgChannelName == null) { + epgChannelName = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray().getJSONObject(0).getString("name"); + } + return epgChannelName; + } + public static ProgramAsset getSharedEpgProgram() { if (epgProgram == null) { - epgProgram = IngestEpgUtils.ingestEPG(epgChannelName).get(0); + epgProgram = insertEpg(new EpgData(getSharedEpgChannelName())).get(0); } return (ProgramAsset) epgProgram; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index a571454e3..97b62e7e3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -4,7 +4,6 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.dbUtils.DBUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -28,6 +27,8 @@ import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -78,8 +79,11 @@ private void asset_list_before_class() { .tags(map); asset3 = insertVod(vodData3); - program = IngestEpgUtils.ingestEPG(epgChannelName, 1).get(0); - program2 = IngestEpgUtils.ingestEPG(epgChannelName2, 1).get(0); + EpgData epgData1 = new EpgData(epgChannelName).episodesNum(1); + program = insertEpg(epgData1).get(0); + + EpgData epgData2 = new EpgData(epgChannelName2).episodesNum(1); + program2 = insertEpg(epgData2).get(0); } // VOD diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index dc396e211..e60c1b2ef 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -19,6 +18,8 @@ import static com.kaltura.client.services.AssetCommentService.ListAssetCommentBuilder; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class AssetCommentAddTests extends BaseTest { @@ -90,7 +91,7 @@ private void addCommentForVod() { @Test private void addCommentForEPGProgram() { // Ingest EPG program - List epgPrograms = IngestEpgUtils.ingestEPG("Shmulik_Series_1"); + List epgPrograms = insertEpg(new EpgData("Shmulik_Series_1")); Long epgProgramId = epgPrograms.get(0).getId(); // Initialize assetComment object diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 93deac285..4a70c8da9 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -168,6 +168,11 @@ public static void addVotesToAsset(Long assetId, int numOfActions, AssetType ass } } } + + public static String getCoguid(Asset asset) { + // TODO: 7/1/2018 finsih util + return null; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 9730842da..86ea001a9 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -13,9 +13,16 @@ import java.io.StringWriter; import java.io.Writer; +import static com.kaltura.client.test.Properties.API_VERSION; +import static com.kaltura.client.test.Properties.INGEST_BASE_URL; +import static com.kaltura.client.test.Properties.getProperty; + public class BaseIngestUtils { // urls + static final String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + + // headers static final Header contentTypeXml = new Header("Content-Type", "text/xml;charset=UTF-8"); static final Header soapActionIngestTvinciData = new Header("SOAPAction", "http://tempuri.org/IService/IngestTvinciData"); static final Header soapActionIngestBusinessModules = new Header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 6bda4ec71..22fe8874f 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -2,7 +2,6 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.enums.DurationPeriod; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.Asset; @@ -10,6 +9,11 @@ import com.kaltura.client.types.ProgramAsset; import com.kaltura.client.types.SearchAssetFilter; import com.kaltura.client.utils.response.base.Response; +import lombok.AccessLevel; +import lombok.Data; +import lombok.NonNull; +import lombok.Setter; +import lombok.experimental.Accessors; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -17,110 +21,120 @@ import java.util.Calendar; import java.util.Date; import java.util.List; -import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.services.AssetService.ListAssetBuilder; +import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static io.restassured.RestAssured.given; +import static io.restassured.path.xml.XmlPath.from; +import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; public class IngestEpgUtils extends BaseIngestUtils { + private static final SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); - // INGEST EPG PARAMS - static final int EPG_DEFAULT_COUNT_OF_SEASONS = 2; - static final int EPG_DEFAULT_COUNT_OF_PROGRAMMES = 2; - static final int EPG_DEFAULT_PROGRAM_DURATION = 30; + private static Response> assetListResponse; + private static int epgChannelId; - // ingest new EPG (Programmes) - public static List ingstEPG(String epgChannelName, Optional programCount, Optional startDate, - Optional programDuration, Optional programDurationPeriod, - Optional isCridUnique4AllPrograms, Optional seasonCount, - Optional coguid, Optional crid, Optional seriesId, - Optional thumb, Optional programNamePrefix) { + @Accessors(fluent = true) + @Data + public static class EpgData { + @Setter(AccessLevel.NONE) private String coguid; + @NonNull private String epgChannelName; - // TODO: complete one-by-one needed fields to cover util ingest_epg from old project - int programCountValue = programCount.orElse(EPG_DEFAULT_COUNT_OF_PROGRAMMES); - int seasonCountValue = seasonCount.orElse(EPG_DEFAULT_COUNT_OF_SEASONS); - Calendar startDateValue = startDate.orElse(Calendar.getInstance()); - int programDurationValue = programDuration.orElse(EPG_DEFAULT_PROGRAM_DURATION); - DurationPeriod programDurationPeriodValue = programDurationPeriod.orElse(DurationPeriod.MINUTES); - boolean isCridUnique4AllProgramsValue = isCridUnique4AllPrograms.orElse(true); - String coguidValue = coguid.orElseGet(() -> getCurrentDateInFormat("yyMMddHHmmssSS")); - String cridValue = crid.orElse(coguidValue); - String seriesIdValue = seriesId.orElse(coguidValue); - String thumbValue = thumb.orElse(DEFAULT_THUMB); - String programNamePrefixValue = programNamePrefix.orElse("Program"); - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - - String reqBody1 = IngestEpgUtils.buildIngestEpgXml(epgChannelName, programCountValue, startDateValue, programDurationValue, - programDurationPeriodValue, isCridUnique4AllProgramsValue, seasonCountValue, coguidValue, cridValue, seriesIdValue, - thumbValue, programNamePrefixValue); - - io.restassured.response.Response resp = - given() - .header(contentTypeXml) - .header(soapActionIngestKalturaEpg) - .body(reqBody1) - .when() - .post(url); + private boolean isCridUnique4AllPrograms = true; - Logger.getLogger(IngestEpgUtils.class).debug(reqBody1); - Logger.getLogger(IngestEpgUtils.class).debug(resp.asString()); + private String crid; + private String seriesId; + private String thumb; + private String programNamePrefix; - // TODO: 6/20/2018 add response assertion + private int episodesNum; + private int seasonsNum; + private int programDuration; - int epgChannelId = IngestFixtureData.getEpgChannelId(epgChannelName); - // TODO: create method getting epoch value from String and pattern - Date firstProgramStartDateAsDate = startDateValue.getTime(); - long epoch = firstProgramStartDateAsDate.getTime() / 1000; // 1000 milliseconds in 1 second + private Calendar startDate; + private DurationPeriod programDurationPeriod; + } - String firstProgramStartDateEpoch = String.valueOf(epoch); + public static List insertEpg(EpgData epgData) { + final String coguidDatePattern = "yyMMddHHmmssSS"; + final int DEFAULT_SEASONS_COUNT = 2; + final int DEFAULT_PROGRAMMES_COUNT = 2; + final int DEFAULT_PROGRAM_DURATION = 30; + // TODO: complete one-by-one needed fields to cover util ingest_epg from old project + epgData.coguid = getCurrentDateInFormat(coguidDatePattern); + + if (epgData.crid == null) { epgData.crid = epgData.coguid; } + if (epgData.seriesId == null) { epgData.seriesId = epgData.coguid; } + if (epgData.episodesNum == 0) { epgData.episodesNum = DEFAULT_PROGRAMMES_COUNT; } + if (epgData.seasonsNum == 0) { epgData.seasonsNum = DEFAULT_SEASONS_COUNT; } + if (epgData.startDate == null) { epgData.startDate = Calendar.getInstance(); } + if (epgData.programDuration == 0) { epgData.programDuration = DEFAULT_PROGRAM_DURATION; } + if (epgData.programDurationPeriod == null) { epgData.programDurationPeriod = DurationPeriod.MINUTES; } + if (epgData.thumb == null) { epgData.thumb = DEFAULT_THUMB; } + if (epgData.programNamePrefix == null) { epgData.programNamePrefix = "Program"; } + + epgChannelId = IngestFixtureData.getEpgChannelId(epgData.epgChannelName); + String reqBody = buildIngestEpgXml(epgData); + executeIngestEpgRequest(reqBody); + + // TODO: create method getting epoch value from String and pattern + String firstProgramStartDateEpoch = String.valueOf(epgData.startDate.getTime().getTime() / 1000); SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); - assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + "' Series_ID='" + seriesIdValue + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + // TODO: 6/29/2018 create ksql builder util + assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch + + "' Series_ID='" + epgData.seriesId + "' end_date >= '" + firstProgramStartDateEpoch + "')"); - int delayBetweenRetriesInSeconds = 5; - int maxTimeExpectingValidResponseInSeconds = 120; + ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(isDataReturned(getAnonymousKs(), assetFilter, programCountValue * seasonCountValue)); - - Response> ingestedProgrammes = executor.executeSync( - AssetService.list(assetFilter, null).setKs(getAnonymousKs())); + .until(isDataReturned(listAssetBuilder, epgData.seasonsNum * epgData.episodesNum)); // TODO: complete Asset.json at least for programs - - return (List) (Object) ingestedProgrammes.results.getObjects(); + return (List) (Object) assetListResponse.results.getObjects(); } - private static Callable isDataReturned(String ks, SearchAssetFilter assetFilter, int totalCount) { + // private methods + private static Callable isDataReturned(ListAssetBuilder listAssetBuilder, int totalCount) { return () -> { - AssetService.ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, null).setKs(ks); - return executor.executeSync(listAssetBuilder).error == null && - executor.executeSync(listAssetBuilder).results.getTotalCount() == totalCount; + assetListResponse = executor.executeSync(listAssetBuilder); + return assetListResponse.error == null && + assetListResponse.results.getTotalCount() == totalCount; }; } - public static List ingestEPG(String epgChannelName, Integer programCount) { - Optional o = Optional.empty(); - return ingstEPG(epgChannelName, Optional.of(programCount), o, o, o, o, o, o, o, o, o, o); - } + private static io.restassured.response.Response executeIngestEpgRequest(String reqBody) { + final String ingestDataResultPath = "Envelope.Body.IngestKalturaEpgResponse.IngestKalturaEpgResult."; + final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; + final String ingestInternalAssetIdPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus.InternalAssetId"; + + io.restassured.response.Response resp = given() + .header(contentTypeXml) + .header(soapActionIngestKalturaEpg) + .body(reqBody) + .when() + .post(url); - public static List ingestEPG(String epgChannelName) { - Optional o = Optional.empty(); - return ingstEPG(epgChannelName, o, o, o, o, o, o, o, o, o, o, o); + Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); + Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); + + // response assertions + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); + assertThat(from(resp.asString()).getList(ingestInternalAssetIdPath)).containsOnly(String.valueOf(epgChannelId)); + + return resp; } - private static String buildIngestEpgXml(String epgChannelName, int episodesNum, Calendar startDate, int programDuration, - DurationPeriod programDurationPeriod, boolean isCridUnique4AllPrograms, int seasonsNum, - String coguid, String crid, String seriesId, String thumb, String programNamePrefix) { + private static String buildIngestEpgXml(EpgData epgData) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestEPG.xml"); // user and password @@ -134,51 +148,40 @@ private static String buildIngestEpgXml(String epgChannelName, int episodesNum, // channel Element channel = (Element) epgChannels.getElementsByTagName("channel").item(0); - channel.setAttribute("id", epgChannelName); + channel.setAttribute("id", epgData.epgChannelName); // programme - SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); - int seasonNum = 1; - while (seasonNum <= seasonsNum) { + while (seasonNum <= epgData.seasonsNum) { int episodeNum = 1; - while (episodeNum <= episodesNum) { - Date endDate = loadEndDate(startDate.getTime(), programDuration, programDurationPeriod); - String startDateFormatted = df.format(startDate.getTime()); + while (episodeNum <= epgData.episodesNum) { + Date endDate = loadEndDate(epgData.startDate.getTime(), epgData.programDuration, epgData.programDurationPeriod); + String startDateFormatted = df.format(epgData.startDate.getTime()); String endDateFormatted = df.format(endDate.getTime()); - String nowDateFormatted = df.format(Calendar.getInstance().getTime()); - Element programmeNode = getProgrammeNode(doc, episodeNum, startDateFormatted, endDateFormatted, epgChannelName, - coguid, crid, programNamePrefix, nowDateFormatted, seriesId, seasonNum, isCridUnique4AllPrograms, thumb); + Element programmeNode = getProgrammeNode(doc, episodeNum, seasonNum, startDateFormatted, endDateFormatted, epgData); epgChannels.appendChild(programmeNode); - startDate.setTime(endDate); + epgData.startDate.setTime(endDate); episodeNum++; } seasonNum++; } // uncomment cdata - String docAsString = docToString(doc); - docAsString = docAsString - .replace("", "-->", "]]>"); - - return docAsString; + return uncommentCdataSection(docToString(doc)); } - private static Element getProgrammeNode(Document doc, int episodeNumber, String startDate, String endDate, String channel, String coguid, String crid, - String programNamePrefix, String currentDate, String seriesId, int seasonNumber, boolean isCridUnique4AllPrograms, - String thumb) { - String name = programNamePrefix + "_" + startDate + "_ser" + seriesId + "_seas" + seasonNumber + "_e" + episodeNumber; - String cridValue = isCridUnique4AllPrograms ? crid + "_" + seasonNumber + "_" + episodeNumber : crid + "_" + episodeNumber; + private static Element getProgrammeNode(Document doc, int episodeNum, int seasonNum, String startDate, String endDate, EpgData epgData) { + String name = epgData.programNamePrefix + "_" + startDate + "_ser" + epgData.seriesId + "_seas" + seasonNum + "_e" + episodeNum; + String crid = epgData.isCridUnique4AllPrograms ? epgData.crid + "_" + seasonNum + "_" + episodeNum : epgData.crid + "_" + episodeNum; // programme Element programme = doc.createElement("programme"); programme.setAttribute("start", startDate); programme.setAttribute("stop", endDate); - programme.setAttribute("channel", channel); - programme.setAttribute("external_id", coguid + "_" + seasonNumber + "_" + episodeNumber); + programme.setAttribute("channel", epgData.epgChannelName); + programme.setAttribute("external_id", epgData.coguid + "_" + seasonNum + "_" + episodeNum); // title Element title = doc.createElement("title"); @@ -188,7 +191,7 @@ private static Element getProgrammeNode(Document doc, int episodeNumber, String // crid Element cridElement = doc.createElement("crid"); - cridElement.setTextContent(cridValue); + cridElement.setTextContent(crid); programme.appendChild(cridElement); // desc @@ -199,7 +202,7 @@ private static Element getProgrammeNode(Document doc, int episodeNumber, String // date Element date = doc.createElement("date"); - date.setTextContent(currentDate); + date.setTextContent(df.format(Calendar.getInstance().getTime())); programme.appendChild(date); // language @@ -211,16 +214,17 @@ private static Element getProgrammeNode(Document doc, int episodeNumber, String // icon Element icon = doc.createElement("icon"); icon.setAttribute("ratio", "16:9"); - icon.setAttribute("src", thumb); + icon.setAttribute("src", epgData.thumb); + programme.appendChild(icon); // season num meta - programme.appendChild(generateMetasNode(doc, "season_num", String.valueOf(seasonNumber))); + programme.appendChild(generateMetasNode(doc, "season_num", String.valueOf(seasonNum))); // series id meta - programme.appendChild(generateMetasNode(doc, "series_id", seriesId)); + programme.appendChild(generateMetasNode(doc, "series_id", epgData.seriesId)); // episode num meta - programme.appendChild(generateMetasNode(doc, "episode_num", String.valueOf(episodeNumber))); + programme.appendChild(generateMetasNode(doc, "episode_num", String.valueOf(episodeNum))); // TODO: 6/19/2018 add missing parameters according to needed tests @@ -232,7 +236,7 @@ private static Element generateMetasNode(Document doc, String metaTypeString, St Element metas = doc.createElement("metas"); // metaType - Element metaType = doc.createElement("MetaType"); + Element metaType = doc.createElement("MetaType"); metaType.setTextContent(metaTypeString); metas.appendChild(metaType); @@ -250,7 +254,7 @@ private static Element generateTagsNode(Document doc, String tagTypeString, Stri Element tags = doc.createElement("tags"); // TagType - Element tagType = doc.createElement("TagType"); + Element tagType = doc.createElement("TagType"); tagType.setTextContent(tagTypeString); tags.appendChild(tagType); @@ -263,7 +267,7 @@ private static Element generateTagsNode(Document doc, String tagTypeString, Stri return tags; } - static Date loadEndDate(Date startDate, int durationValue, DurationPeriod durationPeriod) { + private static Date loadEndDate(Date startDate, int durationValue, DurationPeriod durationPeriod) { Calendar calendar = Calendar.getInstance(); calendar.setTime(startDate); switch (durationPeriod) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 1124483c6..37e64114b 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -64,8 +64,6 @@ public static PricePlan ingestPP(Optional action, Optional ppCod boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - String reqBody = IngestPpUtils.buildIngestPpXml(actionValue, ppCodeValue, isActiveValue, fullLifeCycleValue, viewLifeCycleValue, maxViewsValue, priceValue, currencyValue, discountValue, isRenewableValue, recurringPeriodsValue); @@ -84,8 +82,8 @@ public static PricePlan ingestPP(Optional action, Optional ppCod String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(url); + String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = given().get(reportUrl); Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 369b01275..9338806f6 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -62,8 +62,6 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O String firstFileTypeValue = firstFileType.orElse(getProperty(WEB_FILE_TYPE)); String secondFileTypeValue = secondFileType.orElse(getProperty(MOBILE_FILE_TYPE)); - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - String reqBody = IngestPpvUtils.buildIngestPpvXml(actionValue, ppvCodeValue, isActiveValue, descriptionValue, discountValue, priceValue, currencyValue, usageModuleValue, isSubscriptionOnlyValue, isFirstDeviceLimitationValue, productCodeValue, firstFileTypeValue, secondFileTypeValue); @@ -84,8 +82,8 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); //System.out.println("ReportId = " + reportId); - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(url); + String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = given().get(reportUrl); Logger.getLogger(IngestPpvUtils.class).debug(resp.asString()); Logger.getLogger(IngestPpvUtils.class).debug(resp.asString().split(" = ")[1].replaceAll("\\.", "")); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 8e4c74042..acee571de 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -33,7 +33,7 @@ import static org.awaitility.Awaitility.await; public class IngestVodUtils extends BaseIngestUtils { - private static final String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult."; private static final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; private static final String ingestAssetIdPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus.InternalAssetId"; @@ -47,7 +47,6 @@ public static class VodData { private boolean isActive = true; private boolean isVirtual = false; -// @Setter(AccessLevel.NONE) private String name; private String description; private String thumbUrl; diff --git a/src/test/resources/schemas/Asset.json b/src/test/resources/schemas/Asset.json index 22a7e00b3..1525ba8ee 100644 --- a/src/test/resources/schemas/Asset.json +++ b/src/test/resources/schemas/Asset.json @@ -4,10 +4,7 @@ "Asset": { "type": "object", "properties": { - "objectType": { - "type": "string", - "minLength": 0 - } + "objectType": {"type": "string", "minLength": 0} } } }, From 66d5f2fcdcdd54fe5d3e7970e1896ca5feab4878 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 2 Jul 2018 14:03:42 +0300 Subject: [PATCH 396/605] added MppData object and inserMpp, deleteMpp to MppUtils --- .../kaltura/client/test/tests/BaseTest.java | 18 +- .../EntitlementCancelTests.java | 35 +- .../ProductPriceListTests.java | 84 +++-- .../utils/ingestUtils/BaseIngestUtils.java | 2 +- .../utils/ingestUtils/IngestEpgUtils.java | 2 +- .../utils/ingestUtils/IngestMppUtils.java | 304 +++++++++--------- .../test/utils/ingestUtils/IngestPpUtils.java | 2 +- .../utils/ingestUtils/IngestPpvUtils.java | 2 +- .../utils/ingestUtils/IngestVodUtils.java | 5 +- 9 files changed, 229 insertions(+), 225 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index a12938fcd..0f1f42ba3 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -34,6 +34,7 @@ import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.awaitility.Awaitility.setDefaultTimeout; @@ -181,11 +182,10 @@ public static Subscription getSharedCommonSubscription() { if (sharedCommonSubscription == null) { sharedCommonSubscription = IngestFixtureData.loadSharedCommonSubscription(getSharedCommonPricePlan()); if (sharedCommonSubscription == null) { - sharedCommonSubscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)), Optional.empty(), - Optional.of(false), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + MppData mppData = new MppData() + .pricePlanCode1(getSharedCommonPricePlan().getName()) + .internalDiscount(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)); + sharedCommonSubscription = insertMpp(mppData); } // it should have at least 1 VOD @@ -398,10 +398,10 @@ public static Subscription get5MinRenewableSubscription() { AddChannelBuilder addChannelBuilder = ChannelService.add(channel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); if (channelResponse.results != null && channelResponse.results.getName() != null) { - fiveMinRenewableSubscription = IngestMppUtils.ingestMPP(Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), - Optional.of(channelResponse.results.getName()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + MppData mppData = new MppData() + .pricePlanCode1(pricePlan.getName()) + .channel2(channelResponse.results.getName()); + fiveMinRenewableSubscription = insertMpp(mppData); } } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index fd4b3d842..b3f62adc0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -11,12 +11,11 @@ import com.kaltura.client.services.LicensedUrlService; import com.kaltura.client.services.LicensedUrlService.GetLicensedUrlBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestMppUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -33,8 +32,7 @@ import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.Properties.WEB_FILE_TYPE; import static com.kaltura.client.test.Properties.getProperty; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementCancelTests extends BaseTest { @@ -139,10 +137,11 @@ public void cancelPlayedSubscription() { assertThat(channel.getName()).isNotNull(); PricePlan pricePlan = DBUtils.loadPPWithWaiver(); - Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.of(channel.getName()), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + MppData mppData = new MppData() + .isRenewable(true) + .pricePlanCode1(pricePlan.getName()) + .channel1(channel.getName()); + Subscription subscription = insertMpp(mppData); // set household Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); @@ -181,10 +180,7 @@ public void cancelPlayedSubscription() { // delete household for cleanup executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); //delete subscription - IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + deleteMpp(subscription.getName()); // delete channel executor.executeSync(ChannelService.delete(Math.toIntExact(channel.getId())).setKs(getManagerKs())); } @@ -200,10 +196,10 @@ public void cancelSubscriptionInCancellationWindow() { sharedChannel.setId(channelResponse.results.getId());*/ PricePlan pricePlan = DBUtils.loadPPWithoutWaiver(); - Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(pricePlan.getName()), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + MppData mppData = new MppData() + .pricePlanCode1(pricePlan.getName()) + .isRenewable(true); + Subscription subscription = insertMpp(mppData); // set household /*Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); @@ -241,11 +237,10 @@ public void cancelSubscriptionInCancellationWindow() { // delete household for cleanup //executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); + //delete subscription - IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + deleteMpp(subscription.getName()); + // delete channel //executor.executeSync(ChannelService.delete(Math.toIntExact(sharedChannel.getId())).setKs(getManagerKs())); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 458a04ae4..8a72ed59b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -13,7 +13,6 @@ import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestMppUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -31,8 +30,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_DELETE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -81,11 +79,10 @@ public void beforeClass() { sharedChannel.setIsActive(true); sharedChannel.setAssetTypes(null); - subscriptionWithMultiCurrenciesAndDiscountPercentage = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.of(true), Optional.empty(), - Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + MppData mppData = new MppData() + .isRenewable(true) + .pricePlanCode1(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS); + subscriptionWithMultiCurrenciesAndDiscountPercentage = insertMpp(mppData); } @Severity(SeverityLevel.NORMAL) @@ -221,10 +218,12 @@ public void subscriptionTest() { assertThat(channelResponse.results).isNotNull(); Channel channel = channelResponse.results; assertThat(channel.getName()).isNotNull(); - Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + + MppData mppData = new MppData() + .isRenewable(true) + .channel1(channel.getName()) + .fileType1(getProperty(WEB_FILE_TYPE)); + Subscription subscription = insertMpp(mppData); ListEntitlementBuilder entitlementListBeforePurchase = EntitlementService.list(entitlementSubsFilter, null); entitlementResponse = executor.executeSync(entitlementListBeforePurchase.setKs(classMasterUserKs)); @@ -287,11 +286,9 @@ public void subscriptionTest() { //delete HH for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + //delete subscription - IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + deleteMpp(subscription.getName()); } @Severity(SeverityLevel.NORMAL) @@ -305,10 +302,13 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { assertThat(channelResponse.results).isNotNull(); Channel channel = channelResponse.results; assertThat(channel.getName()).isNotNull(); - Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + + MppData mppData = new MppData() + .isRenewable(true) + .channel1(channel.getName()) + .fileType1(getProperty(WEB_FILE_TYPE)); + Subscription subscription = insertMpp(mppData); + int webHDFileOnlySubId = Integer.valueOf(subscription.getId()); int numberOfUsers = 1; @@ -355,24 +355,24 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + // delete channel DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(Math.toIntExact(channel.getId())); executor.executeSync(deleteChannelBuilder.setKs(getManagerKs())); + //delete subscription - IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(channel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + deleteMpp(subscription.getName()); } @Severity(SeverityLevel.NORMAL) @Description("productPrice/action/list - subscription - no specifed currency") @Test() public void productPriceSubscriptionNoSpecifiedCurrencyTest() { - Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + MppData mppData = new MppData() + .isRenewable(true) + .pricePlanCode1(PRICE_PLAN_WITH_MULTI_CURRENCIES); + Subscription subscription = insertMpp(mppData); + int subWithMultiCurrencyId = Integer.valueOf(subscription.getId()); int numberOfUsers = 1; @@ -419,11 +419,9 @@ public void productPriceSubscriptionNoSpecifiedCurrencyTest() { //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + //delete subscription - IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + deleteMpp(subscription.getName()); } @Severity(SeverityLevel.NORMAL) @@ -485,10 +483,12 @@ public void productPriceSubscriptionWithPercentageDiscountAndSpecifiedCurrencyTe public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLocaleTest() { // TODO: should we save it in Properties? double subPriceAfterDiscount = 4; // as price 5 and discount is 1 - Subscription subscription = IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.of(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_FIXED), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + MppData mppData = new MppData() + .isRenewable(true) + .pricePlanCode1(PRICE_PLAN_WITH_MULTI_CURRENCIES_AND_DISCOUNT_FIXED); + Subscription subscription = insertMpp(mppData); + int subWithDiscountAndCurrencyId = Integer.valueOf(subscription.getId()); int numberOfUsers = 1; @@ -534,11 +534,9 @@ public void productPriceSubscriptionWithFixedDiscountAndSpecifiedCurrencyNotInLo //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + //delete subscription - IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscription.getName()), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + deleteMpp(subscription.getName()); } @Severity(SeverityLevel.NORMAL) @@ -768,10 +766,8 @@ public void afterClass() { //delete household for cleanup HouseholdService.DeleteHouseholdBuilder deleteHouseholdBuilder = delete(Math.toIntExact(household.getId())); executor.executeSync(deleteHouseholdBuilder.setKs(getAdministratorKs())); + // delete subscription - IngestMppUtils.ingestMPP(Optional.of(INGEST_ACTION_DELETE), Optional.of(subscriptionWithMultiCurrenciesAndDiscountPercentage.getName()), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(true), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(sharedChannel.getName()), - Optional.empty(), Optional.of(getProperty(WEB_FILE_TYPE)), Optional.empty(), Optional.empty(), Optional.empty()); + deleteMpp(subscriptionWithMultiCurrenciesAndDiscountPercentage.getName()); } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 86ea001a9..e176e7038 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -20,7 +20,7 @@ public class BaseIngestUtils { // urls - static final String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + static final String ingestUrl = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; // headers static final Header contentTypeXml = new Header("Content-Type", "text/xml;charset=UTF-8"); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 22fe8874f..512419a8e 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -121,7 +121,7 @@ private static io.restassured.response.Response executeIngestEpgRequest(String r .header(soapActionIngestKalturaEpg) .body(reqBody) .when() - .post(url); + .post(ingestUrl); Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index 77a76c268..d9028d67e 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -1,33 +1,33 @@ package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.Logger; +import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.Subscription; +import com.kaltura.client.types.SubscriptionFilter; import io.restassured.response.Response; +import lombok.AccessLevel; +import lombok.Data; +import lombok.Setter; +import lombok.experimental.Accessors; import org.w3c.dom.Document; import org.w3c.dom.Element; -import java.util.Optional; - import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserName; -import static com.kaltura.client.test.tests.BaseTest.getIngestBusinessModuleUserPassword; +import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; +import static org.assertj.core.api.Assertions.assertThat; public class IngestMppUtils extends BaseIngestUtils { - // INGEST MPP PARAMS - static final String MPP_DEFAULT_DESCRIPTION_VALUE = "Ingest MPP description"; - static final String MPP_DEFAULT_START_DATE_VALUE = "20/03/2016 00:00:00"; - static final String MPP_DEFAULT_END_DATE_VALUE = "20/03/2099 00:00:00"; - static final boolean MPP_DEFAULT_IS_ACTIVE_VALUE = true; - static final boolean MPP_DEFAULT_IS_RENEWABLE_VALUE = false; - static final int MPP_DEFAULT_GRACE_PERIOD_VALUE = 0; + private static final String ingestDataResultPath = "Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult."; + private static final String ingestStatusMessagePath = ingestDataResultPath + "Status.Message"; + private static final String ingestReportIdPath = ingestDataResultPath + "ReportId"; // TODO: THIS VALUES RELATED TO OUR ENV ONLY discuss with Alon - static final String MPP_DEFAULT_COUPON_GROUP_VALUE = + private static final String DEFAULT_COUPON_GROUP = "\n" + "01/05/2017 00:00:00\n" + "31/12/2099 23:59:59\n" + @@ -39,7 +39,7 @@ public class IngestMppUtils extends BaseIngestUtils { "Expired coupon group 1\n" + ""; - static final String MPP_DEFAULT_PRODUCT_CODES_VALUE = + private static final String DEFAULT_PRODUCT_CODES = "\n" + "ProductCode1\n" + "Google\n" + @@ -49,124 +49,139 @@ public class IngestMppUtils extends BaseIngestUtils { "Apple\n" + ""; + @Accessors(fluent = true) + @Data + public static class MppData { + private boolean isActive = true; + private boolean isRenewable = false; + + @Setter(AccessLevel.NONE) private String mppCode; + @Setter(AccessLevel.NONE) private String title; + + private String description; + private String startDate; + private String endDate; + private String internalDiscount; + private String productCode; + private String pricePlanCode1; + private String pricePlanCode2; + private String channel1; + private String channel2; + private String fileType1; + private String fileType2; + private String couponGroup; + private String productCodes; + + private Integer gracePeriodMinute; + } + /** - * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert" or "delete" ("update" looks like broken) - * @param mppCode - should have value in case "action" is "delete" - * @param isActive - * @param title - * @param description - * @param startDate - * @param endDate - * @param internalDiscount - * @param productCode - * @param isRenewable - * @param gracePeriodMinute - * @param pricePlanCode1 - * @param pricePlanCode2 - * @param channel1 - * @param channel2 - * @param fileType1 - * @param fileType2 - * @param couponGroup - * @param productCodes - * @return MPP data - *

- * !!!Only created by that method MPP can be deleted!!! - *

- * to delete existed MPP use corresponded action and value mpp.getName() as "mppCode" - * (where mpp is a variable that contains mpp data). - *

- *

- * don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created by ingestPP method) - */ - // ingest new MPP - public static Subscription ingestMPP(Optional action, Optional mppCode, Optional isActive, Optional title, - Optional description, Optional startDate, Optional endDate, Optional internalDiscount, - Optional productCode, Optional isRenewable, Optional gracePeriodMinute, - Optional pricePlanCode1, Optional pricePlanCode2, Optional channel1, - Optional channel2, Optional fileType1, Optional fileType2, Optional couponGroup, - Optional productCodes) { - String mppCodeValue = mppCode.orElse(getRandomValue("MPP_", 9999999999L)); - String actionValue = action.orElse(INGEST_ACTION_INSERT); - boolean isActiveValue = isActive.orElse(MPP_DEFAULT_IS_ACTIVE_VALUE); - String titleValue = INGEST_ACTION_INSERT.equals(actionValue) ? mppCodeValue : title.orElse(mppCodeValue); - String descriptionValue = description.orElse(MPP_DEFAULT_DESCRIPTION_VALUE); - String startDateValue = startDate.orElse(MPP_DEFAULT_START_DATE_VALUE); - String endDateValue = endDate.orElse(MPP_DEFAULT_END_DATE_VALUE); - String defaultCurrencyOfDiscount4IngestMpp = "GBP"; - int defaultPercentageOfDiscount4IngestMpp = 100; - String internalDiscountValue = internalDiscount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestMpp, defaultPercentageOfDiscount4IngestMpp)); - String productCodeValue = productCode.orElse(""); - boolean isRenewableValue = isRenewable.orElse(MPP_DEFAULT_IS_RENEWABLE_VALUE); - int gracePeriodMinuteValue = gracePeriodMinute.orElse(MPP_DEFAULT_GRACE_PERIOD_VALUE); - String pricePlanCode1Value = pricePlanCode1.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP)); - String pricePlanCode2Value = pricePlanCode2.orElse(""); - String channel1Value = channel1.orElse(getProperty(DEFAULT_CHANNEL)); - String channel2Value = channel2.orElse(""); - String fileType1Value = fileType1.orElse(""); - String fileType2Value = fileType2.orElse(""); - String couponGroupValue = couponGroup.orElse(MPP_DEFAULT_COUPON_GROUP_VALUE); - String productCodesValue = productCodes.orElse(MPP_DEFAULT_PRODUCT_CODES_VALUE); - - - String url = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; - - String reqBody = IngestMppUtils.buildIngestMppXml(actionValue, mppCodeValue, isActiveValue, titleValue, - descriptionValue, startDateValue, endDateValue, internalDiscountValue, productCodeValue, - isRenewableValue, gracePeriodMinuteValue, pricePlanCode1Value, pricePlanCode2Value, - channel1Value, channel2Value, fileType1Value, fileType2Value, couponGroupValue, productCodesValue); - - Response resp = - given() - .header(contentTypeXml) - .header(soapActionIngestBusinessModules) - .body(reqBody) - .when() - .post(url); + * IMPORTANT: In order to update or delete existing MPP use subscription.getName() as "mppCode" + * Don't forget after deletion of mpp delete also price plan using by deleted mpp (if it was created by ingestPP method) + **/ + + public static Subscription insertMpp(MppData mppData) { + final String DEFAULT_START_DATE = "20/03/2016 00:00:00"; + final String DEFAULT_END_DATE = "20/03/2099 00:00:00"; + final int DEFAULT_GRACE_PERIOD = 0; + + final String currencyOfDiscount = "GBP"; + final int percentageOfDiscount = 100; + + mppData.mppCode = getRandomValue("MPP_", 9999999999L); + mppData.title = mppData.mppCode; + + if (mppData.description == null) { mppData.description = "Description of " + mppData.mppCode; } + if (mppData.startDate == null) { mppData.startDate = DEFAULT_START_DATE; } + if (mppData.endDate == null) { mppData.endDate = DEFAULT_END_DATE; } + if (mppData.internalDiscount == null) { mppData.internalDiscount = IngestFixtureData.getDiscount(currencyOfDiscount, percentageOfDiscount); } + if (mppData.gracePeriodMinute == null) { mppData.gracePeriodMinute = DEFAULT_GRACE_PERIOD; } + if (mppData.pricePlanCode1 == null) { mppData.pricePlanCode1 = getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP); } + if (mppData.channel1 == null) { mppData.channel1 = getProperty(DEFAULT_CHANNEL); } + if (mppData.couponGroup == null) { mppData.couponGroup = DEFAULT_COUPON_GROUP; } + if (mppData.productCodes == null) { mppData.productCodes = DEFAULT_PRODUCT_CODES; } + + String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_INSERT); + Response resp = executeIngesMppRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); + + String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + + resp = given().get(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); + String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); - Logger.getLogger(IngestMppUtils.class).debug(reqBody); - Logger.getLogger(IngestMppUtils.class).debug("\n Response: " + resp.asString()); + // TODO: 7/1/2018 add wait until in case needed + SubscriptionFilter filter = new SubscriptionFilter(); + filter.setSubscriptionIdIn(id); - // TODO: 6/20/2018 add response assertion -// assertThat(from(resp.asString()) -// .get("").toString()) -// .isEqualTo("OK"); + return executor.executeSync(SubscriptionService.list(filter) + .setKs(getAnonymousKs())) + .results.getObjects().get(0); + } - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //Logger.getLogger(IngestUtils.class).debug("ReportId = " + reportId); + /** Mpp update seems to be broken */ +/* + public static Subscription updateMpp(String subscriptionName, MppData mppData) { + mppData.mppCode = subscriptionName; + String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_UPDATE); + Response resp = executeIngesMppRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); - url = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(url); + String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = given().get(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(reportUrl); Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); - String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); - Subscription subscription = new Subscription(); - subscription.setId(id); - subscription.setName(titleValue); - subscription.setDescription(descriptionValue); - subscription.isRenewable(String.valueOf(isRenewableValue)); - subscription.setGracePeriodMinutes(gracePeriodMinuteValue); - // TODO: complete COMMENTED IF NEEDED - //subscription.setStartDate(); - //subscription.setEndDate(); - //subscription.setDiscountModule(); - //subscription.setProductCodes(); - //subscription.setPricePlanIds(); - //subscription.setChannels(); - //subscription.setFileTypes(); - //subscription.setCouponsGroups(); - return subscription; + SubscriptionFilter filter = new SubscriptionFilter(); + filter.setSubscriptionIdIn(id); + + return executor.executeSync(SubscriptionService.list(filter) + .setKs(getAnonymousKs())) + .results.getObjects().get(0); + } +*/ + + public static void deleteMpp(String subscriptionName) { + MppData mppData = new MppData(); + mppData.mppCode = subscriptionName; + String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_DELETE); + + Response resp = executeIngesMppRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); + String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + + resp = given().get(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); + + assertThat(resp.asString()).contains("delete succeeded"); + + // TODO: 7/1/2018 add wait until SubscriptionService.list(filter) is empty in case needed + } + + // private methods + private static Response executeIngesMppRequest(String reqBody) { + Response resp = given() + .header(contentTypeXml) + .header(soapActionIngestBusinessModules) + .body(reqBody) + .when() + .post(ingestUrl); + + Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); + Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); + + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); + + return resp; } - private static String buildIngestMppXml(String action, String mppCode, boolean isActive, String title, String description, - String startDate, String endDate, String internalDiscount, String productCode, - boolean isRenewable, int gracePeriodMinute, String pricePlanCode1, - String pricePlanCode2, String channel1, String channel2, String fileType1, - String fileType2, String couponGroup, String productCodes) { + private static String buildIngestMppXml(MppData mppData, String action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestMPP.xml"); // user and password @@ -175,62 +190,61 @@ private static String buildIngestMppXml(String action, String mppCode, boolean i // ingest Element ingest = (Element) doc.getElementsByTagName("ingest").item(0); - ingest.setAttribute("id", mppCode); + ingest.setAttribute("id", mppData.mppCode); // multi price plan Element mpp = (Element) ingest.getElementsByTagName("multi_price_plan").item(0); - mpp.setAttribute("code", mppCode); + mpp.setAttribute("code", mppData.mppCode); mpp.setAttribute("action", action); - mpp.setAttribute("is_active", Boolean.toString(isActive)); + mpp.setAttribute("is_active", Boolean.toString(mppData.isActive)); + + if (action.equals(INGEST_ACTION_DELETE)) { + return uncommentCdataSection(docToString(doc)); + } // title - mpp.getElementsByTagName("title").item(0).setTextContent(title); + mpp.getElementsByTagName("title").item(0).setTextContent(mppData.title); // description - mpp.getElementsByTagName("description").item(0).setTextContent(description); + mpp.getElementsByTagName("description").item(0).setTextContent(mppData.description); // start date - mpp.getElementsByTagName("start_date").item(0).setTextContent(startDate); + mpp.getElementsByTagName("start_date").item(0).setTextContent(mppData.startDate); // end date - mpp.getElementsByTagName("end_date").item(0).setTextContent(endDate); + mpp.getElementsByTagName("end_date").item(0).setTextContent(mppData.endDate); // internal discount - mpp.getElementsByTagName("internal_discount").item(0).setTextContent(internalDiscount); + mpp.getElementsByTagName("internal_discount").item(0).setTextContent(mppData.internalDiscount); // product code - mpp.getElementsByTagName("product_code").item(0).setTextContent(productCode); + mpp.getElementsByTagName("product_code").item(0).setTextContent(mppData.productCode); // is renewable - mpp.getElementsByTagName("is_renewable").item(0).setTextContent(Boolean.toString(isRenewable)); + mpp.getElementsByTagName("is_renewable").item(0).setTextContent(Boolean.toString(mppData.isRenewable)); // grace period minutes - mpp.getElementsByTagName("grace_period_minutes").item(0).setTextContent(String.valueOf(gracePeriodMinute)); + mpp.getElementsByTagName("grace_period_minutes").item(0).setTextContent(String.valueOf(mppData.gracePeriodMinute)); // price plan codes - mpp.getElementsByTagName("price_plan_code").item(0).setTextContent(pricePlanCode1); - mpp.getElementsByTagName("price_plan_code").item(1).setTextContent(pricePlanCode2); + mpp.getElementsByTagName("price_plan_code").item(0).setTextContent(mppData.pricePlanCode1); + mpp.getElementsByTagName("price_plan_code").item(1).setTextContent(mppData.pricePlanCode2); // channels - mpp.getElementsByTagName("channel").item(0).setTextContent(channel1); - mpp.getElementsByTagName("channel").item(1).setTextContent(channel2); + mpp.getElementsByTagName("channel").item(0).setTextContent(mppData.channel1); + mpp.getElementsByTagName("channel").item(1).setTextContent(mppData.channel2); // file types - mpp.getElementsByTagName("file_type").item(0).setTextContent(fileType1); - mpp.getElementsByTagName("file_type").item(1).setTextContent(fileType2); + mpp.getElementsByTagName("file_type").item(0).setTextContent(mppData.fileType1); + mpp.getElementsByTagName("file_type").item(1).setTextContent(mppData.fileType2); // subscription coupon group - mpp.getElementsByTagName("subscription_coupon_group").item(0).setTextContent(couponGroup); + mpp.getElementsByTagName("subscription_coupon_group").item(0).setTextContent(mppData.couponGroup); // product codes - mpp.getElementsByTagName("product_codes").item(0).setTextContent(productCodes); + mpp.getElementsByTagName("product_codes").item(0).setTextContent(mppData.productCodes); // uncomment cdata - String docAsString = docToString(doc); - docAsString = docAsString - .replace("", "-->", "]]>"); - - return docAsString; + return uncommentCdataSection(docToString(doc)); } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 37e64114b..029688792 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -73,7 +73,7 @@ public static PricePlan ingestPP(Optional action, Optional ppCod .header(soapActionIngestBusinessModules) .body(reqBody) .when() - .post(url); + .post(ingestUrl); Logger.getLogger(IngestPpUtils.class).debug(reqBody); Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 9338806f6..7e501b2c5 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -72,7 +72,7 @@ public static Ppv ingestPPV(Optional action, Optional ppvCode, O .header(soapActionIngestBusinessModules) .body(reqBody) .when() - .post(url); + .post(ingestUrl); Logger.getLogger(IngestPpvUtils.class).debug(reqBody); Logger.getLogger(IngestPpvUtils.class).debug("\n Response: " + resp.asString()); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index acee571de..86a37af69 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -38,7 +38,6 @@ public class IngestVodUtils extends BaseIngestUtils { private static final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; private static final String ingestAssetIdPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus.InternalAssetId"; - @Accessors(fluent = true) @Data public static class VodData { @@ -141,7 +140,7 @@ private static Response executeIngestVodRequest(String reqBody) { .header(soapActionIngestTvinciData) .body(reqBody) .when() - .post(url); + .post(ingestUrl); Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); @@ -185,7 +184,7 @@ private static String buildIngestVodXml(VodData vodData, String action) { // thumb Element thumb = (Element) media.getElementsByTagName("thumb").item(0); - thumb.setAttribute("url", vodData.thumbUrl()); + thumb.setAttribute("ingestUrl", vodData.thumbUrl()); // description Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); From 69f6b984efa5b3f516cc127c9fe4db03901a79a3 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 2 Jul 2018 14:31:58 +0300 Subject: [PATCH 397/605] no message --- .../kaltura/client/test/utils/AssetUtils.java | 7 - .../test/utils/ingestUtils/IngestPpUtils.java | 124 ++++++++++++++++++ 2 files changed, 124 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 4a70c8da9..5f5f6216e 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -72,13 +72,6 @@ public static List getAssetFileIds(String assetId) { List mediaFiles = assetResponse.results.getMediaFiles(); assertThat(mediaFiles.size()).as("media files list").isGreaterThan(0); -// List fileIdsList = new ArrayList<>(); -// for (MediaFile mediaFile : mediaFiles) { -// fileIdsList.add(mediaFile.getId()); -// } -// -// return fileIdsList; - return mediaFiles.stream().map(MediaFile::getId).collect(Collectors.toList()); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 029688792..a3fa4a689 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -8,9 +8,15 @@ import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.PricePlan; import com.kaltura.client.types.PricePlanFilter; +import lombok.AccessLevel; +import lombok.Data; +import lombok.Setter; +import lombok.experimental.Accessors; import org.w3c.dom.Document; import org.w3c.dom.Element; + import java.util.Optional; + import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; @@ -26,6 +32,81 @@ public class IngestPpUtils extends BaseIngestUtils { static final int PP_DEFAULT_MAX_VIEWS_VALUE = 0; static final int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; + + @Accessors(fluent = true) + @Data + public static class PpData { + boolean isActive = true; + boolean isRenewable = false; + + @Setter(AccessLevel.NONE) String ppCode; + + String fullLifeCycle; + String viewLifeCycle; + String price; + String currency; + String discount; + + Integer maxViews; + Integer recurringPeriods; + } + + public static PricePlan insertPp(PpData ppData) { + final int defaultPercentageOfDiscount = 100; + DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount); + + ppData.ppCode = getRandomValue("AUTOPricePlan_", MAX_RANDOM_VALUE); + + if (ppData.fullLifeCycle == null) { ppData.fullLifeCycle = FIVE_MINUTES_PERIOD; } + if (ppData.viewLifeCycle == null) { ppData.viewLifeCycle = FIVE_MINUTES_PERIOD; } + if (ppData.maxViews == null) { ppData.maxViews = PP_DEFAULT_MAX_VIEWS_VALUE; } + if (ppData.price == null) { ppData.price = getProperty(PRICE_CODE_AMOUNT); } + if (ppData.currency == null) { ppData.currency = EUR.getValue(); } + if (ppData.discount == null) { ppData.discount = discountModule.toParams().get("code").toString(); } + if (ppData.recurringPeriods == null) { ppData.recurringPeriods = PP_DEFAULT_RECURRING_PERIODS_VALUE; } + + String reqBody = IngestPpUtils.buildIngestPpXml(ppData, INGEST_ACTION_INSERT); + + io.restassured.response.Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestBusinessModules) + .body(reqBody) + .when() + .post(ingestUrl); + + Logger.getLogger(IngestPpUtils.class).debug(reqBody); + Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); + + // TODO: 6/20/2018 add response assertion + + String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + + String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = given().get(reportUrl); + + Logger.getLogger(IngestPpUtils.class).debug(reportUrl); + Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); + + String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); + + + PricePlanFilter filter = new PricePlanFilter(); + filter.setIdIn(id); + + return executor.executeSync(PricePlanService.list(filter) + .setKs(getOperatorKs())) + .results.getObjects().get(0); + } + + public static void updatePp(String ppCode, PpData ppData) { + + } + + public static void deletePp(String ppCode) { + + } + /** * IMPORTANT: please delete inserted by that method items * @@ -145,4 +226,47 @@ private static String buildIngestPpXml(String action, String ppCode, boolean isA return docAsString; } + + private static String buildIngestPpXml(PpData ppData, String action) { + Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestPP.xml"); + + // user and password + doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); + doc.getElementsByTagName("tem:password").item(0).setTextContent(getIngestBusinessModuleUserPassword()); + + // ingest + Element ingest = (Element) doc.getElementsByTagName("ingest").item(0); + ingest.setAttribute("id", "reportIngestPricePlan"); + + // price plan + Element pp = (Element) ingest.getElementsByTagName("price_plan").item(0); + pp.setAttribute("code", ppData.ppCode); + pp.setAttribute("action", action); + pp.setAttribute("is_active", Boolean.toString(ppData.isActive)); + + // full life cycles + pp.getElementsByTagName("full_life_cycle").item(0).setTextContent(ppData.fullLifeCycle); + + // view life cycle + pp.getElementsByTagName("view_life_cycle").item(0).setTextContent(ppData.viewLifeCycle); + + // max views + pp.getElementsByTagName("max_views").item(0).setTextContent(String.valueOf(ppData.maxViews)); + + // price code + pp.getElementsByTagName("price").item(0).setTextContent(ppData.price); + pp.getElementsByTagName("currency").item(0).setTextContent(ppData.currency); + + // discount + pp.getElementsByTagName("discount").item(0).setTextContent(ppData.discount); + + // is renewable + pp.getElementsByTagName("is_renewable").item(0).setTextContent(Boolean.toString(ppData.isRenewable)); + + // recurring periods + pp.getElementsByTagName("recurring_periods").item(0).setTextContent(String.valueOf(ppData.recurringPeriods)); + + // uncomment cdata + return uncommentCdataSection(docToString(doc)); + } } From c51ff846a011192c47de4c63d697d6497f5cb071 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 2 Jul 2018 15:24:19 +0300 Subject: [PATCH 398/605] ingestPp refacor --- .../kaltura/client/test/tests/BaseTest.java | 29 ++- .../utils/ingestUtils/IngestMppUtils.java | 14 +- .../test/utils/ingestUtils/IngestPpUtils.java | 192 +++++------------- 3 files changed, 84 insertions(+), 151 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 0f1f42ba3..18962747e 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -35,6 +35,7 @@ import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.awaitility.Awaitility.setDefaultTimeout; @@ -143,10 +144,17 @@ public static PricePlan getSharedCommonPricePlan() { if (sharedCommonPricePlan == null) { sharedCommonPricePlan = IngestFixtureData.loadPricePlan(Double.valueOf(COMMON_PRICE_CODE_AMOUNT), EUR.getValue(), getSharedCommonDiscount()); if (sharedCommonPricePlan == null) { - sharedCommonPricePlan = IngestPpUtils.ingestPP(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), - Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(cycles.get(CYCLE_1_DAY)), Optional.of(0), Optional.of(COMMON_PRICE_CODE_AMOUNT), - Optional.of(EUR.getValue()), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), getSharedCommonDiscount().getPercent().intValue())), - Optional.of(true), Optional.of(0)); + PpData ppData = new PpData() + .fullLifeCycle(cycles.get(CYCLE_1_DAY)) + .viewLifeCycle(cycles.get(CYCLE_1_DAY)) + .maxViews(0) + .price(COMMON_PRICE_CODE_AMOUNT) + .currency(EUR.getValue()) + .discount(IngestFixtureData.getDiscount(EUR.getValue(), getSharedCommonDiscount().getPercent().intValue())) + .isRenewable(true) + .recurringPeriods(0); + + sharedCommonPricePlan = insertPp(ppData); } } return sharedCommonPricePlan; @@ -387,10 +395,15 @@ public static Subscription get5MinRenewableSubscription() { ingestVODIntoSubscription(fiveMinRenewableSubscription); } if (fiveMinRenewableSubscription == null) { - PricePlan pricePlan = IngestPpUtils.ingestPP(Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(FIVE_MINUTES_PERIOD), Optional.of(FIVE_MINUTES_PERIOD), Optional.empty(), - Optional.of(getProperty(PRICE_CODE_AMOUNT)), Optional.of(EUR.getValue()), Optional.of(""), - Optional.of(true), Optional.of(3)); + PpData ppData = new PpData() + .fullLifeCycle(FIVE_MINUTES_PERIOD) + .viewLifeCycle(FIVE_MINUTES_PERIOD) + .price(PRICE_CODE_AMOUNT) + .currency(EUR.getValue()) + .isRenewable(true) + .recurringPeriods(3); + + PricePlan pricePlan = insertPp(ppData); // it should have at least 1 VOD Channel channel = loadDefaultChannel(); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index d9028d67e..1d9694dcc 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -122,9 +122,8 @@ public static Subscription insertMpp(MppData mppData) { } /** Mpp update seems to be broken */ -/* - public static Subscription updateMpp(String subscriptionName, MppData mppData) { - mppData.mppCode = subscriptionName; +/* public static Subscription updateMpp(String mppCode, MppData mppData) { + mppData.mppCode = mppCode; String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_UPDATE); Response resp = executeIngesMppRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -142,12 +141,13 @@ public static Subscription updateMpp(String subscriptionName, MppData mppData) { return executor.executeSync(SubscriptionService.list(filter) .setKs(getAnonymousKs())) .results.getObjects().get(0); - } -*/ - public static void deleteMpp(String subscriptionName) { + // TODO: 7/1/2018 add wait until SubscriptionService.list(filter) is updated in case needed + }*/ + + public static void deleteMpp(String mppCode) { MppData mppData = new MppData(); - mppData.mppCode = subscriptionName; + mppData.mppCode = mppCode; String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_DELETE); Response resp = executeIngesMppRequest(reqBody); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index a3fa4a689..4b72dbdce 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -2,12 +2,11 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.PricePlanService; -import com.kaltura.client.services.PricePlanService.ListPricePlanBuilder; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.DiscountModule; -import com.kaltura.client.types.ListResponse; import com.kaltura.client.types.PricePlan; import com.kaltura.client.types.PricePlanFilter; +import io.restassured.response.Response; import lombok.AccessLevel; import lombok.Data; import lombok.Setter; @@ -15,22 +14,19 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; -import java.util.Optional; - import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; +import static org.assertj.core.api.Assertions.assertThat; public class IngestPpUtils extends BaseIngestUtils { - // INGEST PP PARAMS - static final boolean PP_DEFAULT_IS_ACTIVE_VALUE = true; - static final boolean PP_DEFAULT_IS_RENEWABLE_VALUE = false; - static final int PP_DEFAULT_MAX_VIEWS_VALUE = 0; - static final int PP_DEFAULT_RECURRING_PERIODS_VALUE = 1; + private static final String ingestDataResultPath = "Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult."; + private static final String ingestStatusMessagePath = ingestDataResultPath + "Status.Message"; + private static final String ingestReportIdPath = ingestDataResultPath + "ReportId"; @Accessors(fluent = true) @@ -51,7 +47,13 @@ public static class PpData { Integer recurringPeriods; } + /** + * IMPORTANT: In order to update or delete existed price plan use pricePlan.getName() as "ppCode" + */ public static PricePlan insertPp(PpData ppData) { + final int DEFAULT_MAX_VIEWS = 0; + final int DEFAULT_RECURRING_PERIODS = 1; + final int defaultPercentageOfDiscount = 100; DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount); @@ -59,38 +61,23 @@ public static PricePlan insertPp(PpData ppData) { if (ppData.fullLifeCycle == null) { ppData.fullLifeCycle = FIVE_MINUTES_PERIOD; } if (ppData.viewLifeCycle == null) { ppData.viewLifeCycle = FIVE_MINUTES_PERIOD; } - if (ppData.maxViews == null) { ppData.maxViews = PP_DEFAULT_MAX_VIEWS_VALUE; } + if (ppData.maxViews == null) { ppData.maxViews = DEFAULT_MAX_VIEWS; } if (ppData.price == null) { ppData.price = getProperty(PRICE_CODE_AMOUNT); } if (ppData.currency == null) { ppData.currency = EUR.getValue(); } if (ppData.discount == null) { ppData.discount = discountModule.toParams().get("code").toString(); } - if (ppData.recurringPeriods == null) { ppData.recurringPeriods = PP_DEFAULT_RECURRING_PERIODS_VALUE; } - - String reqBody = IngestPpUtils.buildIngestPpXml(ppData, INGEST_ACTION_INSERT); - - io.restassured.response.Response resp = - given() - .header(contentTypeXml) - .header(soapActionIngestBusinessModules) - .body(reqBody) - .when() - .post(ingestUrl); - - Logger.getLogger(IngestPpUtils.class).debug(reqBody); - Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); - - // TODO: 6/20/2018 add response assertion + if (ppData.recurringPeriods == null) { ppData.recurringPeriods = DEFAULT_RECURRING_PERIODS; } - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_INSERT); + Response resp = executeIngesPpRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(reportUrl); + resp = given().get(reportUrl); Logger.getLogger(IngestPpUtils.class).debug(reportUrl); Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); - String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); - PricePlanFilter filter = new PricePlanFilter(); filter.setIdIn(id); @@ -99,132 +86,65 @@ public static PricePlan insertPp(PpData ppData) { .results.getObjects().get(0); } - public static void updatePp(String ppCode, PpData ppData) { - - } - - public static void deletePp(String ppCode) { - - } + public static PricePlan updatePp(String ppCode, PpData ppData) { + ppData.ppCode = ppCode; - /** - * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert", "update" and "delete" - * @param ppCode - should have value in case "action" one of {"update" and "delete"} - * @param isActive - * @param fullLifeCycle - * @param viewLifeCycle - * @param maxViews - * @param price - * @param currency - * @param discount - * @param isRenewable - * @param recurringPeriods - * @return PricePlan data - *

- * to update or delete existed price plan use corresponded action and value pricePlan.getName() as "ppCode" - * (where pricePlan is a variable that contains price plan data) - *

- * !!!Only created by that method PP can be deleted/updated!!! - */ - public static PricePlan ingestPP(Optional action, Optional ppCode, Optional isActive, Optional fullLifeCycle, - Optional viewLifeCycle, Optional maxViews, Optional price, Optional currency, - Optional discount, Optional isRenewable, Optional recurringPeriods) { - String ppCodeValue = ppCode.orElse(getRandomValue("AUTOPricePlan_", MAX_RANDOM_VALUE)); - String actionValue = action.orElse(INGEST_ACTION_INSERT); - boolean isActiveValue = isActive.orElse(PP_DEFAULT_IS_ACTIVE_VALUE); - String fullLifeCycleValue = fullLifeCycle.orElse(FIVE_MINUTES_PERIOD); - String viewLifeCycleValue = viewLifeCycle.orElse(FIVE_MINUTES_PERIOD); - int maxViewsValue = maxViews.orElse(PP_DEFAULT_MAX_VIEWS_VALUE); - String priceValue = price.orElse(getProperty(PRICE_CODE_AMOUNT)); - String currencyValue = currency.orElse(EUR.getValue()); - int defaultPercentageOfDiscount4IngestMpp = 100; - DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount4IngestMpp); - String discountValue = discount.orElse(discountModule.toParams().get("code").toString()); - boolean isRenewableValue = isRenewable.orElse(PP_DEFAULT_IS_RENEWABLE_VALUE); - int recurringPeriodsValue = recurringPeriods.orElse(PP_DEFAULT_RECURRING_PERIODS_VALUE); - - String reqBody = IngestPpUtils.buildIngestPpXml(actionValue, ppCodeValue, isActiveValue, fullLifeCycleValue, - viewLifeCycleValue, maxViewsValue, priceValue, currencyValue, discountValue, isRenewableValue, recurringPeriodsValue); - - io.restassured.response.Response resp = - given() - .header(contentTypeXml) - .header(soapActionIngestBusinessModules) - .body(reqBody) - .when() - .post(ingestUrl); - - Logger.getLogger(IngestPpUtils.class).debug(reqBody); - Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); - - // TODO: 6/20/2018 add response assertion - - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); + String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_UPDATE); + Response resp = executeIngesPpRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(reportUrl); + resp = given().get(reportUrl); + Logger.getLogger(IngestPpUtils.class).debug(reportUrl); Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); - String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); PricePlanFilter filter = new PricePlanFilter(); filter.setIdIn(id); - ListPricePlanBuilder pricePlanBuilder = PricePlanService.list(filter); - com.kaltura.client.utils.response.base.Response> pricePlanListResponse = - executor.executeSync(pricePlanBuilder.setKs(getOperatorKs())); - return pricePlanListResponse.results.getObjects().get(0); - } - - private static String buildIngestPpXml(String action, String ppCode, boolean isActive, String fullLifeCycle, String viewLifeCycle, - int maxViews, String price, String currency, String discount, boolean isRenewable, int recurringPeriods) { - Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestPP.xml"); - - // user and password - doc.getElementsByTagName("tem:username").item(0).setTextContent(getIngestBusinessModuleUserName()); - doc.getElementsByTagName("tem:password").item(0).setTextContent(getIngestBusinessModuleUserPassword()); - // ingest - Element ingest = (Element) doc.getElementsByTagName("ingest").item(0); - ingest.setAttribute("id", "reportIngestPricePlan"); + return executor.executeSync(PricePlanService.list(filter) + .setKs(getOperatorKs())) + .results.getObjects().get(0); - // price plan - Element pp = (Element) ingest.getElementsByTagName("price_plan").item(0); - pp.setAttribute("code", ppCode); - pp.setAttribute("action", action); - pp.setAttribute("is_active", Boolean.toString(isActive)); + // TODO: 7/1/2018 add wait until PricePlanService.list(filter) is updated in case needed + } - // full life cycles - pp.getElementsByTagName("full_life_cycle").item(0).setTextContent(fullLifeCycle); + public static void deletePp(String ppCode) { + PpData ppData = new PpData(); + ppData.ppCode = ppCode; + String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_DELETE); - // view life cycle - pp.getElementsByTagName("view_life_cycle").item(0).setTextContent(viewLifeCycle); + Response resp = executeIngesPpRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); + String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - // max views - pp.getElementsByTagName("max_views").item(0).setTextContent(String.valueOf(maxViews)); + resp = given().get(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); - // price code - pp.getElementsByTagName("price").item(0).setTextContent(price); - pp.getElementsByTagName("currency").item(0).setTextContent(currency); + assertThat(resp.asString()).contains("delete succeeded"); - // discount - pp.getElementsByTagName("discount").item(0).setTextContent(discount); + // TODO: 7/1/2018 add wait until SubscriptionService.list(filter) is empty in case needed + } - // is renewable - pp.getElementsByTagName("is_renewable").item(0).setTextContent(Boolean.toString(isRenewable)); + //private methods + private static Response executeIngesPpRequest(String reqBody) { + io.restassured.response.Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestBusinessModules) + .body(reqBody) + .when() + .post(ingestUrl); - // recurring periods - pp.getElementsByTagName("recurring_periods").item(0).setTextContent(String.valueOf(recurringPeriods)); + Logger.getLogger(IngestPpUtils.class).debug(reqBody); + Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); - // uncomment cdata - String docAsString = docToString(doc); - docAsString = docAsString - .replace("", "-->", "]]>"); + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); - return docAsString; + return resp; } private static String buildIngestPpXml(PpData ppData, String action) { From c0322a917e65079f249e020c53b07bede4f1731e Mon Sep 17 00:00:00 2001 From: Shmulik Kummer Date: Mon, 2 Jul 2018 16:23:28 +0300 Subject: [PATCH 399/605] Added additonal test to class - "SearchAssetFilterTests" --- .../SearchAssetFilterTests.java | 22 +++++++++++++++++-- .../SearchAssetFilterTests.md | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index cdd44ecac..8df487462 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -53,6 +53,7 @@ public class SearchAssetFilterTests extends BaseTest { private String ksqlQuery; private AssetFilter assetFilter; private String masterUserKs; + private String geoBlockRule = "Philippines Only"; @BeforeClass @@ -87,7 +88,9 @@ private void asset_list_before_class() { .mediaType(MOVIE_MEDIA_TYPE) .catalogStartDate(getTimeInDate(-100)) .tags(tagMap) - .strings(stringMetaMap1); + .strings(stringMetaMap1) + .geoBlockRule(geoBlockRule); + asset2 = insertVod(vodData2); // ingest asset 3 @@ -116,7 +119,22 @@ private void asset_list_before_class() { // Filter by KSQL // ********************* - // TODO: 27/06/2018 - Add test that filter by Geo block after Alon will refactor the ingest util + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - VOD - filter by geo blocked assets." + + "The filter return only asset that are not blocked for playback because of geo restriction") + @Test + private void listVodAssetsByGeoBlock() { + ksqlQuery = "(and (or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "') geo_block = 'true')"; + assetFilter = getSearchAssetFilter(ksqlQuery); + + Response> assetListResponse = executor.executeSync(list(assetFilter) + .setKs(masterUserKs)); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + // Only asset 1 returned (asset 2 has geo block rule) + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + } + @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - filter by entitled asset") diff --git a/src/test/resources/Tests documentation/SearchAssetFilterTests.md b/src/test/resources/Tests documentation/SearchAssetFilterTests.md index 620ef47cd..654127dfa 100644 --- a/src/test/resources/Tests documentation/SearchAssetFilterTests.md +++ b/src/test/resources/Tests documentation/SearchAssetFilterTests.md @@ -51,7 +51,7 @@ Inherited from KalturaBaseSearchAssetFilter * entitled_assets - valid values: * free - gets only free to watch assets(TODO) * entitled - only those that the user is implicitly entitled to watch - * "both" + * "both" (TODO) * Logical conjunction * or From 0840ccf5bb9285466e676cda27c6f876a4a0597a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 2 Jul 2018 17:10:41 +0300 Subject: [PATCH 400/605] refactor ingestPpvUtils --- .../kaltura/client/test/tests/BaseTest.java | 20 +- .../utils/ingestUtils/BaseIngestUtils.java | 19 +- .../utils/ingestUtils/IngestMppUtils.java | 23 +- .../test/utils/ingestUtils/IngestPpUtils.java | 75 ++++--- .../utils/ingestUtils/IngestPpvUtils.java | 207 ++++++++++-------- src/test/resources/schemas/Ppv.json | 202 +++++++++++++++++ 6 files changed, 391 insertions(+), 155 deletions(-) create mode 100644 src/test/resources/schemas/Ppv.json diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 18962747e..4d912feba 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -13,7 +13,6 @@ import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; -import com.kaltura.client.test.utils.ingestUtils.*; import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; @@ -31,11 +30,14 @@ import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; import static com.kaltura.client.test.utils.SubscriptionUtils.getAssetsListBySubscription; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.FIVE_MINUTES_PERIOD; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.INGEST_ACTION_INSERT; -import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; -import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestPpUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.MppData; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.insertMpp; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpUtils.PpData; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpUtils.insertPp; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpvUtils.PpvData; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpvUtils.insertPpv; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.awaitility.Awaitility.setDefaultTimeout; @@ -237,10 +239,10 @@ public static Ppv getSharedCommonPpv(){ if (sharedCommonPpv == null) { sharedCommonPpv = IngestFixtureData.loadSharedCommonPpv(getSharedCommonPricePlan()); if (sharedCommonPpv == null) { - sharedCommonPpv = IngestPpvUtils.ingestPPV(Optional.of(INGEST_ACTION_INSERT), Optional.empty(), Optional.of(true), - Optional.empty(), Optional.of(IngestFixtureData.getDiscount(EUR.getValue(), (int) discountPercentValue)), - Optional.empty(), Optional.empty(), Optional.of(getSharedCommonPricePlan().getName()), - Optional.of(false), Optional.of(false), Optional.empty(), Optional.empty(), Optional.empty()); + PpvData ppvData = new PpvData() + .discount(IngestFixtureData.getDiscount(EUR.getValue(), (int) discountPercentValue)) + .usageModule(getSharedCommonPricePlan().getName()); + sharedCommonPpv = insertPpv(ppvData); } } return sharedCommonPpv; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index e176e7038..10048cb3a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -1,6 +1,8 @@ package com.kaltura.client.test.utils.ingestUtils; +import com.kaltura.client.Logger; import io.restassured.http.Header; +import io.restassured.response.Response; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; @@ -13,14 +15,15 @@ import java.io.StringWriter; import java.io.Writer; -import static com.kaltura.client.test.Properties.API_VERSION; -import static com.kaltura.client.test.Properties.INGEST_BASE_URL; -import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.Properties.PARTNER_ID; +import static io.restassured.RestAssured.given; public class BaseIngestUtils { // urls static final String ingestUrl = getProperty(INGEST_BASE_URL) + "/Ingest_" + getProperty(API_VERSION) + "/Service.svc?wsdl"; + private static final String ingestBaseReportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/"; // headers static final Header contentTypeXml = new Header("Content-Type", "text/xml;charset=UTF-8"); @@ -110,4 +113,14 @@ static String uncommentCdataSection(String docAsString) { return docAsString; } + + static Response executeIngestReportRequest(String reportId) { + String reportUrl = ingestBaseReportUrl + reportId; + Logger.getLogger(IngestMppUtils.class).debug(reportUrl); + + Response resp = given().get(reportUrl); + Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); + + return resp; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index 1d9694dcc..24b137d08 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -102,14 +102,11 @@ public static Subscription insertMpp(MppData mppData) { if (mppData.productCodes == null) { mppData.productCodes = DEFAULT_PRODUCT_CODES; } String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_INSERT); - Response resp = executeIngesMppRequest(reqBody); + Response resp = executeIngestMppRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); - String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = executeIngestReportRequest(reportId); - resp = given().get(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); // TODO: 7/1/2018 add wait until in case needed @@ -125,14 +122,11 @@ public static Subscription insertMpp(MppData mppData) { /* public static Subscription updateMpp(String mppCode, MppData mppData) { mppData.mppCode = mppCode; String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_UPDATE); - Response resp = executeIngesMppRequest(reqBody); + Response resp = executeIngestMppRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); - String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = executeIngestReportRequest(reportId); - resp = given().get(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); SubscriptionFilter filter = new SubscriptionFilter(); @@ -150,13 +144,10 @@ public static void deleteMpp(String mppCode) { mppData.mppCode = mppCode; String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_DELETE); - Response resp = executeIngesMppRequest(reqBody); + Response resp = executeIngestMppRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); - String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); + resp = executeIngestReportRequest(reportId); assertThat(resp.asString()).contains("delete succeeded"); @@ -164,7 +155,7 @@ public static void deleteMpp(String mppCode) { } // private methods - private static Response executeIngesMppRequest(String reqBody) { + private static Response executeIngestMppRequest(String reqBody) { Response resp = given() .header(contentTypeXml) .header(soapActionIngestBusinessModules) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 4b72dbdce..72261896d 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -28,23 +28,23 @@ public class IngestPpUtils extends BaseIngestUtils { private static final String ingestStatusMessagePath = ingestDataResultPath + "Status.Message"; private static final String ingestReportIdPath = ingestDataResultPath + "ReportId"; - @Accessors(fluent = true) @Data public static class PpData { - boolean isActive = true; - boolean isRenewable = false; + private boolean isActive = true; + private boolean isRenewable = false; - @Setter(AccessLevel.NONE) String ppCode; + @Setter(AccessLevel.NONE) + private String ppCode; - String fullLifeCycle; - String viewLifeCycle; - String price; - String currency; - String discount; + private String fullLifeCycle; + private String viewLifeCycle; + private String price; + private String currency; + private String discount; - Integer maxViews; - Integer recurringPeriods; + private Integer maxViews; + private Integer recurringPeriods; } /** @@ -59,23 +59,34 @@ public static PricePlan insertPp(PpData ppData) { ppData.ppCode = getRandomValue("AUTOPricePlan_", MAX_RANDOM_VALUE); - if (ppData.fullLifeCycle == null) { ppData.fullLifeCycle = FIVE_MINUTES_PERIOD; } - if (ppData.viewLifeCycle == null) { ppData.viewLifeCycle = FIVE_MINUTES_PERIOD; } - if (ppData.maxViews == null) { ppData.maxViews = DEFAULT_MAX_VIEWS; } - if (ppData.price == null) { ppData.price = getProperty(PRICE_CODE_AMOUNT); } - if (ppData.currency == null) { ppData.currency = EUR.getValue(); } - if (ppData.discount == null) { ppData.discount = discountModule.toParams().get("code").toString(); } - if (ppData.recurringPeriods == null) { ppData.recurringPeriods = DEFAULT_RECURRING_PERIODS; } + if (ppData.fullLifeCycle == null) { + ppData.fullLifeCycle = FIVE_MINUTES_PERIOD; + } + if (ppData.viewLifeCycle == null) { + ppData.viewLifeCycle = FIVE_MINUTES_PERIOD; + } + if (ppData.maxViews == null) { + ppData.maxViews = DEFAULT_MAX_VIEWS; + } + if (ppData.price == null) { + ppData.price = getProperty(PRICE_CODE_AMOUNT); + } + if (ppData.currency == null) { + ppData.currency = EUR.getValue(); + } + if (ppData.discount == null) { + ppData.discount = discountModule.toParams().get("code").toString(); + } + if (ppData.recurringPeriods == null) { + ppData.recurringPeriods = DEFAULT_RECURRING_PERIODS; + } String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_INSERT); - Response resp = executeIngesPpRequest(reqBody); + Response resp = executeIngestPpRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); - String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = executeIngestReportRequest(reportId); - resp = given().get(reportUrl); - Logger.getLogger(IngestPpUtils.class).debug(reportUrl); - Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); PricePlanFilter filter = new PricePlanFilter(); @@ -90,14 +101,11 @@ public static PricePlan updatePp(String ppCode, PpData ppData) { ppData.ppCode = ppCode; String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_UPDATE); - Response resp = executeIngesPpRequest(reqBody); + Response resp = executeIngestPpRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); - String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; + resp = executeIngestReportRequest(reportId); - resp = given().get(reportUrl); - Logger.getLogger(IngestPpUtils.class).debug(reportUrl); - Logger.getLogger(IngestPpUtils.class).debug(resp.asString()); String id = resp.asString().split(" = ")[1].trim().replaceAll("\\.", ""); PricePlanFilter filter = new PricePlanFilter(); @@ -115,13 +123,10 @@ public static void deletePp(String ppCode) { ppData.ppCode = ppCode; String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_DELETE); - Response resp = executeIngesPpRequest(reqBody); + Response resp = executeIngestPpRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); - String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(reportUrl); - Logger.getLogger(IngestMppUtils.class).debug(resp.asString()); + resp = executeIngestReportRequest(reportId); assertThat(resp.asString()).contains("delete succeeded"); @@ -129,8 +134,8 @@ public static void deletePp(String ppCode) { } //private methods - private static Response executeIngesPpRequest(String reqBody) { - io.restassured.response.Response resp = + private static Response executeIngestPpRequest(String reqBody) { + Response resp = given() .header(contentTypeXml) .header(soapActionIngestBusinessModules) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 7e501b2c5..e3c57588c 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -1,104 +1,132 @@ package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.Logger; -import com.kaltura.client.services.PpvService; -import com.kaltura.client.services.PpvService.GetPpvBuilder; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Ppv; import io.restassured.response.Response; +import lombok.AccessLevel; +import lombok.Data; +import lombok.Setter; +import lombok.experimental.Accessors; import org.w3c.dom.Document; import org.w3c.dom.Element; -import java.util.Optional; + +import static com.kaltura.client.services.PpvService.get; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; +import static org.assertj.core.api.Assertions.assertThat; public class IngestPpvUtils extends BaseIngestUtils { - /** - * IMPORTANT: please delete inserted by that method items - * - * @param action - can be "insert", "update" and "delete" - * @param ppvCode - should have value in case "action" one of {"update" and "delete"} - * @param isActive - * @param description - * @param discount - * @param price - * @param currency - * @param usageModule - * @param isSubscriptionOnly - * @param isFirstDeviceLimitation - * @param productCode - * @param firstFileType - * @param secondFileType - * @return PPV data - *

- * to update or delete existed ppv use corresponded action and value ppv.getName() as "ppvCode" - * (where ppv is a variable that contains ppv data) - *

- * !!!Only created by that method PPV can be deleted/update!!! - */ - // ingest new PPV - public static Ppv ingestPPV(Optional action, Optional ppvCode, Optional isActive, Optional description, - Optional discount, Optional price, Optional currency, Optional usageModule, - Optional isSubscriptionOnly, Optional isFirstDeviceLimitation, Optional productCode, - Optional firstFileType, Optional secondFileType) { - String actionValue = action.orElse(INGEST_ACTION_INSERT); - String ppvCodeValue = ppvCode.orElse(getRandomValue("PPV_", MAX_RANDOM_VALUE)); - boolean isActiveValue = isActive.isPresent() ? isActive.get() : true; - String descriptionValue = description.orElse("My ingest PPV"); - String defaultCurrencyOfDiscount4IngestPpv = "ILS"; - int defaultPercentageOfDiscount4IngestPpv = 50; - String discountValue = discount.orElse(IngestFixtureData.getDiscount(defaultCurrencyOfDiscount4IngestPpv, defaultPercentageOfDiscount4IngestPpv)); - double priceValue = price.orElse(Double.valueOf(getProperty(PRICE_CODE_AMOUNT))); - String currencyValue = currency.orElse(EUR.getValue()); - String usageModuleValue = usageModule.orElse(getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV)); - boolean isSubscriptionOnlyValue = isSubscriptionOnly.isPresent() ? isSubscriptionOnly.get() : false; - boolean isFirstDeviceLimitationValue = isFirstDeviceLimitation.isPresent() ? isFirstDeviceLimitation.get() : false; - String productCodeValue = productCode.orElse(getProperty(DEFAULT_PRODUCT_CODE)); - String firstFileTypeValue = firstFileType.orElse(getProperty(WEB_FILE_TYPE)); - String secondFileTypeValue = secondFileType.orElse(getProperty(MOBILE_FILE_TYPE)); - - String reqBody = IngestPpvUtils.buildIngestPpvXml(actionValue, ppvCodeValue, isActiveValue, descriptionValue, - discountValue, priceValue, currencyValue, usageModuleValue, isSubscriptionOnlyValue, - isFirstDeviceLimitationValue, productCodeValue, firstFileTypeValue, secondFileTypeValue); + private static final String ingestDataResultPath = "Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult."; + private static final String ingestStatusMessagePath = ingestDataResultPath + "Status.Message"; + private static final String ingestReportIdPath = ingestDataResultPath + "ReportId"; - Response resp = - given() - .header(contentTypeXml) - .header(soapActionIngestBusinessModules) - .body(reqBody) - .when() - .post(ingestUrl); + @Accessors(fluent = true) + @Data + public static class PpvData { + private boolean isActive = true; + private boolean isSubscriptionOnly = false; + private boolean isFirstDeviceLimitation = false; - Logger.getLogger(IngestPpvUtils.class).debug(reqBody); - Logger.getLogger(IngestPpvUtils.class).debug("\n Response: " + resp.asString()); + @Setter(AccessLevel.NONE) private String ppvCode; - // TODO: 6/20/2018 add response assertion + private String description; + private String discount; + private String currency; + private String usageModule; + private String productCode; + private String firstFileType; + private String secondFileType; - String reportId = from(resp.asString()).get("Envelope.Body.IngestBusinessModulesResponse.IngestBusinessModulesResult.ReportId").toString(); - //System.out.println("ReportId = " + reportId); + private Double price; + } - String reportUrl = getProperty(INGEST_REPORT_URL) + "/" + getProperty(PARTNER_ID) + "/" + reportId; - resp = given().get(reportUrl); + /** IMPORTANT: In order to update or delete existed ppv use ppv.getName() as "ppvCode" */ - Logger.getLogger(IngestPpvUtils.class).debug(resp.asString()); - Logger.getLogger(IngestPpvUtils.class).debug(resp.asString().split(" = ")[1].replaceAll("\\.", "")); + public static Ppv insertPpv(PpvData ppvData) { + String currencyOfDiscount = "ILS"; + int percentageOfDiscount = 50; + + ppvData.ppvCode = getRandomValue("PPV_", MAX_RANDOM_VALUE); + + if (ppvData.description == null) { ppvData.description = ppvData.ppvCode; } + if (ppvData.discount == null) { ppvData.discount = IngestFixtureData.getDiscount(currencyOfDiscount, percentageOfDiscount); } + if (ppvData.price == null) { ppvData.price = Double.valueOf(getProperty(PRICE_CODE_AMOUNT)); } + if (ppvData.currency == null) { ppvData.currency = EUR.getValue(); } + if (ppvData.usageModule == null) { ppvData.usageModule = getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV); } + if (ppvData.productCode == null) { ppvData.productCode = getProperty(DEFAULT_PRODUCT_CODE); } + if (ppvData.firstFileType == null) { ppvData.firstFileType = getProperty(WEB_FILE_TYPE); } + if (ppvData.secondFileType == null) { ppvData.secondFileType = getProperty(MOBILE_FILE_TYPE); } + + String reqBody = buildIngestPpvXml(ppvData, INGEST_ACTION_INSERT); + Response resp = executeIngestPpvRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); + + resp = executeIngestReportRequest(reportId); String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); - GetPpvBuilder getPpvBuilder = PpvService.get(Long.valueOf(id)); - com.kaltura.client.utils.response.base.Response ppvResponse = executor.executeSync(getPpvBuilder.setKs(getOperatorKs())); + // TODO: 7/1/2018 add wait until in case needed + return executor.executeSync(get(Long.valueOf(id)) + .setKs(getOperatorKs())) + .results; + } + + public static Ppv updatePpv(String ppvCode, PpvData ppvData) { + ppvData.ppvCode = ppvCode; + + String reqBody = buildIngestPpvXml(ppvData, INGEST_ACTION_UPDATE); + Response resp = executeIngestPpvRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); + + resp = executeIngestReportRequest(reportId); + + String id = resp.asString().split(" = ")[1].replaceAll("\\.", "").trim(); - return ppvResponse.results; + // TODO: 7/1/2018 add wait until in case needed + return executor.executeSync(get(Long.valueOf(id)) + .setKs(getOperatorKs())) + .results; } - private static String buildIngestPpvXml(String action, String ppvCode, boolean isActive, String description, String discount, - double price, String currency, String usageModule, boolean isSubscriptionOnly, - boolean isFirstDeviceLimitation, String productCode, String firstFileType, String secondFileType) { + public static void deletePpv(String ppvCode) { + PpvData ppvData = new PpvData(); + ppvData.ppvCode = ppvCode; + String reqBody = buildIngestPpvXml(ppvData, INGEST_ACTION_DELETE); + + Response resp = executeIngestPpvRequest(reqBody); + String reportId = from(resp.asString()).getString(ingestReportIdPath); + + resp = executeIngestReportRequest(reportId); + + assertThat(resp.asString()).contains("delete succeeded"); + } + + // private methods + private static Response executeIngestPpvRequest(String reqBody) { + Response resp = + given() + .header(contentTypeXml) + .header(soapActionIngestBusinessModules) + .body(reqBody) + .when() + .post(ingestUrl); + + Logger.getLogger(IngestPpvUtils.class).debug(reqBody); + Logger.getLogger(IngestPpvUtils.class).debug(resp.asString()); + + assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); + + return resp; + } + + private static String buildIngestPpvXml(PpvData ppvData, String action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestPPV.xml"); // user and password @@ -107,46 +135,41 @@ private static String buildIngestPpvXml(String action, String ppvCode, boolean i // ingest Element ingest = (Element) doc.getElementsByTagName("ingest").item(0); - ingest.setAttribute("id", ppvCode); + ingest.setAttribute("id", ppvData.ppvCode); // ppv Element ppv = (Element) ingest.getElementsByTagName("ppv").item(0); - ppv.setAttribute("code", ppvCode); + ppv.setAttribute("code", ppvData.ppvCode); ppv.setAttribute("action", action); - ppv.setAttribute("is_active", Boolean.toString(isActive)); + ppv.setAttribute("is_active", Boolean.toString(ppvData.isActive)); // description - ppv.getElementsByTagName("description").item(0).setTextContent(description); + ppv.getElementsByTagName("description").item(0).setTextContent(ppvData.description); // price code - ppv.getElementsByTagName("price").item(0).setTextContent(String.valueOf(price)); - ppv.getElementsByTagName("currency").item(0).setTextContent(currency); + ppv.getElementsByTagName("price").item(0).setTextContent(String.valueOf(ppvData.price)); + ppv.getElementsByTagName("currency").item(0).setTextContent(ppvData.currency); // usage module - ppv.getElementsByTagName("usage_module").item(0).setTextContent(usageModule); + ppv.getElementsByTagName("usage_module").item(0).setTextContent(ppvData.usageModule); // discount - ppv.getElementsByTagName("discount").item(0).setTextContent(discount); + ppv.getElementsByTagName("discount").item(0).setTextContent(ppvData.discount); // subscription only - ppv.getElementsByTagName("subscription_only").item(0).setTextContent(Boolean.toString(isSubscriptionOnly)); + ppv.getElementsByTagName("subscription_only").item(0).setTextContent(Boolean.toString(ppvData.isSubscriptionOnly)); // first device limitation - ppv.getElementsByTagName("first_device_limitation").item(0).setTextContent(Boolean.toString(isFirstDeviceLimitation)); + ppv.getElementsByTagName("first_device_limitation").item(0).setTextContent(Boolean.toString(ppvData.isFirstDeviceLimitation)); // product_code - ppv.getElementsByTagName("product_code").item(0).setTextContent(productCode); + ppv.getElementsByTagName("product_code").item(0).setTextContent(ppvData.productCode); // file types - ppv.getElementsByTagName("file_type").item(0).setTextContent(firstFileType); - ppv.getElementsByTagName("file_type").item(1).setTextContent(secondFileType); + ppv.getElementsByTagName("file_type").item(0).setTextContent(ppvData.firstFileType); + ppv.getElementsByTagName("file_type").item(1).setTextContent(ppvData.secondFileType); // uncomment cdata - String docAsString = docToString(doc); - docAsString = docAsString - .replace("", "-->", "]]>"); - - return docAsString; + return uncommentCdataSection(docToString(doc)); } } diff --git a/src/test/resources/schemas/Ppv.json b/src/test/resources/schemas/Ppv.json new file mode 100644 index 000000000..a5b037586 --- /dev/null +++ b/src/test/resources/schemas/Ppv.json @@ -0,0 +1,202 @@ +{ + "$id": "Ppv", + "definitions": { + "Ppv": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 0 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "price": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "minimum": 0 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "price": { + "type": "object", + "properties": { + "amount": { + "type": "number", + "minimum": 0 + }, + "currency": { + "type": "string", + "minLength": 0 + }, + "currencySign": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "descriptions": { + "type": "array" + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "price" + ] + }, + "fileTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + } + }, + "discountModule": { + "type": "object", + "properties": { + "percent": { + "type": "integer", + "minimum": 0 + }, + "startDate": { + "type": "integer", + "minimum": 0 + }, + "endDate": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "descriptions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "language": { + "type": "string", + "minLength": 0 + }, + "value": { + "type": "string", + "minLength": 0 + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + } + }, + "productCode": { + "type": "string", + "minLength": 0 + }, + "isSubscriptionOnly": { + "type": "boolean" + }, + "firstDeviceLimitation": { + "type": "boolean" + }, + "usageModule": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "minimum": 0 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "maxViewsNumber": { + "type": "integer", + "minimum": 0 + }, + "viewLifeCycle": { + "type": "integer", + "minimum": 0 + }, + "fullLifeCycle": { + "type": "integer", + "minimum": 0 + }, + "couponId": { + "type": "integer", + "minimum": 0 + }, + "waiverPeriod": { + "type": "integer", + "minimum": 0 + }, + "isWaiverEnabled": { + "type": "boolean" + }, + "isOfflinePlayback": { + "type": "boolean" + }, + "objectType": { + "type": "string", + "minLength": 0 + } + } + }, + "objectType": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "id", + "name", + "price", + "fileTypes", + "discountModule", + "descriptions", + "productCode", + "isSubscriptionOnly", + "firstDeviceLimitation", + "usageModule" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/Ppv" + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} + From 96a4326c710f61e4df91630e9c61479b5edc2a26 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 3 Jul 2018 13:53:23 +0300 Subject: [PATCH 401/605] added ksqlBuilder util --- .../test/tests/enums/DurationPeriod.java | 1 - .../client/test/tests/enums/KsqlKeys.java | 46 ++++++++ .../SearchAssetFilterTests.java | 55 ++++++--- .../client/test/utils/KsqlBuilder.java | 110 ++++++++++++++++++ .../utils/ingestUtils/IngestEpgUtils.java | 17 ++- .../test/utils/ingestUtils/IngestPpUtils.java | 4 + .../utils/ingestUtils/IngestPpvUtils.java | 4 + 7 files changed, 218 insertions(+), 19 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/KsqlKeys.java create mode 100644 src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java diff --git a/src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java b/src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java index 5ceaab1dc..c3a54b497 100644 --- a/src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java +++ b/src/test/java/com/kaltura/client/test/tests/enums/DurationPeriod.java @@ -37,5 +37,4 @@ public static DurationPeriod get(String value) { // in case the requested value was not found in the enum values, we return the first item as default. return Currency.values().length > 0 ? DurationPeriod.values()[0]: null; } - } diff --git a/src/test/java/com/kaltura/client/test/tests/enums/KsqlKeys.java b/src/test/java/com/kaltura/client/test/tests/enums/KsqlKeys.java new file mode 100644 index 000000000..08a2e5220 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/KsqlKeys.java @@ -0,0 +1,46 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum KsqlKeys implements EnumAsString { + + START_DATE("start_date"), + END_DATE("end_date"), + GEO_BLOCK("geo_block"), + PARENTAL_RULES("parental_rules"), + USER_INTERESTS("user_interests"), + EPG_CHANNEL_ID("epg_channel_id"), + EPG_ID("epg_id"), + MEDIA_ID("media_id"), + ENTITLED_ASSETS("entitled_assets"); + + private String value; + + KsqlKeys(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static KsqlKeys get(String value) { + if(value == null) { + return null; + } + + // goes over Currency defined values and compare the inner value with the given one: + for(KsqlKeys item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return Currency.values().length > 0 ? KsqlKeys.values()[0]: null; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index cdd44ecac..79fbd2a1b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; @@ -27,6 +28,8 @@ import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; +import static com.kaltura.client.test.tests.enums.KsqlKeys.ENTITLED_ASSETS; +import static com.kaltura.client.test.tests.enums.KsqlKeys.MEDIA_ID; import static com.kaltura.client.test.utils.AssetUtils.*; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; @@ -122,8 +125,16 @@ private void asset_list_before_class() { @Description("asset/action/list - VOD - filter by entitled asset") @Test private void listVodAssetsByEntitled() { - ksqlQuery = "(and (or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "') entitled_assets = 'entitled')"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder() + .openAnd() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .closeOr() + .equal(ENTITLED_ASSETS.getValue(), "entitled") + .closeAnd() + .toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(masterUserKs)); @@ -132,13 +143,12 @@ private void listVodAssetsByEntitled() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); } - @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - filter by asset name") @Test private void listVodAssetsByAssetName() { - ksqlQuery = "name = '" + asset.getName() + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder().equal("name", asset.getName()).toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -151,8 +161,8 @@ private void listVodAssetsByAssetName() { @Description("Reserved key: asset/action/list - VOD - filter by media_id") @Test private void listVodAssetsByMediaId() { - ksqlQuery = "media_id = '" + asset.getId() + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder().equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())).toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -165,8 +175,8 @@ private void listVodAssetsByMediaId() { @Description("asset/action/list - VOD - filter by meta") @Test private void listVodAssetsByMeta() { - ksqlQuery = "" + metaName + " = '" + metaValue1 + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder().equal(metaName, metaValue1).toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -180,8 +190,13 @@ private void listVodAssetsByMeta() { @Description("Logical conjunction: asset/action/list - VOD - OR query") @Test private void listVodAssetsWithOrQuery() { - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .closeOr() + .toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -195,8 +210,13 @@ private void listVodAssetsWithOrQuery() { @Description("Logical conjunction: asset/action/list - VOD - AND query") @Test private void listVodAssetsWithAndQuery() { - ksqlQuery = "(and media_id = '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder() + .openAnd() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .equal(tagName, tagValue) + .closeAnd() + .toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -209,8 +229,13 @@ private void listVodAssetsWithAndQuery() { @Description("Alpha numeric field: asset/action/list - VOD - not query") @Test private void listVodAssetsWithNotKsqlQuery() { - ksqlQuery = "(and media_id != '" + asset3.getId() + "' " + tagName + " = '" + tagValue + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder() + .openAnd() + .notEqual(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .equal(tagName, tagValue) + .closeAnd() + .toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); diff --git a/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java new file mode 100644 index 000000000..9aec3585e --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java @@ -0,0 +1,110 @@ +package com.kaltura.client.test.utils; + +public class KsqlBuilder { + private String query; + private StringBuilder sb; + + public KsqlBuilder() { + sb = new StringBuilder(); + } + + // numerical fields operators + public KsqlBuilder equal(String key, int value) { + sb.append(key).append("=").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder notEqual(String key, int value) { + sb.append(key).append("!=").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder greater(String key, int value) { + sb.append(key).append(">").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder less(String key, int value) { + sb.append(key).append("<").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder greaterOrEqual(String key, int value) { + sb.append(key).append(">=").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder lessOrEqual(String key, int value) { + sb.append(key).append("<=").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + // alpha-numerical fields + public KsqlBuilder equal(String key, String value) { + sb.append(key).append("=").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder notEqual(String key, String value) { + sb.append(key).append("!=").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder like(String key, String value) { + sb.append(key).append("~").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder notLike(String key, String value) { + sb.append(key).append("!~").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + public KsqlBuilder startsWith(String key, String value) { + sb.append(key).append("^").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + // searching one value in a list of numeric values + public KsqlBuilder inList(String key, String value) { + sb.append(key).append(":").append("'").append(String.valueOf(value)).append("' "); + return this; + } + + // logical conjunctions + public KsqlBuilder and(String statment) { + sb.append("(and ").append(statment).append(") "); + return this; + } + + public KsqlBuilder or(String statment) { + sb.append("(or ").append(statment).append(") "); + return this; + } + + public KsqlBuilder openAnd() { + sb.append("(and "); + return this; + } + + public KsqlBuilder openOr() { + sb.append("(or "); + return this; + } + + public KsqlBuilder closeAnd() { + String s = sb.toString().trim(); + sb = new StringBuilder(s).append(") "); + return this; + } + + public KsqlBuilder closeOr() { + String s = sb.toString().trim(); + sb = new StringBuilder(s).append(") "); + return this; + } + + public String toString() { + return sb.toString().trim(); + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 512419a8e..ebf1c7cfe 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -3,6 +3,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.test.tests.enums.DurationPeriod; +import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.Asset; import com.kaltura.client.types.ListResponse; @@ -27,6 +28,9 @@ import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.enums.KsqlKeys.END_DATE; +import static com.kaltura.client.test.tests.enums.KsqlKeys.EPG_CHANNEL_ID; +import static com.kaltura.client.test.tests.enums.KsqlKeys.START_DATE; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; @@ -88,9 +92,16 @@ public static List insertEpg(EpgData epgData) { String firstProgramStartDateEpoch = String.valueOf(epgData.startDate.getTime().getTime() / 1000); SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); - // TODO: 6/29/2018 create ksql builder util - assetFilter.setKSql("(and epg_channel_id='" + epgChannelId + "' start_date >= '" + firstProgramStartDateEpoch - + "' Series_ID='" + epgData.seriesId + "' end_date >= '" + firstProgramStartDateEpoch + "')"); + + String query = new KsqlBuilder() + .openAnd() + .equal(EPG_CHANNEL_ID.getValue(), epgChannelId) + .greaterOrEqual(START_DATE.getValue(), Integer.valueOf(firstProgramStartDateEpoch)) + .equal("Series_ID", epgData.seriesId) + .greaterOrEqual(END_DATE.getValue(), Integer.valueOf(firstProgramStartDateEpoch)) + .closeAnd() + .toString(); + assetFilter.setKSql(query); ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); await() diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 72261896d..f525d7c52 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -169,6 +169,10 @@ private static String buildIngestPpXml(PpData ppData, String action) { pp.setAttribute("action", action); pp.setAttribute("is_active", Boolean.toString(ppData.isActive)); + if (action.equals(INGEST_ACTION_DELETE)) { + return uncommentCdataSection(docToString(doc)); + } + // full life cycles pp.getElementsByTagName("full_life_cycle").item(0).setTextContent(ppData.fullLifeCycle); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index e3c57588c..85dc1bd8f 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -143,6 +143,10 @@ private static String buildIngestPpvXml(PpvData ppvData, String action) { ppv.setAttribute("action", action); ppv.setAttribute("is_active", Boolean.toString(ppvData.isActive)); + if (action.equals(INGEST_ACTION_DELETE)) { + return uncommentCdataSection(docToString(doc)); + } + // description ppv.getElementsByTagName("description").item(0).setTextContent(ppvData.description); From dd2b60263e7767315cc9ba6c13548f780f08fa9f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 3 Jul 2018 16:06:14 +0300 Subject: [PATCH 402/605] Added PerformanceAppLogUtils --- .../com/kaltura/client/test/Properties.java | 9 +- .../test/TestAPIOkRequestsExecutor.java | 15 +- .../test/utils/PerformanceAppLogUtils.java | 276 ++++++++++++++++++ src/test/resources/test.template.properties | 9 +- 4 files changed, 296 insertions(+), 13 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 2db9224e3..066b2834f 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -76,9 +76,12 @@ public class Properties { public static final String PHOENIX_SERVER_USER_NAME = "phoenix_server_user_name"; public static final String PHOENIX_SERVER_PASSWORD = "phoenix_server_password"; public static final String PHOENIX_SERVER_LOGS_DIRECTORY = "phoenix_server_logs_directory"; - public static final String PHOENIX_SERVER_LOG_FILE_NAME = "phoenix_server_logs_file_name"; - public static final String PHOENIX_SERVER_LOGS_LOCAL_PATH = "phoenix_server_logs_local_path"; - public static final String REGRESSION_LOGS_LOCAL_PATH = "regression_logs_local_path"; + public static final String PHOENIX_SERVER_LOG_FILE_NAME_PREFIX = "phoenix_server_logs_file_name_prefix"; + public static final String PHOENIX_SERVER_LOG_FILE_EXTENSION = "phoenix_server_logs_file_extension"; + public static final String PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH = "phoenix_server_logs_local_folder_path"; + public static final String REGRESSION_LOGS_LOCAL_FILE = "regression_logs_local_file"; + public static final String SHOULD_REGRESSION_LOGS_BE_SAVED = "should_regression_logs_be_saved"; + public static final String MAX_ALLOWED_PERCENTAGE = "max_allowed_percentage"; public static String getProperty(String propertyKey) { if (resourceBundle == null) { diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 2a6576d9f..944633ccf 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -15,9 +15,7 @@ import java.io.*; import java.util.concurrent.atomic.AtomicBoolean; -import static com.kaltura.client.test.Properties.MAX_OBJECTS_AT_LIST_RESPONSE; -import static com.kaltura.client.test.Properties.REGRESSION_LOGS_LOCAL_PATH; -import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.LOG_HEADERS; import static com.kaltura.client.test.tests.BaseTest.client; import static com.kaltura.client.utils.ErrorElement.*; @@ -92,16 +90,19 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request /*date = new Date(); System.out.println("AFTER VALIDATION: " + formatter.format(date));*/ - String serviceMethod = action.getUrl().split("service")[1]; - String kalturaSession = okhttpResponse.headers().get("X-Kaltura-Session"); - write2LogFile(serviceMethod, kalturaSession); + if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { + String serviceMethod = action.getUrl().split("service")[1]; + String kalturaSession = okhttpResponse.headers().get("X-Kaltura-Session"); + write2LogFile(serviceMethod, kalturaSession); + } } } return responseElement; } private void write2LogFile(String serviceMethod, String kalturaSession) { - try(FileWriter fw = new FileWriter(getProperty(REGRESSION_LOGS_LOCAL_PATH), true); + try(FileWriter fw = new FileWriter(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(REGRESSION_LOGS_LOCAL_FILE), true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out = new PrintWriter(bw)) { out.println(serviceMethod + " " + kalturaSession); diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java new file mode 100644 index 000000000..a04f551c1 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -0,0 +1,276 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.Logger; +import com.kaltura.client.test.Sandbox; +import org.apache.commons.vfs2.*; +import org.apache.commons.vfs2.auth.StaticUserAuthenticator; +import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; +import java.io.*; +import java.io.FileNotFoundException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; +import static com.kaltura.client.test.Properties.*; +import static com.kaltura.client.test.Properties.API_VERSION; +import static com.kaltura.client.test.Properties.getProperty; + +public class PerformanceAppLogUtils extends BaseUtils { + + private static final int maxAllowedPercentage = Integer.valueOf(getProperty(MAX_ALLOWED_PERCENTAGE)); + private static final String domain = getProperty(PHOENIX_SERVER_DOMAIN_NAME); + private static final String userName = getProperty(PHOENIX_SERVER_USER_NAME); + private static final String password = getProperty(PHOENIX_SERVER_PASSWORD); + private static final UserAuthenticator auth = new StaticUserAuthenticator(domain, userName, password); + private static final FileSystemOptions options = new FileSystemOptions(); + private static final String remoteSourceFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY) + getProperty(API_VERSION) + "\\"; + + private static final String COUCHBASE_LOG_DATA = "\"e\":\"cb\""; + private static final String DB_LOG_DATA = "\"e\":\"db\""; + private static final String ELASTIC_SEARCH_LOG_DATA = "\"e\":\"es\""; + private static final String RABBIT_LOG_DATA = "\"e\":\"rabbit\""; + + private static final List nonRelated2CodeStringsList = new ArrayList<>(); + { + nonRelated2CodeStringsList.add("\"e\":\"start_api\""); + nonRelated2CodeStringsList.add(COUCHBASE_LOG_DATA); + nonRelated2CodeStringsList.add(DB_LOG_DATA); + nonRelated2CodeStringsList.add(ELASTIC_SEARCH_LOG_DATA); + nonRelated2CodeStringsList.add(RABBIT_LOG_DATA); + } + + private static double timeOfCode; + private static double timeOfCB; + private static double timeOfDB; + private static double timeOfES; + private static double timeOfRabbit; + private static double totalTime; + private static boolean isKalturaSessionFoundInFile; + + public static void testPerformanceCode() { + try { + List appRemoteFileNames = getRemoteAppLogFileNames(); + for (String fileName: appRemoteFileNames) { + copyRemoteFile2LocalMachine(fileName); + } + + Map> methodsAndKalturaSessions = loadMethodsAndSessionsFromTestFile(); + + for (String method: methodsAndKalturaSessions.keySet()) { + Logger.getLogger(PerformanceAppLogUtils.class).debug("Method: [" + method + "]"); + for (String xKalturaSession: methodsAndKalturaSessions.get(method)) { + Logger.getLogger(PerformanceAppLogUtils.class).debug("xKalturaSession: [" + xKalturaSession + "]"); + for (String appFileName: appRemoteFileNames) { + isKalturaSessionFoundInFile = false; + timeOfCode = 0.0; + timeOfCB = 0.0; + timeOfDB = 0.0; + timeOfES = 0.0; + timeOfRabbit = 0.0; + totalTime = 0.0; + + calcTimeExecution(appFileName, xKalturaSession); + + if (isKalturaSessionFoundInFile) { + // display results + double percentageCodeTime2TotalTime = timeOfCode / totalTime * 100; + if (percentageCodeTime2TotalTime > maxAllowedPercentage) { + // TODO: save report into file and add summary + Logger.getLogger(PerformanceAppLogUtils.class).debug("code time = " + timeOfCode + " PERFORMANCE LEVEL IS TOO WEAK: " + + String.format("%.2f", percentageCodeTime2TotalTime) + "%" + " \"" + xKalturaSession + "\""); + } /* THAT PART COMMENTED TO GET IT EASY IN CASE IT NEEDED LATEE + else { + logIfValueMoreThanZero(timeOfCode, "code time = "); + logIfValueMoreThanZero(timeOfCB, "Couchbase time = "); + logIfValueMoreThanZero(timeOfDB, "Database time = "); + logIfValueMoreThanZero(timeOfES, "Elastic search time = "); + logIfValueMoreThanZero(timeOfRabbit, "Rabbit time = "); + }*/ + } + } + } + } + + deleteResultsOfRegressionExecution(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * After execution of util we have to delete log file created during regression execution to not affect results of next checking + */ + private static void deleteResultsOfRegressionExecution() { + String fileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(REGRESSION_LOGS_LOCAL_FILE); + String prefix = getOffsetDateInFormat(0, "dd.MM.yyyy hh.mm"); + String targetFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + prefix + + getProperty(REGRESSION_LOGS_LOCAL_FILE); + try { + Files.copy(Paths.get(fileName), new FileOutputStream(targetFileName)); + File targetFile = new File(targetFileName); + if (targetFile.exists()) { + deleteFile(fileName); + Logger.getLogger(Sandbox.class).debug("File: [" + targetFileName + "] has been created"); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void logIfValueMoreThanZero(double time, String message) { + if (time > 0) { + Logger.getLogger(Sandbox.class).debug(message + time); + } + } + + private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IOException { + Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine() with [" + remoteFileName + "]: started"); + + // add local target folder in case it does not exist + File localTargetFolderPath = new File(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH)); + if (!localTargetFolderPath.exists()) { + boolean isDirCreated = localTargetFolderPath.mkdir(); + Logger.getLogger(PerformanceAppLogUtils.class).debug("Directory [" + + getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "] was created == [" + isDirCreated + "]"); + } + + String remoteFilePath = remoteSourceFileDir + remoteFileName; + String localTargetFilePath = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "copied-" + remoteFileName; + + // remove local target file in case it exists and create it empty + File targetFile = new File(localTargetFilePath); + if (targetFile.exists()) { + targetFile.delete(); + } + targetFile.createNewFile(); + FileObject destination = VFS.getManager().resolveFile(targetFile.getAbsolutePath()); + + //domain, username, password + DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); + + FileObject fileObject = VFS.getManager().resolveFile(remoteFilePath, options); + + // copy file from remote to local folder + if (fileObject.exists()) { + destination.copyFrom(fileObject, Selectors.SELECT_SELF); + } + destination.close(); + Logger.getLogger(PerformanceAppLogUtils.class).debug("File [" + remoteFilePath + "] was copied into [" + localTargetFilePath + "]"); + + Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine(): closed"); + } + + private static List getRemoteAppLogFileNames() throws IOException { + Logger.getLogger(PerformanceAppLogUtils.class).debug("getRemoteAppLogFileNames(): started"); + List fileNames = new ArrayList<>(); + String sourceFileName = getProperty(PHOENIX_SERVER_LOG_FILE_NAME_PREFIX) + getProperty(API_VERSION) + + getProperty(PHOENIX_SERVER_LOG_FILE_EXTENSION); + String remoteFilePath = remoteSourceFileDir + sourceFileName; + + //domain, username, password + DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); + + FileObject fileObject = VFS.getManager().resolveFile(remoteFilePath, options); + + if (fileObject.exists()) { + fileNames.add(sourceFileName); + } + int idx = 1; + while (fileObject.exists()) { + // all files related needed logs have the same name as value from sourceFileName and additionally they have suffix looks like ".1", ".2", etc + String name = sourceFileName + "." + idx; + fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); + idx++; + // sometimes file can be removed and it means we should one more time check names + if (fileObject.exists()) { + fileNames.add(name); + } else { + name = sourceFileName + "." + idx; + fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); + idx++; + if (fileObject.exists()) { + fileNames.add(name); + } + } + } + return fileNames; + } + + /** + * We have file with name getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(REGRESSION_LOGS_LOCAL_FILE) + * that saves information about all executed methods and their kaltura sessions. + * That file will be filled with data only in case test.properties has should_regression_logs_be_saved=true + * + * @return map contains all methods and kaltura sessions related to regression + */ + private static Map> loadMethodsAndSessionsFromTestFile() { + Map> result = new HashMap<>(); + String[] values; + try { + InputStream is = new FileInputStream(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(REGRESSION_LOGS_LOCAL_FILE)); + BufferedReader buf = new BufferedReader(new InputStreamReader(is)); + + String line; + List sessions; + while ((line = buf.readLine()) != null) { + values = line.split(" "); + sessions = result.get(values[0]); + if (sessions == null) { + sessions = new ArrayList<>(); + } + sessions.add(values[1]); + result.put(values[0], sessions); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + return result; + } + } + + private static void calcTimeExecution(String appFileName, String kalturaSession) { + String path2File = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "copied-" + appFileName; + + String[] nonRelated2CodeStringsArray = new String[nonRelated2CodeStringsList.size()]; + String executionTimeString; + try(BufferedReader br = new BufferedReader(new FileReader(path2File))) { + for(String line; (line = br.readLine()) != null; ) { + if (line.contains(kalturaSession)) { + isKalturaSessionFoundInFile = true; + // this is a usual position of time in the whole string + executionTimeString = line.split("\"")[3]; + // "e": "ws" should be ignored as it partially described in other events + if (stringContainsItemFromArray(line, nonRelated2CodeStringsList.toArray(nonRelated2CodeStringsArray))) { + timeOfCode = timeOfCode - Double.valueOf(executionTimeString); + } else { + if (line.contains("\"e\":\"end_api\"")) { + //System.out.println(2); + totalTime = Double.valueOf(executionTimeString); + timeOfCode = timeOfCode + totalTime; + } + } + if (line.contains(COUCHBASE_LOG_DATA)) { + timeOfCB = timeOfCB + Double.valueOf(executionTimeString); + } + if (line.contains(DB_LOG_DATA)) { + timeOfDB = timeOfDB + Double.valueOf(executionTimeString); + } + if (line.contains(ELASTIC_SEARCH_LOG_DATA)) { + timeOfES = timeOfES + Double.valueOf(executionTimeString); + } + if (line.contains(RABBIT_LOG_DATA)) { + timeOfRabbit = timeOfRabbit + Double.valueOf(executionTimeString); + } + } + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static boolean stringContainsItemFromArray(String inputStr, String[] items) { + return Arrays.stream(items).parallel().anyMatch(inputStr::contains); + } +} diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index 7ee6403f4..d5c2ee447 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -40,6 +40,9 @@ phoenix_server_domain_name=@PHOENIX_SERVER_DOMAIN_NAME@ phoenix_server_user_name=@PHOENIX_SERVER_USER_NAME@ phoenix_server_password=@PHOENIX_SERVER_PASSWORD@ phoenix_server_logs_directory=@PHOENIX_SERVER_LOGS_DIRECTORY@ -phoenix_server_logs_file_name=@PHOENIX_SERVER_LOGS_FILE_NAME@ -phoenix_server_logs_local_path=@PHOENIX_SERVER_LOGS_LOCAL_PATH@ -regression_logs_local_path=@REGRESSION_LOGS_LOCAL_PATH@ \ No newline at end of file +phoenix_server_logs_file_name_prefix=@PHOENIX_SERVER_LOGS_FILE_NAME_PREFIX@ +phoenix_server_logs_file_extension=@PHOENIX_SERVER_LOGS_FILE_EXTENSION@ +phoenix_server_logs_local_folder_path=@PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH@ +regression_logs_local_file=@REGRESSION_LOGS_LOCAL_FILE@ +should_regression_logs_be_saved=@SHOULD_REGRESSION_LOGS_BE_SAVED@ +max_allowed_percentage=@MAX_ALLOWED_PERCENTAGE@ \ No newline at end of file From e29253eb1b92a94a33a21e7c8375da3595ee4ad7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 3 Jul 2018 16:06:27 +0300 Subject: [PATCH 403/605] fixed failed test --- .../productPriceTests/ProductPriceListTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 458a04ae4..33a63dc88 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -669,8 +669,8 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { String masterKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); VodData vodData = new VodData() - .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) - .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS); + .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT) + .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT); MediaAsset mediaAsset = insertVod(vodData); int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); From c3fd76c09d5df6b088ec23669b5c960a64a27cc0 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 3 Jul 2018 16:21:46 +0300 Subject: [PATCH 404/605] no message --- .../SearchAssetFilterTests.java | 130 ++++++++++++------ .../client/test/utils/KsqlBuilder.java | 13 +- 2 files changed, 103 insertions(+), 40 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 79fbd2a1b..7b05a9c8e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -42,20 +42,16 @@ public class SearchAssetFilterTests extends BaseTest { - private MediaAsset asset; - private MediaAsset asset2; - private MediaAsset asset3; - private ProgramAsset program; - private ProgramAsset program2; private final String tagName = "Genre"; - private String tagValue; private final String metaName = "synopsis"; private final String metaName2 = "Short title"; - private String metaValue1 = "A" + getRandomValue("_", 999999); - private String metaValue2 = "B" + getRandomValue("_", 999999); - private String ksqlQuery; + private final String metaValue1 = "A" + getRandomValue("_", 999999); + private final String metaValue2 = "B" + getRandomValue("_", 999999); + + private MediaAsset asset, asset2, asset3; + private ProgramAsset program, program2; + private String tagValue, masterUserKs; private AssetFilter assetFilter; - private String masterUserKs; @BeforeClass @@ -249,8 +245,16 @@ private void listVodAssetsWithNotKsqlQuery() { @Description("Alpha numeric field: asset/action/list - VOD - with existing meta value (+)") @Test private void listVodAssetsWithExistingMetaValue() { - ksqlQuery = "(and (or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "')" + metaName2 + "+''" + " )"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder() + .openAnd() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .closeOr() + .exists(metaName2) + .closeAnd() + .toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -263,8 +267,8 @@ private void listVodAssetsWithExistingMetaValue() { @Description("Alpha numeric field: asset/action/list - VOD - like query") @Test private void listVodAssetsWithLikeKsqlQuery() { - ksqlQuery = "" + tagName + " ~ '" + tagValue + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder().like(tagName, tagValue).toString(); + assetFilter = getSearchAssetFilter(query); List assets = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())) @@ -280,8 +284,8 @@ private void listVodAssetsWithLikeKsqlQuery() { @Description("Alpha numeric field: asset/action/list - VOD - start with query") @Test private void listVodAssetsWithStartWithKsqlQuery() { - ksqlQuery = "" + tagName + " ^ '" + tagValue + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder().startsWith(tagName, tagValue).toString(); + assetFilter = getSearchAssetFilter(query); List assets = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())) @@ -297,8 +301,13 @@ private void listVodAssetsWithStartWithKsqlQuery() { @Description("asset/action/list - VOD - filtered by type (Movie)") @Test private void listVodAssetsFilteredByType() { - ksqlQuery = "(and " + tagName + " = '" + tagValue + "' asset_type = '" + getProperty(MOVIE_MEDIA_TYPE_ID) + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, null); + String query = new KsqlBuilder() + .openAnd() + .equal(tagName, tagValue) + .equal("asset_type", getProperty(MOVIE_MEDIA_TYPE_ID)) + .closeAnd() + .toString(); + assetFilter = getSearchAssetFilter(query); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -316,8 +325,14 @@ private void orderVodAssetsByViews() { addViewsToAsset(asset2.getId(), 2, AssetType.MEDIA); addViewsToAsset(asset3.getId(), 1, AssetType.MEDIA); - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .closeOr() + .toString(); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -341,8 +356,14 @@ private void orderVodAssetsByName() { vodData.name("CCC"); updateVod(asset3.getName(), vodData); - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .closeOr() + .toString(); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -352,7 +373,7 @@ private void orderVodAssetsByName() { assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); @@ -370,8 +391,14 @@ private void orderVodAssetsByLikes() { addLikesToAsset(asset2.getId(), 2, AssetType.MEDIA); addLikesToAsset(asset.getId(), 1, AssetType.MEDIA); - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .closeOr() + .toString(); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -390,8 +417,14 @@ private void orderVodAssetsByVotesAndRating() { addVotesToAsset(asset3.getId(), 1, AssetType.MEDIA, 5); // Order by number of votes (highest to lowest) - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .closeOr() + .toString(); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -403,7 +436,7 @@ private void orderVodAssetsByVotesAndRating() { assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); // Order by Ratings (highest to lowest) - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); @@ -418,8 +451,14 @@ private void orderVodAssetsByVotesAndRating() { @Description("asset/action/list - VOD - order by CATALOG START DATE") @Test private void orderVodAssetsByCatalogStartDate() { - ksqlQuery = "(or media_id = '" + asset.getId() + "' media_id = '" + asset2.getId() + "'media_id = '" + asset3.getId() + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .closeOr() + .toString(); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -430,7 +469,7 @@ private void orderVodAssetsByCatalogStartDate() { assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, null, null, null, AssetOrderBy.START_DATE_ASC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.START_DATE_ASC.getValue()); listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); @@ -446,11 +485,19 @@ private void orderVodAssetsByCatalogStartDate() { @Test(enabled = false) private void dynamicOrderByMeta() { - ksqlQuery = "(and (or media_id = '" + asset2.getId() + "' media_id = '" + asset3.getId() + "') asset_type = '" + getProperty(MOVIE_MEDIA_TYPE_ID) + "')"; + String query = new KsqlBuilder() + .openAnd() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) + .closeOr() + .equal("asset_type", getProperty(MOVIE_MEDIA_TYPE_ID)) + .closeAnd() + .toString(); DynamicOrderBy dynamicOrderBy = new DynamicOrderBy(); dynamicOrderBy.setName(metaName); dynamicOrderBy.setOrderBy(MetaTagOrderBy.META_ASC); - assetFilter = getSearchAssetFilter(ksqlQuery, null, null, dynamicOrderBy, null, null, null); + assetFilter = getSearchAssetFilter(query, null, null, dynamicOrderBy, null, null, null); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -469,8 +516,8 @@ private void dynamicOrderByMeta() { @Description("asset/action/list - EPG - name equal query") @Test private void listEpgProgramByName() { - ksqlQuery = "name = '" + program.getName() + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery, null, "0", null, null, null, null); + String query = new KsqlBuilder().equal("name", program.getName()).toString(); + assetFilter = getSearchAssetFilter(query, null, "0", null, null, null, null); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -483,8 +530,8 @@ private void listEpgProgramByName() { @Description("asset/action/list - EPG - epg channel id equal query") @Test private void listEpgProgramByChannelId() { - ksqlQuery = "epg_channel_id = '" + program.getEpgChannelId() + "'"; - assetFilter = getSearchAssetFilter(ksqlQuery); + String query = new KsqlBuilder().equal("epg_channel_id", Math.toIntExact(program.getEpgChannelId())).toString(); + assetFilter = getSearchAssetFilter(query); List epgPrograms = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())) @@ -500,8 +547,13 @@ private void listEpgProgramByChannelId() { @Description("asset/action/list - EPG - filter by epg channel id") @Test private void listEpgProgramsFilteredByEpgChannel() { - ksqlQuery = "(or name = '" + program.getName() + "' name = '" + program2.getName() + "')"; - assetFilter = getSearchAssetFilter(ksqlQuery, program2.getEpgChannelId().toString(), "0", null, null, null, null); + String query = new KsqlBuilder() + .openOr() + .equal("name", program.getName()) + .equal("name", program2.getName()) + .closeOr() + .toString(); + assetFilter = getSearchAssetFilter(query, program2.getEpgChannelId().toString(), "0", null, null, null, null); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); diff --git a/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java index 9aec3585e..075e6aa02 100644 --- a/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java +++ b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java @@ -65,12 +65,23 @@ public KsqlBuilder startsWith(String key, String value) { return this; } - // searching one value in a list of numeric values + // searching one value in a list of numeric values operator public KsqlBuilder inList(String key, String value) { sb.append(key).append(":").append("'").append(String.valueOf(value)).append("' "); return this; } + // exists operators + public KsqlBuilder exists(String key) { + sb.append(key).append("+''"); + return this; + } + + public KsqlBuilder notExists(String key) { + sb.append(key).append("!+''"); + return this; + } + // logical conjunctions public KsqlBuilder and(String statment) { sb.append("(and ").append(statment).append(") "); From 678a0b30f49b832cac9b05fa054379ce7e101e86 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 4 Jul 2018 14:28:38 +0300 Subject: [PATCH 405/605] AssetListTest.ChannelFilterTests --- .../com/kaltura/client/test/Properties.java | 1 - .../kaltura/client/test/tests/BaseTest.java | 19 +-- .../AssetListTests/ChannelFilterTests.java | 140 ++++++++++++++++++ .../SearchAssetFilterTests.java | 3 +- .../householdTests/HouseholdPurgeTests.java | 16 +- .../client/test/utils/HouseholdUtils.java | 16 +- .../test/utils/PerformanceAppLogUtils.java | 9 +- .../utils/ingestUtils/IngestMppUtils.java | 6 +- .../test/utils/ingestUtils/IngestPpUtils.java | 7 +- .../utils/ingestUtils/IngestPpvUtils.java | 6 +- .../utils/ingestUtils/IngestVodUtils.java | 8 +- .../SearchAssetFilterTests.md | 0 12 files changed, 188 insertions(+), 43 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java rename src/test/resources/{Tests documentation => tests_documentation}/SearchAssetFilterTests.md (100%) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 066b2834f..774a82d1a 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -95,4 +95,3 @@ public static String getProperty(String propertyKey) { // TODO: 3/12/2018 open conference page with all the documentation problems // TODO: 12/MAR/2018 decide if we need that autoskip logic for tests with known opened bugs: // https://dzone.com/articles/how-to-automatically-skip-tests-based-on-defects-s -// TODO: 3/19/2018 update readme file with project structure and list of services diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 4d912feba..29cd62ab0 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -63,7 +63,8 @@ public class BaseTest { private static String administratorKs, operatorKs, managerKs, anonymousKs; // shared ingest users data - private static String ingestAssetUserUsername, ingestAssetUserPassword, ingestBusinessModuleUserUsername, ingestBusinessModuleUserPassword; + private static String ingestAssetUserUsername, ingestAssetUserPassword, ingestBusinessModuleUserUsername, + ingestBusinessModuleUserPassword, ingestVirtualAssetUserUsername, ingestVirtualAssetUserPassword; // shared VOD private static MediaAsset mediaAsset; @@ -285,21 +286,21 @@ public static String getIngestAssetUserPassword() { } public static String getIngestVirualAssetUserName() { - if (ingestAssetUserUsername == null) { + if (ingestVirtualAssetUserUsername == null) { String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 2); - ingestAssetUserUsername = userInfo.split(":")[0]; - ingestAssetUserPassword = userInfo.split(":")[1]; + ingestVirtualAssetUserUsername = userInfo.split(":")[0]; + ingestVirtualAssetUserPassword = userInfo.split(":")[1]; } - return ingestAssetUserUsername; + return ingestVirtualAssetUserUsername; } public static String getIngestVirualAssetUserPassword() { - if (ingestAssetUserPassword == null) { + if (ingestVirtualAssetUserPassword == null) { String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 2); - ingestAssetUserUsername = userInfo.split(":")[0]; - ingestAssetUserPassword = userInfo.split(":")[1]; + ingestVirtualAssetUserUsername = userInfo.split(":")[0]; + ingestVirtualAssetUserPassword = userInfo.split(":")[1]; } - return ingestAssetUserPassword; + return ingestVirtualAssetUserPassword; } // getters for shared params diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java new file mode 100644 index 000000000..9af1e44e0 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -0,0 +1,140 @@ +package com.kaltura.client.test.tests.servicesTests.AssetTests.AssetListTests; + +import com.kaltura.client.services.ChannelService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.json.JSONArray; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.services.AssetService.list; +import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; +import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static org.assertj.core.api.Assertions.assertThat; + +public class ChannelFilterTests extends BaseTest { + private final Long maxValue = 999999L; + private final String tagName = "Genre"; + private final String metaName = "synopsis"; + private final String metaName2 = "Short title"; + private final String metaValue1 = getRandomValue(" A_", maxValue); + private final String metaValue2 = getRandomValue("B_", maxValue); + + private MediaAsset asset, asset2, asset3; + private ProgramAsset program, program2; + private String tagValue, masterUserKs; + private AssetFilter assetFilter; + private Channel channel; + + + @BeforeClass + private void asset_list_channelFilter_before_class() { + // Get asset from shared asset method + tagValue = getRandomValue(tagName + "_", 999999); + + ArrayList list = new ArrayList<>(); + list.add(tagValue); + + HashMap> tagMap = new HashMap<>(); + tagMap.put(tagName, list); + + HashMap stringMetaMap1 = new HashMap<>(); + stringMetaMap1.put(metaName, metaValue1); + stringMetaMap1.put(metaName2, metaValue1); + + HashMap stringMetaMap2 = new HashMap<>(); + stringMetaMap2.put(metaName, metaValue2); + + JSONArray ja = getLinearAssetIdAndEpgChannelNameJsonArray(); + String epgChannelName = ja.getJSONObject(0).getString("name"); + String epgChannelName2 = ja.getJSONObject(1).getString("name"); + + // ingest movie + VodData vodData1 = new VodData() + .mediaType(MOVIE_MEDIA_TYPE); + System.out.println("1! " + vodData1.toString()); + asset = insertVod(vodData1); + + // ingest series + VodData vodData2 = new VodData() + .mediaType(SERIES_MEDIA_TYPE) + .isVirtual(true); + System.out.println("2! " + vodData2.toString()); + asset2 = insertVod(vodData2); + + // ingest episode + System.out.println("3!"); + VodData vodData3 = new VodData() + .mediaType(EPISODE_MEDIA_TYPE) + .catalogStartDate(getTimeInDate(-10)) + .tags(tagMap) + .strings(stringMetaMap2); + asset3 = insertVod(vodData3); + +// // ingest epg 1 +// EpgData epgData1 = new EpgData(epgChannelName).episodesNum(1); +// program = insertEpg(epgData1).get(0); +// +// // ingest epg 2 +// EpgData epgData2 = new EpgData(epgChannelName2).episodesNum(1); +// program2 = insertEpg(epgData2).get(0); + + Household household = createHousehold(); + masterUserKs = getHouseholdMasterUserKs(household); + + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(asset.getId().intValue()), Optional.empty(), Optional.empty()); + + // add channel + channel = new Channel(); + channel.setName(getRandomValue("channel_", maxValue)); + channel.description("Description of " + channel.getName()); + channel.setIsActive(true); + channel.setFilterExpression("Free='" + channel.getName() + "'"); +// channel.setOrder(AssetOrderBy.NAME_ASC); + + channel = executor.executeSync(ChannelService.add(channel) + .setKs(getOperatorKs())).results; + } + + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - vod - channelFilter") + @Test + private void listVodAssetsByChannel() { +// String query = new KsqlBuilder() +// .openAnd() +// .openOr() +// .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) +// .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) +// .closeOr() +// .equal(ENTITLED_ASSETS.getValue(), "entitled") +// .closeAnd() +// .toString(); + + ChannelFilter filter = new ChannelFilter(); + filter.setIdEqual(Math.toIntExact(channel.getId())); + + Response> assetListResponse = executor.executeSync(list(filter) + .setKs(masterUserKs)); + + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + } + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 7b05a9c8e..4936f52b8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -55,7 +55,7 @@ public class SearchAssetFilterTests extends BaseTest { @BeforeClass - private void asset_list_before_class() { + private void asset_list_searchAssetFilter_before_class() { // Get asset from shared asset method tagValue = getRandomValue(tagName + "_", 999999); @@ -109,7 +109,6 @@ private void asset_list_before_class() { masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household); PurchaseUtils.purchasePpv(masterUserKs, Optional.of(asset.getId().intValue()), Optional.empty(), Optional.empty()); - } // Filter by KSQL diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java index 30470d6f2..883011a26 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdPurgeTests.java @@ -22,8 +22,8 @@ public class HouseholdPurgeTests extends BaseTest { - private final int numberOfUsersInHousehold = 1; - private final int numberOfDevicesInHousehold = 1; + private final int numbOfUsers = 1; + private final int numbOfDevices = 1; @Severity(SeverityLevel.CRITICAL) @@ -31,7 +31,7 @@ public class HouseholdPurgeTests extends BaseTest { @Test() private void purge_active_household() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numbOfUsers, numbOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // assert relevant statuses in db before purge @@ -67,7 +67,7 @@ private void purge_active_household() { @Test() private void purge_deleted_household() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numbOfUsers, numbOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // delete household before purge @@ -106,7 +106,7 @@ private void purge_deleted_household() { @Test() private void purge_after_delete_user() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numbOfUsers, numbOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); @@ -152,7 +152,7 @@ private void purge_after_delete_user() { @Test() private void purge_after_remove_user_from_household() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numbOfUsers, numbOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); @@ -197,7 +197,7 @@ private void purge_after_remove_user_from_household() { @Test() private void purge_on_suspended_household() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numbOfUsers, numbOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // suspend household before purge @@ -236,7 +236,7 @@ private void purge_on_suspended_household() { @Test() private void purge_after_delete_user_and_household() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numbOfUsers, numbOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); HouseholdUser user = HouseholdUtils.getRegularUsersList(household).get(0); diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index 7c22734ea..b1fd897a9 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -23,9 +23,17 @@ public class HouseholdUtils extends BaseUtils { - // create household - public static Household createHousehold(int numberOfUsersInHoushold, int numberOfDevicesInHousehold, boolean isPreparePG) { + // default household params + private static final int defaultNumOfUsers = 2; + private static final int defaultNumOfDevices = 1; + private static final boolean defaultIsPreparePG = true; + + // create household with default params + public static Household createHousehold() { + return createHousehold(defaultNumOfUsers, defaultNumOfDevices, defaultIsPreparePG); + } + public static Household createHousehold(int numOfUsers, int numOfDevices, boolean isPreparePG) { // register master user RegisterOttUserBuilder registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword); OTTUser masterUser = executor.executeSync(registerOttUserBuilder).results; @@ -46,7 +54,7 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO household = executor.executeSync(addHouseholdBuilder).results; // add additional users to household - for (int i = 0; i < numberOfUsersInHoushold; i++) { + for (int i = 0; i < numOfUsers; i++) { // register additional user registerOttUserBuilder = register(partnerId, generateOttUser(), defaultUserPassword); OTTUser additionalUser = executor.executeSync(registerOttUserBuilder).results; @@ -62,7 +70,7 @@ public static Household createHousehold(int numberOfUsersInHoushold, int numberO } // add household devices - for (int i = 0; i < numberOfDevicesInHousehold; i++) { + for (int i = 0; i < numOfDevices; i++) { // create household device HouseholdDevice householdDevice = generateHouseholdDevice(); diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index a04f551c1..261c2a56c 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -1,18 +1,17 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Logger; -import com.kaltura.client.test.Sandbox; import org.apache.commons.vfs2.*; import org.apache.commons.vfs2.auth.StaticUserAuthenticator; import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; + import java.io.*; import java.io.FileNotFoundException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; + import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.Properties.API_VERSION; -import static com.kaltura.client.test.Properties.getProperty; public class PerformanceAppLogUtils extends BaseUtils { @@ -109,7 +108,7 @@ private static void deleteResultsOfRegressionExecution() { File targetFile = new File(targetFileName); if (targetFile.exists()) { deleteFile(fileName); - Logger.getLogger(Sandbox.class).debug("File: [" + targetFileName + "] has been created"); + Logger.getLogger(PerformanceAppLogUtils.class).debug("File: [" + targetFileName + "] has been created"); } } catch (IOException e) { e.printStackTrace(); @@ -118,7 +117,7 @@ private static void deleteResultsOfRegressionExecution() { private static void logIfValueMoreThanZero(double time, String message) { if (time > 0) { - Logger.getLogger(Sandbox.class).debug(message + time); + Logger.getLogger(PerformanceAppLogUtils.class).debug(message + time); } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index 24b137d08..0f97e4f3c 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -52,12 +52,12 @@ public class IngestMppUtils extends BaseIngestUtils { @Accessors(fluent = true) @Data public static class MppData { - private boolean isActive = true; - private boolean isRenewable = false; - + @Setter(AccessLevel.NONE) private boolean isActive = true; @Setter(AccessLevel.NONE) private String mppCode; @Setter(AccessLevel.NONE) private String title; + private boolean isRenewable = false; + private String description; private String startDate; private String endDate; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index f525d7c52..32550c8f8 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -31,11 +31,10 @@ public class IngestPpUtils extends BaseIngestUtils { @Accessors(fluent = true) @Data public static class PpData { - private boolean isActive = true; - private boolean isRenewable = false; + @Setter(AccessLevel.NONE) private boolean isActive = true; + @Setter(AccessLevel.NONE) private String ppCode; - @Setter(AccessLevel.NONE) - private String ppCode; + private boolean isRenewable = false; private String fullLifeCycle; private String viewLifeCycle; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 85dc1bd8f..06fe81f07 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -29,12 +29,12 @@ public class IngestPpvUtils extends BaseIngestUtils { @Accessors(fluent = true) @Data public static class PpvData { - private boolean isActive = true; + @Setter(AccessLevel.NONE) private boolean isActive = true; + @Setter(AccessLevel.NONE) private String ppvCode; + private boolean isSubscriptionOnly = false; private boolean isFirstDeviceLimitation = false; - @Setter(AccessLevel.NONE) private String ppvCode; - private String description; private String discount; private String currency; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 86a37af69..1e39f6da3 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -34,16 +34,16 @@ public class IngestVodUtils extends BaseIngestUtils { - private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult."; - private static final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; - private static final String ingestAssetIdPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus.InternalAssetId"; + private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus."; + private static final String ingestStatusMessagePath = ingestDataResultPath + "Status.Message"; + private static final String ingestAssetIdPath = ingestDataResultPath + "InternalAssetId"; @Accessors(fluent = true) @Data public static class VodData { @Setter(AccessLevel.NONE) private String coguid; + @Setter(AccessLevel.NONE) private boolean isActive = true; - private boolean isActive = true; private boolean isVirtual = false; private String name; diff --git a/src/test/resources/Tests documentation/SearchAssetFilterTests.md b/src/test/resources/tests_documentation/SearchAssetFilterTests.md similarity index 100% rename from src/test/resources/Tests documentation/SearchAssetFilterTests.md rename to src/test/resources/tests_documentation/SearchAssetFilterTests.md From d3b7e55d45356837e08ee4689b1fa067d282cc1c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 4 Jul 2018 18:17:42 +0300 Subject: [PATCH 406/605] channelFilter --- .../enums/{KsqlKeys.java => KsqlKey.java} | 11 +- .../client/test/tests/enums/MediaType.java | 41 ++++ .../AssetListTests/BundleFilterTests.java | 7 + .../AssetListTests/ChannelFilterTests.java | 180 +++++++++--------- .../SearchAssetFilterTests.java | 4 +- .../kaltura/client/test/utils/BaseUtils.java | 5 + .../test/utils/dbUtils/DBConstants.java | 2 + .../client/test/utils/dbUtils/DBUtils.java | 40 +++- .../utils/ingestUtils/BaseIngestUtils.java | 2 +- .../utils/ingestUtils/IngestEpgUtils.java | 6 +- 10 files changed, 196 insertions(+), 102 deletions(-) rename src/test/java/com/kaltura/client/test/tests/enums/{KsqlKeys.java => KsqlKey.java} (79%) create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/MediaType.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/enums/KsqlKeys.java b/src/test/java/com/kaltura/client/test/tests/enums/KsqlKey.java similarity index 79% rename from src/test/java/com/kaltura/client/test/tests/enums/KsqlKeys.java rename to src/test/java/com/kaltura/client/test/tests/enums/KsqlKey.java index 08a2e5220..c5816bc22 100644 --- a/src/test/java/com/kaltura/client/test/tests/enums/KsqlKeys.java +++ b/src/test/java/com/kaltura/client/test/tests/enums/KsqlKey.java @@ -2,8 +2,9 @@ import com.kaltura.client.enums.EnumAsString; -public enum KsqlKeys implements EnumAsString { +public enum KsqlKey implements EnumAsString { + NAME("name"), START_DATE("start_date"), END_DATE("end_date"), GEO_BLOCK("geo_block"), @@ -16,7 +17,7 @@ public enum KsqlKeys implements EnumAsString { private String value; - KsqlKeys(String value) { + KsqlKey(String value) { this.value = value; } @@ -29,18 +30,18 @@ public void setValue(String value) { this.value = value; } - public static KsqlKeys get(String value) { + public static KsqlKey get(String value) { if(value == null) { return null; } // goes over Currency defined values and compare the inner value with the given one: - for(KsqlKeys item: values()) { + for(KsqlKey item: values()) { if(item.getValue().equals(value)) { return item; } } // in case the requested value was not found in the enum values, we return the first item as default. - return Currency.values().length > 0 ? KsqlKeys.values()[0]: null; + return Currency.values().length > 0 ? KsqlKey.values()[0]: null; } } diff --git a/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java b/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java new file mode 100644 index 000000000..c5016238b --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum MediaType implements EnumAsString { + + MOVIE("Movie"), + SERIES("Series"), + EPISODE("Episode"), + LINEAR("Linear"); + + private String value; + + MediaType(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static MediaType get(String value) { + if(value == null) { + return null; + } + + // goes over Currency defined values and compare the inner value with the given one: + for(MediaType item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return Currency.values().length > 0 ? MediaType.values()[0]: null; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java new file mode 100644 index 000000000..c2193f678 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -0,0 +1,7 @@ +package com.kaltura.client.test.tests.servicesTests.AssetTests.AssetListTests; + +import com.kaltura.client.test.tests.BaseTest; + +public class BundleFilterTests extends BaseTest { + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 9af1e44e0..2306fcedb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -2,139 +2,139 @@ import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.types.*; -import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.json.JSONArray; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; - import static com.kaltura.client.services.AssetService.list; -import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; +import static com.kaltura.client.test.tests.enums.KsqlKey.NAME; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.SERIES_MEDIA_TYPE; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class ChannelFilterTests extends BaseTest { - private final Long maxValue = 999999L; - private final String tagName = "Genre"; - private final String metaName = "synopsis"; - private final String metaName2 = "Short title"; - private final String metaValue1 = getRandomValue(" A_", maxValue); - private final String metaValue2 = getRandomValue("B_", maxValue); - - private MediaAsset asset, asset2, asset3; - private ProgramAsset program, program2; - private String tagValue, masterUserKs; - private AssetFilter assetFilter; + + private MediaAsset asset1, asset2, asset3; + private ProgramAsset program; + private String masterUserKs; private Channel channel; @BeforeClass private void asset_list_channelFilter_before_class() { - // Get asset from shared asset method - tagValue = getRandomValue(tagName + "_", 999999); - - ArrayList list = new ArrayList<>(); - list.add(tagValue); - - HashMap> tagMap = new HashMap<>(); - tagMap.put(tagName, list); - - HashMap stringMetaMap1 = new HashMap<>(); - stringMetaMap1.put(metaName, metaValue1); - stringMetaMap1.put(metaName2, metaValue1); - - HashMap stringMetaMap2 = new HashMap<>(); - stringMetaMap2.put(metaName, metaValue2); - - JSONArray ja = getLinearAssetIdAndEpgChannelNameJsonArray(); - String epgChannelName = ja.getJSONObject(0).getString("name"); - String epgChannelName2 = ja.getJSONObject(1).getString("name"); - // ingest movie - VodData vodData1 = new VodData() + VodData movieData = new VodData() .mediaType(MOVIE_MEDIA_TYPE); - System.out.println("1! " + vodData1.toString()); - asset = insertVod(vodData1); + asset1 = insertVod(movieData); // ingest series - VodData vodData2 = new VodData() + VodData seriesData = new VodData() .mediaType(SERIES_MEDIA_TYPE) .isVirtual(true); - System.out.println("2! " + vodData2.toString()); - asset2 = insertVod(vodData2); + asset2 = insertVod(seriesData); // ingest episode - System.out.println("3!"); - VodData vodData3 = new VodData() - .mediaType(EPISODE_MEDIA_TYPE) - .catalogStartDate(getTimeInDate(-10)) - .tags(tagMap) - .strings(stringMetaMap2); - asset3 = insertVod(vodData3); - -// // ingest epg 1 -// EpgData epgData1 = new EpgData(epgChannelName).episodesNum(1); -// program = insertEpg(epgData1).get(0); -// -// // ingest epg 2 -// EpgData epgData2 = new EpgData(epgChannelName2).episodesNum(1); -// program2 = insertEpg(epgData2).get(0); - - Household household = createHousehold(); - masterUserKs = getHouseholdMasterUserKs(household); - - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(asset.getId().intValue()), Optional.empty(), Optional.empty()); + VodData episodeData = new VodData() + .mediaType(EPISODE_MEDIA_TYPE); + asset3 = insertVod(episodeData); + + // ingest epg + EpgData epgData = new EpgData(getSharedEpgChannelName()) + .episodesNum(1); + program = insertEpg(epgData).get(0); + + // add assets to channel query + String query = new KsqlBuilder() + .openOr() + .equal(NAME.getValue(), program.getName()) + .equal(NAME.getValue(), asset1.getName()) + .equal(NAME.getValue(), asset2.getName()) + .equal(NAME.getValue(), asset3.getName()) + .closeOr() + .toString(); // add channel channel = new Channel(); - channel.setName(getRandomValue("channel_", maxValue)); + channel.setName("channel_" + getTimeInEpoch()); channel.description("Description of " + channel.getName()); channel.setIsActive(true); - channel.setFilterExpression("Free='" + channel.getName() + "'"); -// channel.setOrder(AssetOrderBy.NAME_ASC); + channel.setFilterExpression(query); // "Free='" + channel.getName() + "'" channel = executor.executeSync(ChannelService.add(channel) .setKs(getOperatorKs())).results; - } + // create household + Household household = createHousehold(); + masterUserKs = getHouseholdMasterUserKs(household); + } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - vod - channelFilter") + @Description("asset/action/list - vod - channelFilter - idEqual") @Test - private void listVodAssetsByChannel() { -// String query = new KsqlBuilder() -// .openAnd() -// .openOr() -// .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) -// .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) -// .closeOr() -// .equal(ENTITLED_ASSETS.getValue(), "entitled") -// .closeAnd() -// .toString(); + private void list_vod_assets_with_channelFilter_by_channelId() { + // set channelFilter + ChannelFilter filter = new ChannelFilter(); + filter.setIdEqual(Math.toIntExact(channel.getId())); + + // get list + ListResponse assetListResponse = executor.executeSync(list(filter) + .setKs(getAnonymousKs())).results; + // assert response + assertThat(assetListResponse.getTotalCount()).isEqualTo(4); + assertThat(assetListResponse.getObjects()).extracting("id") + .containsExactlyInAnyOrder(asset1.getId(), asset2.getId(), asset3.getId(), program.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - vod - channelFilter - idEqual and KSql") + @Test + private void list_vod_assets_with_channelFilter_by_channelId_and_ksql() { + // build query + String query = new KsqlBuilder() + .openOr() + .equal(NAME.getValue(), asset1.getName()) + .equal(NAME.getValue(), program.getName()) + .closeOr() + .toString(); + + // set channelFilter ChannelFilter filter = new ChannelFilter(); filter.setIdEqual(Math.toIntExact(channel.getId())); + filter.setKSql(query); + + // get list + ListResponse assetListResponse = executor.executeSync(list(filter) + .setKs(getAnonymousKs())).results; + + // assert response + assertThat(assetListResponse.getTotalCount()).isEqualTo(2); + assertThat(assetListResponse.getObjects()).extracting("id") + .containsExactlyInAnyOrder(asset1.getId(), program.getId()); + } - Response> assetListResponse = executor.executeSync(list(filter) - .setKs(masterUserKs)); + @AfterClass + private void asset_list_channelFilter_after_class() { + // delete ingests + deleteVod(asset1.getName()); + deleteVod(asset2.getName()); + deleteVod(asset3.getName()); - assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); + // delete channel + executor.executeSync(ChannelService.delete(Math.toIntExact(channel.getId())) + .setKs(getOperatorKs())); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 4936f52b8..a0fb26464 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -28,8 +28,8 @@ import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; -import static com.kaltura.client.test.tests.enums.KsqlKeys.ENTITLED_ASSETS; -import static com.kaltura.client.test.tests.enums.KsqlKeys.MEDIA_ID; +import static com.kaltura.client.test.tests.enums.KsqlKey.ENTITLED_ASSETS; +import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.utils.AssetUtils.*; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 58ac873a8..43ce838da 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -14,6 +14,7 @@ import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.*; import java.util.concurrent.ThreadLocalRandom; @@ -65,6 +66,10 @@ public static long getTimeInEpoch(int offSetInMinutes) { return calendar.getTimeInMillis() / 1000; } + public static long getTimeInEpoch() { + return Instant.now().toEpochMilli(); + } + // generate current data String in specified format public static String getCurrentDateInFormat(String pattern) { return getOffsetDateInFormat(0, pattern); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 2af6cfb30..04cc6bf17 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -184,6 +184,8 @@ public class DBConstants { static final String USER_BY_ID_SELECT = "SELECT * from [Users].[dbo].[users] where group_id = ? and ID = ?"; + static final String ASSETS_SELECT = "SELECT top (?) NAME FROM [TVinci].[dbo].[media] where group_id = ? and status = 1 and is_Active = 1 order by id desc"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index e7b07e19b..cc22d2596 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -1,8 +1,12 @@ package com.kaltura.client.test.utils.dbUtils; import com.kaltura.client.Logger; +import com.kaltura.client.test.tests.enums.KsqlKey; import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.KsqlBuilder; +import com.kaltura.client.types.MediaAsset; import com.kaltura.client.types.PricePlan; +import com.kaltura.client.types.SearchAssetFilter; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; @@ -11,9 +15,11 @@ import java.sql.*; import java.util.Arrays; +import java.util.List; +import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.tests.BaseTest.partnerId; +import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; import static com.kaltura.client.test.utils.dbUtils.IngestFixtureData.loadFirstPricePlanFromJsonArray; import static org.assertj.core.api.Assertions.fail; @@ -228,4 +234,36 @@ public static JSONObject getUserById(int userId) { return getJsonArrayFromQueryResult(USER_BY_ID_SELECT, partnerId, userId) .getJSONObject(0); } + + public static List getAssets(int numOfAssets, boolean isVirtual) { + JSONArray jsonArray; + if (isVirtual) { + jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 2); + } else { + jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 1); + } + + KsqlBuilder builder = new KsqlBuilder(); + for (int i = 0; i < jsonArray.length(); i++) { + builder.equal(KsqlKey.NAME.getValue(), jsonArray.getJSONObject(i).getString("name")); + } + + String query = new KsqlBuilder() + .or(builder.toString()) + .toString(); + + SearchAssetFilter filter = new SearchAssetFilter(); + filter.setKSql(query); + return (List)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); +// +// SELECT top (10) m.ID, m.NAME, m.MEDIA_TYPE_ID, mt.NAME +// FROM [TVinci].[dbo].[media] m +// inner join [TVinci].[dbo].[media_types] mt +// on m.MEDIA_TYPE_ID = mt.ID +// where m.group_id = 204 +// and m.status = 1 +// and m.is_Active = 1 +// and mt.NAME = 'Episode' +// order by m.id desc + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 10048cb3a..75191cfa8 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -43,7 +43,7 @@ public class BaseIngestUtils { // life cycles periods public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; - // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts + // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts (ask Elram) public static final String MOVIE_MEDIA_TYPE = "Movie"; public static final String SERIES_MEDIA_TYPE = "Series"; public static final String EPISODE_MEDIA_TYPE = "Episode"; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index ebf1c7cfe..a774c4be3 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -28,9 +28,9 @@ import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.tests.enums.KsqlKeys.END_DATE; -import static com.kaltura.client.test.tests.enums.KsqlKeys.EPG_CHANNEL_ID; -import static com.kaltura.client.test.tests.enums.KsqlKeys.START_DATE; +import static com.kaltura.client.test.tests.enums.KsqlKey.END_DATE; +import static com.kaltura.client.test.tests.enums.KsqlKey.EPG_CHANNEL_ID; +import static com.kaltura.client.test.tests.enums.KsqlKey.START_DATE; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; From 319d6141e2008d44fe0e0d2a845fbc0f26744324 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 4 Jul 2018 18:24:06 +0300 Subject: [PATCH 407/605] added MediaType enum --- .../AssetListTests/ChannelFilterTests.java | 10 ++++------ .../AssetListTests/SearchAssetFilterTests.java | 9 ++++----- .../assetCommentTests/AssetCommentListTests.java | 7 ++++--- .../assetHistoryTests/AssetHistoryCleanTests.java | 9 ++++----- .../assetHistoryTests/AssetHistoryListTests.java | 9 ++++----- .../servicesTests/channelTests/ChannelAddTests.java | 10 +++++----- .../test/utils/ingestUtils/BaseIngestUtils.java | 12 +++--------- .../test/utils/ingestUtils/IngestVodUtils.java | 7 ++++--- 8 files changed, 32 insertions(+), 41 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 2306fcedb..6b42ad2ba 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -2,6 +2,7 @@ import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.types.*; import io.qameta.allure.Description; @@ -16,9 +17,6 @@ import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.SERIES_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; @@ -36,18 +34,18 @@ public class ChannelFilterTests extends BaseTest { private void asset_list_channelFilter_before_class() { // ingest movie VodData movieData = new VodData() - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); asset1 = insertVod(movieData); // ingest series VodData seriesData = new VodData() - .mediaType(SERIES_MEDIA_TYPE) + .mediaType(MediaType.SERIES) .isVirtual(true); asset2 = insertVod(seriesData); // ingest episode VodData episodeData = new VodData() - .mediaType(EPISODE_MEDIA_TYPE); + .mediaType(MediaType.EPISODE); asset3 = insertVod(episodeData); // ingest epg diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index a0fb26464..2de558b52 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.PurchaseUtils; @@ -33,8 +34,6 @@ import static com.kaltura.client.test.utils.AssetUtils.*; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; @@ -78,12 +77,12 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 1 VodData vodData1 = new VodData() - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); asset = insertVod(vodData1); // ingest asset 2 VodData vodData2 = new VodData() - .mediaType(MOVIE_MEDIA_TYPE) + .mediaType(MediaType.MOVIE) .catalogStartDate(getTimeInDate(-100)) .tags(tagMap) .strings(stringMetaMap1); @@ -91,7 +90,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 3 VodData vodData3 = new VodData() - .mediaType(EPISODE_MEDIA_TYPE) + .mediaType(MediaType.EPISODE) .catalogStartDate(getTimeInDate(-10)) .tags(tagMap) .strings(stringMetaMap2); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index edfa75c45..d56ac09e0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.services.AssetCommentService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.AssetCommentUtils; import com.kaltura.client.types.AssetComment; import com.kaltura.client.types.AssetCommentFilter; @@ -17,8 +18,8 @@ import static com.kaltura.client.services.AssetCommentService.ListAssetCommentBuilder; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; public class AssetCommentListTests extends BaseTest { @@ -44,7 +45,7 @@ private void checkCommentsOrder() { String text = "A lot of text"; VodData vodData = new VodData() - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); Long assetId = insertVod(vodData).getId(); // Initialize assetComment object diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 159658be2..960ae8da4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.enums.WatchStatus; import com.kaltura.client.services.AssetHistoryService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; @@ -22,8 +23,6 @@ import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; @@ -48,21 +47,21 @@ public class AssetHistoryCleanTests extends BaseTest { private void clean_tests_before_class() { // Ingest first movie asset VodData vodData = new VodData() - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); movie = insertVod(vodData); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset VodData vodData2 = new VodData() - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); movie2 = insertVod(vodData2); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset VodData vodData3 = new VodData() - .mediaType(EPISODE_MEDIA_TYPE); + .mediaType(MediaType.EPISODE); episode = insertVod(vodData3); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index b6d0303af..d4a20d7b9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -24,8 +25,6 @@ import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; @@ -47,19 +46,19 @@ public class AssetHistoryListTests extends BaseTest { private void list_tests_before_class() { // Ingest first movie asset VodData vodData = new VodData() - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); movie = insertVod(vodData); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); // Ingest second movie asset VodData vodData2 = new VodData() - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); movie2 = insertVod(vodData2); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset VodData vodData3 = new VodData() - .mediaType(EPISODE_MEDIA_TYPE); + .mediaType(MediaType.EPISODE); episode = insertVod(vodData3); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index b4ed545ff..1995c42c8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.services.AssetService; import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.ChannelUtils; @@ -21,9 +22,8 @@ import static com.kaltura.client.services.ChannelService.AddChannelBuilder; import static com.kaltura.client.services.ChannelService.DeleteChannelBuilder; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.EPISODE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.MOVIE_MEDIA_TYPE; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; public class ChannelAddTests extends BaseTest { @@ -65,13 +65,13 @@ private void checkOrderOfAssetsInChannel() { // Ingest first asset VodData vodData = new VodData() .name(asset1Name) - .mediaType(MOVIE_MEDIA_TYPE); + .mediaType(MediaType.MOVIE); MediaAsset movieAsset = insertVod(vodData); // Ingest second asset VodData vodData1 = new VodData() .name(asset2Name) - .mediaType(EPISODE_MEDIA_TYPE); + .mediaType(MediaType.EPISODE); MediaAsset episodeAsset = insertVod(vodData1); filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 75191cfa8..71273cb4a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -32,9 +32,9 @@ public class BaseIngestUtils { static final Header soapActionIngestKalturaEpg = new Header("SOAPAction", "http://tempuri.org/IService/IngestKalturaEpg"); // actions - public static final String INGEST_ACTION_INSERT = "insert"; - public static final String INGEST_ACTION_UPDATE = "update"; - public static final String INGEST_ACTION_DELETE = "delete"; + static final String INGEST_ACTION_INSERT = "insert"; + static final String INGEST_ACTION_UPDATE = "update"; + static final String INGEST_ACTION_DELETE = "delete"; // wait configuration static final int delayBetweenRetriesInSeconds = 5; @@ -43,12 +43,6 @@ public class BaseIngestUtils { // life cycles periods public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; - // media types // TODO: ask if these types (from TVM edit VOD page) are default for all accounts (ask Elram) - public static final String MOVIE_MEDIA_TYPE = "Movie"; - public static final String SERIES_MEDIA_TYPE = "Series"; - public static final String EPISODE_MEDIA_TYPE = "Episode"; - public static final String LINEAR_MEDIA_TYPE = "Linear"; - // data static final Long MAX_RANDOM_VALUE = 9999999999L; static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 1e39f6da3..ac79b55a3 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; @@ -53,10 +54,10 @@ public static class VodData { private String catalogEndDate; private String startDate; private String endDate; - private String mediaType; private String ppvWebName; private String ppvMobileName; private String geoBlockRule; + private MediaType mediaType; private Map> tags; private Map strings; @@ -82,7 +83,7 @@ public static MediaAsset insertVod(VodData vodData) { if (vodData.catalogEndDate == null) { vodData.catalogEndDate = endDateValue; } if (vodData.startDate == null) { vodData.startDate = offsetDateValue; } if (vodData.endDate == null) { vodData.endDate = endDateValue; } - if (vodData.mediaType == null) { vodData.mediaType = MOVIE_MEDIA_TYPE; } + if (vodData.mediaType == null) { vodData.mediaType = MediaType.MOVIE; } if (vodData.ppvWebName == null) { vodData.ppvWebName = ppvModuleName; } if (vodData.ppvMobileName == null) { vodData.ppvMobileName = ppvModuleName; } if (vodData.tags == null) { vodData.tags = getDefaultTags(); } @@ -205,7 +206,7 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // media type - media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType()); + media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType().getValue()); // geo block rule media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.geoBlockRule()); From cf70decc155cce18d74b0439cf87fe05214c684a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 4 Jul 2018 18:59:41 +0300 Subject: [PATCH 408/605] no message --- .../kaltura/client/test/tests/enums/MediaType.java | 3 ++- .../client/test/utils/dbUtils/DBConstants.java | 10 ++++++++++ .../kaltura/client/test/utils/dbUtils/DBUtils.java | 14 +++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java b/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java index c5016238b..b0f362b00 100644 --- a/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java +++ b/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java @@ -7,7 +7,8 @@ public enum MediaType implements EnumAsString { MOVIE("Movie"), SERIES("Series"), EPISODE("Episode"), - LINEAR("Linear"); + LINEAR("Linear"), + PACKAGE("Package"); private String value; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 04cc6bf17..73f5a2384 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -186,6 +186,16 @@ public class DBConstants { static final String ASSETS_SELECT = "SELECT top (?) NAME FROM [TVinci].[dbo].[media] where group_id = ? and status = 1 and is_Active = 1 order by id desc"; + static final String ASSETS_SELECT_WITH_MEDIA_TYPE = "SELECT top (?) m.ID, m.NAME, m.MEDIA_TYPE_ID, mt.NAME " + + "FROM [TVinci].[dbo].[media] m" + + "inner join [TVinci].[dbo].[media_types] mt " + + "on m.MEDIA_TYPE_ID = mt.ID" + + "where m.group_id = ?" + + "and m.status = 1" + + "and m.is_Active = 1" + + "and mt.NAME = ?" + + "order by m.id desc"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index cc22d2596..364bd14bf 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.tests.enums.KsqlKey; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.types.MediaAsset; @@ -16,6 +17,7 @@ import java.sql.*; import java.util.Arrays; import java.util.List; +import java.util.Optional; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.Properties.*; @@ -235,7 +237,7 @@ public static JSONObject getUserById(int userId) { .getJSONObject(0); } - public static List getAssets(int numOfAssets, boolean isVirtual) { + public static List getAssets(int numOfAssets, boolean isVirtual, Optional mediaType) { JSONArray jsonArray; if (isVirtual) { jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 2); @@ -255,15 +257,5 @@ public static List getAssets(int numOfAssets, boolean isVirtual) { SearchAssetFilter filter = new SearchAssetFilter(); filter.setKSql(query); return (List)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); -// -// SELECT top (10) m.ID, m.NAME, m.MEDIA_TYPE_ID, mt.NAME -// FROM [TVinci].[dbo].[media] m -// inner join [TVinci].[dbo].[media_types] mt -// on m.MEDIA_TYPE_ID = mt.ID -// where m.group_id = 204 -// and m.status = 1 -// and m.is_Active = 1 -// and mt.NAME = 'Episode' -// order by m.id desc } } From a76c80a7f8c255fc2d0ae9e28879ef4609bb2813 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 5 Jul 2018 12:49:23 +0300 Subject: [PATCH 409/605] Completed util PerformanceAppLogUtils.java --- .../com/kaltura/client/test/Properties.java | 1 + .../kaltura/client/test/tests/BaseTest.java | 32 +++- .../test/utils/PerformanceAppLogUtils.java | 173 +++++++++++++----- src/test/resources/test.template.properties | 1 + 4 files changed, 157 insertions(+), 50 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 066b2834f..06bcc9c88 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -82,6 +82,7 @@ public class Properties { public static final String REGRESSION_LOGS_LOCAL_FILE = "regression_logs_local_file"; public static final String SHOULD_REGRESSION_LOGS_BE_SAVED = "should_regression_logs_be_saved"; public static final String MAX_ALLOWED_PERCENTAGE = "max_allowed_percentage"; + public static final String CODE_PERFORMANCE_REPORT_FILE = "code_performance_report_file"; public static String getProperty(String propertyKey) { if (resourceBundle == null) { diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 4d912feba..cf81adc05 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -11,18 +11,18 @@ import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.PerformanceAppLogUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; - import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.TimeUnit; - import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; @@ -539,4 +539,32 @@ public static HouseholdUser getSharedUser() { return sharedUser; } } + + // as we have only 1 suite it helps do cleaning after regression execution + @AfterSuite + public void tearDownSuite() { + if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { + // processing of logs and creation of app performance code report + PerformanceAppLogUtils.createPerformanceCodeReport(); + PerformanceAppLogUtils.removeCopiedAppLogFiles(); + } + } + + // as we have only 1 suite it helps process fixture etc before regression execution + @BeforeSuite + public void setupSuite() { + if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { + // Before execution of regression we have to delete log file created during previous regression execution + // to not affect results of current check + String regressionLogsFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(REGRESSION_LOGS_LOCAL_FILE); + deleteFile(regressionLogsFileName); + + // Before execution of regression we have to delete report file created during previous regression execution + // to not affect results of current check + String codePerformanceReportFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(CODE_PERFORMANCE_REPORT_FILE); + deleteFile(codePerformanceReportFileName); + } + } } diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index a04f551c1..6b2721571 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Logger; -import com.kaltura.client.test.Sandbox; +import lombok.Data; import org.apache.commons.vfs2.*; import org.apache.commons.vfs2.auth.StaticUserAuthenticator; import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; @@ -10,12 +10,22 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; +import java.util.stream.Stream; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.Properties.API_VERSION; import static com.kaltura.client.test.Properties.getProperty; public class PerformanceAppLogUtils extends BaseUtils { + /** + * class to save data about count of slow executions and count of total executions for methods checking in regression + */ + @Data + static class SlowRatio { + private int slowCount; + private int totalCount; + } + private static final int maxAllowedPercentage = Integer.valueOf(getProperty(MAX_ALLOWED_PERCENTAGE)); private static final String domain = getProperty(PHOENIX_SERVER_DOMAIN_NAME); private static final String userName = getProperty(PHOENIX_SERVER_USER_NAME); @@ -29,14 +39,15 @@ public class PerformanceAppLogUtils extends BaseUtils { private static final String ELASTIC_SEARCH_LOG_DATA = "\"e\":\"es\""; private static final String RABBIT_LOG_DATA = "\"e\":\"rabbit\""; - private static final List nonRelated2CodeStringsList = new ArrayList<>(); - { - nonRelated2CodeStringsList.add("\"e\":\"start_api\""); - nonRelated2CodeStringsList.add(COUCHBASE_LOG_DATA); - nonRelated2CodeStringsList.add(DB_LOG_DATA); - nonRelated2CodeStringsList.add(ELASTIC_SEARCH_LOG_DATA); - nonRelated2CodeStringsList.add(RABBIT_LOG_DATA); - } + private static List appLogLocalFileNames = new ArrayList<>(); + + private static final List nonRelated2CodeStringsList = new ArrayList() {{ + add("\"e\":\"start_api\""); + add(COUCHBASE_LOG_DATA); + add(DB_LOG_DATA); + add(ELASTIC_SEARCH_LOG_DATA); + add(RABBIT_LOG_DATA); + }}; private static double timeOfCode; private static double timeOfCB; @@ -44,9 +55,9 @@ public class PerformanceAppLogUtils extends BaseUtils { private static double timeOfES; private static double timeOfRabbit; private static double totalTime; - private static boolean isKalturaSessionFoundInFile; + private static boolean isKalturaSessionFoundInAppLogFile; - public static void testPerformanceCode() { + public static void createPerformanceCodeReport() { try { List appRemoteFileNames = getRemoteAppLogFileNames(); for (String fileName: appRemoteFileNames) { @@ -55,12 +66,18 @@ public static void testPerformanceCode() { Map> methodsAndKalturaSessions = loadMethodsAndSessionsFromTestFile(); + Map methodsAndSlowRatioData = new HashMap<>(); + SlowRatio slowRatio; for (String method: methodsAndKalturaSessions.keySet()) { - Logger.getLogger(PerformanceAppLogUtils.class).debug("Method: [" + method + "]"); + methodsAndSlowRatioData.put(method, new SlowRatio()); + //Logger.getLogger(PerformanceAppLogUtils.class).debug("Method: [" + method + "]"); for (String xKalturaSession: methodsAndKalturaSessions.get(method)) { - Logger.getLogger(PerformanceAppLogUtils.class).debug("xKalturaSession: [" + xKalturaSession + "]"); + slowRatio = methodsAndSlowRatioData.get(method); + slowRatio.totalCount++; + methodsAndSlowRatioData.put(method, slowRatio); + //Logger.getLogger(PerformanceAppLogUtils.class).debug("xKalturaSession: [" + xKalturaSession + "]"); for (String appFileName: appRemoteFileNames) { - isKalturaSessionFoundInFile = false; + isKalturaSessionFoundInAppLogFile = false; timeOfCode = 0.0; timeOfCB = 0.0; timeOfDB = 0.0; @@ -70,55 +87,106 @@ public static void testPerformanceCode() { calcTimeExecution(appFileName, xKalturaSession); - if (isKalturaSessionFoundInFile) { - // display results + if (isKalturaSessionFoundInAppLogFile) { double percentageCodeTime2TotalTime = timeOfCode / totalTime * 100; if (percentageCodeTime2TotalTime > maxAllowedPercentage) { - // TODO: save report into file and add summary - Logger.getLogger(PerformanceAppLogUtils.class).debug("code time = " + timeOfCode + " PERFORMANCE LEVEL IS TOO WEAK: " + - String.format("%.2f", percentageCodeTime2TotalTime) + "%" + " \"" + xKalturaSession + "\""); - } /* THAT PART COMMENTED TO GET IT EASY IN CASE IT NEEDED LATEE - else { - logIfValueMoreThanZero(timeOfCode, "code time = "); - logIfValueMoreThanZero(timeOfCB, "Couchbase time = "); - logIfValueMoreThanZero(timeOfDB, "Database time = "); - logIfValueMoreThanZero(timeOfES, "Elastic search time = "); - logIfValueMoreThanZero(timeOfRabbit, "Rabbit time = "); - }*/ + slowRatio = methodsAndSlowRatioData.get(method); + slowRatio.slowCount++; + methodsAndSlowRatioData.put(method, slowRatio); + + // save results + writeReport2File(method, xKalturaSession, percentageCodeTime2TotalTime); + } } } } } + addSummary2Report(methodsAndSlowRatioData); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void addSummary2Report(Map methodsAndSlowRatioData) throws IOException { + if (methodsAndSlowRatioData.keySet().size() > 0) { + String reportFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(CODE_PERFORMANCE_REPORT_FILE); + String summaryTemporaryFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "SUMMARY" + + getProperty(CODE_PERFORMANCE_REPORT_FILE); + + createSummaryFile(methodsAndSlowRatioData, summaryTemporaryFileName); + addReportDataIntoSummaryFile(reportFileName, summaryTemporaryFileName); + + File source = new File(summaryTemporaryFileName); + File target = new File(reportFileName); + deleteFile(reportFileName); + boolean success = source.renameTo(target); + if (!success) { + throw new IOException("File can't be renamed"); + } + Logger.getLogger(PerformanceAppLogUtils.class).debug("Report was successfully created: [" + reportFileName + "]"); + } + } - deleteResultsOfRegressionExecution(); + private static void addReportDataIntoSummaryFile(String fromFile, String toFile) { + try(BufferedReader br = Files.newBufferedReader(Paths.get(fromFile)); + FileWriter fw = new FileWriter(toFile, true); + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter out = new PrintWriter(bw)) { + Stream lines = br.lines(); + lines.forEach(out::println); + lines.close(); } catch (IOException e) { e.printStackTrace(); } } - /** - * After execution of util we have to delete log file created during regression execution to not affect results of next checking - */ - private static void deleteResultsOfRegressionExecution() { - String fileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(REGRESSION_LOGS_LOCAL_FILE); - String prefix = getOffsetDateInFormat(0, "dd.MM.yyyy hh.mm"); - String targetFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + prefix + - getProperty(REGRESSION_LOGS_LOCAL_FILE); - try { - Files.copy(Paths.get(fileName), new FileOutputStream(targetFileName)); - File targetFile = new File(targetFileName); - if (targetFile.exists()) { - deleteFile(fileName); - Logger.getLogger(Sandbox.class).debug("File: [" + targetFileName + "] has been created"); + private static void createSummaryFile(Map methodsAndSlowRatioData, String summaryTemporaryFileName) { + try(FileWriter fw = new FileWriter(summaryTemporaryFileName, true); + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter out = new PrintWriter(bw)) { + out.println("Report of slow methods on " + getCurrentDateInFormat("dd/MM/yyyy HH:mm")); + out.println("Max allowed percentage: " + getProperty(MAX_ALLOWED_PERCENTAGE)); + out.println(); + for (String method: methodsAndSlowRatioData.keySet()) { + if (methodsAndSlowRatioData.get(method).slowCount > 0) { + out.println(method + " was slow " + String.format("%.2f", methodsAndSlowRatioData.get(method).slowCount * + 1.0 / methodsAndSlowRatioData.get(method).totalCount * 100) + "% of executions"); + } + } + + out.println(); + out.println("Details of slow methods are below:"); + out.println(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void writeReport2File(String method, String xKalturaSession, double codeTimePercentage) { + try(FileWriter fw = new FileWriter(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(CODE_PERFORMANCE_REPORT_FILE), true); + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter out = new PrintWriter(bw)) { + // we want to see only data where code time is less than 100% + if (timeOfCB > 0 || timeOfDB > 0 || timeOfES > 0 || timeOfRabbit > 0) { + out.println(method); + out.println("\"" + xKalturaSession + "\""); + out.println("Code: " + String.format("%.2f", codeTimePercentage) + "%"); + writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime); + writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime); + writeIfValueMoreThanZero(out, "Elastic: ", timeOfES, totalTime); + writeIfValueMoreThanZero(out, "Rabbit: ", timeOfRabbit, totalTime); + out.println(); } } catch (IOException e) { e.printStackTrace(); } } - private static void logIfValueMoreThanZero(double time, String message) { - if (time > 0) { - Logger.getLogger(Sandbox.class).debug(message + time); + private static void writeIfValueMoreThanZero(PrintWriter out, String title, double timeOfEvent, double totalTime) { + if (timeOfEvent > 0) { + out.println(title + " " + String.format("%.2f", timeOfEvent / totalTime * 100) + "% (" + timeOfEvent + ")"); } } @@ -135,6 +203,7 @@ private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IO String remoteFilePath = remoteSourceFileDir + remoteFileName; String localTargetFilePath = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "copied-" + remoteFileName; + appLogLocalFileNames.add(localTargetFilePath); // remove local target file in case it exists and create it empty File targetFile = new File(localTargetFilePath); @@ -156,7 +225,7 @@ private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IO destination.close(); Logger.getLogger(PerformanceAppLogUtils.class).debug("File [" + remoteFilePath + "] was copied into [" + localTargetFilePath + "]"); - Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine(): closed"); + Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine(): completed"); } private static List getRemoteAppLogFileNames() throws IOException { @@ -236,7 +305,7 @@ private static void calcTimeExecution(String appFileName, String kalturaSession) try(BufferedReader br = new BufferedReader(new FileReader(path2File))) { for(String line; (line = br.readLine()) != null; ) { if (line.contains(kalturaSession)) { - isKalturaSessionFoundInFile = true; + isKalturaSessionFoundInAppLogFile = true; // this is a usual position of time in the whole string executionTimeString = line.split("\"")[3]; // "e": "ws" should be ignored as it partially described in other events @@ -244,7 +313,6 @@ private static void calcTimeExecution(String appFileName, String kalturaSession) timeOfCode = timeOfCode - Double.valueOf(executionTimeString); } else { if (line.contains("\"e\":\"end_api\"")) { - //System.out.println(2); totalTime = Double.valueOf(executionTimeString); timeOfCode = timeOfCode + totalTime; } @@ -273,4 +341,13 @@ private static void calcTimeExecution(String appFileName, String kalturaSession) private static boolean stringContainsItemFromArray(String inputStr, String[] items) { return Arrays.stream(items).parallel().anyMatch(inputStr::contains); } + + /** + * method removes from local computer copied on it from remote machine app log files + */ + public static void removeCopiedAppLogFiles() { + for (String file: appLogLocalFileNames) { + deleteFile(file); + } + } } diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index d5c2ee447..3b59996bb 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -44,5 +44,6 @@ phoenix_server_logs_file_name_prefix=@PHOENIX_SERVER_LOGS_FILE_NAME_PREFIX@ phoenix_server_logs_file_extension=@PHOENIX_SERVER_LOGS_FILE_EXTENSION@ phoenix_server_logs_local_folder_path=@PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH@ regression_logs_local_file=@REGRESSION_LOGS_LOCAL_FILE@ +code_performance_report_file=@CODE_PERFORMANCE_REPORT_FILE@ should_regression_logs_be_saved=@SHOULD_REGRESSION_LOGS_BE_SAVED@ max_allowed_percentage=@MAX_ALLOWED_PERCENTAGE@ \ No newline at end of file From a27982e1b150066787a4b09639f5fb3e500f0b40 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 5 Jul 2018 16:14:27 +0300 Subject: [PATCH 410/605] Added time of code to the report --- .../com/kaltura/client/test/utils/PerformanceAppLogUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 6b2721571..2493cb78e 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -172,7 +172,7 @@ private static void writeReport2File(String method, String xKalturaSession, doub if (timeOfCB > 0 || timeOfDB > 0 || timeOfES > 0 || timeOfRabbit > 0) { out.println(method); out.println("\"" + xKalturaSession + "\""); - out.println("Code: " + String.format("%.2f", codeTimePercentage) + "%"); + out.println("Code: " + String.format("%.2f", codeTimePercentage) + "% (" + timeOfCode + ")"); writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime); writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime); writeIfValueMoreThanZero(out, "Elastic: ", timeOfES, totalTime); From 9c26e96ce9d4d6fda810da58729e62a5bd79b202 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 5 Jul 2018 16:28:49 +0300 Subject: [PATCH 411/605] DbUtils added get assets methods --- .../client/test/tests/enums/KsqlKey.java | 3 +- .../AssetListTests/ChannelFilterTests.java | 73 +++++++++---------- .../kaltura/client/test/utils/BaseUtils.java | 14 ++-- .../test/utils/dbUtils/DBConstants.java | 19 +++-- .../client/test/utils/dbUtils/DBUtils.java | 48 +++++++++++- .../resources/ingest_xml_templates/test.xml | 30 ++++++++ 6 files changed, 134 insertions(+), 53 deletions(-) create mode 100644 src/test/resources/ingest_xml_templates/test.xml diff --git a/src/test/java/com/kaltura/client/test/tests/enums/KsqlKey.java b/src/test/java/com/kaltura/client/test/tests/enums/KsqlKey.java index c5816bc22..36201220e 100644 --- a/src/test/java/com/kaltura/client/test/tests/enums/KsqlKey.java +++ b/src/test/java/com/kaltura/client/test/tests/enums/KsqlKey.java @@ -13,7 +13,8 @@ public enum KsqlKey implements EnumAsString { EPG_CHANNEL_ID("epg_channel_id"), EPG_ID("epg_id"), MEDIA_ID("media_id"), - ENTITLED_ASSETS("entitled_assets"); + ENTITLED_ASSETS("entitled_assets"), + ASSET_TYPE("asset_type"); private String value; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 6b42ad2ba..d633d5083 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; @@ -12,54 +13,42 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Optional; + import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.enums.KsqlKey.NAME; import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; -import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; -import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; -import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; import static org.assertj.core.api.Assertions.assertThat; public class ChannelFilterTests extends BaseTest { private MediaAsset asset1, asset2, asset3; - private ProgramAsset program; - private String masterUserKs; + private ProgramAsset program1; private Channel channel; @BeforeClass private void asset_list_channelFilter_before_class() { // ingest movie - VodData movieData = new VodData() - .mediaType(MediaType.MOVIE); - asset1 = insertVod(movieData); + asset1 = getAssets(1, Optional.of(MediaType.MOVIE)).get(0); // ingest series - VodData seriesData = new VodData() - .mediaType(MediaType.SERIES) - .isVirtual(true); - asset2 = insertVod(seriesData); + asset2 = getVirtualAssets(1, Optional.of(MediaType.SERIES)).get(0); // ingest episode - VodData episodeData = new VodData() - .mediaType(MediaType.EPISODE); - asset3 = insertVod(episodeData); + asset3 = getAssets(1, Optional.of(MediaType.EPISODE)).get(0); // ingest epg - EpgData epgData = new EpgData(getSharedEpgChannelName()) - .episodesNum(1); - program = insertEpg(epgData).get(0); + program1 = getPrograms(1).get(0); // add assets to channel query String query = new KsqlBuilder() .openOr() - .equal(NAME.getValue(), program.getName()) .equal(NAME.getValue(), asset1.getName()) .equal(NAME.getValue(), asset2.getName()) .equal(NAME.getValue(), asset3.getName()) + .equal(NAME.getValue(), program1.getName()) .closeOr() .toString(); @@ -72,16 +61,12 @@ private void asset_list_channelFilter_before_class() { channel = executor.executeSync(ChannelService.add(channel) .setKs(getOperatorKs())).results; - - // create household - Household household = createHousehold(); - masterUserKs = getHouseholdMasterUserKs(household); } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - vod - channelFilter - idEqual") + @Description("asset/action/list - channelFilter - idEqual") @Test - private void list_vod_assets_with_channelFilter_by_channelId() { + private void list_assets_with_channelFilter_by_channelId() { // set channelFilter ChannelFilter filter = new ChannelFilter(); filter.setIdEqual(Math.toIntExact(channel.getId())); @@ -93,18 +78,18 @@ private void list_vod_assets_with_channelFilter_by_channelId() { // assert response assertThat(assetListResponse.getTotalCount()).isEqualTo(4); assertThat(assetListResponse.getObjects()).extracting("id") - .containsExactlyInAnyOrder(asset1.getId(), asset2.getId(), asset3.getId(), program.getId()); + .containsExactlyInAnyOrder(asset1.getId(), asset2.getId(), asset3.getId(), program1.getId()); } @Severity(SeverityLevel.CRITICAL) - @Description("asset/action/list - vod - channelFilter - idEqual and KSql") + @Description("asset/action/list - channelFilter - idEqual and KSql") @Test - private void list_vod_assets_with_channelFilter_by_channelId_and_ksql() { + private void list_assets_with_channelFilter_by_channelId_and_ksql() { // build query String query = new KsqlBuilder() .openOr() .equal(NAME.getValue(), asset1.getName()) - .equal(NAME.getValue(), program.getName()) + .equal(NAME.getValue(), program1.getName()) .closeOr() .toString(); @@ -120,19 +105,31 @@ private void list_vod_assets_with_channelFilter_by_channelId_and_ksql() { // assert response assertThat(assetListResponse.getTotalCount()).isEqualTo(2); assertThat(assetListResponse.getObjects()).extracting("id") - .containsExactlyInAnyOrder(asset1.getId(), program.getId()); + .containsExactlyInAnyOrder(asset1.getId(), program1.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - with invalid channelId") + @Test + private void list_vod_assets_with_channelFilter_by_channelId_and_ksql() { + // set channelFilter + int invalidChannelId = 1; + ChannelFilter filter = new ChannelFilter(); + filter.setIdEqual(invalidChannelId); + + // get list + Response> assetListResponse = executor.executeSync(list(filter) + .setKs(getAnonymousKs())); + + // assert response + assertThat(assetListResponse.results).isNull(); + assertThat(assetListResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4018).getCode()); } @AfterClass private void asset_list_channelFilter_after_class() { - // delete ingests - deleteVod(asset1.getName()); - deleteVod(asset2.getName()); - deleteVod(asset3.getName()); - // delete channel executor.executeSync(ChannelService.delete(Math.toIntExact(channel.getId())) .setKs(getOperatorKs())); } - } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 43ce838da..465d8211b 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -139,12 +139,16 @@ private static List getApiExceptionList() { } // Get concatenated string - public static String getConcatenatedString(String... args) { - List assetIds = new ArrayList<>(); - for (String arg : args) { - assetIds.add(arg); + public static String getConcatenatedString(String... strings) { + List list = new ArrayList<>(); + for (String arg : strings) { + list.add(arg); } - return String.join(",", assetIds); + return String.join(",", list); + } + + public static String getConcatenatedString(List strings) { + return String.join(",", strings); } public static String getFileContent(String filePath) { diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 73f5a2384..582f43fd5 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -184,16 +184,23 @@ public class DBConstants { static final String USER_BY_ID_SELECT = "SELECT * from [Users].[dbo].[users] where group_id = ? and ID = ?"; + static final String PROGRAMS_SELECT = "SELECT top (?) NAME " + + "FROM [TVinci].[dbo].[epg_channels_schedule] " + + "where status = 1 " + + "and is_active = 1 " + + "and group_id = ? " + + "order by id desc"; + static final String ASSETS_SELECT = "SELECT top (?) NAME FROM [TVinci].[dbo].[media] where group_id = ? and status = 1 and is_Active = 1 order by id desc"; static final String ASSETS_SELECT_WITH_MEDIA_TYPE = "SELECT top (?) m.ID, m.NAME, m.MEDIA_TYPE_ID, mt.NAME " + - "FROM [TVinci].[dbo].[media] m" + + "FROM [TVinci].[dbo].[media] m " + "inner join [TVinci].[dbo].[media_types] mt " + - "on m.MEDIA_TYPE_ID = mt.ID" + - "where m.group_id = ?" + - "and m.status = 1" + - "and m.is_Active = 1" + - "and mt.NAME = ?" + + "on m.MEDIA_TYPE_ID = mt.ID " + + "where m.group_id = ? " + + "and m.status = 1 " + + "and m.is_Active = 1 " + + "and mt.NAME = ? " + "order by m.id desc"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 364bd14bf..fd4e7586b 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -7,6 +7,7 @@ import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.types.MediaAsset; import com.kaltura.client.types.PricePlan; +import com.kaltura.client.types.ProgramAsset; import com.kaltura.client.types.SearchAssetFilter; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; @@ -237,10 +238,11 @@ public static JSONObject getUserById(int userId) { .getJSONObject(0); } - public static List getAssets(int numOfAssets, boolean isVirtual, Optional mediaType) { + public static List getAssets(int numOfAssets, Optional mediaType) { JSONArray jsonArray; - if (isVirtual) { - jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 2); + if (mediaType.isPresent()) { + jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT_WITH_MEDIA_TYPE, numOfAssets, partnerId + 1, + mediaType.get().getValue()); } else { jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 1); } @@ -258,4 +260,44 @@ public static List getAssets(int numOfAssets, boolean isVirtual, Opt filter.setKSql(query); return (List)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); } + + public static List getVirtualAssets(int numOfAssets, Optional mediaType) { + JSONArray jsonArray; + if (mediaType.isPresent()) { + jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT_WITH_MEDIA_TYPE, numOfAssets, partnerId + 2, + mediaType.get().getValue()); + } else { + jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 2); + } + + KsqlBuilder builder = new KsqlBuilder(); + for (int i = 0; i < jsonArray.length(); i++) { + builder.equal(KsqlKey.NAME.getValue(), jsonArray.getJSONObject(i).getString("name")); + } + + String query = new KsqlBuilder() + .or(builder.toString()) + .toString(); + + SearchAssetFilter filter = new SearchAssetFilter(); + filter.setKSql(query); + return (List)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); + } + + public static List getPrograms(int numOfPrograms) { + JSONArray jsonArray = getJsonArrayFromQueryResult(PROGRAMS_SELECT, numOfPrograms, partnerId + 1); + + KsqlBuilder builder = new KsqlBuilder(); + for (int i = 0; i < jsonArray.length(); i++) { + builder.equal(KsqlKey.NAME.getValue(), jsonArray.getJSONObject(i).getString("name")); + } + + String query = new KsqlBuilder() + .or(builder.toString()) + .toString(); + + SearchAssetFilter filter = new SearchAssetFilter(); + filter.setKSql(query); + return (List)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); + } } diff --git a/src/test/resources/ingest_xml_templates/test.xml b/src/test/resources/ingest_xml_templates/test.xml new file mode 100644 index 000000000..c64e2e52b --- /dev/null +++ b/src/test/resources/ingest_xml_templates/test.xml @@ -0,0 +1,30 @@ + + + + + + + 0 + OK + + OK + + 18070413420791 + 636429 + + + entry_18070413420791 + 18070413420791 + 636429 + + + 0 + OK + + + + + + + + \ No newline at end of file From 2c57e87dafc2c512852b07b1fa3c5af253a3f17f Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 8 Jul 2018 11:49:07 +0300 Subject: [PATCH 412/605] updated PermissionsManagementDBUtils --- .../PermissionsManagementTests.java | 737 +++++++++--------- .../test/utils/PermissionManagementUtils.java | 306 ++++---- .../client/test/utils/dbUtils/DBUtils.java | 4 +- .../dbUtils/PermissionsManagementDBUtils.java | 541 ++++++------- 4 files changed, 745 insertions(+), 843 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 26175d93c..bb2a974cc 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -1,370 +1,367 @@ -//package com.kaltura.client.test.tests.featuresTests.versions.four_eight; -// -//import com.kaltura.client.test.utils.PermissionManagementUtils; -//import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; -//import io.qameta.allure.Description; -//import io.qameta.allure.Severity; -//import io.qameta.allure.SeverityLevel; -//import org.testng.annotations.BeforeClass; -//import org.testng.annotations.Test; -// -//import java.io.File; -//import java.util.ArrayList; -//import java.util.List; -// -//import static com.kaltura.client.test.utils.BaseUtils.deleteFile; -//import static com.kaltura.client.test.utils.BaseUtils.getFileContent; -//import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; -//import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; -//import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; -//import static org.assertj.core.api.Assertions.assertThat; -// -///** -// * -// * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 -// */ -//public class PermissionsManagementTests { -// -// String mainFile = "PermissionsDeployment.exe"; -// // that file generated automatically -// String path2Log = "C:\\log\\permissions\\permissions.log"; -// String path2Util = "C:\\123\\222\\"; -// -// // these files are generated -// String dataFilePath = path2Util + "333\\" + "exp1.txt"; -// String generatedDataFilePath = path2Util + "333\\" + "import.txt"; -// -// // these files added into project -// String importOnly4TablesFilePath; -// String path2EmptyFile; -// -// @BeforeClass -// public void setUp() { -// ClassLoader classLoader = PermissionsManagementTests.class.getClassLoader(); -// File file = new File(classLoader.getResource("permission_management_data/empty_file.txt").getFile()); -// path2EmptyFile = file.getAbsolutePath(); -// file = new File(classLoader.getResource("permission_management_data/importOnly4Tables.txt").getFile()); -// importOnly4TablesFilePath = file.getAbsolutePath(); -// } -// -// public static final String EXPORT_KEY = "e="; -// public static final String IMPORT_KEY = "i="; -// public static final String DELETE_KEY = "d="; -// -// @Severity(SeverityLevel.MINOR) -// @Test(groups = {"Permission management"}, description = "execute console util without parameters") -// public void runningWithoutParameters() { -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// String consoleOutput = executeCommandsInColsole(commands); -// -// assertThat(consoleOutput).contains("Permissions deployment tool"); -// assertThat(consoleOutput).contains("Shortcut: e"); -// assertThat(consoleOutput).contains("Shortcut: i"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") -// public void runningExportWithoutFile() { -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(EXPORT_KEY); -// String consoleOutput = executeCommandsInColsole(commands); -// -// assertThat(consoleOutput).contains("The system cannot find the file specified"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") -// public void runningImportWithoutFile() { -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(IMPORT_KEY); -// String consoleOutput = executeCommandsInColsole(commands); -// -// assertThat(consoleOutput).contains("The system cannot find the file specified"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") -// public void runningDeleteWithoutFile() { -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(DELETE_KEY); -// String consoleOutput = executeCommandsInColsole(commands); -// -// assertThat(consoleOutput).contains("The system cannot find the file specified"); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") -// public void export() { -// // prepare data inserting them in DB using stored procedures -// String suffix = String.valueOf(getTimeInEpoch(0)); -// PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", -// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, -// "parameter" + suffix); -// -// // export from DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(EXPORT_KEY + dataFilePath); -// executeCommandsInColsole(commands); -// -// // checks that created file contains inserted data -// String fileContent = getFileContent(dataFilePath); -// assertThat(fileContent).contains("MaxTest" + suffix); -// assertThat(fileContent).contains("Asset_List_Max" + suffix); -// assertThat(fileContent).contains("permissionItemObject" + suffix); -// assertThat(fileContent).contains("parameter" + suffix); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from file having only 4 tables instead of 5") -// public void runningImportFromFileNotHavingAllTables() { -// // remove log file -// deleteFile(path2Log); -// -// // try to import into DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(IMPORT_KEY + importOnly4TablesFilePath); -// executeCommandsInColsole(commands); -// -// String fileContent = getFileContent(path2Log); -// assertThat(fileContent).contains("Import failed: reading from XML resulted in empty data set or data set with less than 5 tables"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(groups = {"Permission management"}, description = "execute console util to try import data into DB from empty file") -// public void runningImportFromEmptyFile() { -// // remove log file -// deleteFile(path2Log); -// -// // try to import into DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(IMPORT_KEY + path2EmptyFile); -// executeCommandsInColsole(commands); -// -// String fileContent = getFileContent(path2Log); -// assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(groups = {"Permission management"}, description = "execute console util to try delete data from DB using empty file") -// public void runningDeleteUsingEmptyFile() { -// // remove log file -// deleteFile(path2Log); -// -// // try to import into DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(DELETE_KEY + path2EmptyFile); -// executeCommandsInColsole(commands); -// -// String fileContent = getFileContent(path2Log); -// assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") -// public void importFromFile() { -// String suffix = String.valueOf(getTimeInEpoch(0)); -// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", -// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, -// "parameter" + suffix, 1, 2, 3, 4, 5); -// -// // import into DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(IMPORT_KEY + generatedDataFilePath); -// executeCommandsInColsole(commands); -// -// // check data in DB -// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); -// assertThat(rowsInRolesHavingName).isEqualTo(1); -// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); -// -// int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); -// assertThat(rowsInPermissionsHavingName).isEqualTo(1); -// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); -// -// int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); -// assertThat(idRolePermission).isEqualTo(1); -// -// int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); -// assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); -// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); -// -// int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, -// idPermissionItemHavingName, 0); -// assertThat(rowsInPermissionsPermissions).isEqualTo(1); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(groups = {"Permission management"}, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") -// public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { -// // remove log file -// deleteFile(path2Log); -// -// // insert data in DB -// String suffix = String.valueOf(getTimeInEpoch(0)) + "inserted"; -// PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", -// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, -// "parameter" + suffix); -// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); -// -// // generate import file data -// suffix = String.valueOf(getTimeInEpoch(0)); -// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", -// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, -// "parameter" + suffix, 1, 2, 3, 4, 5); -// -// // try to import into DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(DELETE_KEY + path2EmptyFile); -// executeCommandsInColsole(commands); -// -// String fileContent = getFileContent(path2Log); -// assertThat(fileContent).contains("!!NOT EXISTS IN SOURCE!! Table : role Id : " + idRoleHavingName + " Name : " + "MaxTest" + suffix); -// assertThat(fileContent).contains("Asset_List_Max" + suffix); -// assertThat(fileContent).contains("permissionItemObject" + suffix); -// assertThat(fileContent).contains("parameter" + suffix); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") -// public void deleteFromDB() { -// String suffix = String.valueOf(getTimeInEpoch(0)); -// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", -// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, -// "parameter" + suffix, 1, 2, 3, 4, 5); -// -// // import into DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(IMPORT_KEY + generatedDataFilePath); -// executeCommandsInColsole(commands); -// -// // check data in DB -// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); -// assertThat(rowsInRolesHavingName).isEqualTo(1); -// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); -// -// int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); -// assertThat(rowsInPermissionsHavingName).isEqualTo(1); -// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); -// -// int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); -// assertThat(idRolePermission).isEqualTo(1); -// -// int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); -// assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); -// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); -// -// int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, -// idPermissionItemHavingName, 0); -// assertThat(rowsInPermissionsPermissions).isEqualTo(1); -// -// // remove log file -// deleteFile(path2Log); -// -// // delete from DB -// commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(DELETE_KEY + generatedDataFilePath); -// executeCommandsInColsole(commands); -// -// // DB should be empty -// rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); -// assertThat(rowsInRolesHavingName).isEqualTo(0); -// -// rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); -// assertThat(rowsInPermissionsHavingName).isEqualTo(0); -// -// rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); -// assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") -// public void importAlreadyExistedFromFile() { -// String suffix = String.valueOf(getTimeInEpoch(0)); -// PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", -// "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, -// "parameter" + suffix, 1, 2, 3, 4, 5); -// -// // import into DB -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(IMPORT_KEY + generatedDataFilePath); -// executeCommandsInColsole(commands); -// -// // retry import -// executeCommandsInColsole(commands); -// -// // check data in DB -// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); -// assertThat(rowsInRolesHavingName).isEqualTo(1); -// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); -// -// int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); -// assertThat(rowsInPermissionsHavingName).isEqualTo(1); -// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); -// -// int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); -// assertThat(idRolePermission).isEqualTo(1); -// -// int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); -// assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); -// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); -// -// int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, -// idPermissionItemHavingName, 0); -// assertThat(rowsInPermissionsPermissions).isEqualTo(1); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") -// public void runningDeleteUsingFileWithInvalidTags() { -// // insert role in DB -// String suffix = String.valueOf(getTimeInEpoch(0)); -// PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); -// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); -// -// PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); -// -// // try delete -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(DELETE_KEY + generatedDataFilePath); -// executeCommandsInColsole(commands); -// -// // check data still in DB -// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); -// assertThat(rowsInRolesHavingName).isEqualTo(1); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") -// public void deleteOnlyFromOneTable() { -// // insert role in DB -// String suffix = String.valueOf(getTimeInEpoch(0)); -// PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); -// int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); -// -// PermissionManagementUtils.generateFileForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); -// -// // delete -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(DELETE_KEY + generatedDataFilePath); -// executeCommandsInColsole(commands); -// -// // check data deleted from DB -// int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); -// assertThat(rowsInRolesHavingName).isEqualTo(0); -// } -//} +package com.kaltura.client.test.tests.featuresTests.versions.four_eight; + +import com.kaltura.client.test.utils.PermissionManagementUtils; +import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import static com.kaltura.client.test.utils.BaseUtils.deleteFile; +import static com.kaltura.client.test.utils.BaseUtils.getFileContent; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; +import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; +import static org.assertj.core.api.Assertions.assertThat; + +/** + * + * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 + */ +public class PermissionsManagementTests { + + String mainFile = "PermissionsDeployment.exe"; + // that file generated automatically + String path2Log = "C:\\log\\permissions\\permissions.log"; + String path2Util = "C:\\123\\222\\"; + + // these files are generated + String dataFilePath = path2Util + "333\\" + "exp1.txt"; + String generatedDataFilePath = path2Util + "333\\" + "import.txt"; + + // these files added into project + String importOnly4TablesFilePath; + String path2EmptyFile; + + @BeforeClass + public void setUp() { + ClassLoader classLoader = PermissionsManagementTests.class.getClassLoader(); + File file = new File(classLoader.getResource("permission_management_data/empty_file.txt").getFile()); + path2EmptyFile = file.getAbsolutePath(); + file = new File(classLoader.getResource("permission_management_data/importOnly4Tables.txt").getFile()); + importOnly4TablesFilePath = file.getAbsolutePath(); + } + + public static final String EXPORT_KEY = "e="; + public static final String IMPORT_KEY = "i="; + public static final String DELETE_KEY = "d="; + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util without parameters") + public void runningWithoutParameters() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("Permissions deployment tool"); + assertThat(consoleOutput).contains("Shortcut: e"); + assertThat(consoleOutput).contains("Shortcut: i"); + } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") + public void runningExportWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(EXPORT_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") + public void runningImportWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") + public void runningDeleteWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") + public void export() { + // prepare data inserting them in DB using stored procedures + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix); + + // export from DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(EXPORT_KEY + dataFilePath); + executeCommandsInColsole(commands); + + // checks that created file contains inserted data + String fileContent = getFileContent(dataFilePath); + assertThat(fileContent).contains("MaxTest" + suffix); + assertThat(fileContent).contains("Asset_List_Max" + suffix); + assertThat(fileContent).contains("permissionItemObject" + suffix); + assertThat(fileContent).contains("parameter" + suffix); + } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from file having only 4 tables instead of 5") + public void runningImportFromFileNotHavingAllTables() { + // remove log file + deleteFile(path2Log); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + importOnly4TablesFilePath); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("Import failed: reading from XML resulted in empty data set or data set with less than 5 tables"); + } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to try import data into DB from empty file") + public void runningImportFromEmptyFile() { + // remove log file + deleteFile(path2Log); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + path2EmptyFile); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); + } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to try delete data from DB using empty file") + public void runningDeleteUsingEmptyFile() { + // remove log file + deleteFile(path2Log); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + path2EmptyFile); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") + public void importFromFile() { + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(1); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + + int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); + assertThat(idRolePermission).isEqualTo(1); + + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + + int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, + idPermissionItemHavingName, 0); + assertThat(rowsInPermissionsPermissions).isEqualTo(1); + } + + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"Permission management"}, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") + public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { + // remove log file + deleteFile(path2Log); + + // insert data in DB + String suffix = String.valueOf(getTimeInEpoch(0)) + "inserted"; + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + // generate import file data + suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // try to import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + path2EmptyFile); + executeCommandsInColsole(commands); + + String fileContent = getFileContent(path2Log); + assertThat(fileContent).contains("!!NOT EXISTS IN SOURCE!! Table : role Id : " + idRoleHavingName + " Name : " + "MaxTest" + suffix); + assertThat(fileContent).contains("Asset_List_Max" + suffix); + assertThat(fileContent).contains("permissionItemObject" + suffix); + assertThat(fileContent).contains("parameter" + suffix); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") + public void deleteFromDB() { + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(1); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + + int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); + assertThat(idRolePermission).isEqualTo(1); + + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + + int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, + idPermissionItemHavingName, 0); + assertThat(rowsInPermissionsPermissions).isEqualTo(1); + + // remove log file + deleteFile(path2Log); + + // delete from DB + commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // DB should be empty + rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(0); + + rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(0); + + rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") + public void importAlreadyExistedFromFile() { + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, 1, 2, 3, 4, 5); + + // import into DB + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // retry import + executeCommandsInColsole(commands); + + // check data in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + assertThat(rowsInPermissionsHavingName).isEqualTo(1); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + + int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); + assertThat(idRolePermission).isEqualTo(1); + + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + + int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, + idPermissionItemHavingName, 0); + assertThat(rowsInPermissionsPermissions).isEqualTo(1); + } + + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") + public void runningDeleteUsingFileWithInvalidTags() { + // insert role in DB + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); + + // try delete + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data still in DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(1); + } + + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") + public void deleteOnlyFromOneTable() { + // insert role in DB + String suffix = String.valueOf(getTimeInEpoch(0)); + PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + + PermissionManagementUtils.generateFileForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); + + // delete + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(DELETE_KEY + generatedDataFilePath); + executeCommandsInColsole(commands); + + // check data deleted from DB + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + assertThat(rowsInRolesHavingName).isEqualTo(0); + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index 096742dbf..be97f5558 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -1,153 +1,153 @@ -//package com.kaltura.client.test.utils; -// -//import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; -//import java.io.*; -//import java.util.List; -// -//public class PermissionManagementUtils extends BaseUtils { -// -// public static void printPermissionPermissionItem(PrintWriter writer, long id, long permissionId, long permissionItemId, -// int isExcluded, String permissionItemName, String permissionName) { -// writer.println(""); -// writer.println("" + id + ""); -// writer.println("" + permissionId + ""); -// writer.println("" + permissionItemId + ""); -// writer.println("" + isExcluded + ""); -// writer.println("" + permissionItemName + ""); -// writer.println("" + permissionName + ""); -// writer.println(""); -// } -// -// public static void printPermissionItem(PrintWriter writer, long id, String name, int type, String service, String action, -// String object, String parameter) { -// writer.println(""); -// writer.println("" + id + ""); -// writer.println("" + name + ""); -// writer.println("" + type + ""); -// writer.println("" + service + ""); -// writer.println("" + action + ""); -// writer.println("" + object + ""); -// writer.println("" + parameter + ""); -// writer.println(""); -// } -// -// public static void printPermission(PrintWriter writer, long id, String name, int type, String usersGroup) { -// writer.println(""); -// writer.println("" + id + ""); -// writer.println("" + name + ""); -// writer.println("" + type + ""); -// writer.println("" + usersGroup + ""); -// writer.println(""); -// } -// -// public static void printRolePermission(PrintWriter writer, long permissionRoleId, long roleId, long permissionId, -// int isExcluded, String roleName, String permissionName) { -// writer.println(""); -// writer.println("" + permissionRoleId + ""); -// writer.println("" + roleId + ""); -// writer.println("" + permissionId + ""); -// writer.println("" + isExcluded + ""); -// writer.println("" + roleName + ""); -// writer.println("" + permissionName + ""); -// writer.println(""); -// } -// -// public static void printRole(PrintWriter writer, Long roleId, String roleName) { -// writer.println(""); -// writer.println("" + roleId + ""); -// writer.println("" + roleName + ""); -// writer.println(""); -// } -// -// public static String executeCommandsInColsole(List commands) { -// StringBuilder output = new StringBuilder(); -// -// ProcessBuilder pb = new ProcessBuilder(commands); -// pb.redirectErrorStream(true); -// BufferedReader inStreamReader; -// try { -// Process process = pb.start(); -// inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream())); -// String line; -// while((line = inStreamReader.readLine()) != null){ -// output.append(line); -// } -// } catch (IOException e) { -// e.printStackTrace(); -// output.append(e.getMessage()); -// } -// -// return output.toString(); -// } -// -// public static void insertDataInAllTables(String path2ResultFile, String role, String usersGroup, String permissionItemName, -// String service, String action, String permissionItemObject, String parameter) { -// long roleId = PermissionsManagementDBUtils.insertRole(role); -// long permissionId = PermissionsManagementDBUtils.insertPermission(role, 2, usersGroup); -// long permissionRoleId = PermissionsManagementDBUtils.insertPermissionRole(roleId, permissionId, 0); -// -// long permissionItemId = PermissionsManagementDBUtils.insertPermissionItem(permissionItemName, 1, service, action, permissionItemObject, parameter); -// long permissionPermissionItemId = PermissionsManagementDBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); -// -// generateFileWithInsertedIntoDBData(path2ResultFile, role, usersGroup, permissionItemName, service, action, -// permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId); -// } -// -// public static void generateFileWithInsertedIntoDBData(String path2ResultFile, String role, String usersGroup, String permissionItemName, -// String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, -// long permissionRoleId, long permissionItemId, long permissionPermissionItemId) { -// try { -// File file = new File(path2ResultFile); -// PrintWriter writer = new PrintWriter(file); -// printOpenTag(writer); -// printRole(writer, roleId, role); -// printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); -// printPermission(writer, permissionId, role, 2, usersGroup); -// printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); -// printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); -// printCloseTag(writer); -// writer.close(); -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// } -// } -// -// public static void generateFileWithInvalidTagForRole(String path2ResultFile, String roleName, int roleId) { -// try { -// File file = new File(path2ResultFile); -// PrintWriter writer = new PrintWriter(file); -// printOpenTag(writer); -// writer.println(""); // this 1 here to make tag invalid -// writer.println("" + roleId + ""); -// writer.println("" + roleName + ""); -// writer.println(""); // this 1 here to make tag invalid -// printCloseTag(writer); -// writer.close(); -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// } -// } -// -// private static void printOpenTag(PrintWriter writer) { -// writer.println(""); -// writer.println(""); -// } -// -// private static void printCloseTag(PrintWriter writer) { -// writer.println(""); -// } -// -// public static void generateFileForRole(String path2ResultFile, String roleName, long roleId) { -// try { -// File file = new File(path2ResultFile); -// PrintWriter writer = new PrintWriter(file); -// printOpenTag(writer); -// printRole(writer, roleId, roleName); -// printCloseTag(writer); -// writer.close(); -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// } -// } -//} -// +package com.kaltura.client.test.utils; + +import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +import java.io.*; +import java.util.List; + +public class PermissionManagementUtils extends BaseUtils { + + public static void printPermissionPermissionItem(PrintWriter writer, long id, long permissionId, long permissionItemId, + int isExcluded, String permissionItemName, String permissionName) { + writer.println(""); + writer.println("" + id + ""); + writer.println("" + permissionId + ""); + writer.println("" + permissionItemId + ""); + writer.println("" + isExcluded + ""); + writer.println("" + permissionItemName + ""); + writer.println("" + permissionName + ""); + writer.println(""); + } + + public static void printPermissionItem(PrintWriter writer, long id, String name, int type, String service, String action, + String object, String parameter) { + writer.println(""); + writer.println("" + id + ""); + writer.println("" + name + ""); + writer.println("" + type + ""); + writer.println("" + service + ""); + writer.println("" + action + ""); + writer.println("" + object + ""); + writer.println("" + parameter + ""); + writer.println(""); + } + + public static void printPermission(PrintWriter writer, long id, String name, int type, String usersGroup) { + writer.println(""); + writer.println("" + id + ""); + writer.println("" + name + ""); + writer.println("" + type + ""); + writer.println("" + usersGroup + ""); + writer.println(""); + } + + public static void printRolePermission(PrintWriter writer, long permissionRoleId, long roleId, long permissionId, + int isExcluded, String roleName, String permissionName) { + writer.println(""); + writer.println("" + permissionRoleId + ""); + writer.println("" + roleId + ""); + writer.println("" + permissionId + ""); + writer.println("" + isExcluded + ""); + writer.println("" + roleName + ""); + writer.println("" + permissionName + ""); + writer.println(""); + } + + public static void printRole(PrintWriter writer, Long roleId, String roleName) { + writer.println(""); + writer.println("" + roleId + ""); + writer.println("" + roleName + ""); + writer.println(""); + } + + public static String executeCommandsInColsole(List commands) { + StringBuilder output = new StringBuilder(); + + ProcessBuilder pb = new ProcessBuilder(commands); + pb.redirectErrorStream(true); + BufferedReader inStreamReader; + try { + Process process = pb.start(); + inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while((line = inStreamReader.readLine()) != null){ + output.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + output.append(e.getMessage()); + } + + return output.toString(); + } + + public static void insertDataInAllTables(String path2ResultFile, String role, String usersGroup, String permissionItemName, + String service, String action, String permissionItemObject, String parameter) { + long roleId = PermissionsManagementDBUtils.insertRole(role); + long permissionId = PermissionsManagementDBUtils.insertPermission(role, 2, usersGroup); + long permissionRoleId = PermissionsManagementDBUtils.insertPermissionRole(roleId, permissionId, 0); + + long permissionItemId = PermissionsManagementDBUtils.insertPermissionItem(permissionItemName, 1, service, action, permissionItemObject, parameter); + long permissionPermissionItemId = PermissionsManagementDBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); + + generateFileWithInsertedIntoDBData(path2ResultFile, role, usersGroup, permissionItemName, service, action, + permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId); + } + + public static void generateFileWithInsertedIntoDBData(String path2ResultFile, String role, String usersGroup, String permissionItemName, + String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, + long permissionRoleId, long permissionItemId, long permissionPermissionItemId) { + try { + File file = new File(path2ResultFile); + PrintWriter writer = new PrintWriter(file); + printOpenTag(writer); + printRole(writer, roleId, role); + printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); + printPermission(writer, permissionId, role, 2, usersGroup); + printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); + printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); + printCloseTag(writer); + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + public static void generateFileWithInvalidTagForRole(String path2ResultFile, String roleName, int roleId) { + try { + File file = new File(path2ResultFile); + PrintWriter writer = new PrintWriter(file); + printOpenTag(writer); + writer.println(""); // this 1 here to make tag invalid + writer.println("" + roleId + ""); + writer.println("" + roleName + ""); + writer.println(""); // this 1 here to make tag invalid + printCloseTag(writer); + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + private static void printOpenTag(PrintWriter writer) { + writer.println(""); + writer.println(""); + } + + private static void printCloseTag(PrintWriter writer) { + writer.println(""); + } + + public static void generateFileForRole(String path2ResultFile, String roleName, long roleId) { + try { + File file = new File(path2ResultFile); + PrintWriter writer = new PrintWriter(file); + printOpenTag(writer); + printRole(writer, roleId, roleName); + printCloseTag(writer); + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } +} + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index fd4e7586b..a9d67a681 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -80,7 +80,7 @@ private static JSONArray buildJsonArrayFromQueryResult(ResultSet rs) throws SQLE return jsonArray; } - private static SQLServerDataSource getDataSource() { + protected static SQLServerDataSource getDataSource() { SQLServerDataSource dataSource = new SQLServerDataSource(); dataSource.setUser(getProperty(DB_USER)); dataSource.setPassword(getProperty(DB_PASSWORD)); @@ -128,7 +128,7 @@ static JSONArray getJsonArrayFromQueryResult(String query, Object... queryParams return jsonArray; } - private static PreparedStatement preparedStatementExecution(Connection conn, String query, Object... args) { + protected static PreparedStatement preparedStatementExecution(Connection conn, String query, Object... args) { PreparedStatement pstm = null; try { pstm = conn.prepareStatement(query); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java index 5a97bbc1f..3490fbce8 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java @@ -1,318 +1,223 @@ -//package com.kaltura.client.test.utils.dbUtils; -// -//import org.json.JSONArray; -//import java.sql.*; -//import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; -// -//public class PermissionsManagementDBUtils extends DBUtils { -// -// /** -// * Call Stored Procedure to create role -// */ -// public static int insertRole(String role) { -// int result =-1; -// try { -// prepareCall(SP_INSERT_ROLE); -// cStmt.setInt(1, 0); // group_id == 0 -// cStmt.setString(2, role); -// -// rs = cStmt.executeQuery(); -// String columnName = rs.getMetaData().getColumnName(1); -// while (rs.next()) { -// result = rs.getInt(columnName); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// return result; -// } -// } -// -// /** -// * Call Stored Procedure to delete role and its permissions -// */ -// public static void deleteRoleAndItsPermissions(int roleId) { -// try { -// prepareCall(SP_DELETE_ROLE_AND_ITS_PERMISSIONS); -// cStmt.setInt(1, 0); // group_id == 0 -// cStmt.setInt(2, roleId); -// -// cStmt.execute(); -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// } -// } -// -// /** -// * Call Stored Procedure to insert permissions -// */ -// public static int insertPermission(String name, int type, String usersGroup) { -// int result =-1; -// try { -// prepareCall(SP_INSERT_PERMISSION); -// cStmt.setInt(1, 0); // group_id == 0 -// cStmt.setString(2, name); -// cStmt.setInt(3, type); -// cStmt.setString(4, usersGroup); -// -// rs = cStmt.executeQuery(); -// String columnName = rs.getMetaData().getColumnName(1); -// while (rs.next()) { -// result = rs.getInt(columnName); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// return result; -// } -// } -// -// /** -// * Call Stored Procedure to delete permission -// */ -// public static void deletePermission(int id) { -// try { -// prepareCall(SP_DELETE_PERMISSION); -// cStmt.setInt(1, id); -// -// cStmt.execute(); -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// } -// } -// -// /** -// * Call Stored Procedure to insert permission role -// */ -// public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { -// int result =-1; -// try { -// prepareCall(SP_INSERT_PERMISSION_ROLE); -// cStmt.setInt(1, 0); // group_id == 0 -// cStmt.setLong(2, roleId); -// cStmt.setLong(3, permissionId); -// cStmt.setInt(4, isExcluded); -// -// rs = cStmt.executeQuery(); -// String columnName = rs.getMetaData().getColumnName(1); -// while (rs.next()) { -// result = rs.getInt(columnName); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// return result; -// } -// } -// -// /** -// * Call Stored Procedure to insert permission item -// */ -// public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { -// int result =-1; -// try { -// prepareCall(SP_INSERT_PERMISSION_ITEM); -// cStmt.setString(1, name); -// cStmt.setInt(2, type); -// cStmt.setString(3, service); -// cStmt.setString(4, action); -// cStmt.setString(5, permissionItemObject); -// cStmt.setString(6, parameter); -// rs = cStmt.executeQuery(); -// -// String columnName = rs.getMetaData().getColumnName(1); -// while (rs.next()) { -// result = rs.getInt(columnName); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// return result; -// } -// } -// -// /** -// * Call Stored Procedure to delete permission item -// */ -// public static void deletePermissionItem(int id) { -// try { -// prepareCall(SP_DELETE_PERMISSION_ITEM); -// cStmt.setInt(1, id); -// -// cStmt.execute(); -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// } -// } -// -// /** -// * Call Stored Procedure to insert permission permission item -// */ -// public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { -// int result =-1; -// try { -// prepareCall(SP_INSERT_PERMISSION_PERMISSION_ITEM); -// cStmt.setInt(1, 0);; // group_id == 0 -// cStmt.setLong(2, permissionId); -// cStmt.setLong(3, permissionItemId); -// cStmt.setInt(4, isExcluded); -// rs = cStmt.executeQuery(); -// -// String columnName = rs.getMetaData().getColumnName(1); -// while (rs.next()) { -// result = rs.getInt(columnName); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// return result; -// } -// } -// -// /** -// * Call Stored Procedure to delete permission permission item -// */ -// public static void deletePermissionPermissionItem(int id) { -// try { -// prepareCall(SP_DELETE_PERMISSION_PERMISSION_ITEM); -// cStmt.setInt(1, id); -// -// cStmt.execute(); -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// closeConnection(); -// } -// } -// -// public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { -// int count = 0; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, -// name, groupId), true); -// if (!jsonArray.isNull(0)) { -// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return count; -// } -// -// public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { -// int id =-1; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT, -// name, groupId), true); -// if (!jsonArray.isNull(0)) { -// id = jsonArray.getJSONObject(0).getInt(ID); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return id; -// } -// -// public static int getCountRowsHavingRoleNameInPermissions(String name, int groupId) { -// int count = 0; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, -// name, groupId), true); -// if (!jsonArray.isNull(0)) { -// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return count; -// } -// -// public static int getIdRecordHavingRoleNameInPermissions(String name, int groupId) { -// int count =-1; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, -// name, groupId), true); -// if (!jsonArray.isNull(0)) { -// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return count; -// } -// -// public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permissionId, int groupId) { -// int count = 0; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT, -// roleId, permissionId, groupId), true); -// if (!jsonArray.isNull(0)) { -// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return count; -// } -// -// public static int getCountRowsHavingNameInPermissionItems(String name, int groupId) { -// int count = 0; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT, -// name, groupId), true); -// if (!jsonArray.isNull(0)) { -// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return count; -// } -// -// public static int getIdRecordHavingNameInPermissionItems(String name, int groupId) { -// int count =-1; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT, -// name, groupId), true); -// if (!jsonArray.isNull(0)) { -// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return count; -// } -// -// public static int getCountSpecificRowsFromPermissionsPermissionsItems(int permissionId, int permissionItemId, int groupId) { -// int count = 0; -// try { -// JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT, -// permissionId, permissionItemId, groupId), true); -// if (!jsonArray.isNull(0)) { -// count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return count; -// } -//} +package com.kaltura.client.test.utils.dbUtils; + +import com.microsoft.sqlserver.jdbc.SQLServerDataSource; +import org.apache.commons.dbutils.DbUtils; +import org.json.JSONArray; +import java.sql.*; +import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; + +public class PermissionsManagementDBUtils extends DBUtils { + + /** + * Call Stored Procedure to create role + */ + public static int insertRole(String role) { + JSONArray jsonArray = getJsonArrayFromQueryResult(SP_INSERT_ROLE, 0, role); // group_id == 0 + return Integer.valueOf(jsonArray.getJSONObject(0).get(ID).toString()); + } + + /** + * Call Stored Procedure to delete role and its permissions + */ + public static void deleteRoleAndItsPermissions(int roleId) { + executeQuery(SP_DELETE_ROLE_AND_ITS_PERMISSIONS, 0, roleId); // group_id == 0 + } + + /** + * Call Stored Procedure to insert permissions + */ + public static int insertPermission(String name, int type, String usersGroup) { + JSONArray jsonArray = getJsonArrayFromQueryResult(SP_INSERT_PERMISSION, 0, name, type, usersGroup); // group_id == 0 + return Integer.valueOf(jsonArray.getJSONObject(0).get(ID).toString()); + } + + /** + * Call Stored Procedure to delete permission + */ + public static void deletePermission(int id) { + executeQuery(SP_DELETE_PERMISSION, id); + } + + /** + * Call Stored Procedure to insert permission role + */ + public static int insertPermissionRole(long roleId, long permissionId, int isExcluded) { + JSONArray jsonArray = getJsonArrayFromQueryResult(SP_INSERT_PERMISSION_ROLE, 0, roleId, permissionId, isExcluded); // group_id == 0 + return Integer.valueOf(jsonArray.getJSONObject(0).get(ID).toString()); + } + + /** + * Call Stored Procedure to insert permission item + */ + public static int insertPermissionItem(String name, int type, String service, String action, String permissionItemObject, String parameter) { + JSONArray jsonArray = getJsonArrayFromQueryResult(SP_INSERT_PERMISSION_ITEM, name, type, service, action, permissionItemObject, parameter); + return Integer.valueOf(jsonArray.getJSONObject(0).get(ID).toString()); + } + + /** + * Call Stored Procedure to delete permission item + */ + public static void deletePermissionItem(int id) { + executeQuery(SP_DELETE_PERMISSION_ITEM, id); + } + + /** + * Call Stored Procedure to insert permission permission item + */ + public static int insertPermissionPermissionItem(long permissionId, long permissionItemId, int isExcluded) { + JSONArray jsonArray = getJsonArrayFromQueryResult(SP_INSERT_PERMISSION_PERMISSION_ITEM, 0, permissionId, permissionItemId, isExcluded); // group_id == 0 + return Integer.valueOf(jsonArray.getJSONObject(0).get(ID).toString()); + } + + /** + * Call Stored Procedure to delete permission permission item + */ + public static void deletePermissionPermissionItem(int id) { + executeQuery(SP_DELETE_PERMISSION_PERMISSION_ITEM, id); + } + + static void executeQuery(String query, Object... queryParams) { + SQLServerDataSource dataSource = DBUtils.getDataSource(); + Connection conn = null; + PreparedStatement pstm = null; + ResultSet rs = null; + + try { + conn = dataSource.getConnection(); + if (queryParams.length > 0) { + pstm = preparedStatementExecution(conn, query, queryParams); + } else { + pstm = conn.prepareStatement(query); + } + + pstm.execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DbUtils.closeQuietly(rs); + DbUtils.closeQuietly(pstm); + DbUtils.closeQuietly(conn); + } + } + + + public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { + int id =-1; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + id = jsonArray.getJSONObject(0).getInt(ID); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return id; + } + + public static int getCountRowsHavingRoleNameInPermissions(String name, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getIdRecordHavingRoleNameInPermissions(String name, int groupId) { + int count =-1; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permissionId, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT, + roleId, permissionId, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getCountRowsHavingNameInPermissionItems(String name, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getIdRecordHavingNameInPermissionItems(String name, int groupId) { + int count =-1; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT, + name, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } + + public static int getCountSpecificRowsFromPermissionsPermissionsItems(int permissionId, int permissionItemId, int groupId) { + int count = 0; + try { + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT, + permissionId, permissionItemId, groupId), true); + if (!jsonArray.isNull(0)) { + count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return count; + } +} From f425532da66fc59f2fac03fe4a9682614f8e06ce Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Jul 2018 14:10:15 +0300 Subject: [PATCH 413/605] AssetListTests/BundleFilterTests --- .../com/kaltura/client/enums/WatchStatus.java | 3 +- .../com/kaltura/client/test/Properties.java | 10 +- .../test/TestAPIOkRequestsExecutor.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../client/test/tests/enums/MediaType.java | 1 - .../test/tests/enums/PremiumService.java | 41 ++++ .../AssetListTests/BundleFilterTests.java | 212 ++++++++++++++++++ .../AssetListTests/ChannelFilterTests.java | 8 +- .../AssetListTests/RelatedFilterTests.java | 5 + .../ScheduledRecordingProgramFilterTests.java | 7 + .../SearchAssetFilterTests.java | 20 +- .../AssetHistoryCleanTests.java | 194 ++++++++-------- .../AssetHistoryListTests.java | 159 +++++++------ .../householdTests/HouseholdSuspendTests.java | 10 +- .../OttUserLoginWithPinTests.java | 2 - .../OttUserResendActivationTokenTests.java | 8 - .../kaltura/client/test/utils/AssetUtils.java | 12 +- .../kaltura/client/test/utils/BaseUtils.java | 7 + .../client/test/utils/HouseholdUtils.java | 2 +- .../client/test/utils/KsqlBuilder.java | 1 - .../test/utils/dbUtils/DBConstants.java | 19 +- .../client/test/utils/dbUtils/DBUtils.java | 39 +++- .../utils/ingestUtils/BaseIngestUtils.java | 1 - .../utils/ingestUtils/IngestVodUtils.java | 4 +- .../resources/ingest_xml_templates/test.xml | 30 --- 25 files changed, 533 insertions(+), 266 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/PremiumService.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/RelatedFilterTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java diff --git a/src/main/java/com/kaltura/client/enums/WatchStatus.java b/src/main/java/com/kaltura/client/enums/WatchStatus.java index e4fee43c9..3d465b1d3 100644 --- a/src/main/java/com/kaltura/client/enums/WatchStatus.java +++ b/src/main/java/com/kaltura/client/enums/WatchStatus.java @@ -54,8 +54,7 @@ public void setValue(String value) { } public static WatchStatus get(String value) { - if(value == null) - { + if(value == null) { return null; } diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index c990e9996..16a01bd4f 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -28,12 +28,12 @@ public class Properties { public static final String WEB_FILE_TYPE = "web_file_type"; public static final String MOBILE_FILE_TYPE = "mobile_file_type"; - // media types ids - public static final String MOVIE_MEDIA_TYPE_ID = "movie_media_type_id"; - public static final String EPISODE_MEDIA_TYPE_ID = "episode_media_type_id"; - // channels - public static final String DEFAULT_CHANNEL = "default_channel"; // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" + public static final String DEFAULT_CHANNEL = "default_channel"; + // automatic channel with "Cut Tags Type"="Or", Tags "Series name"="Shay_Series;" and "Free"="Shay_Series;" + + // collections + public static final String DEFAULT_COLLECTION = "default_collection"; // price codes values public static final String PRICE_CODE_AMOUNT = "price_code_amount"; // 4.99 diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 944633ccf..b242091d7 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -61,7 +61,7 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request // logger.debug("response body:\n" + responseElement.getResponse()); // was found in base class if (LOG_HEADERS) { - logger.debug("response headers:\n" + okhttpResponse.headers()); + logger.debug("Session: " + okhttpResponse.headers().get("X-Kaltura-Session")); } if (responseElement.isSuccess()) { diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 0df904d17..89c3ca882 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -43,7 +43,7 @@ public class BaseTest { - public static final boolean LOG_HEADERS = false; + public static final boolean LOG_HEADERS = true; public static Client client; public static Configuration config; diff --git a/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java b/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java index b0f362b00..0e78e531d 100644 --- a/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java +++ b/src/test/java/com/kaltura/client/test/tests/enums/MediaType.java @@ -3,7 +3,6 @@ import com.kaltura.client.enums.EnumAsString; public enum MediaType implements EnumAsString { - MOVIE("Movie"), SERIES("Series"), EPISODE("Episode"), diff --git a/src/test/java/com/kaltura/client/test/tests/enums/PremiumService.java b/src/test/java/com/kaltura/client/test/tests/enums/PremiumService.java new file mode 100644 index 000000000..8ca00d71d --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/PremiumService.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum PremiumService implements EnumAsString { + CATCH_UP("1"), + START_OVER("2"), + NPVR("3"), + DOWNLOAD("4"), + AD_CONTROL("5"); + + private String value; + + PremiumService(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static PremiumService get(String value) { + if(value == null) { + return null; + } + + // goes over Currency defined values and compare the inner value with the given one: + for(PremiumService item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return Currency.values().length > 0 ? PremiumService.values()[0]: null; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index c2193f678..e65291d10 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -1,7 +1,219 @@ package com.kaltura.client.test.tests.servicesTests.AssetTests.AssetListTests; +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.enums.BundleType; +import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.KsqlBuilder; +import com.kaltura.client.test.utils.ingestUtils.IngestMppUtils; +import com.kaltura.client.types.*; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.services.AssetService.list; +import static com.kaltura.client.services.ChannelService.add; +import static com.kaltura.client.test.Properties.DEFAULT_COLLECTION; +import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.tests.enums.KsqlKey.NAME; +import static com.kaltura.client.test.tests.enums.MediaType.*; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.MppData; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.insertMpp; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; public class BundleFilterTests extends BaseTest { + private MediaAsset movie1, movie2; + private MediaAsset series1, series2; + private MediaAsset episode1, episode2; + private Channel channel1, channel2; + private Subscription subscription; + + + @BeforeClass + private void asset_list_bundleFilter_before_class() { + // get movie + List medias = getAssets(2, Optional.of(MOVIE)); + movie1 = medias.get(0); + movie2 = medias.get(1); + + // get series + List series = getVirtualAssets(2, Optional.of(SERIES)); + series1 = series.get(0); + series2 = series.get(1); + + // get episode + List episodes = getAssets(2, Optional.of(EPISODE)); + episode1 = episodes.get(0); + episode2 = episodes.get(1); + + // add assets to channel query 1 + String channel1Query = new KsqlBuilder() + .openOr() + .equal(NAME.getValue(), movie1.getName()) + .equal(NAME.getValue(), series1.getName()) + .equal(NAME.getValue(), episode1.getName()) + .closeOr() + .toString(); + + // add assets to channel query 2 + String channel2Query = new KsqlBuilder() + .openOr() + .equal(NAME.getValue(), movie2.getName()) + .equal(NAME.getValue(), series2.getName()) + .equal(NAME.getValue(), episode2.getName()) + .closeOr() + .toString(); + + // add channel1 + channel1 = new Channel(); + channel1.setName("channel_" + getTimeInEpoch()); + channel1.description("Description of " + channel1.getName()); + channel1.setIsActive(true); + channel1.setFilterExpression(channel1Query); + + channel1 = executor.executeSync(add(channel1) + .setKs(getOperatorKs())).results; + + // add channel2 + channel2 = new Channel(); + channel2.setName("channel_" + getTimeInEpoch()); + channel2.description("Description of " + channel2.getName()); + channel2.setIsActive(true); + channel2.setFilterExpression(channel2Query); + + channel2 = executor.executeSync(add(channel2) + .setKs(getOperatorKs())).results; + + // ingest subscription with 2 new channels + MppData mppData = new MppData() + .channel1(channel1.getName()) + .channel2(channel2.getName()); + subscription = insertMpp(mppData); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - bundleFilter - idEqual - subscription") + @Test + private void list_assets_with_bundleFilter_subscription_by_idEqual() { + // set bundleFilter + BundleFilter filter = new BundleFilter(); + filter.setIdEqual(Integer.valueOf(subscription.getId())); + filter.setOrderBy(AssetOrderBy.NAME_ASC.getValue()); + + // get list + ListResponse assetListResponse = executor.executeSync(list(filter) + .setKs(getAnonymousKs())).results; + + // assert response + assertThat(assetListResponse.getTotalCount()).isEqualTo(6); + + assertThat(assetListResponse.getObjects()).extracting("id") + .containsExactlyInAnyOrder(movie1.getId(), episode1.getId(), series1.getId(), movie2.getId(), + episode2.getId(), series2.getId()); + + assertThat(assetListResponse.getObjects()).extracting("name") + .isSorted(); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - bundleFilter - idEqual and typeIn - subscription") + @Test + private void list_assets_with_bundleFilter_subscription_by_idEqual_and_typeIn() { + // adding "MOVIE", "SERIES" and "LINEAR" to string types (excluding "EPISODE") + String types = getConcatenatedString(String.valueOf(getMediaTypeId(MOVIE)), + String.valueOf(getVirtualMediaTypeId(SERIES)), + String.valueOf(getMediaTypeId(LINEAR))); + + // set bundleFilter + BundleFilter filter = new BundleFilter(); + filter.setBundleTypeEqual(BundleType.SUBSCRIPTION); + filter.setIdEqual(Integer.valueOf(subscription.getId())); + filter.setTypeIn(types); + + // get list + ListResponse assetListResponse = executor.executeSync(list(filter) + .setKs(getAnonymousKs())).results; + + // assert response + assertThat(assetListResponse.getTotalCount()).isEqualTo(4); + + assertThat(assetListResponse.getObjects()).extracting("id") + .containsExactlyInAnyOrder(movie1.getId(), movie2.getId(), series1.getId(), series2.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - bundleFilter - idEqual and typeIn - collection") + @Test + private void list_assets_with_bundleFilter_collection_by_idEqual_and_typeIn() { + // set bundleFilter + BundleFilter filter = new BundleFilter(); + filter.setBundleTypeEqual(BundleType.COLLECTION); + filter.setIdEqual(Integer.valueOf(getProperty(DEFAULT_COLLECTION))); + + // get full list + List assets = executor.executeSync(list(filter) + .setKs(getAnonymousKs())).results.getObjects(); + + Asset movie = null; + for (Asset asset : assets) { + if (asset.getType() == getMediaTypeId(MOVIE)) { + movie = asset; + break; + } + } + + if (movie == null){ + fail("missing movie asset in channel related to the provided collection"); + } + + // get movies list + filter.setTypeIn(String.valueOf(getMediaTypeId(MOVIE))); + ListResponse assetListResponse = executor.executeSync(list(filter) + .setKs(getAnonymousKs())).results; + + // assert response + assertThat(assetListResponse.getTotalCount()).isEqualTo(1); + + assertThat(assetListResponse.getObjects()).extracting("id") + .containsExactly(movie.getId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - bundleFilter - subscription - idEqual and collection bundleType") + @Test + private void list_assets_with_bundleFilter_by_subscription_idEqual_and_collection_bundleType() { + // set bundleFilter + BundleFilter filter = new BundleFilter(); + filter.setBundleTypeEqual(BundleType.COLLECTION); + filter.setIdEqual(Integer.valueOf(subscription.getId())); + + // get list + ListResponse assetListResponse = executor.executeSync(list(filter) + .setKs(getAnonymousKs())).results; + + // assert response + assertThat(assetListResponse.getTotalCount()).isEqualTo(0); + } + + @AfterClass + private void asset_list_bundleFilter_after_class() { + // delete channels + executor.executeSync(ChannelService.delete(Math.toIntExact(channel1.getId())) + .setKs(getOperatorKs())); + + executor.executeSync(ChannelService.delete(Math.toIntExact(channel2.getId())) + .setKs(getOperatorKs())); + // delete subscription + IngestMppUtils.deleteMpp(subscription.getName()); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index d633d5083..6b36235a6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -30,16 +30,16 @@ public class ChannelFilterTests extends BaseTest { @BeforeClass private void asset_list_channelFilter_before_class() { - // ingest movie + // get movie asset1 = getAssets(1, Optional.of(MediaType.MOVIE)).get(0); - // ingest series + // get series asset2 = getVirtualAssets(1, Optional.of(MediaType.SERIES)).get(0); - // ingest episode + // get episode asset3 = getAssets(1, Optional.of(MediaType.EPISODE)).get(0); - // ingest epg + // get epg program1 = getPrograms(1).get(0); // add assets to channel query diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/RelatedFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/RelatedFilterTests.java new file mode 100644 index 000000000..5cb6a0c28 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/RelatedFilterTests.java @@ -0,0 +1,5 @@ +package com.kaltura.client.test.tests.servicesTests.AssetTests.AssetListTests; + +public class RelatedFilterTests { + // TODO: 7/9/2018 implement RelatedFilterTests +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java new file mode 100644 index 000000000..4219f15e5 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java @@ -0,0 +1,7 @@ +package com.kaltura.client.test.tests.servicesTests.AssetTests.AssetListTests; + +import com.kaltura.client.test.tests.BaseTest; + +public class ScheduledRecordingProgramFilterTests extends BaseTest { + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 2de558b52..979b8557e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -4,11 +4,9 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.PurchaseUtils; -import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -26,14 +24,16 @@ import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.AssetService.list; -import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; -import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.enums.KsqlKey.ENTITLED_ASSETS; import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; +import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; +import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.AssetUtils.*; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; @@ -71,18 +71,18 @@ private void asset_list_searchAssetFilter_before_class() { HashMap stringMetaMap2 = new HashMap<>(); stringMetaMap2.put(metaName, metaValue2); - JSONArray ja = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray(); + JSONArray ja = getLinearAssetIdAndEpgChannelNameJsonArray(); String epgChannelName = ja.getJSONObject(0).getString("name"); String epgChannelName2 = ja.getJSONObject(1).getString("name"); // ingest asset 1 VodData vodData1 = new VodData() - .mediaType(MediaType.MOVIE); + .mediaType(MOVIE); asset = insertVod(vodData1); // ingest asset 2 VodData vodData2 = new VodData() - .mediaType(MediaType.MOVIE) + .mediaType(MOVIE) .catalogStartDate(getTimeInDate(-100)) .tags(tagMap) .strings(stringMetaMap1); @@ -90,7 +90,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 3 VodData vodData3 = new VodData() - .mediaType(MediaType.EPISODE) + .mediaType(EPISODE) .catalogStartDate(getTimeInDate(-10)) .tags(tagMap) .strings(stringMetaMap2); @@ -302,7 +302,7 @@ private void listVodAssetsFilteredByType() { String query = new KsqlBuilder() .openAnd() .equal(tagName, tagValue) - .equal("asset_type", getProperty(MOVIE_MEDIA_TYPE_ID)) + .equal("asset_type", getMediaTypeId(MOVIE)) .closeAnd() .toString(); assetFilter = getSearchAssetFilter(query); @@ -489,7 +489,7 @@ private void dynamicOrderByMeta() { .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) .closeOr() - .equal("asset_type", getProperty(MOVIE_MEDIA_TYPE_ID)) + .equal("asset_type", getMediaTypeId(MOVIE)) .closeAnd() .toString(); DynamicOrderBy dynamicOrderBy = new DynamicOrderBy(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 960ae8da4..cd4e02396 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -3,41 +3,40 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; -import com.kaltura.client.services.AssetHistoryService; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.tests.enums.MediaType; -import com.kaltura.client.test.utils.AssetHistoryUtils; import com.kaltura.client.test.utils.AssetUtils; -import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.services.AssetHistoryService.CleanAssetHistoryBuilder; -import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.services.AssetHistoryService.*; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; -import static com.kaltura.client.test.Properties.EPISODE_MEDIA_TYPE_ID; -import static com.kaltura.client.test.Properties.getProperty; -import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; -import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; +import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; +import static com.kaltura.client.test.utils.BookmarkUtils.addBookmark; +import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAssets; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryCleanTests extends BaseTest { private final int position1 = 10; private final int position2 = 20; - private final int numbOfDevices = 1; - private final int numOfUsers = 1; private MediaAsset movie; private int movieFileId; + private MediaAsset movie2; private int movie2FileId; + private MediaAsset episode; private int episodeFileId; @@ -45,205 +44,220 @@ public class AssetHistoryCleanTests extends BaseTest { @BeforeClass // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { - // Ingest first movie asset - VodData vodData = new VodData() - .mediaType(MediaType.MOVIE); + List movies = getAssets(2, Optional.of(MOVIE)); - movie = insertVod(vodData); + // get first movie asset + movie = movies.get(0); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); - // Ingest second movie asset - VodData vodData2 = new VodData() - .mediaType(MediaType.MOVIE); - - movie2 = insertVod(vodData2); + // get second movie asset + movie2 = movies.get(1); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - VodData vodData3 = new VodData() - .mediaType(MediaType.EPISODE); - - episode = insertVod(vodData3); + episode = getAssets(1, Optional.of(EPISODE)).get(0); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } @Description("assetHistory/action/clean - no filtering") @Test private void cleanHistory() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + Bookmark bookmark1 = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark1).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset - bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(userKs); + Bookmark bookmark2 = addBookmark(position1, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + addBookmarkBuilder = add(bookmark2).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + // assetHistory/action/list - both assets should returned + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); - //assetHistory/action/list - both assets should returned - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) - .setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); - //assetHistory/action/clean - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + // assetHistory/action/clean + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - no object returned - listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null) - .setKs(userKs); - assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } @Description("assetHistory/action/clean - filtered by asset id") @Test private void cleanSpecifcAssetHistory() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + bookmark = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movie.getId()), null, WatchStatus.ALL, null); + // assetHistory/action/clean + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setAssetIdIn(String.valueOf(movie.getId())); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); - //assetHistory/action/clean - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) - assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + assetHistoryFilter.setAssetIdIn(null); // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } @Description("assetHistory/action/clean - filtered by asset type") @Test private void cleanSpecifcAssetTypeHistory() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, getProperty(EPISODE_MEDIA_TYPE_ID)); - //assetHistory/action/clean - only episode type (episode) + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setTypeIn(String.valueOf(getMediaTypeId(EPISODE))); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) - assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + assetHistoryFilter.setTypeIn(null); // assetHistory/action/list - after clean - only movie returned (was not cleaned) - - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } @Description("assetHistory/action/clean - filtered by asset finished") @Test private void cleanAssetsAccordingToWatchStatusDone() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); + bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); - //assetHistory/action/clean - only asset that were finished (episode) + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setStatusEqual(WatchStatus.DONE); - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); - assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); - // assetHistory/action/list - after clean - only movie returned (was not cleaned) + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } @Description("assetHistory/action/clean - filtered by asset in progress") @Test private void cleanAssetsAccordingToWatchStatusProgress() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); + bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); + // assetHistory/action/clean - only asset that in progress (movie) + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setStatusEqual(WatchStatus.PROGRESS); - //assetHistory/action/clean - only asset that in progress (movie) - CleanAssetHistoryBuilder cleanAssetHistoryBuilder = AssetHistoryService.clean(assetHistoryFilter); + CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); cleanAssetHistoryBuilder.setKs(userKs); executor.executeSync(cleanAssetHistoryBuilder); - assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); - // assetHistory/action/list - after clean - only episode returned (was not cleaned) - ListAssetHistoryBuilder listAssetHistoryBuilder = AssetHistoryService.list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index d4a20d7b9..cfcd19d83 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -3,75 +3,70 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; -import com.kaltura.client.test.utils.*; +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; import java.util.List; +import java.util.Optional; -import static com.kaltura.client.services.AssetHistoryService.ListAssetHistoryBuilder; import static com.kaltura.client.services.AssetHistoryService.list; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; -import static com.kaltura.client.test.Properties.MOVIE_MEDIA_TYPE_ID; -import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; +import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; -import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; -import static com.kaltura.client.test.utils.HouseholdUtils.getHouseholdMasterUserKs; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAssets; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryListTests extends BaseTest { - private final int position1 = 10; private final int position2 = 20; - private final int numbOfDevices = 1; - private final int numOfUsers = 1; + private MediaAsset movie; private int movieFileId; + private MediaAsset movie2; private int movie2FileId; + private MediaAsset episode; private int episodeFileId; + @BeforeClass private void list_tests_before_class() { - // Ingest first movie asset - VodData vodData = new VodData() - .mediaType(MediaType.MOVIE); - movie = insertVod(vodData); + List movies = getAssets(2, Optional.of(MOVIE)); + + // get first movie asset + movie = movies.get(0); movieFileId = AssetUtils.getAssetFileIds(String.valueOf(movie.getId())).get(0); - // Ingest second movie asset - VodData vodData2 = new VodData() - .mediaType(MediaType.MOVIE); - movie2 = insertVod(vodData2); + // get second movie asset + movie2 = movies.get(1); movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - VodData vodData3 = new VodData() - .mediaType(MediaType.EPISODE); - - episode = insertVod(vodData3); + episode = getAssets(1, Optional.of(EPISODE)).get(0); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } @Description("assetHistory/action/list - with no filter") @Test private void vodAssetHistory() { - - // Create HH with one user and one device - Household household = createHousehold(numOfUsers, numbOfDevices, false); - HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); - String userKs = OttUserUtils.getKs(Integer.parseInt(masterUser.getUserId())); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -83,13 +78,14 @@ private void vodAssetHistory() { addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - // Build AssetHistoryFilter object - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, null); + // assetHistory/action/list - both assets should returned + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); - //assetHistory/action/list - both assets should returned - ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) - .setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); // objects can be returned in any order AssetHistory assetHistoryObject1, assetHistoryObject2; @@ -118,13 +114,18 @@ private void vodAssetHistory() { // Assert total count = 2 (two bookmarks) assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } @Description("assetHistory/action/list - filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -141,43 +142,38 @@ private void vodAssetHistoryFilteredByAssetId() { addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(String.valueOf(movie2.getId()), - null, WatchStatus.ALL, null); - - //assetHistory/action/list - filter by asset 2 id - ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null) - .setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setAssetIdIn(String.valueOf(movie2.getId())); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); - String concatenatedString = getConcatenatedString(String.valueOf(movie2.getId()), String.valueOf(episode.getId())); - - //assetHistory/action/list - filter by asset 2 and asset 3 ids - assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(concatenatedString, null, WatchStatus.ALL, null); + String concatenatedString = getConcatenatedString(String.valueOf(movie2.getId()), String.valueOf(episode.getId())); + assetHistoryFilter.setAssetIdIn(concatenatedString); - listAssetHistoryBuilder = list(assetHistoryFilter, null) - .setKs(userKs); - assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + List assetHistoryList = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)).results.getObjects(); - List assetHistoryList = assetHistoryListResponse.results.getObjects(); + assertThat(assetHistoryList).extracting("assetId") + .containsExactlyInAnyOrder(movie2.getId(), episode.getId()); - List assetHistoryIdsList = new ArrayList<>(); - for (AssetHistory assetHistory : assetHistoryList) { - assetHistoryIdsList.add(assetHistory.getAssetId()); - } - assertThat(assetHistoryIdsList).containsOnly(movie2.getId(), episode.getId()); + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } - @Description("assetHistory/action/list -filtered by movie type id") + @Description("assetHistory/action/list - filtered by movie type id") @Test private void vodAssetHistoryFilteredByAssetType() { - - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -189,25 +185,28 @@ private void vodAssetHistoryFilteredByAssetType() { addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.ALL, - getProperty(MOVIE_MEDIA_TYPE_ID)); - //assetHistory/action/list - filter by in progress assets only + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + assetHistoryFilter.setTypeIn(String.valueOf(getMediaTypeId(MediaType.MOVIE))); - ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null); - listAssetHistoryBuilder.setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } - @Description("assetHistory/action/list -filtered by assets progress") + @Description("assetHistory/action/list - filtered by assets progress") @Test private void vodAssetHistoryFilteredByAssetProgress() { - - Household household = createHousehold(numOfUsers, numbOfDevices, false); - String userKs = getHouseholdMasterUserKs(household); + // create household + Household household = createHousehold(); + String udid = getDevicesList(household).get(0).getUdid(); + String userKs = getHouseholdMasterUserKs(household, udid); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -219,27 +218,27 @@ private void vodAssetHistoryFilteredByAssetProgress() { addBookmarkBuilder = add(bookmark).setKs(userKs); executor.executeSync(addBookmarkBuilder); - AssetHistoryFilter assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.PROGRESS, null); - //assetHistory/action/list - filter by in progress assets only + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setStatusEqual(WatchStatus.PROGRESS); - ListAssetHistoryBuilder listAssetHistoryBuilder = list(assetHistoryFilter, null).setKs(userKs); - Response> assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); - assetHistoryFilter = AssetHistoryUtils.getAssetHistoryFilter(null, null, WatchStatus.DONE, null); - //assetHistory/action/list - filter by finished assets only + assetHistoryFilter.setStatusEqual(WatchStatus.DONE); - listAssetHistoryBuilder = list(assetHistoryFilter, null).setKs(userKs); - assetHistoryListResponse = executor.executeSync(listAssetHistoryBuilder); + assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(userKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(userKs)); } - //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index b5943e028..77cc7757e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.enums.*; import com.kaltura.client.services.*; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.PremiumService; import com.kaltura.client.test.utils.*; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; @@ -459,7 +460,6 @@ private void suspend_with_renew_subscription_role_before_wait() { @Test(groups = "slow_after", dependsOnGroups = {"slow_before"}, priority = 3) private void suspend_with_renew_subscription_role_after_wait() { // get productprice list for asset in subscription - after renew - Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(fiveMinRenewSubscriptionSlowTest.getId()), Optional.empty(), false).get(0); ProductPriceFilter assetFilter = new ProductPriceFilter(); assetFilter.setFileIdIn(String.valueOf(asset.getMediaFiles().get(0).getId())); @@ -532,11 +532,14 @@ private void suspend_with_purchase_service_role() { .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getUserId())); Response booleanResponse = executor.executeSync(suspendHouseholdBuilder); + assertThat(booleanResponse.results).isTrue(); // purchase subscription with premium service - int subscriptionId = DBUtils.getSubscriptionWithPremiumService(); - Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, subscriptionId, Optional.empty()); + Subscription subscription = DBUtils.getSubscriptionWithPremiumService(PremiumService.NPVR); + Response transactionResponse = PurchaseUtils + .purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); + assertThat(transactionResponse.results).isNull(); assertThat(transactionResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(7013).getCode()); @@ -544,6 +547,7 @@ private void suspend_with_purchase_service_role() { Integer mediaFileId = asset.getMediaFiles().get(0).getId(); transactionResponse = PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(asset.getId())), Optional.of(mediaFileId), Optional.empty()); + assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index 0ece3279f..03868da9b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.types.APIException; import com.kaltura.client.types.LoginResponse; import com.kaltura.client.types.OTTUser; import com.kaltura.client.types.UserLoginPin; @@ -32,7 +31,6 @@ public class OttUserLoginWithPinTests extends BaseTest { private Response userLoginPinResponse; private final String SECRET = "secret"; - private APIException apiException; @BeforeClass private void ottUser_login_tests_setup() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java index 70d41cf0e..a46985df8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserResendActivationTokenTests.java @@ -7,7 +7,6 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.kaltura.client.services.OttUserService.*; @@ -16,13 +15,6 @@ public class OttUserResendActivationTokenTests extends BaseTest { - private OTTUser user; - - @BeforeClass - private void ottUser_resendActivationToken_tests_setup() { - - } - @Severity(SeverityLevel.CRITICAL) @Description("ottUser/action/resendActivationToken - resendActivationToken") @Test(enabled = false) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 5f5f6216e..6875d2ae1 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -5,7 +5,6 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.SocialActionType; -import com.kaltura.client.services.AssetService; import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.SocialActionService; import com.kaltura.client.types.*; @@ -16,8 +15,7 @@ import java.util.Optional; import java.util.stream.Collectors; -import static com.kaltura.client.services.AssetService.GetAssetBuilder; -import static com.kaltura.client.services.AssetService.ListAssetBuilder; +import static com.kaltura.client.services.AssetService.*; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.SocialActionService.AddSocialActionBuilder; @@ -63,10 +61,8 @@ public static ChannelFilter getChannelFilter(int idEqual, Optional ksql, } public static List getAssetFileIds(String assetId) { - AssetReferenceType assetReferenceType = AssetReferenceType.get(AssetReferenceType.MEDIA.getValue()); - - GetAssetBuilder getAssetBuilder = AssetService.get(assetId, assetReferenceType); - getAssetBuilder.setKs(getSharedMasterUserKs()); + GetAssetBuilder getAssetBuilder = get(assetId, AssetReferenceType.MEDIA) + .setKs(getSharedMasterUserKs()); Response assetResponse = executor.executeSync(getAssetBuilder); List mediaFiles = assetResponse.results.getMediaFiles(); @@ -82,7 +78,7 @@ public static List getAssetsByType(String typeIn) { filterPager.setPageSize(20); filterPager.setPageIndex(1); - ListAssetBuilder listAssetBuilder = AssetService.list(assetFilter, filterPager) + ListAssetBuilder listAssetBuilder = list(assetFilter, filterPager) .setKs(getSharedMasterUserKs()); Response> assetResponse = executor.executeSync(listAssetBuilder); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 465d8211b..8858e382e 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -20,6 +20,8 @@ import static com.kaltura.client.test.Properties.API_VERSION; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.tests.BaseTest.config; +import static io.restassured.RestAssured.given; public class BaseUtils { @@ -181,4 +183,9 @@ public static void deleteFile(String filePath) { Logger.getLogger(BaseUtils.class).error("Failed to delete the file: " + filePath); } } + + public static void clearCache() { + String url = config.getEndpoint() + "/clear_cache.aspx"; + given().queryParam("action", "clear_all").get(url); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index b1fd897a9..e06f3c3c6 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -24,7 +24,7 @@ public class HouseholdUtils extends BaseUtils { // default household params - private static final int defaultNumOfUsers = 2; + private static final int defaultNumOfUsers = 1; private static final int defaultNumOfDevices = 1; private static final boolean defaultIsPreparePG = true; diff --git a/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java index 075e6aa02..c29a33540 100644 --- a/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java +++ b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.utils; public class KsqlBuilder { - private String query; private StringBuilder sb; public KsqlBuilder() { diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 582f43fd5..f22f8d1e4 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -125,12 +125,17 @@ public class DBConstants { "and s.group_id=? and s.is_active=1 and s.[status]=1 and s.[type]=0 and sc.is_active=1 and sc.[status]=1\n" + "order by s.create_date desc"; - static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) SUBSCRIPTION_ID as " + SUB_ID + - ", SERVICE_ID as " + SERV_ID + "\n" + - "FROM [Pricing].[dbo].[subscriptions] s\n" + - "INNER JOIN [Pricing].[dbo].[subscriptions_services] ss\n" + - "ON s.ID = SS.SUBSCRIPTION_ID\n" + - "where s.group_id=?"; + static final String SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT = "select TOP (1) " + + "SUBSCRIPTION_ID as " + SUB_ID + ", " + + "SERVICE_ID as " + SERV_ID + " " + + "FROM [Pricing].[dbo].[subscriptions] s " + + "INNER JOIN [Pricing].[dbo].[subscriptions_services] ss " + + "ON s.ID = SS.SUBSCRIPTION_ID " + + "where s.group_id = ? " + + "and s.IS_ACTIVE = 1 " + + "and s.status = 1 " + + "and ss.STATUS = 1 " + + "and ss.SERVICE_ID = ?"; static final String COLLECTION_SELECT = "select top 1 * from [Pricing].[dbo].[collections]\n" + "where [status]=1 and is_active=1\n" + @@ -203,6 +208,8 @@ public class DBConstants { "and mt.NAME = ? " + "order by m.id desc"; + static final String MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where GROUP_ID = ? and name = ?"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index fd4e7586b..2184025c7 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -1,14 +1,13 @@ package com.kaltura.client.test.utils.dbUtils; import com.kaltura.client.Logger; +import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.test.tests.enums.KsqlKey; import com.kaltura.client.test.tests.enums.MediaType; +import com.kaltura.client.test.tests.enums.PremiumService; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; -import com.kaltura.client.types.MediaAsset; -import com.kaltura.client.types.PricePlan; -import com.kaltura.client.types.ProgramAsset; -import com.kaltura.client.types.SearchAssetFilter; +import com.kaltura.client.types.*; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; @@ -212,10 +211,16 @@ public static int getUnActiveAsset() { .getInt("id"); } - public static int getSubscriptionWithPremiumService() { - return getJsonArrayFromQueryResult(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, partnerId) + public static Subscription getSubscriptionWithPremiumService(PremiumService premiumService) { + int subscriptionId = getJsonArrayFromQueryResult(SUBSCRIPTION_WITH_PREMIUM_SERVICE_SELECT, partnerId, premiumService.getValue()) .getJSONObject(0) .getInt(SUB_ID); + + SubscriptionFilter filter = new SubscriptionFilter(); + filter.setSubscriptionIdIn(String.valueOf(subscriptionId)); + + return executor.executeSync(SubscriptionService.list(filter) + .setKs(getOperatorKs())).results.getObjects().get(0); } public static PricePlan loadPPWithWaiver() { @@ -251,14 +256,14 @@ public static List getAssets(int numOfAssets, Optional me for (int i = 0; i < jsonArray.length(); i++) { builder.equal(KsqlKey.NAME.getValue(), jsonArray.getJSONObject(i).getString("name")); } - + String query = new KsqlBuilder() .or(builder.toString()) .toString(); - + SearchAssetFilter filter = new SearchAssetFilter(); filter.setKSql(query); - return (List)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); + return (List) (List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); } public static List getVirtualAssets(int numOfAssets, Optional mediaType) { @@ -281,7 +286,7 @@ public static List getVirtualAssets(int numOfAssets, Optional)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); + return (List) (List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); } public static List getPrograms(int numOfPrograms) { @@ -298,6 +303,18 @@ public static List getPrograms(int numOfPrograms) { SearchAssetFilter filter = new SearchAssetFilter(); filter.setKSql(query); - return (List)(List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); + return (List) (List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); + } + + public static int getMediaTypeId(MediaType mediaType) { + return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 1, mediaType.getValue()) + .getJSONObject(0) + .getInt("id"); + } + + public static int getVirtualMediaTypeId(MediaType mediaType) { + return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 2, mediaType.getValue()) + .getJSONObject(0) + .getInt("id"); } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 71273cb4a..88f7b4601 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -97,7 +97,6 @@ static void prettyPrint(Document doc) throws Exception { tf.setOutputProperty(OutputKeys.INDENT, "yes"); Writer out = new StringWriter(); tf.transform(new DOMSource(doc), new StreamResult(out)); - System.out.println(out.toString()); } static String uncommentCdataSection(String docAsString) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index ac79b55a3..21c0b9014 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -206,7 +206,9 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // media type - media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType().getValue()); + if (action.equals(INGEST_ACTION_INSERT)) { + media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType().getValue()); + } // geo block rule media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.geoBlockRule()); diff --git a/src/test/resources/ingest_xml_templates/test.xml b/src/test/resources/ingest_xml_templates/test.xml index c64e2e52b..e69de29bb 100644 --- a/src/test/resources/ingest_xml_templates/test.xml +++ b/src/test/resources/ingest_xml_templates/test.xml @@ -1,30 +0,0 @@ - - - - - - - 0 - OK - - OK - - 18070413420791 - 636429 - - - entry_18070413420791 - 18070413420791 - 636429 - - - 0 - OK - - - - - - - - \ No newline at end of file From 7e2a9bdff0af12e312087c6dec30defe0ee661ff Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Jul 2018 15:31:16 +0300 Subject: [PATCH 414/605] fix compile errors after rebase --- .../kaltura/client/test/tests/BaseTest.java | 14 ++++---- .../AssetListTests/BundleFilterTests.java | 14 ++++---- .../AssetListTests/ChannelFilterTests.java | 8 ++--- .../channelTests/ChannelAddTests.java | 32 ++++++++++++------- .../channelTests/ChannelDeleteTests.java | 7 ++-- .../EntitlementCancelTests.java | 6 ++-- .../ProductPriceListTests.java | 8 ++--- .../client/test/utils/ChannelUtils.java | 16 ++++------ .../test/utils/dbUtils/IngestFixtureData.java | 7 ++-- 9 files changed, 61 insertions(+), 51 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 89c3ca882..6a1f16f14 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -409,8 +409,8 @@ public static Subscription get5MinRenewableSubscription() { PricePlan pricePlan = insertPp(ppData); // it should have at least 1 VOD - Channel channel = loadDefaultChannel(); - channel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + DynamicChannel channel = loadDefaultChannel(); + channel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(channel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); if (channelResponse.results != null && channelResponse.results.getName() != null) { @@ -433,10 +433,10 @@ private static void ingestVODIntoSubscription(Subscription subscription) { Verify.verify(listResponse.results.getObjects().get(0).getChannels().size() > 0); int channelId = listResponse.results.getObjects().get(0).getChannels().get(0).getId().intValue(); - Channel channel = IngestFixtureData.getChannel(channelId); + DynamicChannel channel = IngestFixtureData.getChannel(channelId); String[] parameters; String tag = null, name = null; - if (null == channel.getFilterExpression()) { + if (null == channel.getKSql()) { // automatic channel String automaticChannelExpression = IngestFixtureData.getAutomaticChannelExpression(channelId); parameters = automaticChannelExpression.split(":"); @@ -444,7 +444,7 @@ private static void ingestVODIntoSubscription(Subscription subscription) { tag = parameters[0]; } else { // KSQL channel - parameters = channel.getFilterExpression().split("="); + parameters = channel.getKSql().split("="); Verify.verify(parameters.length == 2); if ("name".equals(parameters[0].toLowerCase())) { // ingest VOD with mentioned name @@ -474,8 +474,8 @@ private static void ingestVODIntoSubscription(Subscription subscription) { } } - private static Channel loadDefaultChannel() { - Channel channel = new Channel(); + private static DynamicChannel loadDefaultChannel() { + DynamicChannel channel = new DynamicChannel(); channel.setName(BaseUtils.getRandomValue("Channel_", 999999)); channel.setDescription("Description of " + channel.getName()); channel.setIsActive(true); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index e65291d10..9d305a2ea 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -34,7 +34,7 @@ public class BundleFilterTests extends BaseTest { private MediaAsset movie1, movie2; private MediaAsset series1, series2; private MediaAsset episode1, episode2; - private Channel channel1, channel2; + private DynamicChannel channel1, channel2; private Subscription subscription; @@ -74,23 +74,23 @@ private void asset_list_bundleFilter_before_class() { .toString(); // add channel1 - channel1 = new Channel(); + channel1 = new DynamicChannel(); channel1.setName("channel_" + getTimeInEpoch()); channel1.description("Description of " + channel1.getName()); channel1.setIsActive(true); - channel1.setFilterExpression(channel1Query); + channel1.setKSql(channel1Query); - channel1 = executor.executeSync(add(channel1) + channel1 = (DynamicChannel) executor.executeSync(add(channel1) .setKs(getOperatorKs())).results; // add channel2 - channel2 = new Channel(); + channel2 = new DynamicChannel(); channel2.setName("channel_" + getTimeInEpoch()); channel2.description("Description of " + channel2.getName()); channel2.setIsActive(true); - channel2.setFilterExpression(channel2Query); + channel2.setKSql(channel2Query); - channel2 = executor.executeSync(add(channel2) + channel2 = (DynamicChannel) executor.executeSync(add(channel2) .setKs(getOperatorKs())).results; // ingest subscription with 2 new channels diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 6b36235a6..6f34a3d1d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -25,7 +25,7 @@ public class ChannelFilterTests extends BaseTest { private MediaAsset asset1, asset2, asset3; private ProgramAsset program1; - private Channel channel; + private DynamicChannel channel; @BeforeClass @@ -53,13 +53,13 @@ private void asset_list_channelFilter_before_class() { .toString(); // add channel - channel = new Channel(); + channel = new DynamicChannel(); channel.setName("channel_" + getTimeInEpoch()); channel.description("Description of " + channel.getName()); channel.setIsActive(true); - channel.setFilterExpression(query); // "Free='" + channel.getName() + "'" + channel.setKSql(query); // "Free='" + channel.getName() + "'" - channel = executor.executeSync(ChannelService.add(channel) + channel = (DynamicChannel) executor.executeSync(ChannelService.add(channel) .setKs(getOperatorKs())).results; } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 1995c42c8..b72300a11 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -1,6 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.channelTests; -import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.enums.ChannelOrderBy; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; @@ -28,11 +28,11 @@ public class ChannelAddTests extends BaseTest { - private Channel channel; + private DynamicChannel channel; private String channelName; private String description; private Boolean isActive = true; - private String filterExpression; + private String ksqlExpression; private IntegerValue integerValue = new IntegerValue(); private List assetTypes = new ArrayList<>(); @@ -46,8 +46,10 @@ private void channel_addTests_before_class() { @Description("channel/action/add - with all asset types") @Test private void addChannel() { - filterExpression = "name ~ 'movie'"; - channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + ksqlExpression = "name ~ 'movie'"; + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); @@ -74,8 +76,10 @@ private void checkOrderOfAssetsInChannel() { .mediaType(MediaType.EPISODE); MediaAsset episodeAsset = insertVod(vodData1); - filterExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; - channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.NAME_DESC, null, null); + ksqlExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.NAME_DESC); + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); @@ -106,7 +110,9 @@ private void checkOrderOfAssetsInChannel() { private void addChannelWithInvalidAssetType() { integerValue.setValue(666); assetTypes.add(integerValue); - channel = ChannelUtils.addChannel(channelName, description, isActive, null, AssetOrderBy.LIKES_DESC, assetTypes, null); + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, null, channelOrder, assetTypes); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel) @@ -120,7 +126,9 @@ private void addChannelWithInvalidAssetType() { @Description("channel/action/add - mandatory channel name not provided") @Test private void addChannelWithNoName() { - channel = ChannelUtils.addChannel(null, description, isActive, null, AssetOrderBy.LIKES_DESC, null, null); + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + channel = ChannelUtils.addDynamicChannel(null, description, isActive, null, channelOrder, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel) @@ -134,8 +142,10 @@ private void addChannelWithNoName() { @Description("channel/action/add - syntax error in filter expression") @Test private void addChannelWithSyntaxErrorInFilterExpression() { - filterExpression = "name = 'syntax error"; - channel = ChannelUtils.addChannel(channelName, description, isActive, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + ksqlExpression = "name = 'syntax error"; + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); //channel/action/add AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 8d258b5b0..fcac65d97 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -1,10 +1,11 @@ package com.kaltura.client.test.tests.servicesTests.channelTests; -import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.enums.ChannelOrderBy; import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.ChannelUtils; import com.kaltura.client.types.Channel; +import com.kaltura.client.types.ChannelOrder; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; @@ -28,7 +29,9 @@ public class ChannelDeleteTests extends BaseTest { @Description("channel/action/delete") @Test private void DeleteChannel() { - channel = ChannelUtils.addChannel(channelName, description, true, filterExpression, AssetOrderBy.LIKES_DESC, null, null); + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + channel = ChannelUtils.addDynamicChannel(channelName, description, true, filterExpression, channelOrder, null); // channel/action/add ChannelService.AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index b3f62adc0..3db909610 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -43,7 +43,7 @@ public class EntitlementCancelTests extends BaseTest { private HouseholdUser testSharedMasterUser; private BookmarkPlayerData playerData; private Bookmark bookmark; - private Channel sharedChannel; + private DynamicChannel sharedChannel; private final int numberOfUsersInHousehold = 2; private final int numberOfDevicesInHousehold = 1; @@ -66,7 +66,7 @@ public void cancelTestBeforeClass() { bookmark.setPosition(0); bookmark.setType(AssetType.MEDIA); - sharedChannel = new Channel(); + sharedChannel = new DynamicChannel(); sharedChannel.setName(BaseUtils.getRandomValue("Channel_", 999999)); sharedChannel.setDescription("Description of " + sharedChannel.getName()); sharedChannel.setIsActive(true); @@ -129,7 +129,7 @@ public void cancelWithInvalidSubscription() { @Test public void cancelPlayedSubscription() { // create mpp having at least 1 media on its channel - sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + sharedChannel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); assertThat(channelResponse.results).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index ae7876a47..51faaea08 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -42,7 +42,7 @@ public class ProductPriceListTests extends BaseTest { private Household household; private String classMasterUserKs; private String classMasterUserId; - private Channel sharedChannel; + private DynamicChannel sharedChannel; private Subscription subscriptionWithMultiCurrenciesAndDiscountPercentage; private Response> productPriceResponse; @@ -73,7 +73,7 @@ public void beforeClass() { classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); classMasterUserId = HouseholdUtils.getMasterUser(household).getUserId(); - sharedChannel = new Channel(); + sharedChannel = new DynamicChannel(); sharedChannel.setName(BaseUtils.getRandomValue("Channel_", 999999)); sharedChannel.setDescription("Description of " + sharedChannel.getName()); sharedChannel.setIsActive(true); @@ -212,7 +212,7 @@ public void subscriptionTest() { String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); // create mpp with supporting of 1 type only and having at least 1 media on its channel - sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + sharedChannel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); assertThat(channelResponse.results).isNotNull(); @@ -296,7 +296,7 @@ public void subscriptionTest() { @Test() public void productPriceSubscriptionWebHDFileTypeOnlyTest() { // create mpp with supporting of 1 type only and having at least 1 media on its channel - sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); + sharedChannel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); assertThat(channelResponse.results).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java index c6e3aaf52..94350e6c2 100644 --- a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java @@ -1,25 +1,21 @@ package com.kaltura.client.test.utils; -import com.kaltura.client.enums.AssetOrderBy; -import com.kaltura.client.types.Channel; -import com.kaltura.client.types.IntegerValue; -import com.kaltura.client.types.MediaImage; +import com.kaltura.client.types.*; import javax.annotation.Nullable; import java.util.List; public class ChannelUtils extends BaseUtils { - public static Channel addChannel(String name, @Nullable String description, @Nullable Boolean isActive, @Nullable String filterExpression, - @Nullable AssetOrderBy orderBy, @Nullable List assetTypes, @Nullable List images) { - Channel channel = new Channel(); + public static DynamicChannel addDynamicChannel(String name, @Nullable String description, @Nullable Boolean isActive, @Nullable String ksqlExpression, + @Nullable ChannelOrder channelOrder, @Nullable List assetTypes) { + DynamicChannel channel = new DynamicChannel(); channel.setName(name); channel.setDescription(description); channel.setIsActive(isActive); - channel.setFilterExpression(filterExpression); - channel.setOrder(orderBy); channel.setAssetTypes(assetTypes); - channel.setImages(images); + channel.setKSql(ksqlExpression); + channel.setOrderBy(channelOrder); return channel; } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index b3021b788..6ca49f75d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -167,14 +167,15 @@ public static Subscription loadShared5MinutesRenewableSubscription() { return subscription; } - public static Channel getChannel(int id) { + public static DynamicChannel getChannel(int id) { Logger.getLogger(IngestFixtureData.class).debug("getChannel(): id = " + id); JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_SELECT, id); GetChannelBuilder getChannelBuilder = ChannelService.get(jsonArray.getJSONObject(0).getInt(ID)); - Response channelResponse = executor.executeSync(getChannelBuilder.setKs(getOperatorKs())); + Response channelResponse = executor.executeSync(getChannelBuilder + .setKs(getOperatorKs())); - return channelResponse.results; + return (DynamicChannel) channelResponse.results; } public static String getAutomaticChannelExpression(int channelId) { From b8d1a813d2c8ff210885bb827659f5cdb1aad25a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 10 Jul 2018 16:24:36 +0300 Subject: [PATCH 415/605] fix compile error after rebase --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 5 +++-- .../com/kaltura/client/test/utils/dbUtils/DBConstants.java | 2 ++ .../java/com/kaltura/client/test/utils/dbUtils/DBUtils.java | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 6a1f16f14..e64a3e621 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -379,9 +379,10 @@ public static MediaFile getSharedMobileMediaFile() { return mobileMediaFile; } - public static MediaFile getMediaFileByType(MediaAsset asset, String type) { + public static MediaFile getMediaFileByType(MediaAsset asset, String fileType) { MediaFile result; - if (type.equals(asset.getMediaFiles().get(0).getType())) { + int fileTypeId = asset.getMediaFiles().get(0).getTypeId(); + if (fileType.equals(DBUtils.getMediaFileTypeName(fileTypeId))) { result = mediaAsset.getMediaFiles().get(0); } else { result = mediaAsset.getMediaFiles().get(1); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index f22f8d1e4..6afb14049 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -210,6 +210,8 @@ public class DBConstants { static final String MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where GROUP_ID = ? and name = ?"; + static final String MEDIA_FILE_TYPE_ID_SELECT = "SELECT [NAME] FROM [TVinci].[dbo].[groups_media_type] where GROUP_ID = ? and ID = ?"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 58957a3a0..83bea4398 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -317,4 +317,10 @@ public static int getVirtualMediaTypeId(MediaType mediaType) { .getJSONObject(0) .getInt("id"); } + + public static int getMediaFileTypeName(int mediaFileId) { + return getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_ID_SELECT, partnerId + 1, mediaFileId) + .getJSONObject(0) + .getInt("name"); + } } From 192f1ca2228ebccc7ebaa6c4407bc1b6d745a29a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 11 Jul 2018 14:02:04 +0300 Subject: [PATCH 416/605] fixed bookmark/action/add tests according to the new logic --- .../AssetHistoryCleanTests.java | 95 +++++++++++-------- .../AssetHistoryListTests.java | 76 +++++++++------ .../bookmarkTests/BookmarkAddTests.java | 53 ++++++----- 3 files changed, 126 insertions(+), 98 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index cd4e02396..571e9b83f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -27,9 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; public class AssetHistoryCleanTests extends BaseTest { - private final int position1 = 10; private final int position2 = 20; + private final int numOfUsers = 1; + private final int numOfDevices = 2; private MediaAsset movie; private int movieFileId; @@ -63,18 +64,20 @@ private void clean_tests_before_class() { @Test private void cleanHistory() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark1 = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark1).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark1).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset Bookmark bookmark2 = addBookmark(position1, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark2).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark2).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // assetHistory/action/list - both assets should returned @@ -82,41 +85,43 @@ private void cleanHistory() { assetHistoryFilter.setStatusEqual(WatchStatus.ALL); Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); // assetHistory/action/clean CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(userKs); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - no object returned assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } @Description("assetHistory/action/clean - filtered by asset id") @Test private void cleanSpecifcAssetHistory() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // assetHistory/action/clean @@ -125,7 +130,7 @@ private void cleanSpecifcAssetHistory() { assetHistoryFilter.setStatusEqual(WatchStatus.ALL); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(userKs); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) @@ -133,31 +138,33 @@ private void cleanSpecifcAssetHistory() { // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } @Description("assetHistory/action/clean - filtered by asset type") @Test private void cleanSpecifcAssetTypeHistory() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); //assetHistory/action/clean - only episode type (episode) @@ -166,7 +173,7 @@ private void cleanSpecifcAssetTypeHistory() { assetHistoryFilter.setStatusEqual(WatchStatus.ALL); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(userKs); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = null) @@ -174,31 +181,33 @@ private void cleanSpecifcAssetTypeHistory() { // assetHistory/action/list - after clean - only movie returned (was not cleaned) Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } @Description("assetHistory/action/clean - filtered by asset finished") @Test private void cleanAssetsAccordingToWatchStatusDone() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); //assetHistory/action/clean - only asset that were finished (episode) @@ -206,38 +215,40 @@ private void cleanAssetsAccordingToWatchStatusDone() { assetHistoryFilter.setStatusEqual(WatchStatus.DONE); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(userKs); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - only movie returned (was not cleaned) assetHistoryFilter.setStatusEqual(WatchStatus.ALL); Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } @Description("assetHistory/action/clean - filtered by asset in progress") @Test private void cleanAssetsAccordingToWatchStatusProgress() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // assetHistory/action/clean - only asset that in progress (movie) @@ -245,19 +256,19 @@ private void cleanAssetsAccordingToWatchStatusProgress() { assetHistoryFilter.setStatusEqual(WatchStatus.PROGRESS); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(userKs); + cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - only episode returned (was not cleaned) assetHistoryFilter.setStatusEqual(WatchStatus.ALL); Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index cfcd19d83..7d314043c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -32,6 +32,9 @@ public class AssetHistoryListTests extends BaseTest { private final int position1 = 10; private final int position2 = 20; + private final int numOfUsers = 1; + private final int numOfDevices = 2; + private MediaAsset movie; private int movieFileId; @@ -64,18 +67,20 @@ private void list_tests_before_class() { @Test private void vodAssetHistory() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // assetHistory/action/list - both assets should returned @@ -83,7 +88,7 @@ private void vodAssetHistory() { assetHistoryFilter.setStatusEqual(WatchStatus.ALL); Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); @@ -116,30 +121,35 @@ private void vodAssetHistory() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } @Description("assetHistory/action/list - filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + int numOfDevices = 3; + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String udid3 = getDevicesList(household).get(2).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark Second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark third asset bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid3); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); //assetHistory/action/list - filter by asset 2 id @@ -148,7 +158,7 @@ private void vodAssetHistoryFilteredByAssetId() { assetHistoryFilter.setStatusEqual(WatchStatus.ALL); Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); @@ -158,31 +168,33 @@ private void vodAssetHistoryFilteredByAssetId() { assetHistoryFilter.setAssetIdIn(concatenatedString); List assetHistoryList = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)).results.getObjects(); + .setKs(masterUserKs)).results.getObjects(); assertThat(assetHistoryList).extracting("assetId") .containsExactlyInAnyOrder(movie2.getId(), episode.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } @Description("assetHistory/action/list - filtered by movie type id") @Test private void vodAssetHistoryFilteredByAssetType() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark Second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); //assetHistory/action/list - filter by in progress assets only @@ -191,31 +203,33 @@ private void vodAssetHistoryFilteredByAssetType() { assetHistoryFilter.setTypeIn(String.valueOf(getMediaTypeId(MediaType.MOVIE))); Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } @Description("assetHistory/action/list - filtered by assets progress") @Test private void vodAssetHistoryFilteredByAssetProgress() { // create household - Household household = createHousehold(); - String udid = getDevicesList(household).get(0).getUdid(); - String userKs = getHouseholdMasterUserKs(household, udid); + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(userKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark Second asset bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - addBookmarkBuilder = add(bookmark).setKs(userKs); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); //assetHistory/action/list - filter by in progress assets only @@ -223,7 +237,7 @@ private void vodAssetHistoryFilteredByAssetProgress() { assetHistoryFilter.setStatusEqual(WatchStatus.PROGRESS); Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); @@ -232,13 +246,13 @@ private void vodAssetHistoryFilteredByAssetProgress() { assetHistoryFilter.setStatusEqual(WatchStatus.DONE); assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(userKs)); + .setKs(masterUserKs)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(userKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 06bd04eaa..ec9a6f84d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -1,11 +1,15 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; -import com.kaltura.client.enums.*; -import com.kaltura.client.services.BookmarkService; +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.enums.BookmarkActionType; +import com.kaltura.client.enums.BookmarkOrderBy; +import com.kaltura.client.enums.PositionOwner; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; -import com.kaltura.client.types.*; +import com.kaltura.client.types.Bookmark; +import com.kaltura.client.types.BookmarkFilter; +import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import org.testng.annotations.BeforeClass; @@ -15,7 +19,7 @@ import java.util.List; import static com.kaltura.client.services.BookmarkService.*; -import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; +import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -24,7 +28,6 @@ public class BookmarkAddTests extends BaseTest { private long assetId; private int fileId; - private int position; private List assetList; private Bookmark bookmark; private BookmarkFilter bookmarkFilter; @@ -44,18 +47,18 @@ private void bookmark_addTests_before_class() { @Description("bookmark/action/add - first play") @Test private void firstPlayback() { - position = 0; + int position = 0; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); @@ -64,7 +67,7 @@ private void firstPlayback() { assertThat(bookmark1.getId()).isEqualTo(String.valueOf(assetId)); // Match content of asset position - assertThat(bookmark1.getPosition()).isEqualTo(this.position); + assertThat(bookmark1.getPosition()).isEqualTo(position); // verify finishedWatching = false assertThat(bookmark1.getFinishedWatching()).isFalse(); @@ -82,40 +85,40 @@ private void firstPlayback() { @Description("bookmark/action/add - pause") @Test private void pausePlayback() { - position = 30; + int position = 30; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PAUSE); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); - Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + Response> bookmarkListResponse = executor.executeSync(list(bookmarkFilter) + .setKs(getSharedMasterUserKs())); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Match content of asset position - assertThat(bookmark.getPosition()).isEqualTo(this.position); + assertThat(bookmark.getPosition()).isEqualTo(position); } @Description("bookmark/action/add - 95% watching == finish watching") @Test private void watchingNinetyFive() { - position = 999; + int position = 999; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PLAY); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark3 = bookmarkListResponse.results.getObjects().get(0); @@ -126,14 +129,14 @@ private void watchingNinetyFive() { @Description("bookmark/action/add - back to start - position:0") @Test private void backToStart() { - position = 0; + int position = 0; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.STOP); - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); @@ -144,18 +147,18 @@ private void backToStart() { @Description("bookmark/action/add - finish watching") @Test private void finishWatching() { - position = 60; + int position = 60; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FINISH); // Invoke bookmark/action/add request - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); - Response booleanResponse = executor.executeSync(addBookmarkBuilder); + Response booleanResponse = executor.executeSync(add(bookmark) + .setKs(getSharedMasterUserKs())); assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); // Invoke bookmark/action/list to verify insertion of bookmark position - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); + ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); @@ -167,7 +170,7 @@ private void finishWatching() { @Test private void emptyAssetId() { bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results).isNull(); From b7596e57ab6527411c003e462c1c4f6b8d57c5c1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 12 Jul 2018 17:22:18 +0300 Subject: [PATCH 417/605] no message --- .../AssetHistoryListTests.java | 102 ++++++++++++++---- 1 file changed, 80 insertions(+), 22 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 7d314043c..dded5460f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -7,7 +7,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.AssetUtils; -import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -24,6 +23,7 @@ import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BookmarkUtils.addBookmark; import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAssets; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; @@ -35,7 +35,6 @@ public class AssetHistoryListTests extends BaseTest { private final int numOfUsers = 1; private final int numOfDevices = 2; - private MediaAsset movie; private int movieFileId; @@ -63,25 +62,45 @@ private void list_tests_before_class() { episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } - @Description("assetHistory/action/list - with no filter") + @Description("assetHistory/action/list - with no filter and one device and two media") @Test - private void vodAssetHistory() { + private void assetHistory_vod_with_one_device_and_two_media() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); - String udid2 = getDevicesList(household).get(1).getUdid(); String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); - executor.executeSync(addBookmarkBuilder); - - // Bookmark second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); - executor.executeSync(addBookmarkBuilder); +// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(movie.getId())), Optional.of(movieFileId), Optional.empty()); +// +// // getPlaybackContext +// PlaybackContextOptions options = new PlaybackContextOptions(); +// options.setStreamerType("applehttp"); +// options.setMediaProtocol("http"); +// options.setContext(PlaybackContextType.PLAYBACK); +// +// GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = +// getPlaybackContext(String.valueOf(movie.getId()), AssetType.MEDIA, options) +// .setKs(masterUserKs); +// executor.executeSync(getPlaybackContextAssetBuilder); + + // Bookmark first asset - first play + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + executor.executeSync(add(bookmark).setKs(masterUserKs)); + + // Bookmark first asset - stop + bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.STOP); + executor.executeSync(add(bookmark).setKs(masterUserKs)); + + // Bookmark second asset - first play +// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(movie2.getId())), Optional.of(movie2FileId), Optional.empty()); +// +// getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(movie2.getId()), AssetType.MEDIA, options) +// .setKs(masterUserKs); +// executor.executeSync(getPlaybackContextAssetBuilder); + + bookmark = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + executor.executeSync(add(bookmark).setKs(masterUserKs)); // assetHistory/action/list - both assets should returned AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -124,6 +143,45 @@ private void vodAssetHistory() { executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } + @Description("assetHistory/action/list - with no filter and two devices and one media") + @Test + private void assetHistory_vod_with_two_devices_and_one_media() { + // create household + Household household = createHousehold(numOfUsers, numOfDevices, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); + + // Bookmark first device - first play + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + executor.executeSync(add(bookmark).setKs(masterUserKs)); + + // Bookmark second device - first play + bookmark = addBookmark(position2, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + masterUserKs = getHouseholdMasterUserKs(household, udid2); + executor.executeSync(add(bookmark).setKs(masterUserKs)); + + // assetHistory/action/list - both assets should returned + AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); + assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) + .setKs(masterUserKs)); + + assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); + + AssetHistory assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); + assertThat(assetHistoryObject1.getAssetType()).isEqualTo(AssetType.MEDIA); + assertThat(assetHistoryObject1.getDuration()).isGreaterThan(0); + assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); + assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movie.getId()); + assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); + assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(getTimeInEpoch(0)); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + } + @Description("assetHistory/action/list - filtered by movie asset id") @Test private void vodAssetHistoryFilteredByAssetId() { @@ -136,18 +194,18 @@ private void vodAssetHistoryFilteredByAssetId() { String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark Second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + bookmark = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); masterUserKs = getHouseholdMasterUserKs(household, udid2); addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark third asset - bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + bookmark = addBookmark(position1, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); masterUserKs = getHouseholdMasterUserKs(household, udid3); addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); @@ -187,12 +245,12 @@ private void vodAssetHistoryFilteredByAssetType() { String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark Second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); masterUserKs = getHouseholdMasterUserKs(household, udid2); addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); @@ -222,12 +280,12 @@ private void vodAssetHistoryFilteredByAssetProgress() { String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset - Bookmark bookmark = BookmarkUtils.addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); // Bookmark Second asset - bookmark = BookmarkUtils.addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); + bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); masterUserKs = getHouseholdMasterUserKs(household, udid2); addBookmarkBuilder = add(bookmark).setKs(masterUserKs); executor.executeSync(addBookmarkBuilder); @@ -255,4 +313,4 @@ private void vodAssetHistoryFilteredByAssetProgress() { executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] -} +} \ No newline at end of file From 0345765e5996574f3fabe660be9d5d3df2a5a0ec Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sat, 14 Jul 2018 22:35:00 +0300 Subject: [PATCH 418/605] fix compile errors after rebase to 5.0.1 --- .../client/services/RecordingService.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 18 +++++++++++------- .../AssetListTests/BundleFilterTests.java | 12 ++++++------ .../AssetListTests/ChannelFilterTests.java | 4 ++-- .../channelTests/ChannelDeleteTests.java | 4 ++-- .../EntitlementCancelTests.java | 12 ++++++------ .../ProductPriceListTests.java | 7 +++---- .../kaltura/client/test/utils/BaseUtils.java | 12 ++++++++++++ .../client/test/utils/ChannelUtils.java | 4 ++-- .../client/test/utils/dbUtils/DBUtils.java | 4 ++-- .../test/utils/dbUtils/IngestFixtureData.java | 7 ++++--- 11 files changed, 51 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/kaltura/client/services/RecordingService.java b/src/main/java/com/kaltura/client/services/RecordingService.java index ef9b1db99..790bb9273 100644 --- a/src/main/java/com/kaltura/client/services/RecordingService.java +++ b/src/main/java/com/kaltura/client/services/RecordingService.java @@ -200,7 +200,7 @@ public static NotifyRecordingBuilder notify_(String externalDomainRecordingId, R } public static NotifyRecordingBuilder notify_(String externalDomainRecordingId, RecordingStatus recordingStatus, int domainId, String externalEpgId, RecordingType recordingType) { - return notify_(externalDomainRecordingId, recordingStatus, domainId, externalEpgId, recordingType, False); + return notify_(externalDomainRecordingId, recordingStatus, domainId, externalEpgId, recordingType, false); } /** diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index e64a3e621..1fda33fa3 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -10,7 +10,6 @@ import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.PerformanceAppLogUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; @@ -20,12 +19,17 @@ import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; + import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.TimeUnit; + import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; +import static com.kaltura.client.test.utils.BaseUtils.deleteFile; +import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static com.kaltura.client.test.utils.BaseUtils.setTranslationToken; import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.OttUserUtils.getOttUserById; import static com.kaltura.client.test.utils.SubscriptionUtils.getAssetsListBySubscription; @@ -380,14 +384,14 @@ public static MediaFile getSharedMobileMediaFile() { } public static MediaFile getMediaFileByType(MediaAsset asset, String fileType) { - MediaFile result; + MediaFile mediaFile; int fileTypeId = asset.getMediaFiles().get(0).getTypeId(); if (fileType.equals(DBUtils.getMediaFileTypeName(fileTypeId))) { - result = mediaAsset.getMediaFiles().get(0); + mediaFile = mediaAsset.getMediaFiles().get(0); } else { - result = mediaAsset.getMediaFiles().get(1); + mediaFile = mediaAsset.getMediaFiles().get(1); } - return result; + return mediaFile; } public static Subscription get5MinRenewableSubscription() { @@ -477,8 +481,8 @@ private static void ingestVODIntoSubscription(Subscription subscription) { private static DynamicChannel loadDefaultChannel() { DynamicChannel channel = new DynamicChannel(); - channel.setName(BaseUtils.getRandomValue("Channel_", 999999)); - channel.setDescription("Description of " + channel.getName()); + channel.setMultilingualName(setTranslationToken(getRandomValue("Channel_", 999999))); + channel.setMultilingualDescription(setTranslationToken("Description of " + channel.getName())); channel.setIsActive(true); channel.setAssetTypes(null); return channel; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index 9d305a2ea..9077f62d1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -75,8 +75,8 @@ private void asset_list_bundleFilter_before_class() { // add channel1 channel1 = new DynamicChannel(); - channel1.setName("channel_" + getTimeInEpoch()); - channel1.description("Description of " + channel1.getName()); + channel1.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); + channel1.setMultilingualDescription(setTranslationToken("Description of " + channel1.getName())); channel1.setIsActive(true); channel1.setKSql(channel1Query); @@ -85,8 +85,8 @@ private void asset_list_bundleFilter_before_class() { // add channel2 channel2 = new DynamicChannel(); - channel2.setName("channel_" + getTimeInEpoch()); - channel2.description("Description of " + channel2.getName()); + channel2.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); + channel2.setMultilingualDescription(setTranslationToken("Description of " + channel2.getName())); channel2.setIsActive(true); channel2.setKSql(channel2Query); @@ -95,8 +95,8 @@ private void asset_list_bundleFilter_before_class() { // ingest subscription with 2 new channels MppData mppData = new MppData() - .channel1(channel1.getName()) - .channel2(channel2.getName()); + .channel1(channel1.getMultilingualName().get(0).getValue()) + .channel2(channel2.getMultilingualName().get(0).getValue()); subscription = insertMpp(mppData); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 6f34a3d1d..3e45d8738 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -54,8 +54,8 @@ private void asset_list_channelFilter_before_class() { // add channel channel = new DynamicChannel(); - channel.setName("channel_" + getTimeInEpoch()); - channel.description("Description of " + channel.getName()); + channel.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); + channel.setMultilingualDescription(setTranslationToken("Description of " + channel.getName())); channel.setIsActive(true); channel.setKSql(query); // "Free='" + channel.getName() + "'" diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index fcac65d97..2ae00e94e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -23,7 +23,7 @@ public class ChannelDeleteTests extends BaseTest { private final String channelName = "Channel_12345"; private final String description = "description of channel"; - private final String filterExpression = "name ~ 'movie'"; + private final String ksqlExpression = "name ~ 'movie'"; @Severity(SeverityLevel.CRITICAL) @Description("channel/action/delete") @@ -31,7 +31,7 @@ public class ChannelDeleteTests extends BaseTest { private void DeleteChannel() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - channel = ChannelUtils.addDynamicChannel(channelName, description, true, filterExpression, channelOrder, null); + channel = ChannelUtils.addDynamicChannel(channelName, description, true, ksqlExpression, channelOrder, null); // channel/action/add ChannelService.AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 3db909610..417dc2ed7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -11,7 +11,6 @@ import com.kaltura.client.services.LicensedUrlService; import com.kaltura.client.services.LicensedUrlService.GetLicensedUrlBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; @@ -32,6 +31,7 @@ import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.Properties.WEB_FILE_TYPE; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -67,8 +67,8 @@ public void cancelTestBeforeClass() { bookmark.setType(AssetType.MEDIA); sharedChannel = new DynamicChannel(); - sharedChannel.setName(BaseUtils.getRandomValue("Channel_", 999999)); - sharedChannel.setDescription("Description of " + sharedChannel.getName()); + sharedChannel.setMultilingualName(setTranslationToken(getRandomValue("Channel_", 999999))); + sharedChannel.setMultilingualDescription(setTranslationToken("Description of " + sharedChannel.getName())); sharedChannel.setIsActive(true); sharedChannel.setAssetTypes(null); } @@ -121,7 +121,7 @@ public void cancelWithInvalidSubscription() { CancelEntitlementBuilder cancelEntitlementBuilder = cancel(invalidSubscriptionId, TransactionType.SUBSCRIPTION); Response booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(userKs)); assertThat(booleanResponse.results).isNull(); - assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3000).getCode()); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3000).getCode()); } @Severity(SeverityLevel.NORMAL) @@ -175,7 +175,7 @@ public void cancelPlayedSubscription() { TransactionType.SUBSCRIPTION); booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(masterKs)); assertThat(booleanResponse.results).isNull(); - assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3005).getCode()); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3005).getCode()); // delete household for cleanup executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); @@ -233,7 +233,7 @@ public void cancelSubscriptionInCancellationWindow() { TransactionType.SUBSCRIPTION); Response booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(masterKs)); assertThat(booleanResponse.results).isNull(); - assertThat(booleanResponse.error.getCode()).isEqualTo(BaseUtils.getAPIExceptionFromList(3001).getCode()); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3001).getCode()); // delete household for cleanup //executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 51faaea08..24987a34a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -9,7 +9,6 @@ import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.services.TransactionHistoryService.ListTransactionHistoryBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; @@ -29,7 +28,7 @@ import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.*; -import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -74,8 +73,8 @@ public void beforeClass() { classMasterUserId = HouseholdUtils.getMasterUser(household).getUserId(); sharedChannel = new DynamicChannel(); - sharedChannel.setName(BaseUtils.getRandomValue("Channel_", 999999)); - sharedChannel.setDescription("Description of " + sharedChannel.getName()); + sharedChannel.setMultilingualName(setTranslationToken(getRandomValue("Channel_", 999999))); + sharedChannel.setMultilingualDescription(setTranslationToken("Description of " + sharedChannel.getName())); sharedChannel.setIsActive(true); sharedChannel.setAssetTypes(null); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 8858e382e..50dec83fb 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.types.APIException; +import com.kaltura.client.types.TranslationToken; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -188,4 +189,15 @@ public static void clearCache() { String url = config.getEndpoint() + "/clear_cache.aspx"; given().queryParam("action", "clear_all").get(url); } + + public static List setTranslationToken(String value) { + TranslationToken translationToken = new TranslationToken(); + translationToken.setLanguage("eng"); + translationToken.setValue(value); + + List translationTokens = new ArrayList<>(); + translationTokens.add(translationToken); + + return translationTokens; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java index 94350e6c2..45af948f9 100644 --- a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java @@ -10,8 +10,8 @@ public class ChannelUtils extends BaseUtils { public static DynamicChannel addDynamicChannel(String name, @Nullable String description, @Nullable Boolean isActive, @Nullable String ksqlExpression, @Nullable ChannelOrder channelOrder, @Nullable List assetTypes) { DynamicChannel channel = new DynamicChannel(); - channel.setName(name); - channel.setDescription(description); + channel.setMultilingualName(setTranslationToken(name)); + channel.setMultilingualDescription(setTranslationToken(description)); channel.setIsActive(isActive); channel.setAssetTypes(assetTypes); channel.setKSql(ksqlExpression); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 83bea4398..4ee73791a 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -318,9 +318,9 @@ public static int getVirtualMediaTypeId(MediaType mediaType) { .getInt("id"); } - public static int getMediaFileTypeName(int mediaFileId) { + public static String getMediaFileTypeName(int mediaFileId) { return getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_ID_SELECT, partnerId + 1, mediaFileId) .getJSONObject(0) - .getInt("name"); + .getString("name"); } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 6ca49f75d..a61a49f52 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -12,6 +12,7 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.json.JSONArray; + import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getJsonArrayFromQueryResult; @@ -78,7 +79,7 @@ public static Subscription loadSharedCommonSubscription(PricePlan pricePlan) { Subscription subscription = new Subscription(); subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); + subscription.setMultilingualName(setTranslationToken(jsonArray.getJSONObject(0).getString(NAME))); subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); subscription.setIsRenewable(false); subscription.setDependencyType(SubscriptionDependencyType.BASE); @@ -94,7 +95,7 @@ public static Collection loadSharedCommonCollection(PricePlan pricePlan) { getSharedCommonDiscount().toParams().get("id"), pricePlan.getPriceDetailsId(), pricePlan.getId()); Collection collection = new Collection(); collection.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); - collection.setName(jsonArray.getJSONObject(0).getString(NAME)); + collection.setMultilingualName(setTranslationToken(jsonArray.getJSONObject(0).getString(NAME))); // TODO: add more data in case it needed return collection; } @@ -158,7 +159,7 @@ public static Subscription loadShared5MinutesRenewableSubscription() { JSONArray jsonArray = getJsonArrayFromQueryResult(SUBSCRIPTION_5_MIN_RENEW_SELECT, partnerId); Subscription subscription = new Subscription(); subscription.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID)).trim()); - subscription.setName(jsonArray.getJSONObject(0).getString(NAME)); + subscription.setMultilingualName(setTranslationToken(jsonArray.getJSONObject(0).getString(NAME))); subscription.setPricePlanIds(String.valueOf(jsonArray.getJSONObject(0).getLong(PRICE_PLAN_ID))); subscription.setIsRenewable(false); subscription.setDependencyType(SubscriptionDependencyType.BASE); From 59d4c0ff85b28851dbb775b7f2938e8dece26e32 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 15 Jul 2018 11:57:46 +0300 Subject: [PATCH 419/605] no message --- .../AssetListTests/BundleFilterTests.java | 2 ++ .../AssetListTests/ChannelFilterTests.java | 1 + .../channelTests/ChannelAddTests.java | 2 +- .../channelTests/ChannelDeleteTests.java | 11 +++++------ .../channelTests/ChannelGetTests.java | 14 +------------- .../kaltura/client/test/utils/ChannelUtils.java | 1 + 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index 9077f62d1..12791661e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -77,6 +77,7 @@ private void asset_list_bundleFilter_before_class() { channel1 = new DynamicChannel(); channel1.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); channel1.setMultilingualDescription(setTranslationToken("Description of " + channel1.getName())); + channel1.setSystemName(channel1.getMultilingualName().get(0).getValue()); channel1.setIsActive(true); channel1.setKSql(channel1Query); @@ -87,6 +88,7 @@ private void asset_list_bundleFilter_before_class() { channel2 = new DynamicChannel(); channel2.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); channel2.setMultilingualDescription(setTranslationToken("Description of " + channel2.getName())); + channel2.setSystemName(channel2.getMultilingualName().get(0).getValue()); channel2.setIsActive(true); channel2.setKSql(channel2Query); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 3e45d8738..bd66ca843 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -56,6 +56,7 @@ private void asset_list_channelFilter_before_class() { channel = new DynamicChannel(); channel.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); channel.setMultilingualDescription(setTranslationToken("Description of " + channel.getName())); + channel.setSystemName(channel.getMultilingualName().get(0).getValue()); channel.setIsActive(true); channel.setKSql(query); // "Free='" + channel.getName() + "'" diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index b72300a11..a7a76779d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -85,7 +85,7 @@ private void checkOrderOfAssetsInChannel() { AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); Response channelResponse = executor.executeSync(addChannelBuilder); - assertThat(channelResponse.results.getName()).isEqualTo(channelName); + assertThat(channelResponse.results.getMultilingualName().get(0).getValue()).isEqualTo(channelName); int channelId = Math.toIntExact(channelResponse.results.getId()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 2ae00e94e..71d7b233e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.channelTests; import com.kaltura.client.enums.ChannelOrderBy; -import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.ChannelUtils; import com.kaltura.client.types.Channel; @@ -12,7 +11,7 @@ import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; -import static com.kaltura.client.services.ChannelService.GetChannelBuilder; +import static com.kaltura.client.services.ChannelService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -34,19 +33,19 @@ private void DeleteChannel() { channel = ChannelUtils.addDynamicChannel(channelName, description, true, ksqlExpression, channelOrder, null); // channel/action/add - ChannelService.AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); - Response channelResponse = executor.executeSync(addChannelBuilder); + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs())); channelId = Math.toIntExact(channelResponse.results.getId()); // channel/action/delete - ChannelService.DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId).setKs(getManagerKs()); + DeleteChannelBuilder deleteChannelBuilder = delete(channelId).setKs(getManagerKs()); Response deleteResponse = executor.executeSync(deleteChannelBuilder); assertThat(deleteResponse.results.booleanValue()).isTrue(); // channel/action/get - verify channel wasn't found - GetChannelBuilder getChannelBuilder = ChannelService.get(channelId).setKs(getManagerKs()); + GetChannelBuilder getChannelBuilder = get(channelId).setKs(getManagerKs()); Response getResponse = executor.executeSync(getChannelBuilder); assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java index 248163de1..715a5155e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelGetTests.java @@ -2,10 +2,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.Channel; -import io.qameta.allure.Description; -import io.qameta.allure.Severity; -import io.qameta.allure.SeverityLevel; -import org.testng.annotations.Test; public class ChannelGetTests extends BaseTest { @@ -15,14 +11,6 @@ public class ChannelGetTests extends BaseTest { private final String channelName = "Channel_12345"; private final String description = "description of channel"; - public class ChannelActionGet extends BaseTest { - - @Severity(SeverityLevel.NORMAL) - @Description() - @Test - private void channelGetTests() { - - } - } + // TODO: 7/14/2018 implement tests } diff --git a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java index 45af948f9..560014811 100644 --- a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java @@ -16,6 +16,7 @@ public static DynamicChannel addDynamicChannel(String name, @Nullable String des channel.setAssetTypes(assetTypes); channel.setKSql(ksqlExpression); channel.setOrderBy(channelOrder); + channel.setSystemName(channel.getMultilingualName().get(0).getValue()); return channel; } From 31293e25e8069dc0461e81da30d7795292da9f91 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 15 Jul 2018 13:08:52 +0300 Subject: [PATCH 420/605] no message --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 1 + .../servicesTests/entitlementTests/EntitlementCancelTests.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 1fda33fa3..cb152a2e5 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -402,6 +402,7 @@ public static Subscription get5MinRenewableSubscription() { getAssetsListBySubscription(Integer.valueOf(fiveMinRenewableSubscription.getId()), Optional.empty(), true).size() == 0) { ingestVODIntoSubscription(fiveMinRenewableSubscription); } + if (fiveMinRenewableSubscription == null) { PpData ppData = new PpData() .fullLifeCycle(FIVE_MINUTES_PERIOD) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 417dc2ed7..2a03da39a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -69,6 +69,7 @@ public void cancelTestBeforeClass() { sharedChannel = new DynamicChannel(); sharedChannel.setMultilingualName(setTranslationToken(getRandomValue("Channel_", 999999))); sharedChannel.setMultilingualDescription(setTranslationToken("Description of " + sharedChannel.getName())); + sharedChannel.setSystemName(sharedChannel.getMultilingualName().get(0).getValue()); sharedChannel.setIsActive(true); sharedChannel.setAssetTypes(null); } From 1b6f87918bc9c76fc31c561a7f7481723d0eea64 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 16 Jul 2018 14:16:01 +0300 Subject: [PATCH 421/605] ScheduledRecordingProgramFilterTests --- .../com/kaltura/client/test/Properties.java | 1 + .../ScheduledRecordingProgramFilterTests.java | 139 ++++++++++++++++++ .../kaltura/client/test/utils/BaseUtils.java | 1 - .../test/utils/PerformanceAppLogUtils.java | 42 +++--- .../test/utils/dbUtils/DBConstants.java | 11 +- .../client/test/utils/dbUtils/DBUtils.java | 2 +- .../utils/ingestUtils/IngestEpgUtils.java | 2 +- src/test/resources/schemas/Recording.json | 66 +++++++++ 8 files changed, 241 insertions(+), 23 deletions(-) create mode 100644 src/test/resources/schemas/Recording.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 16a01bd4f..6ff6bd556 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -83,6 +83,7 @@ public class Properties { public static final String SHOULD_REGRESSION_LOGS_BE_SAVED = "should_regression_logs_be_saved"; public static final String MAX_ALLOWED_PERCENTAGE = "max_allowed_percentage"; public static final String CODE_PERFORMANCE_REPORT_FILE = "code_performance_report_file"; + public static final String MAX_ALLOWED_EXECUTION_TIME_IN_SEC = "max_allowed_execution_time_in_sec"; public static String getProperty(String propertyKey) { if (resourceBundle == null) { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java index 4219f15e5..fd9283d92 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java @@ -1,7 +1,146 @@ package com.kaltura.client.test.tests.servicesTests.AssetTests.AssetListTests; +import com.kaltura.client.enums.RecordingStatus; +import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.PremiumService; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.json.JSONArray; +import org.json.JSONObject; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Calendar; +import java.util.List; +import java.util.Optional; + +import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.services.RecordingService.add; +import static com.kaltura.client.test.utils.BaseUtils.getCalendarWithOffset; +import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; +import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getSubscriptionWithPremiumService; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; +import static org.assertj.core.api.Assertions.assertThat; public class ScheduledRecordingProgramFilterTests extends BaseTest { + private int linearAssetId1, linearAssetId2; + private JSONObject linearAssetJsonObject1, linearAssetJsonObject2; + private String masterUserKs; + private List programAssets1, programAssets2; + + + @BeforeClass + private void asset_list_scheduledRecordingProgramFilter_before_class() { + // create household + Household household = createHousehold(); + String udid = HouseholdUtils.getDevicesList(household).get(0).getUdid(); + masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, udid); + + // purchase subscription with npvr premium service + Subscription subscription = getSubscriptionWithPremiumService(PremiumService.NPVR); + PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); + + // get linearAsset and epg channelId + JSONArray jsonArray = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray(); + linearAssetJsonObject1 = jsonArray.getJSONObject(0); + linearAssetJsonObject2 = jsonArray.getJSONObject(1); + linearAssetId1 = linearAssetJsonObject1.getInt("media_id"); + linearAssetId2 = linearAssetJsonObject2.getInt("media_id"); + + // purchase linearAsset + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(linearAssetId1), Optional.empty(), Optional.empty()); + PurchaseUtils.purchasePpv(masterUserKs, Optional.of(linearAssetId2), Optional.empty(), Optional.empty()); + + // ingest epg's + EpgData epgData1 = new EpgData(linearAssetJsonObject1.getString("name")) + .startDate(getTimeInEpoch(10)); + programAssets1 = insertEpg(epgData1); + + EpgData epgData2 = new EpgData(linearAssetJsonObject2.getString("name")) + .startDate(getCalendarWithOffset(120)); + programAssets2 = insertEpg(epgData2); + + // add recordings 1 + Recording recording1 = new Recording(); + recording1.setAssetId(programAssets1.get(0).getId()); + + Response recordingResponse = executor.executeSync(add(recording1).setKs(masterUserKs)); + assertThat(recordingResponse.results.getStatus()).isEqualTo(RecordingStatus.SCHEDULED); + + // add recordings 2 + Recording recording2 = new Recording(); + recording2.setAssetId(programAssets2.get(0).getId()); + + recordingResponse = executor.executeSync(add(recording2).setKs(masterUserKs)); + assertThat(recordingResponse.results.getStatus()).isEqualTo(RecordingStatus.SCHEDULED); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - scheduledRecordingProgramFilter - channelsIn") + @Test + private void list_assets_with_channelFilter_by_channelId() { + // set scheduledRecordingProgramFilter + ScheduledRecordingProgramFilter filter = new ScheduledRecordingProgramFilter(); + String channelsIn = getConcatenatedString(String.valueOf(linearAssetJsonObject1.getInt("id")), + String.valueOf(linearAssetJsonObject2.getInt("id"))); + filter.setChannelsIn(channelsIn); + + // get list + Response> assetListResponse = executor.executeSync(AssetService.list(filter) + .setKs(masterUserKs)); + + // assert response + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(2); + + assertThat(assetListResponse.results.getObjects()).extracting("id") + .containsExactlyInAnyOrder(programAssets1.get(0).getId(), programAssets2.get(0).getId()); + + assertThat(assetListResponse.results.getObjects()).extracting("name") + .containsExactlyInAnyOrder(programAssets1.get(0).getName(), programAssets2.get(0).getName()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - scheduledRecordingProgramFilter - startDateGreaterThanOrNull") + @Test + private void list_assets_with_channelFilter_by_startDateGreaterThanOrNull() { + // set scheduledRecordingProgramFilter + String channelsIn = getConcatenatedString(String.valueOf(linearAssetJsonObject1.getInt("id")), + String.valueOf(linearAssetJsonObject2.getInt("id"))); + + ScheduledRecordingProgramFilter filter = new ScheduledRecordingProgramFilter(); +// filter.setChannelsIn(channelsIn); + filter.setStartDateGreaterThanOrNull(getCalendarWithOffset(60).getTimeInMillis() / 1000); +// filter.setEndDateLessThanOrNull(getCalendarWithOffset(600).getTimeInMillis() / 1000); +// filter.setRecordingTypeEqual(ScheduledRecordingAssetType.SINGLE); + + // get list + Response> assetListResponse = executor.executeSync(AssetService.list(filter) + .setKs(masterUserKs)); + + // assert response + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(programAssets2.get(0).getId()); + assertThat(assetListResponse.results.getObjects().get(0).getName()).isEqualTo(programAssets2.get(0).getName()); + } + + + + + @AfterClass + private void asset_list_scheduledRecordingProgramFilter_after_class() { + // cleanup + executor.executeSync(delete().setKs(masterUserKs)); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 50dec83fb..1dc1e58b9 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -60,7 +60,6 @@ public static String getTimeInDate(int offSetInMinutes) { // Get epoch time in seconds according to off set parameter provided (in minutes) public static long getTimeInEpoch(int offSetInMinutes) { - //DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date dNow = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(dNow); diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 2493cb78e..1f25a1abb 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -5,12 +5,14 @@ import org.apache.commons.vfs2.*; import org.apache.commons.vfs2.auth.StaticUserAuthenticator; import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; + import java.io.*; import java.io.FileNotFoundException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.stream.Stream; + import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.Properties.API_VERSION; import static com.kaltura.client.test.Properties.getProperty; @@ -60,7 +62,7 @@ static class SlowRatio { public static void createPerformanceCodeReport() { try { List appRemoteFileNames = getRemoteAppLogFileNames(); - for (String fileName: appRemoteFileNames) { + for (String fileName : appRemoteFileNames) { copyRemoteFile2LocalMachine(fileName); } @@ -68,15 +70,15 @@ public static void createPerformanceCodeReport() { Map methodsAndSlowRatioData = new HashMap<>(); SlowRatio slowRatio; - for (String method: methodsAndKalturaSessions.keySet()) { + for (String method : methodsAndKalturaSessions.keySet()) { methodsAndSlowRatioData.put(method, new SlowRatio()); //Logger.getLogger(PerformanceAppLogUtils.class).debug("Method: [" + method + "]"); - for (String xKalturaSession: methodsAndKalturaSessions.get(method)) { + for (String xKalturaSession : methodsAndKalturaSessions.get(method)) { slowRatio = methodsAndSlowRatioData.get(method); slowRatio.totalCount++; methodsAndSlowRatioData.put(method, slowRatio); //Logger.getLogger(PerformanceAppLogUtils.class).debug("xKalturaSession: [" + xKalturaSession + "]"); - for (String appFileName: appRemoteFileNames) { + for (String appFileName : appRemoteFileNames) { isKalturaSessionFoundInAppLogFile = false; timeOfCode = 0.0; timeOfCB = 0.0; @@ -89,7 +91,9 @@ public static void createPerformanceCodeReport() { if (isKalturaSessionFoundInAppLogFile) { double percentageCodeTime2TotalTime = timeOfCode / totalTime * 100; - if (percentageCodeTime2TotalTime > maxAllowedPercentage) { + // include in report only relevant cases + if (percentageCodeTime2TotalTime > maxAllowedPercentage && + totalTime > Double.parseDouble(getProperty(MAX_ALLOWED_EXECUTION_TIME_IN_SEC))) { slowRatio = methodsAndSlowRatioData.get(method); slowRatio.slowCount++; methodsAndSlowRatioData.put(method, slowRatio); @@ -129,10 +133,10 @@ private static void addSummary2Report(Map methodsAndSlowRatio } private static void addReportDataIntoSummaryFile(String fromFile, String toFile) { - try(BufferedReader br = Files.newBufferedReader(Paths.get(fromFile)); - FileWriter fw = new FileWriter(toFile, true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) { + try (BufferedReader br = Files.newBufferedReader(Paths.get(fromFile)); + FileWriter fw = new FileWriter(toFile, true); + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter out = new PrintWriter(bw)) { Stream lines = br.lines(); lines.forEach(out::println); lines.close(); @@ -142,13 +146,13 @@ private static void addReportDataIntoSummaryFile(String fromFile, String toFile) } private static void createSummaryFile(Map methodsAndSlowRatioData, String summaryTemporaryFileName) { - try(FileWriter fw = new FileWriter(summaryTemporaryFileName, true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) { + try (FileWriter fw = new FileWriter(summaryTemporaryFileName, true); + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter out = new PrintWriter(bw)) { out.println("Report of slow methods on " + getCurrentDateInFormat("dd/MM/yyyy HH:mm")); out.println("Max allowed percentage: " + getProperty(MAX_ALLOWED_PERCENTAGE)); out.println(); - for (String method: methodsAndSlowRatioData.keySet()) { + for (String method : methodsAndSlowRatioData.keySet()) { if (methodsAndSlowRatioData.get(method).slowCount > 0) { out.println(method + " was slow " + String.format("%.2f", methodsAndSlowRatioData.get(method).slowCount * 1.0 / methodsAndSlowRatioData.get(method).totalCount * 100) + "% of executions"); @@ -164,10 +168,10 @@ private static void createSummaryFile(Map methodsAndSlowRatio } private static void writeReport2File(String method, String xKalturaSession, double codeTimePercentage) { - try(FileWriter fw = new FileWriter(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + try (FileWriter fw = new FileWriter(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(CODE_PERFORMANCE_REPORT_FILE), true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) { + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter out = new PrintWriter(bw)) { // we want to see only data where code time is less than 100% if (timeOfCB > 0 || timeOfDB > 0 || timeOfES > 0 || timeOfRabbit > 0) { out.println(method); @@ -302,8 +306,8 @@ private static void calcTimeExecution(String appFileName, String kalturaSession) String[] nonRelated2CodeStringsArray = new String[nonRelated2CodeStringsList.size()]; String executionTimeString; - try(BufferedReader br = new BufferedReader(new FileReader(path2File))) { - for(String line; (line = br.readLine()) != null; ) { + try (BufferedReader br = new BufferedReader(new FileReader(path2File))) { + for (String line; (line = br.readLine()) != null; ) { if (line.contains(kalturaSession)) { isKalturaSessionFoundInAppLogFile = true; // this is a usual position of time in the whole string @@ -346,7 +350,7 @@ private static boolean stringContainsItemFromArray(String inputStr, String[] ite * method removes from local computer copied on it from remote machine app log files */ public static void removeCopiedAppLogFiles() { - for (String file: appLogLocalFileNames) { + for (String file : appLogLocalFileNames) { deleteFile(file); } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 6afb14049..d87f2473f 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -181,7 +181,16 @@ public class DBConstants { "from [TVinci].[dbo].[permissions_permission_items]\n" + "where permission_id=? and permission_item_id=? and is_active=1 and [status]=1 and group_id=?"; - static final String ASSET_ID_SELECT = "SELECT [media_id],[name] FROM [TVinci].[dbo].[epg_channels] WHERE group_id=? and status=1 and DATALENGTH(media_id) > 0"; + static final String LINEAR_ASSET_ID_AND_EPG_CHANNEL_NAME_SELECT = "SELECT ec.ID, ec.NAME, m.ID as 'media_id' " + + "FROM [TVinci].[dbo].[media] m " + + "inner join [TVinci].[dbo].[epg_channels] ec on m.EPG_IDENTIFIER = ec.ID " + + "where m.GROUP_ID = ? " + + "and MEDIA_TYPE_ID = 427 " + + "and m.IS_ACTIVE = 1 " + + "and m.STATUS = 1 " + + "and EPG_IDENTIFIER != ''"; + + //"SELECT [media_id],[name] FROM [TVinci].[dbo].[epg_channels] WHERE group_id=? and status=1 and DATALENGTH(media_id) > 0"; static final String UNACTIVE_ASSET_ID_SELECT = "SELECT top 1 [id] FROM [TVinci].[dbo].[media] where group_id = ? and status = 2"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 4ee73791a..12bd72ac6 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -201,7 +201,7 @@ public static String getResetPasswordToken(String username) { // Get epg channel name and linear asset id json array public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { - return getJsonArrayFromQueryResult(ASSET_ID_SELECT, partnerId + 1); + return getJsonArrayFromQueryResult(LINEAR_ASSET_ID_AND_EPG_CHANNEL_NAME_SELECT, partnerId + 1); } // Get un active asset from DB (status = 2) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index a774c4be3..3a5354c47 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -48,7 +48,7 @@ public class IngestEpgUtils extends BaseIngestUtils { @Data public static class EpgData { @Setter(AccessLevel.NONE) private String coguid; - @NonNull private String epgChannelName; + @Setter(AccessLevel.NONE) @NonNull private String epgChannelName; private boolean isCridUnique4AllPrograms = true; diff --git a/src/test/resources/schemas/Recording.json b/src/test/resources/schemas/Recording.json new file mode 100644 index 000000000..c1d1cb836 --- /dev/null +++ b/src/test/resources/schemas/Recording.json @@ -0,0 +1,66 @@ +{ + "$id": "Recording", + "definitions": { + "Recording": { + "type": "object", + "properties": { + "assetId": { + "type": "integer", + "minimum": 0 + }, + "createDate": { + "type": "integer", + "minimum": 0 + }, + "id": { + "type": "integer", + "minimum": 0 + }, + "isProtected": { + "type": "boolean" + }, + "status": { + "type": "string", + "minLength": 0 + }, + "type": { + "type": "string", + "minLength": 0 + }, + "updateDate": { + "type": "integer", + "minimum": 0 + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaRecording" + ] + } + }, + "required": [ + "objectType", + "assetId", + "createDate", + "id", + "isProtected", + "status", + "type", + "updateDate" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/Recording" + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} From 01e7757dd45dcf3fc76112327758bf889538fa7b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Jul 2018 10:23:36 +0300 Subject: [PATCH 422/605] add list_assets_with_channelFilter_by_startDateGreaterThanOrNull() test --- .../PermissionsManagementTests.java | 19 +++++++------- .../AssetListTests/BundleFilterTests.java | 6 ++--- .../AssetListTests/ChannelFilterTests.java | 4 +-- .../ScheduledRecordingProgramFilterTests.java | 20 +++++---------- .../appTokenTests/AppTokenAddTests.java | 4 +-- .../appTokenTests/AppTokenGetTests.java | 2 +- .../AppTokenStartSessionTests.java | 2 +- .../AssetCommentAddTests.java | 4 +-- .../AssetHistoryListTests.java | 7 +++--- .../OttUserLoginWithPinTests.java | 2 +- .../TransactionPurchaseTests.java | 7 +++--- .../kaltura/client/test/utils/BaseUtils.java | 25 ++++++++++++++----- .../utils/ingestUtils/IngestEpgUtils.java | 20 +++++++-------- 13 files changed, 65 insertions(+), 57 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index bb2a974cc..ffa0c7f81 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.tests.featuresTests.versions.four_eight; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.PermissionManagementUtils; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import io.qameta.allure.Severity; @@ -11,7 +12,7 @@ import java.util.List; import static com.kaltura.client.test.utils.BaseUtils.deleteFile; import static com.kaltura.client.test.utils.BaseUtils.getFileContent; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -97,7 +98,7 @@ public void runningDeleteWithoutFile() { @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") public void export() { // prepare data inserting them in DB using stored procedures - String suffix = String.valueOf(getTimeInEpoch(0)); + String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix); @@ -167,7 +168,7 @@ public void runningDeleteUsingEmptyFile() { @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") public void importFromFile() { - String suffix = String.valueOf(getTimeInEpoch(0)); + String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -206,14 +207,14 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { deleteFile(path2Log); // insert data in DB - String suffix = String.valueOf(getTimeInEpoch(0)) + "inserted"; + String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)) + "inserted"; PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); // generate import file data - suffix = String.valueOf(getTimeInEpoch(0)); + suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -234,7 +235,7 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") public void deleteFromDB() { - String suffix = String.valueOf(getTimeInEpoch(0)); + String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -288,7 +289,7 @@ public void deleteFromDB() { @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") public void importAlreadyExistedFromFile() { - String suffix = String.valueOf(getTimeInEpoch(0)); + String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -327,7 +328,7 @@ public void importAlreadyExistedFromFile() { @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") public void runningDeleteUsingFileWithInvalidTags() { // insert role in DB - String suffix = String.valueOf(getTimeInEpoch(0)); + String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); @@ -348,7 +349,7 @@ public void runningDeleteUsingFileWithInvalidTags() { @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") public void deleteOnlyFromOneTable() { // insert role in DB - String suffix = String.valueOf(getTimeInEpoch(0)); + String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index 12791661e..008210047 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -23,7 +23,7 @@ import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.enums.KsqlKey.NAME; import static com.kaltura.client.test.tests.enums.MediaType.*; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.MppData; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.insertMpp; @@ -75,7 +75,7 @@ private void asset_list_bundleFilter_before_class() { // add channel1 channel1 = new DynamicChannel(); - channel1.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); + channel1.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); channel1.setMultilingualDescription(setTranslationToken("Description of " + channel1.getName())); channel1.setSystemName(channel1.getMultilingualName().get(0).getValue()); channel1.setIsActive(true); @@ -86,7 +86,7 @@ private void asset_list_bundleFilter_before_class() { // add channel2 channel2 = new DynamicChannel(); - channel2.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); + channel2.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); channel2.setMultilingualDescription(setTranslationToken("Description of " + channel2.getName())); channel2.setSystemName(channel2.getMultilingualName().get(0).getValue()); channel2.setIsActive(true); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index bd66ca843..1f74d1d6d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -17,7 +17,7 @@ import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.enums.KsqlKey.NAME; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -54,7 +54,7 @@ private void asset_list_channelFilter_before_class() { // add channel channel = new DynamicChannel(); - channel.setMultilingualName(setTranslationToken("channel_" + getTimeInEpoch())); + channel.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); channel.setMultilingualDescription(setTranslationToken("Description of " + channel.getName())); channel.setSystemName(channel.getMultilingualName().get(0).getValue()); channel.setIsActive(true); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java index fd9283d92..809972739 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java @@ -18,15 +18,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Calendar; import java.util.List; import java.util.Optional; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.RecordingService.add; -import static com.kaltura.client.test.utils.BaseUtils.getCalendarWithOffset; -import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getSubscriptionWithPremiumService; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; @@ -65,11 +62,11 @@ private void asset_list_scheduledRecordingProgramFilter_before_class() { // ingest epg's EpgData epgData1 = new EpgData(linearAssetJsonObject1.getString("name")) - .startDate(getTimeInEpoch(10)); + .startDate(getEpochInLocalTime(5)); programAssets1 = insertEpg(epgData1); EpgData epgData2 = new EpgData(linearAssetJsonObject2.getString("name")) - .startDate(getCalendarWithOffset(120)); + .startDate(getEpochInLocalTime(360)); programAssets2 = insertEpg(epgData2); // add recordings 1 @@ -120,10 +117,8 @@ private void list_assets_with_channelFilter_by_startDateGreaterThanOrNull() { String.valueOf(linearAssetJsonObject2.getInt("id"))); ScheduledRecordingProgramFilter filter = new ScheduledRecordingProgramFilter(); -// filter.setChannelsIn(channelsIn); - filter.setStartDateGreaterThanOrNull(getCalendarWithOffset(60).getTimeInMillis() / 1000); -// filter.setEndDateLessThanOrNull(getCalendarWithOffset(600).getTimeInMillis() / 1000); -// filter.setRecordingTypeEqual(ScheduledRecordingAssetType.SINGLE); + filter.setChannelsIn(channelsIn); + filter.setStartDateGreaterThanOrNull(getEpochInUtcTime(180)); // get list Response> assetListResponse = executor.executeSync(AssetService.list(filter) @@ -134,10 +129,7 @@ private void list_assets_with_channelFilter_by_startDateGreaterThanOrNull() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(programAssets2.get(0).getId()); assertThat(assetListResponse.results.getObjects().get(0).getName()).isEqualTo(programAssets2.get(0).getName()); } - - - - + @AfterClass private void asset_list_scheduledRecordingProgramFilter_after_class() { // cleanup diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 4c9ab5984..3fa2291c6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -90,7 +90,7 @@ private void addAppTokenWithExpiryDate_before() { // setup for test add_tests_before_class(); // prepare token with expiration after 1 minute - Long expiryDate = BaseUtils.getTimeInEpoch(1); + Long expiryDate = BaseUtils.getEpochInLocalTime(1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) @@ -137,7 +137,7 @@ private void addAppTokenWithNoExpiryDate() { .setKs(getSharedMasterUserKs()); Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); - assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(BaseUtils.getTimeInEpoch(0))); + assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(BaseUtils.getEpochInLocalTime(0))); } @Description("appToken/action/add - with no specific user id") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index 37256f284..a5ce14cd5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -28,7 +28,7 @@ public class AppTokenGetTests extends BaseTest { @BeforeClass private void get_tests_before_class() { sessionUserId = getSharedUser().getUserId(); - expiryDate = BaseUtils.getTimeInEpoch(offSetInMinutes); + expiryDate = BaseUtils.getEpochInLocalTime(offSetInMinutes); } @Description("AppToken/action/get") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index fb68b20ac..e283691e8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -39,7 +39,7 @@ private void add_tests_before_class() { AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = anonymousLogin(partnerId, udid1); Response loginSessionResponse = executor.executeSync(anonymousLoginOttUserBuilder); anonymousKs = loginSessionResponse.results.getKs(); - expiryDate = BaseUtils.getTimeInEpoch(1); + expiryDate = BaseUtils.getEpochInLocalTime(1); } @Description("appToken/action/startSession - SHA1") diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index e60c1b2ef..0e45611b6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -62,7 +62,7 @@ private void addCommentForVod() { assertThat(assetCommentResponse.results.getText()).isEqualTo(text); assertThat(assetCommentResponse.results.getSubHeader()).isEqualTo(subHeader); assertThat(assetCommentResponse.results.getHeader()).isEqualTo(header); - assertThat(assetCommentResponse.results.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); + assertThat(assetCommentResponse.results.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); //Initialize assetCommentFilter object @@ -83,7 +83,7 @@ private void addCommentForVod() { assertThat(assetCommentObjectResponse.getHeader()).isEqualTo(assetCommentResponse.results.getHeader()); assertThat(assetCommentObjectResponse.getText()).isEqualTo(assetCommentResponse.results.getText()); assertThat(assetCommentObjectResponse.getWriter()).isEqualTo(assetCommentResponse.results.getWriter()); - assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getTimeInEpoch(0)); + assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index dded5460f..0bc4cfa1f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -7,6 +7,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -22,7 +23,7 @@ import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.BookmarkUtils.addBookmark; import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAssets; @@ -129,7 +130,7 @@ private void assetHistory_vod_with_one_device_and_two_media() { // Verify that flag is set to false (user hasn't finish watching the asset) assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); - assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(getTimeInEpoch(0)); + assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); // Assertions for second object returned assertThat(assetHistoryObject2.getAssetId()).isEqualTo(movie.getId()); @@ -176,7 +177,7 @@ private void assetHistory_vod_with_two_devices_and_one_media() { assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movie.getId()); assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); - assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(getTimeInEpoch(0)); + assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); // cleanup - delete household executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index 03868da9b..07234ec86 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -104,7 +104,7 @@ private void loginWithPin_with_expired_pinCode_after() { .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(() -> { long expire = userLoginPinResponse.results.getExpirationTime() + 120; - long now = BaseUtils.getTimeInEpoch(0); + long now = BaseUtils.getEpochInLocalTime(0); return now > expire; }); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index ce4ef3938..98dea91e1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -8,13 +8,14 @@ import com.kaltura.client.services.TransactionService; import com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInEpoch; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; @@ -65,7 +66,7 @@ private void purchasePpvWithDefaultPG() { Response purchaseTransaction = executor.executeSync(purchaseTransactionBuilder); Transaction purchasePpv = purchaseTransaction.results; assertThat(purchasePpv).isNotNull(); - assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)getTimeInEpoch(0), within(15)); + assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)BaseUtils.getEpochInLocalTime(0), within(15)); assertThat(purchasePpv.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpv.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpv.getFailReasonCode()).isEqualTo(0); @@ -100,7 +101,7 @@ private void purchaseSubscriptionWithDefaultPG() { Response purchaseTransaction = executor.executeSync(purchaseTransactionBuilder); Transaction purchasePpv = purchaseTransaction.results; assertThat(purchasePpv).isNotNull(); - assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)getTimeInEpoch(0), within(15)); + assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)BaseUtils.getEpochInLocalTime(0), within(15)); assertThat(purchasePpv.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpv.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpv.getFailReasonCode()).isEqualTo(0); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 1dc1e58b9..ba442a8e6 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -15,7 +15,6 @@ import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.time.Instant; import java.util.*; import java.util.concurrent.ThreadLocalRandom; @@ -59,17 +58,31 @@ public static String getTimeInDate(int offSetInMinutes) { } // Get epoch time in seconds according to off set parameter provided (in minutes) - public static long getTimeInEpoch(int offSetInMinutes) { - Date dNow = new Date(); + public static long getEpochInLocalTime(int offSetInMinutes) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(dNow); calendar.add(Calendar.MINUTE, offSetInMinutes); return calendar.getTimeInMillis() / 1000; } - public static long getTimeInEpoch() { - return Instant.now().toEpochMilli(); + public static long getEpochInUtcTime(int offSetInMinutes) { + Calendar calendar = Calendar.getInstance(); + int timeZoneOffset = TimeZone.getDefault().getRawOffset() / 60000; + calendar.add(Calendar.MINUTE, offSetInMinutes + timeZoneOffset); + + return calendar.getTimeInMillis() / 1000; + } + + public static long getEpochInLocalTime() { + return Calendar.getInstance().getTimeInMillis() / 1000; + } + + public static Date getDateFromEpoch(long epoch) { + return new Date(epoch * 1000); + } + + public static long getEpochFromDate(Date date) { + return date.getTime() / 1000; } // generate current data String in specified format diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 3a5354c47..ccc1dea03 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -31,7 +31,7 @@ import static com.kaltura.client.test.tests.enums.KsqlKey.END_DATE; import static com.kaltura.client.test.tests.enums.KsqlKey.EPG_CHANNEL_ID; import static com.kaltura.client.test.tests.enums.KsqlKey.START_DATE; -import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; +import static com.kaltura.client.test.utils.BaseUtils.*; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; import static org.assertj.core.api.Assertions.assertThat; @@ -61,7 +61,7 @@ public static class EpgData { private int seasonsNum; private int programDuration; - private Calendar startDate; + private Long startDate; private DurationPeriod programDurationPeriod; } @@ -78,7 +78,7 @@ public static List insertEpg(EpgData epgData) { if (epgData.seriesId == null) { epgData.seriesId = epgData.coguid; } if (epgData.episodesNum == 0) { epgData.episodesNum = DEFAULT_PROGRAMMES_COUNT; } if (epgData.seasonsNum == 0) { epgData.seasonsNum = DEFAULT_SEASONS_COUNT; } - if (epgData.startDate == null) { epgData.startDate = Calendar.getInstance(); } + if (epgData.startDate == null) { epgData.startDate = getEpochInLocalTime(); } if (epgData.programDuration == 0) { epgData.programDuration = DEFAULT_PROGRAM_DURATION; } if (epgData.programDurationPeriod == null) { epgData.programDurationPeriod = DurationPeriod.MINUTES; } if (epgData.thumb == null) { epgData.thumb = DEFAULT_THUMB; } @@ -89,7 +89,7 @@ public static List insertEpg(EpgData epgData) { executeIngestEpgRequest(reqBody); // TODO: create method getting epoch value from String and pattern - String firstProgramStartDateEpoch = String.valueOf(epgData.startDate.getTime().getTime() / 1000); + String firstProgramStartDateEpoch = String.valueOf(epgData.startDate); SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); @@ -166,14 +166,14 @@ private static String buildIngestEpgXml(EpgData epgData) { while (seasonNum <= epgData.seasonsNum) { int episodeNum = 1; while (episodeNum <= epgData.episodesNum) { - Date endDate = loadEndDate(epgData.startDate.getTime(), epgData.programDuration, epgData.programDurationPeriod); - String startDateFormatted = df.format(epgData.startDate.getTime()); - String endDateFormatted = df.format(endDate.getTime()); + Date endDate = loadEndDate(epgData.startDate, epgData.programDuration, epgData.programDurationPeriod); + String startDateFormatted = df.format(getDateFromEpoch(epgData.startDate)); + String endDateFormatted = df.format(endDate); Element programmeNode = getProgrammeNode(doc, episodeNum, seasonNum, startDateFormatted, endDateFormatted, epgData); epgChannels.appendChild(programmeNode); - epgData.startDate.setTime(endDate); + epgData.startDate(getEpochFromDate(endDate)); episodeNum++; } seasonNum++; @@ -278,9 +278,9 @@ private static Element generateTagsNode(Document doc, String tagTypeString, Stri return tags; } - private static Date loadEndDate(Date startDate, int durationValue, DurationPeriod durationPeriod) { + private static Date loadEndDate(long startDate, int durationValue, DurationPeriod durationPeriod) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(startDate); + calendar.setTimeInMillis(startDate * 1000); switch (durationPeriod) { case DAYS: calendar.add(Calendar.DATE, durationValue); From 61adfdfd9d9815e36503b0dbde853648ed3d7f76 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Jul 2018 11:26:10 +0300 Subject: [PATCH 423/605] no message --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index cb152a2e5..4e1fed459 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -385,8 +385,7 @@ public static MediaFile getSharedMobileMediaFile() { public static MediaFile getMediaFileByType(MediaAsset asset, String fileType) { MediaFile mediaFile; - int fileTypeId = asset.getMediaFiles().get(0).getTypeId(); - if (fileType.equals(DBUtils.getMediaFileTypeName(fileTypeId))) { + if (fileType.equals(asset.getMediaFiles().get(0).getType())) { mediaFile = mediaAsset.getMediaFiles().get(0); } else { mediaFile = mediaAsset.getMediaFiles().get(1); From e2a32c6ad68415501560a04b9a594da1136b781b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Jul 2018 16:04:14 +0300 Subject: [PATCH 424/605] added setLanguage("*") in channel/action/add requests --- .../kaltura/client/test/tests/BaseTest.java | 3 +- .../AssetListTests/BundleFilterTests.java | 12 +- .../AssetListTests/ChannelFilterTests.java | 4 +- .../SearchAssetFilterTests.java | 6 +- .../channelTests/ChannelAddTests.java | 39 ++--- .../channelTests/ChannelDeleteTests.java | 9 +- .../EntitlementCancelTests.java | 12 +- .../ProductPriceListTests.java | 22 ++- .../kaltura/client/test/utils/BaseUtils.java | 6 + .../client/test/utils/ChannelUtils.java | 2 +- .../utils/ingestUtils/BaseIngestUtils.java | 1 - .../utils/ingestUtils/IngestMppUtils.java | 2 +- .../test/utils/ingestUtils/IngestPpUtils.java | 2 +- .../utils/ingestUtils/IngestPpvUtils.java | 2 +- .../resources/schemas/DynamicChannel.json | 149 ++++++++++++++++++ src/test/resources/schemas/ListResponse.json | 6 +- 16 files changed, 228 insertions(+), 49 deletions(-) create mode 100644 src/test/resources/schemas/DynamicChannel.json diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 4e1fed459..d1d4da5e8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -123,6 +123,7 @@ public void baseTest_beforeSuite() { // set client client = new Client(config); +// client.setLanguage("*"); // set default awaitility timeout setDefaultTimeout(Long.parseLong(getProperty(DEFAULT_TIMEOUT_IN_SEC)), TimeUnit.SECONDS); @@ -481,7 +482,7 @@ private static void ingestVODIntoSubscription(Subscription subscription) { private static DynamicChannel loadDefaultChannel() { DynamicChannel channel = new DynamicChannel(); - channel.setMultilingualName(setTranslationToken(getRandomValue("Channel_", 999999))); + channel.setMultilingualName(setTranslationToken(getRandomValue("Channel_"))); channel.setMultilingualDescription(setTranslationToken("Description of " + channel.getName())); channel.setIsActive(true); channel.setAssetTypes(null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index 008210047..df06b8e22 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -77,23 +77,27 @@ private void asset_list_bundleFilter_before_class() { channel1 = new DynamicChannel(); channel1.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); channel1.setMultilingualDescription(setTranslationToken("Description of " + channel1.getName())); - channel1.setSystemName(channel1.getMultilingualName().get(0).getValue()); + channel1.setSystemName(channel1.getMultilingualName().get(0).getValue() + getRandomValue("")); channel1.setIsActive(true); channel1.setKSql(channel1Query); channel1 = (DynamicChannel) executor.executeSync(add(channel1) - .setKs(getOperatorKs())).results; + .setKs(getOperatorKs()) + .setLanguage("*")) + .results; // add channel2 channel2 = new DynamicChannel(); channel2.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); channel2.setMultilingualDescription(setTranslationToken("Description of " + channel2.getName())); - channel2.setSystemName(channel2.getMultilingualName().get(0).getValue()); + channel2.setSystemName(channel2.getMultilingualName().get(0).getValue() + getRandomValue("")); channel2.setIsActive(true); channel2.setKSql(channel2Query); channel2 = (DynamicChannel) executor.executeSync(add(channel2) - .setKs(getOperatorKs())).results; + .setKs(getOperatorKs()) + .setLanguage("*")) + .results; // ingest subscription with 2 new channels MppData mppData = new MppData() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 1f74d1d6d..827a5551b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -61,7 +61,9 @@ private void asset_list_channelFilter_before_class() { channel.setKSql(query); // "Free='" + channel.getName() + "'" channel = (DynamicChannel) executor.executeSync(ChannelService.add(channel) - .setKs(getOperatorKs())).results; + .setKs(getOperatorKs()) + .setLanguage("*")) + .results; } @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 979b8557e..943788fdb 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -44,8 +44,8 @@ public class SearchAssetFilterTests extends BaseTest { private final String tagName = "Genre"; private final String metaName = "synopsis"; private final String metaName2 = "Short title"; - private final String metaValue1 = "A" + getRandomValue("_", 999999); - private final String metaValue2 = "B" + getRandomValue("_", 999999); + private final String metaValue1 = "A" + getRandomValue("_"); + private final String metaValue2 = "B" + getRandomValue("_"); private MediaAsset asset, asset2, asset3; private ProgramAsset program, program2; @@ -56,7 +56,7 @@ public class SearchAssetFilterTests extends BaseTest { @BeforeClass private void asset_list_searchAssetFilter_before_class() { // Get asset from shared asset method - tagValue = getRandomValue(tagName + "_", 999999); + tagValue = getRandomValue(tagName + "_"); ArrayList list = new ArrayList<>(); list.add(tagValue); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index a7a76779d..4d78df3b5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.enums.ChannelOrderBy; import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.AssetUtils; @@ -19,8 +18,7 @@ import java.util.Optional; import static com.kaltura.client.services.AssetService.ListAssetBuilder; -import static com.kaltura.client.services.ChannelService.AddChannelBuilder; -import static com.kaltura.client.services.ChannelService.DeleteChannelBuilder; +import static com.kaltura.client.services.ChannelService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; @@ -51,9 +49,10 @@ private void addChannel() { channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); - //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); - Response channelResponse = executor.executeSync(addChannelBuilder); + // channel/action/add + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs()) + .setLanguage("*")); assertThat(channelResponse.results.getName()).isEqualTo(channelName); } @@ -81,9 +80,10 @@ private void checkOrderOfAssetsInChannel() { channelOrder.setOrderBy(ChannelOrderBy.NAME_DESC); channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); - //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); - Response channelResponse = executor.executeSync(addChannelBuilder); + // channel/action/add + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs()) + .setLanguage("*")); assertThat(channelResponse.results.getMultilingualName().get(0).getValue()).isEqualTo(channelName); @@ -101,7 +101,7 @@ private void checkOrderOfAssetsInChannel() { assertThat(listResponse.results.getObjects().get(0).getId()).isEqualTo(movieAsset.getId()); // Cleanup - channel/action/delete - DeleteChannelBuilder deleteChannelBuilder = ChannelService.delete(channelId).setKs(getManagerKs()); + DeleteChannelBuilder deleteChannelBuilder = delete(channelId).setKs(getManagerKs()); executor.executeSync(deleteChannelBuilder); } @@ -114,10 +114,10 @@ private void addChannelWithInvalidAssetType() { channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, null, channelOrder, assetTypes); - //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel) - .setKs(getManagerKs()); - Response channelResponse = executor.executeSync(addChannelBuilder); + // channel/action/add + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs()) + .setLanguage("*")); // KalturaAPIException","code":"4020","message":"KSQL Channel media type 666 does not belong to group" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4020).getCode()); @@ -131,9 +131,9 @@ private void addChannelWithNoName() { channel = ChannelUtils.addDynamicChannel(null, description, isActive, null, channelOrder, null); //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel) - .setKs(getManagerKs()); - Response channelResponse = executor.executeSync(addChannelBuilder); + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs()) + .setLanguage("*")); // KalturaAPIException","code":"5005","message":"KSQL Channel must have a name" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(5005).getCode()); @@ -148,8 +148,9 @@ private void addChannelWithSyntaxErrorInFilterExpression() { channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); //channel/action/add - AddChannelBuilder addChannelBuilder = ChannelService.add(channel).setKs(getManagerKs()); - Response channelResponse = executor.executeSync(addChannelBuilder); + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs()) + .setLanguage("*")); // KalturaAPIException","code":"4004","message":"Invalid expression structure" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4004).getCode()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 71d7b233e..3c2a30d18 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -34,7 +34,8 @@ private void DeleteChannel() { // channel/action/add Response channelResponse = executor.executeSync(add(channel) - .setKs(getManagerKs())); + .setKs(getManagerKs()) + .setLanguage("*")); channelId = Math.toIntExact(channelResponse.results.getId()); @@ -45,9 +46,9 @@ private void DeleteChannel() { assertThat(deleteResponse.results.booleanValue()).isTrue(); // channel/action/get - verify channel wasn't found - GetChannelBuilder getChannelBuilder = get(channelId).setKs(getManagerKs()); - Response getResponse = executor.executeSync(getChannelBuilder); + Response getResponse = executor.executeSync(get(channelId) + .setKs(getManagerKs())); - assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); + assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4064).getCode()); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 2a03da39a..40c248f00 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import com.kaltura.client.services.ChannelService; -import com.kaltura.client.services.ChannelService.AddChannelBuilder; import com.kaltura.client.services.EntitlementService; import com.kaltura.client.services.LicensedUrlService; import com.kaltura.client.services.LicensedUrlService.GetLicensedUrlBuilder; @@ -27,6 +26,7 @@ import java.util.List; import java.util.Optional; +import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.services.EntitlementService.*; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.Properties.WEB_FILE_TYPE; @@ -67,7 +67,7 @@ public void cancelTestBeforeClass() { bookmark.setType(AssetType.MEDIA); sharedChannel = new DynamicChannel(); - sharedChannel.setMultilingualName(setTranslationToken(getRandomValue("Channel_", 999999))); + sharedChannel.setMultilingualName(setTranslationToken(getRandomValue("Channel_"))); sharedChannel.setMultilingualDescription(setTranslationToken("Description of " + sharedChannel.getName())); sharedChannel.setSystemName(sharedChannel.getMultilingualName().get(0).getValue()); sharedChannel.setIsActive(true); @@ -131,9 +131,13 @@ public void cancelWithInvalidSubscription() { public void cancelPlayedSubscription() { // create mpp having at least 1 media on its channel sharedChannel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); - AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); - Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + + Response channelResponse = executor.executeSync(add(sharedChannel) + .setKs(getManagerKs()) + .setLanguage("*")); + assertThat(channelResponse.results).isNotNull(); + Channel channel = channelResponse.results; assertThat(channel.getName()).isNotNull(); PricePlan pricePlan = DBUtils.loadPPWithWaiver(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 24987a34a..16453d560 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -3,7 +3,6 @@ import com.kaltura.client.enums.*; import com.kaltura.client.services.*; import com.kaltura.client.services.AssetService.ListAssetBuilder; -import com.kaltura.client.services.ChannelService.AddChannelBuilder; import com.kaltura.client.services.ChannelService.DeleteChannelBuilder; import com.kaltura.client.services.EntitlementService.ListEntitlementBuilder; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; @@ -25,6 +24,7 @@ import java.util.Optional; +import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.*; @@ -73,10 +73,11 @@ public void beforeClass() { classMasterUserId = HouseholdUtils.getMasterUser(household).getUserId(); sharedChannel = new DynamicChannel(); - sharedChannel.setMultilingualName(setTranslationToken(getRandomValue("Channel_", 999999))); + sharedChannel.setMultilingualName(setTranslationToken(getRandomValue("Channel_"))); sharedChannel.setMultilingualDescription(setTranslationToken("Description of " + sharedChannel.getName())); sharedChannel.setIsActive(true); sharedChannel.setAssetTypes(null); + sharedChannel.setSystemName(sharedChannel.getMultilingualName().get(0).getValue() + "_" + getEpochInLocalTime()); MppData mppData = new MppData() .isRenewable(true) @@ -207,14 +208,17 @@ public void subscriptionTest() { int numberOfUsers = 1; int numberOfDevices = 1; Household household = HouseholdUtils.createHousehold(numberOfUsers, numberOfDevices, true); - //HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); // create mpp with supporting of 1 type only and having at least 1 media on its channel sharedChannel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); - AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); - Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + + Response channelResponse = executor.executeSync(add(sharedChannel) + .setKs(getManagerKs()) + .setLanguage("*")); + assertThat(channelResponse.results).isNotNull(); + Channel channel = channelResponse.results; assertThat(channel.getName()).isNotNull(); @@ -296,9 +300,13 @@ public void subscriptionTest() { public void productPriceSubscriptionWebHDFileTypeOnlyTest() { // create mpp with supporting of 1 type only and having at least 1 media on its channel sharedChannel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); - AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); - Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); + + Response channelResponse = executor.executeSync(add(sharedChannel) + .setKs(getManagerKs()) + .setLanguage("*")); + assertThat(channelResponse.results).isNotNull(); + Channel channel = channelResponse.results; assertThat(channel.getName()).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index ba442a8e6..840d2325d 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -96,6 +96,12 @@ public static String getRandomValue(String prefix, long maxValue) { return prefix + randomLongValue; } + public static String getRandomValue(String prefix) { + long max = 9999999999L; + long randomLongValue = ThreadLocalRandom.current().nextLong(max); + return prefix + randomLongValue; + } + // generate random string public static String getRandomString() { String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java index 560014811..f9d97d66f 100644 --- a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java @@ -16,7 +16,7 @@ public static DynamicChannel addDynamicChannel(String name, @Nullable String des channel.setAssetTypes(assetTypes); channel.setKSql(ksqlExpression); channel.setOrderBy(channelOrder); - channel.setSystemName(channel.getMultilingualName().get(0).getValue()); + channel.setSystemName(channel.getMultilingualName().get(0).getValue() + "_" + getEpochInLocalTime()); return channel; } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 88f7b4601..7a406176a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -44,7 +44,6 @@ public class BaseIngestUtils { public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; // data - static final Long MAX_RANDOM_VALUE = 9999999999L; static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; /* diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index 0f97e4f3c..8b2e04069 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -88,7 +88,7 @@ public static Subscription insertMpp(MppData mppData) { final String currencyOfDiscount = "GBP"; final int percentageOfDiscount = 100; - mppData.mppCode = getRandomValue("MPP_", 9999999999L); + mppData.mppCode = getRandomValue("MPP_"); mppData.title = mppData.mppCode; if (mppData.description == null) { mppData.description = "Description of " + mppData.mppCode; } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 32550c8f8..548db233a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -56,7 +56,7 @@ public static PricePlan insertPp(PpData ppData) { final int defaultPercentageOfDiscount = 100; DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount); - ppData.ppCode = getRandomValue("AUTOPricePlan_", MAX_RANDOM_VALUE); + ppData.ppCode = getRandomValue("AUTOPricePlan_"); if (ppData.fullLifeCycle == null) { ppData.fullLifeCycle = FIVE_MINUTES_PERIOD; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 06fe81f07..1f18696a2 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -52,7 +52,7 @@ public static Ppv insertPpv(PpvData ppvData) { String currencyOfDiscount = "ILS"; int percentageOfDiscount = 50; - ppvData.ppvCode = getRandomValue("PPV_", MAX_RANDOM_VALUE); + ppvData.ppvCode = getRandomValue("PPV_"); if (ppvData.description == null) { ppvData.description = ppvData.ppvCode; } if (ppvData.discount == null) { ppvData.discount = IngestFixtureData.getDiscount(currencyOfDiscount, percentageOfDiscount); } diff --git a/src/test/resources/schemas/DynamicChannel.json b/src/test/resources/schemas/DynamicChannel.json new file mode 100644 index 000000000..8a91cc056 --- /dev/null +++ b/src/test/resources/schemas/DynamicChannel.json @@ -0,0 +1,149 @@ +{ + "$id": "DynamicChannel", + "type": "object", + "definitions": { + "DynamicChannel": { + "type": "object", + "properties": { + "executionTime": { + "type": "number", + "minimum": 0 + }, + "result": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "createDate": { + "type": "integer", + "minimum": 0 + }, + "description": { + "type": "string", + "minLength": 0 + }, + "multilingualDescription": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "language": { + "type": "string", + "minLength": 0 + }, + "value": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "objectType", + "language", + "value" + ] + } + }, + "id": { + "type": "integer", + "minimum": 0 + }, + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "minLength": 0 + }, + "multilingualName": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "language": { + "type": "string", + "minLength": 0 + }, + "value": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "objectType", + "language", + "value" + ] + } + }, + "orderBy": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "orderBy": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "objectType", + "orderBy" + ] + }, + "systemName": { + "type": "string", + "minLength": 0 + }, + "updateDate": { + "type": "integer", + "minimum": 0 + }, + "assetTypes": { + "type": "array" + }, + "kSql": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "objectType", + "createDate", + "description", + "multilingualDescription", + "id", + "isActive", + "name", + "multilingualName", + "orderBy", + "systemName", + "updateDate", + "assetTypes", + "kSql" + ] + } + } + } + }, + "properties": { + "result": { + "ref": "#/definitions/DynamicChannel" + }, + "executionTime": { + "type": "number", + "minimum": 0 + } + } +} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 1c949f9cb..50d2fb0ab 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -53,6 +53,9 @@ }, { "$ref": "PricePlan.json#/definitions/PricePlan" + }, + { + "$ref": "DynamicChannel.json#/definitions/DynamicChannel" } ] } @@ -78,7 +81,8 @@ "KalturaSubscriptionListResponse", "KalturaPaymentGatewayProfileListResponse", "KalturaPriceDetailsListResponse", - "KalturaPricePlanListResponse" + "KalturaPricePlanListResponse", + "KalturaDynamicChannelListResponse" ] } }, From ef65b9217b5b9347b0d475d08f69cf24c11b7718 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Jul 2018 17:02:04 +0300 Subject: [PATCH 425/605] no message --- .../AssetListTests/SearchAssetFilterTests.java | 7 ++++--- .../java/com/kaltura/client/test/utils/BaseUtils.java | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 943788fdb..e7071b640 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.PurchaseUtils; @@ -30,8 +31,8 @@ import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.AssetUtils.*; +import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; -import static com.kaltura.client.test.utils.BaseUtils.getTimeInDate; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; @@ -83,7 +84,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 2 VodData vodData2 = new VodData() .mediaType(MOVIE) - .catalogStartDate(getTimeInDate(-100)) + .catalogStartDate(getLocalTimeFormatted(-100)) .tags(tagMap) .strings(stringMetaMap1); asset2 = insertVod(vodData2); @@ -91,7 +92,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 3 VodData vodData3 = new VodData() .mediaType(EPISODE) - .catalogStartDate(getTimeInDate(-10)) + .catalogStartDate(getLocalTimeFormatted(-10)) .tags(tagMap) .strings(stringMetaMap2); asset3 = insertVod(vodData3); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 840d2325d..6a85e6200 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -39,10 +39,10 @@ public static String getOffsetDateInFormat(int offsetDay, String pattern) { } // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) - public static String getTimeInDate(int offSetInMinutes, String timeZone) { - TimeZone theTimeZone = TimeZone.getTimeZone(timeZone); + public static String getTimeFormatted(int offSetInMinutes, TimeZone timeZone) { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); - dateFormat.setTimeZone(theTimeZone); + dateFormat.setTimeZone(timeZone); + Date dNow = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(dNow); @@ -53,8 +53,8 @@ public static String getTimeInDate(int offSetInMinutes, String timeZone) { } // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) - public static String getTimeInDate(int offSetInMinutes) { - return getTimeInDate(offSetInMinutes,"israel"); + public static String getLocalTimeFormatted(int offSetInMinutes) { + return getTimeFormatted(offSetInMinutes, TimeZone.getDefault()); } // Get epoch time in seconds according to off set parameter provided (in minutes) From 1b221ab9db30315fe194f269a3e1479e1ab2b844 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 18 Jul 2018 17:17:55 +0300 Subject: [PATCH 426/605] no message --- .../SearchAssetFilterTests.java | 2 -- .../kaltura/client/test/utils/BaseUtils.java | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index e7071b640..c728437ba 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -4,7 +4,6 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.PurchaseUtils; @@ -31,7 +30,6 @@ import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.AssetUtils.*; -import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 6a85e6200..3e20e39c9 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -38,6 +38,11 @@ public static String getOffsetDateInFormat(int offsetDay, String pattern) { return dateFormat.format(cal.getTime()); } + // generate current data String in specified format + public static String getCurrentDateInFormat(String pattern) { + return getOffsetDateInFormat(0, pattern); + } + // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) public static String getTimeFormatted(int offSetInMinutes, TimeZone timeZone) { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); @@ -62,7 +67,11 @@ public static long getEpochInLocalTime(int offSetInMinutes) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MINUTE, offSetInMinutes); - return calendar.getTimeInMillis() / 1000; + return calendar.toInstant().getEpochSecond(); + } + + public static long getEpochInLocalTime() { + return Calendar.getInstance().toInstant().getEpochSecond(); } public static long getEpochInUtcTime(int offSetInMinutes) { @@ -70,11 +79,7 @@ public static long getEpochInUtcTime(int offSetInMinutes) { int timeZoneOffset = TimeZone.getDefault().getRawOffset() / 60000; calendar.add(Calendar.MINUTE, offSetInMinutes + timeZoneOffset); - return calendar.getTimeInMillis() / 1000; - } - - public static long getEpochInLocalTime() { - return Calendar.getInstance().getTimeInMillis() / 1000; + return calendar.toInstant().getEpochSecond(); } public static Date getDateFromEpoch(long epoch) { @@ -85,11 +90,6 @@ public static long getEpochFromDate(Date date) { return date.getTime() / 1000; } - // generate current data String in specified format - public static String getCurrentDateInFormat(String pattern) { - return getOffsetDateInFormat(0, pattern); - } - // generate string containing prefix and random long suffix public static String getRandomValue(String prefix, long maxValue) { long randomLongValue = ThreadLocalRandom.current().nextLong(maxValue); From d4ee3c55fdf751abf2ed012b4b493f082e90d80d Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 19 Jul 2018 11:49:28 +0300 Subject: [PATCH 427/605] no message --- .../ScheduledRecordingProgramFilterTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java index 809972739..51f4279a7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java @@ -129,6 +129,28 @@ private void list_assets_with_channelFilter_by_startDateGreaterThanOrNull() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(programAssets2.get(0).getId()); assertThat(assetListResponse.results.getObjects().get(0).getName()).isEqualTo(programAssets2.get(0).getName()); } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - scheduledRecordingProgramFilter - setEndDateLessThanOrNull") + @Test(enabled = false) + private void list_assets_with_channelFilter_by_setEndDateLessThanOrNull() { + // set scheduledRecordingProgramFilter + String channelsIn = getConcatenatedString(String.valueOf(linearAssetJsonObject1.getInt("id")), + String.valueOf(linearAssetJsonObject2.getInt("id"))); + + ScheduledRecordingProgramFilter filter = new ScheduledRecordingProgramFilter(); + filter.setChannelsIn(channelsIn); + filter.setEndDateLessThanOrNull(getEpochInUtcTime(60)); + + // get list + Response> assetListResponse = executor.executeSync(AssetService.list(filter) + .setKs(masterUserKs)); + + // assert response + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(programAssets1.get(0).getId()); + assertThat(assetListResponse.results.getObjects().get(0).getName()).isEqualTo(programAssets1.get(0).getName()); + } @AfterClass private void asset_list_scheduledRecordingProgramFilter_after_class() { From e8860b1a021f072f391ef23cc14aa2a360ca69e5 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 24 Jul 2018 10:30:00 +0300 Subject: [PATCH 428/605] no message --- .../ScheduledRecordingProgramFilterTests.java | 40 ++++++++++++++++++- .../appTokenTests/AppTokenDeleteTests.java | 23 ++++++----- .../test/utils/dbUtils/DBConstants.java | 2 +- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java index 51f4279a7..39845a6d4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java @@ -53,6 +53,7 @@ private void asset_list_scheduledRecordingProgramFilter_before_class() { JSONArray jsonArray = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray(); linearAssetJsonObject1 = jsonArray.getJSONObject(0); linearAssetJsonObject2 = jsonArray.getJSONObject(1); + linearAssetId1 = linearAssetJsonObject1.getInt("media_id"); linearAssetId2 = linearAssetJsonObject2.getInt("media_id"); @@ -65,8 +66,11 @@ private void asset_list_scheduledRecordingProgramFilter_before_class() { .startDate(getEpochInLocalTime(5)); programAssets1 = insertEpg(epgData1); +// String seriesId = String.valueOf(getEpochInLocalTime()); EpgData epgData2 = new EpgData(linearAssetJsonObject2.getString("name")) .startDate(getEpochInLocalTime(360)); +// .seriesId(seriesId) +// .seasonsNum(3); programAssets2 = insertEpg(epgData2); // add recordings 1 @@ -82,6 +86,18 @@ private void asset_list_scheduledRecordingProgramFilter_before_class() { recordingResponse = executor.executeSync(add(recording2).setKs(masterUserKs)); assertThat(recordingResponse.results.getStatus()).isEqualTo(RecordingStatus.SCHEDULED); + +// // add series recording +// SeriesRecording seriesRecording = new SeriesRecording(); +// seriesRecording.setChannelId(linearAssetJsonObject2.getLong("id")); +// seriesRecording.setSeasonNumber(1); +// seriesRecording.setType(RecordingType.SERIES); +// seriesRecording.setEpgId(); +// +// Response seriesRecordingResponse = executor.executeSync(SeriesRecordingService.add(seriesRecording) +// .setKs(masterUserKs)); +//// assertThat(seriesRecordingResponse.results.getStatus()).isEqualTo(RecordingStatus.SCHEDULED); + } @Severity(SeverityLevel.CRITICAL) @@ -132,7 +148,7 @@ private void list_assets_with_channelFilter_by_startDateGreaterThanOrNull() { @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - scheduledRecordingProgramFilter - setEndDateLessThanOrNull") - @Test(enabled = false) + @Test(enabled = true) private void list_assets_with_channelFilter_by_setEndDateLessThanOrNull() { // set scheduledRecordingProgramFilter String channelsIn = getConcatenatedString(String.valueOf(linearAssetJsonObject1.getInt("id")), @@ -151,6 +167,28 @@ private void list_assets_with_channelFilter_by_setEndDateLessThanOrNull() { assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(programAssets1.get(0).getId()); assertThat(assetListResponse.results.getObjects().get(0).getName()).isEqualTo(programAssets1.get(0).getName()); } + + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - scheduledRecordingProgramFilter - setRecordingTypeEqual") + @Test(enabled = false) + private void list_assets_with_channelFilter_by_setRecordingTypeEqual() { +// // set scheduledRecordingProgramFilter +// String channelsIn = getConcatenatedString(String.valueOf(linearAssetJsonObject1.getInt("id")), +// String.valueOf(linearAssetJsonObject2.getInt("id"))); +// +// ScheduledRecordingProgramFilter filter = new ScheduledRecordingProgramFilter(); +// filter.setChannelsIn(channelsIn); +// filter.setRecordingTypeEqual(ScheduledRecordingAssetType.SERIES); +// +// // get list +// Response> assetListResponse = executor.executeSync(AssetService.list(filter) +// .setKs(masterUserKs)); +// +// // assert response +// assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); +// assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(programAssets1.get(0).getId()); +// assertThat(assetListResponse.results.getObjects().get(0).getName()).isEqualTo(programAssets1.get(0).getName()); + } @AfterClass private void asset_list_scheduledRecordingProgramFilter_after_class() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java index 7e32acfc8..a77d1834e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java @@ -1,9 +1,7 @@ package com.kaltura.client.test.tests.servicesTests.appTokenTests; import com.kaltura.client.enums.AppTokenHashType; -import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.AppTokenUtils; import com.kaltura.client.types.AppToken; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -23,7 +21,10 @@ public class AppTokenDeleteTests extends BaseTest { @BeforeClass private void add_tests_before_class() { sessionUserId = getSharedUser().getUserId(); - appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA1, null, null); + + appToken = new AppToken(); + appToken.setSessionUserId(sessionUserId); + appToken.setHashType(AppTokenHashType.SHA1); } @Description("appToken/action/delete") @@ -31,29 +32,29 @@ private void add_tests_before_class() { // TODO: 5/3/2018 not clear test name! private void addAppToken() { // Add token - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken).setKs(getOperatorKs()); - Response appTokenResponse = executor.executeSync(addAppTokenBuilder); + Response appTokenResponse = executor.executeSync(add(appToken) + .setKs(getOperatorKs())); assertThat(appTokenResponse.error).isNull(); assertThat(appTokenResponse.results.getExpiry()).isNull(); // Delete token - DeleteAppTokenBuilder deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()).setKs(getOperatorKs()); - Response deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); + Response deleteTokenResponse = executor.executeSync(delete(appTokenResponse.results.getId()) + .setKs(getOperatorKs())); assertThat(deleteTokenResponse.results).isTrue(); // Try to delete token using invalid token id String invalidTokenId = "1234"; - deleteAppTokenBuilder = AppTokenService.delete(invalidTokenId).setKs(getOperatorKs()); - deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); + deleteTokenResponse = executor.executeSync(delete(invalidTokenId) + .setKs(getOperatorKs())); // TODO: 5/3/2018 split two scenarios into separate tests assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); // Try to delete token again - exception returned - deleteAppTokenBuilder = AppTokenService.delete(appTokenResponse.results.getId()).setKs(getOperatorKs()); - deleteTokenResponse = executor.executeSync(deleteAppTokenBuilder); + deleteTokenResponse = executor.executeSync(delete(appTokenResponse.results.getId()) + .setKs(getOperatorKs())); assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index d87f2473f..9cf622281 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -205,7 +205,7 @@ public class DBConstants { "and group_id = ? " + "order by id desc"; - static final String ASSETS_SELECT = "SELECT top (?) NAME FROM [TVinci].[dbo].[media] where group_id = ? and status = 1 and is_Active = 1 order by id desc"; + static final String ASSETS_SELECT = "SELECT top (?) ID, NAME FROM [TVinci].[dbo].[media] where group_id = ? and status = 1 and is_Active = 1 order by id desc"; static final String ASSETS_SELECT_WITH_MEDIA_TYPE = "SELECT top (?) m.ID, m.NAME, m.MEDIA_TYPE_ID, mt.NAME " + "FROM [TVinci].[dbo].[media] m " + From fcb18ac03c77b7bb4284ad63d3d506894fbcba4c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 25 Jul 2018 12:31:27 +0300 Subject: [PATCH 429/605] fix vod ingest start time in asset/action/list with searchFilter --- .../SearchAssetFilterTests.java | 7 +- .../appTokenTests/AppTokenDeleteTests.java | 68 +++++++++++++------ .../channelTests/ChannelAddTests.java | 17 +++-- .../kaltura/client/test/utils/BaseUtils.java | 4 ++ 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index c728437ba..f52523c38 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -82,7 +82,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 2 VodData vodData2 = new VodData() .mediaType(MOVIE) - .catalogStartDate(getLocalTimeFormatted(-100)) + .catalogStartDate(getUtcTimeFormatted(-100)) .tags(tagMap) .strings(stringMetaMap1); asset2 = insertVod(vodData2); @@ -90,7 +90,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 3 VodData vodData3 = new VodData() .mediaType(EPISODE) - .catalogStartDate(getLocalTimeFormatted(-10)) + .catalogStartDate(getUtcTimeFormatted(-10)) .tags(tagMap) .strings(stringMetaMap2); asset3 = insertVod(vodData3); @@ -103,7 +103,7 @@ private void asset_list_searchAssetFilter_before_class() { EpgData epgData2 = new EpgData(epgChannelName2).episodesNum(1); program2 = insertEpg(epgData2).get(0); - Household household = HouseholdUtils.createHousehold(1, 1, true); + Household household = HouseholdUtils.createHousehold(); masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household); PurchaseUtils.purchasePpv(masterUserKs, Optional.of(asset.getId().intValue()), Optional.empty(), Optional.empty()); @@ -360,6 +360,7 @@ private void orderVodAssetsByName() { .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) .closeOr() .toString(); + assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); ListAssetBuilder listAssetBuilder = list(assetFilter) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java index a77d1834e..df630a693 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenDeleteTests.java @@ -5,33 +5,29 @@ import com.kaltura.client.types.AppToken; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; -import org.testng.annotations.BeforeClass; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; -import static com.kaltura.client.services.AppTokenService.*; +import static com.kaltura.client.services.AppTokenService.add; +import static com.kaltura.client.services.AppTokenService.delete; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedUser; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class AppTokenDeleteTests extends BaseTest { - - private String sessionUserId; - private AppToken appToken; - @BeforeClass - private void add_tests_before_class() { - sessionUserId = getSharedUser().getUserId(); + @Severity(SeverityLevel.CRITICAL) + @Description("appToken/action/delete") + @Test + private void deleteAppToken() { + // Add token + String sessionUserId = getSharedUser().getUserId(); - appToken = new AppToken(); + AppToken appToken = new AppToken(); appToken.setSessionUserId(sessionUserId); appToken.setHashType(AppTokenHashType.SHA1); - } - @Description("appToken/action/delete") - @Test - // TODO: 5/3/2018 not clear test name! - private void addAppToken() { - // Add token Response appTokenResponse = executor.executeSync(add(appToken) .setKs(getOperatorKs())); @@ -39,24 +35,52 @@ private void addAppToken() { assertThat(appTokenResponse.results.getExpiry()).isNull(); // Delete token - Response deleteTokenResponse = executor.executeSync(delete(appTokenResponse.results.getId()) + Response booleanResponse = executor.executeSync(delete(appTokenResponse.results.getId()) .setKs(getOperatorKs())); - assertThat(deleteTokenResponse.results).isTrue(); + assertThat(booleanResponse.results).isTrue(); + } + @Severity(SeverityLevel.MINOR) + @Description("appToken/action/delete - invalid token") + @Test + private void deleteInvalidAppToken() { // Try to delete token using invalid token id String invalidTokenId = "1234"; - deleteTokenResponse = executor.executeSync(delete(invalidTokenId) + Response booleanResponse = executor.executeSync(delete(invalidTokenId) + .setKs(getOperatorKs())); + + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + } + + @Severity(SeverityLevel.MINOR) + @Description("appToken/action/delete - same token twice") + @Test + private void deleteSameAppTokenTwice() { + // Add token + String sessionUserId = getSharedUser().getUserId(); + + AppToken appToken = new AppToken(); + appToken.setSessionUserId(sessionUserId); + appToken.setHashType(AppTokenHashType.SHA1); + + Response appTokenResponse = executor.executeSync(add(appToken) + .setKs(getOperatorKs())); + + assertThat(appTokenResponse.error).isNull(); + assertThat(appTokenResponse.results.getExpiry()).isNull(); + + // Delete token + Response booleanResponse = executor.executeSync(delete(appTokenResponse.results.getId()) .setKs(getOperatorKs())); - // TODO: 5/3/2018 split two scenarios into separate tests - assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + assertThat(booleanResponse.results).isTrue(); // Try to delete token again - exception returned - deleteTokenResponse = executor.executeSync(delete(appTokenResponse.results.getId()) + booleanResponse = executor.executeSync(delete(appTokenResponse.results.getId()) .setKs(getOperatorKs())); - assertThat(deleteTokenResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 4d78df3b5..a9c22ff35 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -20,6 +20,7 @@ import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.ChannelService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; @@ -47,6 +48,7 @@ private void addChannel() { ksqlExpression = "name ~ 'movie'"; ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); // channel/action/add @@ -123,20 +125,25 @@ private void addChannelWithInvalidAssetType() { assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4020).getCode()); } - @Description("channel/action/add - mandatory channel name not provided") + @Description("channel/action/add - mandatory channel multilingualName not provided") @Test - private void addChannelWithNoName() { + private void addChannelWithoutMultilingualName() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - channel = ChannelUtils.addDynamicChannel(null, description, isActive, null, channelOrder, null); + ksqlExpression = "name ~ 'movie'"; + + DynamicChannel channel = new DynamicChannel(); + channel.setIsActive(true); + channel.setOrderBy(channelOrder); + channel.setSystemName("systemName " + getEpochInLocalTime()); //channel/action/add Response channelResponse = executor.executeSync(add(channel) .setKs(getManagerKs()) .setLanguage("*")); - // KalturaAPIException","code":"5005","message":"KSQL Channel must have a name" - assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(5005).getCode()); + // KalturaAPIException","code":"50027","message":"Argument [name] cannot be empty" + assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(50027).getCode()); } @Description("channel/action/add - syntax error in filter expression") diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 3e20e39c9..c4d470ed0 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -62,6 +62,10 @@ public static String getLocalTimeFormatted(int offSetInMinutes) { return getTimeFormatted(offSetInMinutes, TimeZone.getDefault()); } + public static String getUtcTimeFormatted(int offSetInMinutes) { + return getTimeFormatted(offSetInMinutes, TimeZone.getTimeZone("UTC")); + } + // Get epoch time in seconds according to off set parameter provided (in minutes) public static long getEpochInLocalTime(int offSetInMinutes) { Calendar calendar = Calendar.getInstance(); From e6af420d5c6d822403eda3a4afab0dd0be48e4a1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 29 Jul 2018 16:55:53 +0300 Subject: [PATCH 430/605] no message --- .../AssetHistoryCleanTests.java | 7 ++--- .../AssetHistoryListTests.java | 8 ++--- .../TransactionHistoryListTests.java | 22 ++++++++------ .../kaltura/client/test/utils/AssetUtils.java | 29 +++++++++++++++++++ .../client/test/utils/ChannelUtils.java | 2 +- .../client/test/utils/HouseholdUtils.java | 4 ++- 6 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 571e9b83f..819eadb20 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -13,16 +13,15 @@ import org.testng.annotations.Test; import java.util.List; -import java.util.Optional; import static com.kaltura.client.services.AssetHistoryService.*; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; +import static com.kaltura.client.test.utils.AssetUtils.getAssets; import static com.kaltura.client.test.utils.BookmarkUtils.addBookmark; import static com.kaltura.client.test.utils.HouseholdUtils.*; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAssets; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; @@ -45,7 +44,7 @@ public class AssetHistoryCleanTests extends BaseTest { @BeforeClass // TODO: 5/3/2018 change before method name private void clean_tests_before_class() { - List movies = getAssets(2, Optional.of(MOVIE)); + List movies = getAssets(2, MOVIE); // get first movie asset movie = movies.get(0); @@ -56,7 +55,7 @@ private void clean_tests_before_class() { movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = getAssets(1, Optional.of(EPISODE)).get(0); + episode = getAssets(1, EPISODE).get(0); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 0bc4cfa1f..1eff0685d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -15,18 +15,16 @@ import org.testng.annotations.Test; import java.util.List; -import java.util.Optional; import static com.kaltura.client.services.AssetHistoryService.list; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; +import static com.kaltura.client.test.utils.AssetUtils.getAssets; import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.BookmarkUtils.addBookmark; import static com.kaltura.client.test.utils.HouseholdUtils.*; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAssets; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; @@ -48,7 +46,7 @@ public class AssetHistoryListTests extends BaseTest { @BeforeClass private void list_tests_before_class() { - List movies = getAssets(2, Optional.of(MOVIE)); + List movies = getAssets(2, MOVIE); // get first movie asset movie = movies.get(0); @@ -59,7 +57,7 @@ private void list_tests_before_class() { movie2FileId = AssetUtils.getAssetFileIds(String.valueOf(movie2.getId())).get(0); // Ingest episode asset - episode = getAssets(1, Optional.of(EPISODE)).get(0); + episode = getAssets(1, EPISODE).get(0); episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java index ce72f2aae..fdad52bb6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionHistoryTests/TransactionHistoryListTests.java @@ -27,26 +27,28 @@ public class TransactionHistoryListTests extends BaseTest{ + private static final String PPV_MODULE_ID_KEY = "ppvModuleId"; + private static final String PRICE_AMOUNT = "price"; + private static final String PRICE_CURRENCY = "currency"; + + //Epoch for transactionHistory filter (86400 sec = 24 hours) + private static final int yesterdayInEpoch = (int)((System.currentTimeMillis()/1000)-86400); + private static final int tomorrowInEpoch = (int)((System.currentTimeMillis()/1000)+86400); + private ListTransactionHistoryBuilder listTransactionHistoryBuilder; private EntitlementFilter entitlementFilter; private TransactionHistoryFilter transactionHistoryFilter; + private Response> listEntitlementServiceResponsePpv; private Response> listEntitlementServiceResponseSubscription; private Response> listBillingTransactionResponse; private Response transactionResponseSubscription; private Response transactionResponseCollection; private Response transactionResponsePpv; - private int numberOfDevicesInHousehold = 2; - private int numberOfUsersInHousehold = 2; + private String masterUserKs; private String userKs; private String methodName; - public static final String PPV_MODULE_ID_KEY = "ppvModuleId"; - public static final String PRICE_AMOUNT = "price"; - public static final String PRICE_CURRENCY = "currency"; - //Epoch for transactionHistory filter (86400 sec = 24 hours) - public static final int yesterdayInEpoch = (int)((System.currentTimeMillis()/1000)-86400); - public static final int tomorrowInEpoch = (int)((System.currentTimeMillis()/1000)+86400); @BeforeClass @@ -62,6 +64,8 @@ public void transactionHistortTestSetup(){ //End date before tomorrow transactionHistoryFilter.setEndDateLessThanOrEqual(tomorrowInEpoch); + int numberOfUsersInHousehold = 2; + int numberOfDevicesInHousehold = 2; Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold,true); //Login with master to first device masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); @@ -231,7 +235,7 @@ private void assertMethod(String methodName, List billingTra case COLLECTION: assertThat(billingTransaction.getRecieptCode()).isEqualTo(transactionResponseCollection.results.getId()); - assertThat(billingTransaction.getPurchasedItemName()).isEqualTo(getSharedCommonCollection().getName()); + assertThat(billingTransaction.getPurchasedItemName()).isEqualTo(getSharedCommonCollection().getMultilingualName().get(0).getValue()); assertThat(billingTransaction.getPurchasedItemCode()).isEqualTo(getSharedCommonCollection().getId()); assertThat(billingTransaction.getItemType()).isEqualTo(BillingItemsType.COLLECTION); assertThat(billingTransaction.getPrice().getAmount().toString()).isEqualTo(PurchaseUtils.purchaseCollectionDetailsMap.get(PRICE_AMOUNT)); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 6875d2ae1..a2994476d 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -5,8 +5,10 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.BookmarkActionType; import com.kaltura.client.enums.SocialActionType; +import com.kaltura.client.services.AssetService; import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.SocialActionService; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -22,6 +24,8 @@ import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.executor; import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; +import static com.kaltura.client.test.tests.enums.KsqlKey.ASSET_TYPE; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; @@ -158,6 +162,31 @@ public static void addVotesToAsset(Long assetId, int numOfActions, AssetType ass } } + public static List getAssets(int numOfAssets, MediaType mediaType) { + SearchAssetFilter filter = new SearchAssetFilter(); + String query = new KsqlBuilder().equal(ASSET_TYPE.getValue(), getMediaTypeId(mediaType)).toString(); + filter.setKSql(query); + + FilterPager pager = new FilterPager(); + pager.setPageIndex(1); + pager.setPageSize(numOfAssets); + + return (List) (List) executor.executeSync(AssetService.list(filter, pager) + .setKs(getOperatorKs())).results.getObjects(); + } + + public static List getPrograms(int numOfAssets) { + SearchAssetFilter filter = new SearchAssetFilter(); + filter.setTypeIn("0"); + + FilterPager pager = new FilterPager(); + pager.setPageIndex(1); + pager.setPageSize(numOfAssets); + + return (List) (List) executor.executeSync(AssetService.list(filter, pager) + .setKs(getOperatorKs())).results.getObjects(); + } + public static String getCoguid(Asset asset) { // TODO: 7/1/2018 finsih util return null; diff --git a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java index f9d97d66f..560014811 100644 --- a/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ChannelUtils.java @@ -16,7 +16,7 @@ public static DynamicChannel addDynamicChannel(String name, @Nullable String des channel.setAssetTypes(assetTypes); channel.setKSql(ksqlExpression); channel.setOrderBy(channelOrder); - channel.setSystemName(channel.getMultilingualName().get(0).getValue() + "_" + getEpochInLocalTime()); + channel.setSystemName(channel.getMultilingualName().get(0).getValue()); return channel; } diff --git a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java index e06f3c3c6..6a02a6e73 100644 --- a/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/HouseholdUtils.java @@ -4,6 +4,7 @@ import com.kaltura.client.services.HouseholdDeviceService; import com.kaltura.client.services.HouseholdPaymentGatewayService; import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.test.Properties; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -18,6 +19,7 @@ import static com.kaltura.client.services.HouseholdUserService.*; import static com.kaltura.client.services.HouseholdUserService.list; import static com.kaltura.client.services.OttUserService.*; +import static com.kaltura.client.test.Properties.PAYMENT_GATEWAY_EXTERNAL_ID; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.OttUserUtils.generateOttUser; @@ -84,7 +86,7 @@ public static Household createHousehold(int numOfUsers, int numOfDevices, boolea // TODO: there should be added logic with getting and using default PG currently it all hardcoded //HouseholdPaymentGateway/action/setChargeId SetChargeIDHouseholdPaymentGatewayBuilder setChargeIDHouseholdPaymentGatewayBuilder = HouseholdPaymentGatewayService - .setChargeID("0110151474255957105", "1234") + .setChargeID(Properties.getProperty(PAYMENT_GATEWAY_EXTERNAL_ID), "1234") .setKs(getOperatorKs()) .setUserId(Integer.valueOf(masterUser.getId())); executor.executeSync(setChargeIDHouseholdPaymentGatewayBuilder); From ef5dfb1cd3a67be16d704b5f9d41e66f80fad819 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 30 Jul 2018 10:54:26 +0300 Subject: [PATCH 431/605] change getAssets to use asset/action/list --- .../com/kaltura/client/test/Properties.java | 4 + .../kaltura/client/test/tests/BaseTest.java | 11 +- .../AssetListTests/BundleFilterTests.java | 24 ++-- .../AssetListTests/ChannelFilterTests.java | 27 ++-- .../channelTests/ChannelAddTests.java | 121 ++++++++++++++---- .../channelTests/ChannelDeleteTests.java | 13 +- .../test/utils/dbUtils/DBConstants.java | 17 ++- .../client/test/utils/dbUtils/DBUtils.java | 89 +++---------- 8 files changed, 168 insertions(+), 138 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 6ff6bd556..fac8fc62f 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -19,6 +19,7 @@ public class Properties { // Request properties public static final String PARTNER_ID = "partner_id"; +// public static final String OPC_PARTNER_ID = "opc_partner_id"; public static final String DEFAULT_TIMEOUT_IN_SEC = "default_timeout_in_sec"; // global users @@ -71,6 +72,9 @@ public class Properties { // product codes public static final String DEFAULT_PRODUCT_CODE = "default_product_code"; + // payment gateway external id + public static final String PAYMENT_GATEWAY_EXTERNAL_ID = "payment_gateway_external_id"; + // processing apps logs from remote connection public static final String PHOENIX_SERVER_DOMAIN_NAME = "phoenix_server_domain_name"; public static final String PHOENIX_SERVER_USER_NAME = "phoenix_server_user_name"; diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index d1d4da5e8..1a487b8a2 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -61,6 +61,7 @@ public class BaseTest { // shared common params public static int partnerId; +// public static int opcPartnerId; public static String defaultUserPassword; // shared ks's @@ -130,6 +131,7 @@ public void baseTest_beforeSuite() { // set shared common params partnerId = Integer.parseInt(getProperty(PARTNER_ID)); +// opcPartnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); } @@ -312,8 +314,7 @@ public static String getIngestVirualAssetUserPassword() { public static String getAdministratorKs() { if (administratorKs == null) { String[] userInfo = DBUtils.getUserData("Administrator").split(":"); - loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], - null, null)); + loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1])); administratorKs = loginResponse.results.getLoginSession().getKs(); } return administratorKs; @@ -322,8 +323,7 @@ public static String getAdministratorKs() { public static String getOperatorKs() { if (operatorKs == null) { String[] userInfo = DBUtils.getUserData("Operator").split(":"); - loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], - null, null)); + loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1])); operatorKs = loginResponse.results.getLoginSession().getKs(); } return operatorKs; @@ -332,8 +332,7 @@ public static String getOperatorKs() { public static String getManagerKs() { if (managerKs == null) { String[] userInfo = DBUtils.getUserData("Manager").split(":"); - loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1], - null, null)); + loginResponse = executor.executeSync(login(partnerId, userInfo[0], userInfo[1])); managerKs = loginResponse.results.getLoginSession().getKs(); } return managerKs; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index df06b8e22..bf425eb78 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -15,14 +15,14 @@ import org.testng.annotations.Test; import java.util.List; -import java.util.Optional; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.test.Properties.DEFAULT_COLLECTION; import static com.kaltura.client.test.Properties.getProperty; -import static com.kaltura.client.test.tests.enums.KsqlKey.NAME; +import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.*; +import static com.kaltura.client.test.utils.AssetUtils.getAssets; import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.MppData; @@ -41,35 +41,35 @@ public class BundleFilterTests extends BaseTest { @BeforeClass private void asset_list_bundleFilter_before_class() { // get movie - List medias = getAssets(2, Optional.of(MOVIE)); + List medias = getAssets(2, MOVIE); movie1 = medias.get(0); movie2 = medias.get(1); // get series - List series = getVirtualAssets(2, Optional.of(SERIES)); + List series = getAssets(2, SERIES); series1 = series.get(0); series2 = series.get(1); // get episode - List episodes = getAssets(2, Optional.of(EPISODE)); + List episodes = getAssets(2, EPISODE); episode1 = episodes.get(0); episode2 = episodes.get(1); // add assets to channel query 1 String channel1Query = new KsqlBuilder() .openOr() - .equal(NAME.getValue(), movie1.getName()) - .equal(NAME.getValue(), series1.getName()) - .equal(NAME.getValue(), episode1.getName()) + .equal(MEDIA_ID.getValue(), String.valueOf(movie1.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(series1.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(episode1.getId())) .closeOr() .toString(); // add assets to channel query 2 String channel2Query = new KsqlBuilder() .openOr() - .equal(NAME.getValue(), movie2.getName()) - .equal(NAME.getValue(), series2.getName()) - .equal(NAME.getValue(), episode2.getName()) + .equal(MEDIA_ID.getValue(), String.valueOf(movie2.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(series2.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(episode2.getId())) .closeOr() .toString(); @@ -136,7 +136,7 @@ private void list_assets_with_bundleFilter_subscription_by_idEqual() { private void list_assets_with_bundleFilter_subscription_by_idEqual_and_typeIn() { // adding "MOVIE", "SERIES" and "LINEAR" to string types (excluding "EPISODE") String types = getConcatenatedString(String.valueOf(getMediaTypeId(MOVIE)), - String.valueOf(getVirtualMediaTypeId(SERIES)), + String.valueOf(getMediaTypeId(SERIES)), String.valueOf(getMediaTypeId(LINEAR))); // set bundleFilter diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 827a5551b..1de381b6b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -13,12 +13,13 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Optional; - import static com.kaltura.client.services.AssetService.list; -import static com.kaltura.client.test.tests.enums.KsqlKey.NAME; +import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; +import static com.kaltura.client.test.utils.AssetUtils.getAssets; +import static com.kaltura.client.test.utils.AssetUtils.getPrograms; import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.setTranslationToken; import static org.assertj.core.api.Assertions.assertThat; public class ChannelFilterTests extends BaseTest { @@ -31,13 +32,13 @@ public class ChannelFilterTests extends BaseTest { @BeforeClass private void asset_list_channelFilter_before_class() { // get movie - asset1 = getAssets(1, Optional.of(MediaType.MOVIE)).get(0); + asset1 = getAssets(1, MediaType.MOVIE).get(0); // get series - asset2 = getVirtualAssets(1, Optional.of(MediaType.SERIES)).get(0); + asset2 = getAssets(1, MediaType.SERIES).get(0); // get episode - asset3 = getAssets(1, Optional.of(MediaType.EPISODE)).get(0); + asset3 = getAssets(1, MediaType.EPISODE).get(0); // get epg program1 = getPrograms(1).get(0); @@ -45,10 +46,10 @@ private void asset_list_channelFilter_before_class() { // add assets to channel query String query = new KsqlBuilder() .openOr() - .equal(NAME.getValue(), asset1.getName()) - .equal(NAME.getValue(), asset2.getName()) - .equal(NAME.getValue(), asset3.getName()) - .equal(NAME.getValue(), program1.getName()) + .equal(MEDIA_ID.getValue(), String.valueOf(asset1.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(asset2.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(asset3.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(program1.getId())) .closeOr() .toString(); @@ -91,8 +92,8 @@ private void list_assets_with_channelFilter_by_channelId_and_ksql() { // build query String query = new KsqlBuilder() .openOr() - .equal(NAME.getValue(), asset1.getName()) - .equal(NAME.getValue(), program1.getName()) + .equal(MEDIA_ID.getValue(), String.valueOf(asset1.getId())) + .equal(MEDIA_ID.getValue(), String.valueOf(program1.getId())) .closeOr() .toString(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index a9c22ff35..0390774c9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -2,6 +2,7 @@ import com.kaltura.client.enums.ChannelOrderBy; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.ChannelService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.AssetUtils; @@ -10,6 +11,9 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -17,10 +21,10 @@ import java.util.List; import java.util.Optional; -import static com.kaltura.client.services.AssetService.ListAssetBuilder; -import static com.kaltura.client.services.ChannelService.*; +import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getOpcMediaTypeId; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; @@ -31,21 +35,20 @@ public class ChannelAddTests extends BaseTest { private String channelName; private String description; private Boolean isActive = true; - private String ksqlExpression; private IntegerValue integerValue = new IntegerValue(); - private List assetTypes = new ArrayList<>(); @BeforeClass private void channel_addTests_before_class() { - channelName = "Channel_12345"; - description = "description of channel"; + channelName = "Channel_" + getEpochInLocalTime(); + description = "description of " + channelName; } + @Severity(SeverityLevel.CRITICAL) @Description("channel/action/add - with all asset types") @Test private void addChannel() { - ksqlExpression = "name ~ 'movie'"; + String ksqlExpression = "name ~ 'movie'"; ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); @@ -57,8 +60,65 @@ private void addChannel() { .setLanguage("*")); assertThat(channelResponse.results.getName()).isEqualTo(channelName); + + // cleanup - delete channel + executor.executeSync(ChannelService.delete(Math.toIntExact(channelResponse.results.getId())) + .setKs(getManagerKs())); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("channel/action/add - with specific asset type") + @Test + private void addChannelWithAssetType() { + String ksqlExpression = "name ~ 'movie'"; + + int mediaTypeId = getOpcMediaTypeId(MediaType.MOVIE); + integerValue.setValue(mediaTypeId); + List assetTypes = new ArrayList<>(); + assetTypes.add(integerValue); + + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); + + // channel/action/add + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs()) + .setLanguage("*")); + + assertThat(channelResponse.results.getName()).isEqualTo(channelName); + + // cleanup - delete channel + executor.executeSync(ChannelService.delete(Math.toIntExact(channelResponse.results.getId())) + .setKs(getManagerKs())); } + @Severity(SeverityLevel.MINOR) + @Description("channel/action/add - with not supported opc partner id") + @Test + private void addDynamicChannelWithNotSupportedOpcPartnerId() { + String ksqlExpression = "name ~ 'movie'"; + + int mediaTypeId = getOpcMediaTypeId(MediaType.MOVIE); + integerValue.setValue(mediaTypeId); + List assetTypes = new ArrayList<>(); + assetTypes.add(integerValue); + + ChannelOrder channelOrder = new ChannelOrder(); + channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); + + // channel/action/add + Response channelResponse = executor.executeSync(add(channel) + .setKs(getManagerKs()) + .setLanguage("*")); + + assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4074).getCode()); + } + + @Severity(SeverityLevel.CRITICAL) @Description("channel/action/add - order by NAME_DESC") @Test private void checkOrderOfAssetsInChannel() { @@ -77,7 +137,7 @@ private void checkOrderOfAssetsInChannel() { .mediaType(MediaType.EPISODE); MediaAsset episodeAsset = insertVod(vodData1); - ksqlExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; + String ksqlExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.NAME_DESC); channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); @@ -88,49 +148,56 @@ private void checkOrderOfAssetsInChannel() { .setLanguage("*")); assertThat(channelResponse.results.getMultilingualName().get(0).getValue()).isEqualTo(channelName); - int channelId = Math.toIntExact(channelResponse.results.getId()); + + // asset/action/list ChannelFilter channelFilter = AssetUtils.getChannelFilter(channelId, Optional.empty(), Optional.empty(), Optional.empty()); - //asset/action/list - ListAssetBuilder listAssetBuilder = AssetService.list(channelFilter) - .setKs(getManagerKs()); - Response> listResponse = executor.executeSync(listAssetBuilder); + Response> listResponse = executor.executeSync(AssetService.list(channelFilter) + .setKs(getManagerKs())); assertThat(listResponse.results.getTotalCount()).isEqualTo(2); // Verify movie asset id returned first (because order is by name_desc) assertThat(listResponse.results.getObjects().get(0).getId()).isEqualTo(movieAsset.getId()); - // Cleanup - channel/action/delete - DeleteChannelBuilder deleteChannelBuilder = delete(channelId).setKs(getManagerKs()); - executor.executeSync(deleteChannelBuilder); + // cleanup - delete channel + executor.executeSync(ChannelService.delete(channelId) + .setKs(getManagerKs())); } - @Description("channel/action/add - with invalid asset type") + @Severity(SeverityLevel.NORMAL) + @Description("channel/action/add - with invalid asset type - error 4028") @Test private void addChannelWithInvalidAssetType() { - integerValue.setValue(666); + String ksqlExpression = "name ~ 'movie'"; + + int invalidAssetType = 1; + integerValue.setValue(invalidAssetType); + List assetTypes = new ArrayList<>(); assetTypes.add(integerValue); + ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, null, channelOrder, assetTypes); + channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); // channel/action/add Response channelResponse = executor.executeSync(add(channel) .setKs(getManagerKs()) .setLanguage("*")); - // KalturaAPIException","code":"4020","message":"KSQL Channel media type 666 does not belong to group" - assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4020).getCode()); + // KalturaAPIException","code":"4028" + assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4028).getCode()); } + @Severity(SeverityLevel.NORMAL) @Description("channel/action/add - mandatory channel multilingualName not provided") @Test private void addChannelWithoutMultilingualName() { + String ksqlExpression = "name ~ 'movie'"; + ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - ksqlExpression = "name ~ 'movie'"; DynamicChannel channel = new DynamicChannel(); channel.setIsActive(true); @@ -146,10 +213,12 @@ private void addChannelWithoutMultilingualName() { assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(50027).getCode()); } + @Severity(SeverityLevel.NORMAL) @Description("channel/action/add - syntax error in filter expression") @Test private void addChannelWithSyntaxErrorInFilterExpression() { - ksqlExpression = "name = 'syntax error"; + String ksqlExpression = "name = 'syntax error"; + ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); @@ -162,4 +231,10 @@ private void addChannelWithSyntaxErrorInFilterExpression() { // KalturaAPIException","code":"4004","message":"Invalid expression structure" assertThat(channelResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4004).getCode()); } + + @AfterClass + private void channel_addTests_after_class() { + + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 3c2a30d18..0d693eec0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -13,6 +13,7 @@ import static com.kaltura.client.services.ChannelService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static org.assertj.core.api.Assertions.assertThat; public class ChannelDeleteTests extends BaseTest { @@ -20,14 +21,14 @@ public class ChannelDeleteTests extends BaseTest { private Channel channel; private int channelId; - private final String channelName = "Channel_12345"; - private final String description = "description of channel"; - private final String ksqlExpression = "name ~ 'movie'"; - @Severity(SeverityLevel.CRITICAL) @Description("channel/action/delete") @Test private void DeleteChannel() { + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; + String ksqlExpression = "name ~ 'movie'"; + ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); channel = ChannelUtils.addDynamicChannel(channelName, description, true, ksqlExpression, channelOrder, null); @@ -40,8 +41,8 @@ private void DeleteChannel() { channelId = Math.toIntExact(channelResponse.results.getId()); // channel/action/delete - DeleteChannelBuilder deleteChannelBuilder = delete(channelId).setKs(getManagerKs()); - Response deleteResponse = executor.executeSync(deleteChannelBuilder); + Response deleteResponse = executor.executeSync(delete(channelId) + .setKs(getManagerKs())); assertThat(deleteResponse.results.booleanValue()).isTrue(); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 9cf622281..12dbc73c7 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -198,14 +198,19 @@ public class DBConstants { static final String USER_BY_ID_SELECT = "SELECT * from [Users].[dbo].[users] where group_id = ? and ID = ?"; - static final String PROGRAMS_SELECT = "SELECT top (?) NAME " + + static final String PROGRAMS_SELECT = "SELECT top (?) ID, NAME " + "FROM [TVinci].[dbo].[epg_channels_schedule] " + "where status = 1 " + "and is_active = 1 " + "and group_id = ? " + "order by id desc"; - static final String ASSETS_SELECT = "SELECT top (?) ID, NAME FROM [TVinci].[dbo].[media] where group_id = ? and status = 1 and is_Active = 1 order by id desc"; + static final String ASSETS_SELECT = "SELECT top (?) ID, NAME " + + "FROM [TVinci].[dbo].[media] " + + "where group_id = ? " + + "and status = 1 " + + "and is_Active = 1 " + + "order by id desc"; static final String ASSETS_SELECT_WITH_MEDIA_TYPE = "SELECT top (?) m.ID, m.NAME, m.MEDIA_TYPE_ID, mt.NAME " + "FROM [TVinci].[dbo].[media] m " + @@ -217,9 +222,11 @@ public class DBConstants { "and mt.NAME = ? " + "order by m.id desc"; - static final String MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where GROUP_ID = ? and name = ?"; + static final String MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where (GROUP_ID = ? OR GROUP_ID = ?) and name = ?"; + static final String OPC_MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where GROUP_ID = ? and name = ?"; + - static final String MEDIA_FILE_TYPE_ID_SELECT = "SELECT [NAME] FROM [TVinci].[dbo].[groups_media_type] where GROUP_ID = ? and ID = ?"; + static final String MEDIA_FILE_TYPE_ID_SELECT = "SELECT [NAME] FROM [TVinci].[dbo].[groups_media_type] where GROUP_ID = ? and ID = ?"; // STORED PROCEDURES: @@ -232,6 +239,4 @@ public class DBConstants { static final String SP_DELETE_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionItem(?)}"; static final String SP_DELETE_PERMISSION_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Delete_PermissionPermissionItem(?)}"; static final String SP_DELETE_ROLE_AND_ITS_PERMISSIONS = "{call TVinci.dbo.__482V0__Delete_RolePermission(?, ?)}"; - - } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 12bd72ac6..818d8834d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -2,12 +2,12 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.SubscriptionService; -import com.kaltura.client.test.tests.enums.KsqlKey; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.tests.enums.PremiumService; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.KsqlBuilder; -import com.kaltura.client.types.*; +import com.kaltura.client.types.PricePlan; +import com.kaltura.client.types.Subscription; +import com.kaltura.client.types.SubscriptionFilter; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; @@ -16,10 +16,7 @@ import java.sql.*; import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; @@ -243,81 +240,29 @@ public static JSONObject getUserById(int userId) { .getJSONObject(0); } - public static List getAssets(int numOfAssets, Optional mediaType) { - JSONArray jsonArray; - if (mediaType.isPresent()) { - jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT_WITH_MEDIA_TYPE, numOfAssets, partnerId + 1, - mediaType.get().getValue()); - } else { - jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 1); - } - - KsqlBuilder builder = new KsqlBuilder(); - for (int i = 0; i < jsonArray.length(); i++) { - builder.equal(KsqlKey.NAME.getValue(), jsonArray.getJSONObject(i).getString("name")); - } - - String query = new KsqlBuilder() - .or(builder.toString()) - .toString(); - - SearchAssetFilter filter = new SearchAssetFilter(); - filter.setKSql(query); - return (List) (List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); - } - - public static List getVirtualAssets(int numOfAssets, Optional mediaType) { - JSONArray jsonArray; - if (mediaType.isPresent()) { - jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT_WITH_MEDIA_TYPE, numOfAssets, partnerId + 2, - mediaType.get().getValue()); - } else { - jsonArray = getJsonArrayFromQueryResult(ASSETS_SELECT, numOfAssets, partnerId + 2); - } - - KsqlBuilder builder = new KsqlBuilder(); - for (int i = 0; i < jsonArray.length(); i++) { - builder.equal(KsqlKey.NAME.getValue(), jsonArray.getJSONObject(i).getString("name")); - } - - String query = new KsqlBuilder() - .or(builder.toString()) - .toString(); - - SearchAssetFilter filter = new SearchAssetFilter(); - filter.setKSql(query); - return (List) (List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); - } - - public static List getPrograms(int numOfPrograms) { - JSONArray jsonArray = getJsonArrayFromQueryResult(PROGRAMS_SELECT, numOfPrograms, partnerId + 1); - - KsqlBuilder builder = new KsqlBuilder(); - for (int i = 0; i < jsonArray.length(); i++) { - builder.equal(KsqlKey.NAME.getValue(), jsonArray.getJSONObject(i).getString("name")); - } - - String query = new KsqlBuilder() - .or(builder.toString()) - .toString(); - - SearchAssetFilter filter = new SearchAssetFilter(); - filter.setKSql(query); - return (List) (List) executor.executeSync(list(filter).setKs(getOperatorKs())).results.getObjects(); - } - public static int getMediaTypeId(MediaType mediaType) { - return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 1, mediaType.getValue()) + return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, + partnerId + 1, + partnerId + 2, + mediaType.getValue()) .getJSONObject(0) .getInt("id"); } - public static int getVirtualMediaTypeId(MediaType mediaType) { - return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 2, mediaType.getValue()) + public static int getOpcMediaTypeId(MediaType mediaType) { + return getJsonArrayFromQueryResult(OPC_MEDIA_TYPE_ID_SELECT, + partnerId, + mediaType.getValue()) .getJSONObject(0) .getInt("id"); } +// public static int getVirtualMediaTypeId(MediaType mediaType) { +// return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 2, mediaType.getValue()) +// .getJSONObject(0) +// .getInt("id"); +// } + public static String getMediaFileTypeName(int mediaFileId) { return getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_ID_SELECT, partnerId + 1, mediaFileId) .getJSONObject(0) From edb7a496a5e7353f6a4d1fa82a10c7a189fc6685 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 30 Jul 2018 12:39:13 +0300 Subject: [PATCH 432/605] no message --- .../channelTests/ChannelAddTests.java | 33 ++++++++++++++----- .../channelTests/ChannelDeleteTests.java | 2 +- .../client/test/utils/dbUtils/DBUtils.java | 14 -------- src/test/resources/testng.xml | 24 +++++++------- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index 0390774c9..e5c0a769e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -24,7 +24,7 @@ import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.getOpcMediaTypeId; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; @@ -32,16 +32,16 @@ public class ChannelAddTests extends BaseTest { private DynamicChannel channel; - private String channelName; - private String description; +// private String channelName; +// private String description; private Boolean isActive = true; private IntegerValue integerValue = new IntegerValue(); @BeforeClass private void channel_addTests_before_class() { - channelName = "Channel_" + getEpochInLocalTime(); - description = "description of " + channelName; + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; } @Severity(SeverityLevel.CRITICAL) @@ -52,6 +52,8 @@ private void addChannel() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); // channel/action/add @@ -72,7 +74,7 @@ private void addChannel() { private void addChannelWithAssetType() { String ksqlExpression = "name ~ 'movie'"; - int mediaTypeId = getOpcMediaTypeId(MediaType.MOVIE); + int mediaTypeId = getMediaTypeId(MediaType.MOVIE); integerValue.setValue(mediaTypeId); List assetTypes = new ArrayList<>(); assetTypes.add(integerValue); @@ -80,6 +82,8 @@ private void addChannelWithAssetType() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); // channel/action/add @@ -96,11 +100,11 @@ private void addChannelWithAssetType() { @Severity(SeverityLevel.MINOR) @Description("channel/action/add - with not supported opc partner id") - @Test + @Test(enabled = false) // no validation in channel/action/add for account 203 private void addDynamicChannelWithNotSupportedOpcPartnerId() { String ksqlExpression = "name ~ 'movie'"; - int mediaTypeId = getOpcMediaTypeId(MediaType.MOVIE); + int mediaTypeId = getMediaTypeId(MediaType.MOVIE); integerValue.setValue(mediaTypeId); List assetTypes = new ArrayList<>(); assetTypes.add(integerValue); @@ -108,6 +112,8 @@ private void addDynamicChannelWithNotSupportedOpcPartnerId() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); // channel/action/add @@ -140,6 +146,9 @@ private void checkOrderOfAssetsInChannel() { String ksqlExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.NAME_DESC); + + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); // channel/action/add @@ -168,7 +177,7 @@ private void checkOrderOfAssetsInChannel() { @Severity(SeverityLevel.NORMAL) @Description("channel/action/add - with invalid asset type - error 4028") - @Test + @Test(enabled = false) // no validation in channel/action/add for account 203 private void addChannelWithInvalidAssetType() { String ksqlExpression = "name ~ 'movie'"; @@ -179,6 +188,9 @@ private void addChannelWithInvalidAssetType() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); // channel/action/add @@ -221,6 +233,9 @@ private void addChannelWithSyntaxErrorInFilterExpression() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); + + String channelName = "Channel_" + getEpochInLocalTime(); + String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); //channel/action/add diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 0d693eec0..6ddb22da5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -50,6 +50,6 @@ private void DeleteChannel() { Response getResponse = executor.executeSync(get(channelId) .setKs(getManagerKs())); - assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4064).getCode()); + assertThat(getResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500007).getCode()); } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 818d8834d..99a9fa4f5 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -249,20 +249,6 @@ public static int getMediaTypeId(MediaType mediaType) { .getInt("id"); } - public static int getOpcMediaTypeId(MediaType mediaType) { - return getJsonArrayFromQueryResult(OPC_MEDIA_TYPE_ID_SELECT, - partnerId, - mediaType.getValue()) - .getJSONObject(0) - .getInt("id"); - } - -// public static int getVirtualMediaTypeId(MediaType mediaType) { -// return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 2, mediaType.getValue()) -// .getJSONObject(0) -// .getInt("id"); -// } - public static String getMediaFileTypeName(int mediaFileId) { return getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_ID_SELECT, partnerId + 1, mediaFileId) .getJSONObject(0) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 19df6e11b..d7fbc2d00 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -15,16 +15,16 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file From 9860620ff76ab2924201c7e3e3373e75043bb2d4 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 30 Jul 2018 14:20:40 +0300 Subject: [PATCH 433/605] no message --- .../ScheduledRecordingProgramFilterTests.java | 9 +++++---- .../com/kaltura/client/test/utils/PurchaseUtils.java | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java index 39845a6d4..9ed90fd3e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.PremiumService; import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -25,6 +24,8 @@ import static com.kaltura.client.services.RecordingService.add; import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.HouseholdUtils.createHousehold; +import static com.kaltura.client.test.utils.PurchaseUtils.purchasePpv; +import static com.kaltura.client.test.utils.PurchaseUtils.purchaseSubscription; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getSubscriptionWithPremiumService; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; @@ -47,7 +48,7 @@ private void asset_list_scheduledRecordingProgramFilter_before_class() { // purchase subscription with npvr premium service Subscription subscription = getSubscriptionWithPremiumService(PremiumService.NPVR); - PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); + purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); // get linearAsset and epg channelId JSONArray jsonArray = DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray(); @@ -58,8 +59,8 @@ private void asset_list_scheduledRecordingProgramFilter_before_class() { linearAssetId2 = linearAssetJsonObject2.getInt("media_id"); // purchase linearAsset - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(linearAssetId1), Optional.empty(), Optional.empty()); - PurchaseUtils.purchasePpv(masterUserKs, Optional.of(linearAssetId2), Optional.empty(), Optional.empty()); + purchasePpv(masterUserKs, Optional.of(linearAssetId1), Optional.empty(), Optional.empty()); + purchasePpv(masterUserKs, Optional.of(linearAssetId2), Optional.empty(), Optional.empty()); // ingest epg's EpgData epgData1 = new EpgData(linearAssetJsonObject1.getString("name")) diff --git a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java index f5f3aafb6..91fd41f39 100644 --- a/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PurchaseUtils.java @@ -3,8 +3,6 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.enums.ProductPriceOrderBy; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.AssetService.GetAssetBuilder; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; import com.kaltura.client.services.TransactionService; @@ -16,6 +14,7 @@ import java.util.Map; import java.util.Optional; +import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.test.tests.BaseTest.executor; public class PurchaseUtils { @@ -34,8 +33,8 @@ public static Response purchasePpv(String ks, Optional med if (fileId.isPresent()) { internalFileId = fileId.get(); } else { - GetAssetBuilder getAssetBuilder = AssetService.get(String.valueOf(mediaId.get()), AssetReferenceType.MEDIA).setKs(ks); - assetResponse = executor.executeSync(getAssetBuilder); + assetResponse = executor.executeSync(get(String.valueOf(mediaId.get()), AssetReferenceType.MEDIA) + .setKs(ks)); internalFileId = assetResponse.results.getMediaFiles().get(0).getId(); } From ce5822237e81056688c8369846b506140e24cf9b Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 30 Jul 2018 15:08:46 +0300 Subject: [PATCH 434/605] remove idIn from SearchAssetFilter --- .../SearchAssetFilterTests.java | 26 +++++++++++-------- .../kaltura/client/test/utils/AssetUtils.java | 5 ++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index f52523c38..45749f4ad 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.KsqlKey; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.PurchaseUtils; @@ -329,7 +330,7 @@ private void orderVodAssetsByViews() { .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) .closeOr() .toString(); - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -361,7 +362,7 @@ private void orderVodAssetsByName() { .closeOr() .toString(); - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); + assetFilter = getSearchAssetFilter(query,null, null, null, null, AssetOrderBy.NAME_ASC.getValue()); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -371,7 +372,7 @@ private void orderVodAssetsByName() { assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset3.getId()); - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); + assetFilter = getSearchAssetFilter(query,null, null, null, null, AssetOrderBy.NAME_DESC.getValue()); listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); @@ -396,7 +397,7 @@ private void orderVodAssetsByLikes() { .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) .closeOr() .toString(); - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); + assetFilter = getSearchAssetFilter(query,null, null, null, null, AssetOrderBy.LIKES_DESC.getValue()); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -422,7 +423,7 @@ private void orderVodAssetsByVotesAndRating() { .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) .closeOr() .toString(); - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, AssetOrderBy.VOTES_DESC.getValue()); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -434,7 +435,7 @@ private void orderVodAssetsByVotesAndRating() { assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); // Order by Ratings (highest to lowest) - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, AssetOrderBy.RATINGS_DESC.getValue()); listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); @@ -456,7 +457,7 @@ private void orderVodAssetsByCatalogStartDate() { .equal(MEDIA_ID.getValue(), Math.toIntExact(asset3.getId())) .closeOr() .toString(); - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, AssetOrderBy.START_DATE_DESC.getValue()); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -467,7 +468,7 @@ private void orderVodAssetsByCatalogStartDate() { assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); assertThat(assetListResponse.results.getObjects().get(2).getId()).isEqualTo(asset.getId()); - assetFilter = getSearchAssetFilter(query, null, null, null, null, null, AssetOrderBy.START_DATE_ASC.getValue()); + assetFilter = getSearchAssetFilter(query, null, null, null, null, AssetOrderBy.START_DATE_ASC.getValue()); listAssetBuilder = list(assetFilter).setKs(getSharedMasterUserKs()); assetListResponse = executor.executeSync(listAssetBuilder); @@ -495,7 +496,7 @@ private void dynamicOrderByMeta() { DynamicOrderBy dynamicOrderBy = new DynamicOrderBy(); dynamicOrderBy.setName(metaName); dynamicOrderBy.setOrderBy(MetaTagOrderBy.META_ASC); - assetFilter = getSearchAssetFilter(query, null, null, dynamicOrderBy, null, null, null); + assetFilter = getSearchAssetFilter(query, null, dynamicOrderBy, null, null, null); ListAssetBuilder listAssetBuilder = list(assetFilter) .setKs(getSharedMasterUserKs()); @@ -515,7 +516,7 @@ private void dynamicOrderByMeta() { @Test private void listEpgProgramByName() { String query = new KsqlBuilder().equal("name", program.getName()).toString(); - assetFilter = getSearchAssetFilter(query, null, "0", null, null, null, null); + assetFilter = getSearchAssetFilter(query, "0", null, null, null, null); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); @@ -546,12 +547,15 @@ private void listEpgProgramByChannelId() { @Test private void listEpgProgramsFilteredByEpgChannel() { String query = new KsqlBuilder() + .openAnd() .openOr() .equal("name", program.getName()) .equal("name", program2.getName()) .closeOr() + .equal(KsqlKey.EPG_CHANNEL_ID.getValue(), program2.getEpgChannelId().toString()) + .closeAnd() .toString(); - assetFilter = getSearchAssetFilter(query, program2.getEpgChannelId().toString(), "0", null, null, null, null); + assetFilter = getSearchAssetFilter(query, "0", null, null, null, null); Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index a2994476d..04aa890b3 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -32,11 +32,10 @@ public class AssetUtils extends BaseUtils { // TODO: 6/21/2018 Use Optional instead of nullable - public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nullable String idIn, @Nullable String typeIn, + public static SearchAssetFilter getSearchAssetFilter(@Nullable String ksql, @Nullable String typeIn, @Nullable DynamicOrderBy dynamicOrderBy, List groupBy, String name, String orderBy) { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); searchAssetFilter.setKSql(ksql); - searchAssetFilter.setIdIn(idIn); searchAssetFilter.setTypeIn(typeIn); searchAssetFilter.setDynamicOrderBy(dynamicOrderBy); searchAssetFilter.setGroupBy(groupBy); @@ -76,7 +75,7 @@ public static List getAssetFileIds(String assetId) { } public static List getAssetsByType(String typeIn) { - AssetFilter assetFilter = getSearchAssetFilter(null, null, typeIn, null, null, null, null); + AssetFilter assetFilter = getSearchAssetFilter(null, typeIn, null, null, null, null); FilterPager filterPager = new FilterPager(); filterPager.setPageSize(20); From d3c99e4fe31062e0d271fe39f5a3b532f1beabca Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 31 Jul 2018 10:56:35 +0300 Subject: [PATCH 435/605] no message --- .../AssetListTests/ChannelFilterTests.java | 5 +- src/test/resources/schemas/LiveAsset.json | 448 ++++++++++++++++++ 2 files changed, 451 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/schemas/LiveAsset.json diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index 1de381b6b..c24a5bcb4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -14,6 +14,7 @@ import org.testng.annotations.Test; import static com.kaltura.client.services.AssetService.list; +import static com.kaltura.client.test.tests.enums.KsqlKey.EPG_ID; import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.utils.AssetUtils.getAssets; import static com.kaltura.client.test.utils.AssetUtils.getPrograms; @@ -49,7 +50,7 @@ private void asset_list_channelFilter_before_class() { .equal(MEDIA_ID.getValue(), String.valueOf(asset1.getId())) .equal(MEDIA_ID.getValue(), String.valueOf(asset2.getId())) .equal(MEDIA_ID.getValue(), String.valueOf(asset3.getId())) - .equal(MEDIA_ID.getValue(), String.valueOf(program1.getId())) + .equal(EPG_ID.getValue(), String.valueOf(program1.getId())) .closeOr() .toString(); @@ -93,7 +94,7 @@ private void list_assets_with_channelFilter_by_channelId_and_ksql() { String query = new KsqlBuilder() .openOr() .equal(MEDIA_ID.getValue(), String.valueOf(asset1.getId())) - .equal(MEDIA_ID.getValue(), String.valueOf(program1.getId())) + .equal(EPG_ID.getValue(), String.valueOf(program1.getId())) .closeOr() .toString(); diff --git a/src/test/resources/schemas/LiveAsset.json b/src/test/resources/schemas/LiveAsset.json new file mode 100644 index 000000000..2586efb8c --- /dev/null +++ b/src/test/resources/schemas/LiveAsset.json @@ -0,0 +1,448 @@ +{ + "$id": "LiveAsset", + "type": "object", + "properties": { + "executionTime": { + "type": "number" + }, + "result": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "createDate": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "endDate": { + "type": "integer" + }, + "externalId": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "images": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "height": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "isDefault": { + "type": "boolean" + }, + "ratio": { + "type": "string" + }, + "url": { + "type": "string" + }, + "version": { + "type": "integer" + }, + "width": { + "type": "integer" + } + } + } + }, + "mediaFiles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "altCdnCode": { + "type": "string" + }, + "assetId": { + "type": "integer" + }, + "cdnCode": { + "type": "string" + }, + "duration": { + "type": "integer" + }, + "externalId": { + "type": "string" + }, + "fileSize": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "type": { + "type": "string" + }, + "url": { + "type": "string" + } + } + } + }, + "metas": { + "type": "object", + "properties": { + "synopsis": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "Short title": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "Runtime": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "Catchup logo URL": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "App Link": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "meta_name": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "groupBy_id": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "External program ID": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "Release year1": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "integer" + } + } + }, + "Catchup allowed": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "boolean" + } + } + }, + "testing": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "boolean" + } + } + } + } + }, + "name": { + "type": "string" + }, + "startDate": { + "type": "integer" + }, + "tags": { + "type": "object", + "properties": { + "Free": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "objects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + }, + "Genre": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "objects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + }, + "Parental Rating": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "objects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + }, + "Director": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "objects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + }, + "Country": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "objects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + }, + "Series name": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "objects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + } + }, + "required": [ + "Genre", + "Parental Rating", + "Director", + "Country", + "Series name" + ] + }, + "type": { + "type": "integer" + }, + "updateDate": { + "type": "integer" + }, + "entryId": { + "type": "string" + }, + "externalIds": { + "type": "string" + }, + "status": { + "type": "boolean" + }, + "typeDescription": { + "type": "string" + }, + "enableCatchUp": { + "type": "boolean" + }, + "enableCdvr": { + "type": "boolean" + }, + "enableRecordingPlaybackNonEntitledChannel": { + "type": "boolean" + }, + "enableStartOver": { + "type": "boolean" + }, + "catchUpBuffer": { + "type": "integer" + }, + "trickPlayBuffer": { + "type": "integer" + }, + "enableTrickPlay": { + "type": "boolean" + } + }, + "required": [ + "objectType", + "createDate", + "description", + "endDate", + "externalId", + "id", + "images", + "mediaFiles", + "metas", + "name", + "startDate", + "tags", + "type", + "updateDate", + "entryId", + "externalIds", + "status", + "typeDescription", + "enableCatchUp", + "enableCdvr", + "enableRecordingPlaybackNonEntitledChannel", + "enableStartOver", + "catchUpBuffer", + "trickPlayBuffer", + "enableTrickPlay" + ] + } + }, + "required": [ + "executionTime", + "result" + ] +} \ No newline at end of file From c742b177d3dce3bbcc740015cd765604df5e9739 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 31 Jul 2018 12:24:08 +0300 Subject: [PATCH 436/605] no message --- .../AssetHistoryCleanTests.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 819eadb20..26b42ce00 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -42,8 +42,7 @@ public class AssetHistoryCleanTests extends BaseTest { @BeforeClass - // TODO: 5/3/2018 change before method name - private void clean_tests_before_class() { + private void assetHistory_clean_tests_before_class() { List movies = getAssets(2, MOVIE); // get first movie asset @@ -113,15 +112,15 @@ private void cleanSpecifcAssetHistory() { String masterUserKs = getHouseholdMasterUserKs(household, udid1); // Bookmark first asset - Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); - executor.executeSync(addBookmarkBuilder); + Bookmark bookmark1 = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + executor.executeSync(add(bookmark1) + .setKs(masterUserKs)); // Bookmark second asset - bookmark = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); + Bookmark bookmark2 = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); - executor.executeSync(addBookmarkBuilder); + executor.executeSync(add(bookmark2) + .setKs(masterUserKs)); // assetHistory/action/clean AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -132,8 +131,8 @@ private void cleanSpecifcAssetHistory() { cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); - // Update assetHistoryFilter object (assetIdIn = null) - assetHistoryFilter.setAssetIdIn(null); + // Update assetHistoryFilter object (assetIdIn = "") + assetHistoryFilter.setAssetIdIn(""); // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) @@ -157,14 +156,14 @@ private void cleanSpecifcAssetTypeHistory() { // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); - executor.executeSync(addBookmarkBuilder); + executor.executeSync(add(bookmark) + .setKs(masterUserKs)); // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); - executor.executeSync(addBookmarkBuilder); + executor.executeSync(add(bookmark) + .setKs(masterUserKs)); //assetHistory/action/clean - only episode type (episode) AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -175,8 +174,8 @@ private void cleanSpecifcAssetTypeHistory() { cleanAssetHistoryBuilder.setKs(masterUserKs); executor.executeSync(cleanAssetHistoryBuilder); - // Update assetHistoryFilter object (assetIdIn = null) - assetHistoryFilter.setTypeIn(null); + // Update assetHistoryFilter object (assetIdIn = "") + assetHistoryFilter.setTypeIn(""); // assetHistory/action/list - after clean - only movie returned (was not cleaned) Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) From f9cb9bab4fd1ff5968f01e294bff55864c2bb5aa Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 1 Aug 2018 10:03:08 +0300 Subject: [PATCH 437/605] local changes commited --- .../test/TestAPIOkRequestsExecutor.java | 24 ++++++ .../kaltura/client/test/tests/BaseTest.java | 86 ++++++++++++++++++- .../test/utils/dbUtils/DBConstants.java | 1 + .../client/test/utils/dbUtils/DBUtils.java | 6 ++ 4 files changed, 115 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index b242091d7..4fb1312b2 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -1,6 +1,8 @@ package com.kaltura.client.test; import com.google.common.primitives.Ints; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; @@ -11,6 +13,7 @@ import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; import com.kaltura.client.utils.response.base.ResponseElement; +import org.apache.commons.lang3.StringUtils; import java.io.*; import java.util.concurrent.atomic.AtomicBoolean; @@ -18,6 +21,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.LOG_HEADERS; import static com.kaltura.client.test.tests.BaseTest.client; +import static com.kaltura.client.test.tests.BaseTest.objectType2JsonValidationSchemaFile4Lists; import static com.kaltura.client.utils.ErrorElement.*; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; @@ -79,9 +83,20 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request listResponse.results.getTotalCount() > MAX_OBJECTS_AT_LIST_RESPONSE) { return responseElement; } + /* TODO: COMPLETE PART OF MAX TASK RELATED JSON VALIDATION + //choose proper json validation schema by object type from response + String objectType = getObjectType(responseElement.getResponse()); + if (StringUtils.isNotEmpty(objectType)) { + s2 = objectType2JsonValidationSchemaFile4Lists.get(objectType); + s3 = ""; + } else { + logger.error("objectType in list wasn't recognized"); + return responseElement; + }*/ } String schema = s1 + s2 + s3; + // TODO: COMPLETE PART OF MAX TASK RELATED JSON VALIDATION Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(schema + " schema"); Logger.getLogger(TestAPIOkRequestsExecutor.class).debug(s2 + " schema"); /*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); Date date = new Date(); @@ -100,6 +115,15 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request return responseElement; } + /* TODO: COMPLETE PART OF MAX TASK RELATED JSON VALIDATION + private String getObjectType(String response) { + JsonParser jsonParser = new JsonParser(); + JsonElement objectType = jsonParser.parse(response) + .getAsJsonObject().get("result") + .getAsJsonObject().get("objectType"); + return objectType.getAsString(); + }*/ + private void write2LogFile(String serviceMethod, String kalturaSession) { try(FileWriter fw = new FileWriter(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(REGRESSION_LOGS_LOCAL_FILE), true); diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 6a1f16f14..9e21aa4ae 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -1,6 +1,10 @@ package com.kaltura.client.test.tests; import com.google.common.base.Verify; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; @@ -17,12 +21,19 @@ import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; +import org.json.JSONObject; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; + +import java.io.*; import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; + import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; @@ -48,6 +59,7 @@ public class BaseTest { public static Client client; public static Configuration config; public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); + public static Map objectType2JsonValidationSchemaFile4Lists = new HashMap<>(); private static Response loginResponse; @@ -379,9 +391,10 @@ public static MediaFile getSharedMobileMediaFile() { return mobileMediaFile; } - public static MediaFile getMediaFileByType(MediaAsset asset, String type) { + public static MediaFile getMediaFileByType(MediaAsset asset, String fileType) { MediaFile result; - if (type.equals(asset.getMediaFiles().get(0).getType())) { + int fileTypeId = asset.getMediaFiles().get(0).getTypeId(); + if (fileType.equals(DBUtils.getMediaFileTypeName(fileTypeId))) { result = mediaAsset.getMediaFiles().get(0); } else { result = mediaAsset.getMediaFiles().get(1); @@ -567,5 +580,74 @@ public void setupSuite() { getProperty(CODE_PERFORMANCE_REPORT_FILE); deleteFile(codePerformanceReportFileName); } + /* TODO: COMPLETE PART OF MAX TASK RELATED JSON VALIDATION + // it was found that json validation schema having more than 10 $ref objects can't validate referenced objects properly + // to handle it instead of one common OLDListResponse.json schema we created ListResponse1.json, ListResponse2.json etc + // based on object type from response we have to find from Map what of json validation file is correct + // below is logic that allow to prepare data for finding proper json validation schema file + objectType2JsonValidationSchemaFile4Lists = collectDataAboutJsonValidationSchemasForLists();*/ + } + + /* TODO: COMPLETE PART OF MAX TASK RELATED JSON VALIDATION + private Map collectDataAboutJsonValidationSchemasForLists() { + Map result = new HashMap<>(); + String folder = "src/test/resources/schemas/"; + List listSchemasFileNames = loadListSchemasFileNames(folder); + for (String fileName: listSchemasFileNames) { + result.putAll(loadSupportedObjectTypesIn(fileName, folder)); + } + + return result; } + + // to fill map by values "objectType": "jsonSchemaFileName" + private Map loadSupportedObjectTypesIn(String jsonSchemaFileName, String folder) { + Map result = new HashMap<>(); + File file = new File(folder + jsonSchemaFileName); + String path = file.getAbsolutePath(); + try { + // read schema validation file content + BufferedReader bufferedReader = new BufferedReader(new FileReader(path)); + StringBuilder stringBuilder = new StringBuilder(); + try(BufferedReader br = Files.newBufferedReader(Paths.get(path))) { + Stream lines = br.lines(); + lines.forEach(stringBuilder::append); + lines.close(); + } catch (IOException e) { + e.printStackTrace(); + } + JSONObject jsonObject = new JSONObject(stringBuilder.toString()); + JsonParser jsonParser = new JsonParser(); + // get object type enums + JsonArray objectTypes = jsonParser.parse(jsonObject.toString()) + .getAsJsonObject().get("properties") + .getAsJsonObject().get("result") + .getAsJsonObject().get("properties") + .getAsJsonObject().get("objectType") + .getAsJsonObject().getAsJsonArray("enum"); + for (JsonElement objectType: objectTypes) { + result.put(objectType.getAsString(), jsonSchemaFileName); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + return result; + } + + private List loadListSchemasFileNames(String folder) { + List result = new ArrayList<>(); + File dir = new File(folder); + File [] files = dir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.startsWith("ListResponse"); + } + }); + + for (File jsonSchemaFile: files) { + result.add(jsonSchemaFile.getName()); + } + return result; + }*/ } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index f22f8d1e4..b287ac53d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -210,6 +210,7 @@ public class DBConstants { static final String MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where GROUP_ID = ? and name = ?"; + static final String MEDIA_FILE_TYPE_ID_SELECT = "SELECT [NAME] FROM [TVinci].[dbo].[groups_media_type] where GROUP_ID = ? and ID = ?"; // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 58957a3a0..83bea4398 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -317,4 +317,10 @@ public static int getVirtualMediaTypeId(MediaType mediaType) { .getJSONObject(0) .getInt("id"); } + + public static int getMediaFileTypeName(int mediaFileId) { + return getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_ID_SELECT, partnerId + 1, mediaFileId) + .getJSONObject(0) + .getInt("name"); + } } From 5272941620ed6739803adb8cc3cef50374317299 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 1 Aug 2018 11:02:48 +0300 Subject: [PATCH 438/605] no message --- pom.xml | 6 ++ .../AssetListTests/BundleFilterTests.java | 6 +- .../AnnouncementAddTest.java | 26 +++++++ .../appTokenTests/AppTokenAddTests.java | 10 ++- .../appTokenTests/AppTokenGetTests.java | 4 + .../AppTokenStartSessionTests.java | 5 ++ .../householdTests/HouseholdSuspendTests.java | 24 +++--- .../kaltura/client/test/utils/EmailUtils.java | 73 +++++++++++++++++++ 8 files changed, 138 insertions(+), 16 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java create mode 100644 src/test/java/com/kaltura/client/test/utils/EmailUtils.java diff --git a/pom.xml b/pom.xml index 24ae8be5a..78dd65bc7 100644 --- a/pom.xml +++ b/pom.xml @@ -228,6 +228,12 @@ provided + + com.sun.mail + javax.mail + 1.6.0 + + diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index bf425eb78..a5d1126b5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -167,7 +167,9 @@ private void list_assets_with_bundleFilter_collection_by_idEqual_and_typeIn() { // get full list List assets = executor.executeSync(list(filter) - .setKs(getAnonymousKs())).results.getObjects(); + .setKs(getAnonymousKs())) + .results + .getObjects(); Asset movie = null; for (Asset asset : assets) { @@ -178,7 +180,7 @@ private void list_assets_with_bundleFilter_collection_by_idEqual_and_typeIn() { } if (movie == null){ - fail("missing movie asset in channel related to the provided collection"); + fail("Please add movie asset into the channel related to the provided collection"); } // get movies list diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java new file mode 100644 index 000000000..f0a2903ef --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java @@ -0,0 +1,26 @@ +package com.kaltura.client.test.tests.servicesTests.announcementTests; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.Announcement; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AnnouncementAddTest extends BaseTest { + + @BeforeClass + private void announcement_add_tests_before_class() { + + } + + @Severity(SeverityLevel.CRITICAL) + @Description("announcement/action/add") + @Test + private void addAnnouncement() { + Announcement announcement = new Announcement(); +// announcement.set +// AnnouncementService.add().setKs(getOperatorKs()); + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 3fa2291c6..4841e5842 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -9,6 +9,8 @@ import com.kaltura.client.types.AppToken; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -36,10 +38,10 @@ private void add_tests_before_class() { appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA1, null, null); } + @Severity(SeverityLevel.CRITICAL) @Description("appToken/action/add") @Test private void addAppToken() { - AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) .setKs(getOperatorKs()); Response appTokenResponse = executor.executeSync(addAppTokenBuilder); @@ -56,6 +58,7 @@ private void addAppToken() { assertThat(appTokenResponse.results.getSessionUserId()).isEqualTo(String.valueOf(sessionUserId)); } + @Severity(SeverityLevel.CRITICAL) @Description("appToken/action/add - without hash type") @Test private void addAppTokenWithDefaultHashType() { @@ -70,6 +73,7 @@ private void addAppTokenWithDefaultHashType() { assertThat(appTokenResponse.results.getHashType()).isEqualTo(AppTokenHashType.SHA256); } + @Severity(SeverityLevel.CRITICAL) @Description("appToken/action/add - with privileges") @Test private void addAppTokenWithPrivileges() { @@ -83,8 +87,8 @@ private void addAppTokenWithPrivileges() { assertThat(appTokenResponse.results.getSessionPrivileges()).isEqualTo(sessionPrivileges); } - // priority needed, because at parralel execution both test threads launch setup method of this class and this cause to Error 1 at login with operator user. @Description("appToken/action/add - with expiry date") + // priority needed, because at parralel execution both test threads launch setup method of this class and this cause to Error 1 at login with operator user. @Test(groups = "slow_before", priority = 1) private void addAppTokenWithExpiryDate_before() { // setup for test @@ -123,6 +127,7 @@ private void addAppTokenWithExpiryDate_after() { assertThat(apiException.getCode()).isEqualTo(getAPIExceptionFromList(500055).getCode()); } + @Severity(SeverityLevel.CRITICAL) @Description("appToken/action/add - with no expiry date (return default expiry date -" + "According to app_token_max_expiry_seconds key value in group_203 CB document") @Test @@ -140,6 +145,7 @@ private void addAppTokenWithNoExpiryDate() { assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(BaseUtils.getEpochInLocalTime(0))); } + @Severity(SeverityLevel.CRITICAL) @Description("appToken/action/add - with no specific user id") @Test private void addAppTokenWithoutSpecificUserId() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index a5ce14cd5..c96e88c49 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -8,6 +8,8 @@ import com.kaltura.client.types.AppToken; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -31,6 +33,7 @@ private void get_tests_before_class() { expiryDate = BaseUtils.getEpochInLocalTime(offSetInMinutes); } + @Severity(SeverityLevel.CRITICAL) @Description("AppToken/action/get") @Test private void getAppToken() { @@ -54,6 +57,7 @@ private void getAppToken() { assertThat(getAppTokenResponse.results.getSessionUserId()).isEqualTo(sessionUserId); } + @Severity(SeverityLevel.MINOR) @Description("AppToken/action/get") @Test // TODO: 5/3/2018 use underscore in test method names and edit the description diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index e283691e8..71c9b01da 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -11,6 +11,8 @@ import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Issue; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -42,6 +44,7 @@ private void add_tests_before_class() { expiryDate = BaseUtils.getEpochInLocalTime(1); } + @Severity(SeverityLevel.CRITICAL) @Description("appToken/action/startSession - SHA1") @Test private void startSessionSha1() { @@ -85,6 +88,7 @@ private void startSessionSha1() { } + @Severity(SeverityLevel.CRITICAL) @Description("appToken/action/startSession - SHA256") @Test private void startSessionSha256() { @@ -125,6 +129,7 @@ private void startSessionSha256() { // TODO - Add session/action/get request with ks received from startSession API } + @Severity(SeverityLevel.CRITICAL) @Issue("BEO-4980") @Description("appToken/action/startSession - token id with default expiry date (according to the value in group_203 CB document") @Test(enabled = false) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 77cc7757e..cba1d6312 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -29,8 +29,8 @@ public class HouseholdSuspendTests extends BaseTest { - private final int numberOfUsersInHousehold = 2; - private final int numberOfDevicesInHousehold = 1; + private final int numOfUsers = 2; + private final int numOfDevices = 1; private Subscription subscription; private Asset asset; @@ -69,7 +69,7 @@ private void household_suspendTests_beforeClass() { @Test private void suspend() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // suspend household @@ -94,7 +94,7 @@ private void suspend() { @Test private void suspend_with_masterUser_ks() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs @@ -116,7 +116,7 @@ private void suspend_with_masterUser_ks() { @Test private void suspend_with_login_role() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // create role @@ -154,7 +154,7 @@ private void suspend_with_login_role() { @Test private void suspend_with_purchase_subscription_role() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs @@ -209,7 +209,7 @@ private void suspend_with_purchase_subscription_role() { @Test private void suspend_with_cancel_subscription_role() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs @@ -256,7 +256,7 @@ private void suspend_with_cancel_subscription_role() { @Test private void suspend_with_playback_subscription_role() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs @@ -308,7 +308,7 @@ private void suspend_with_playback_subscription_role() { @Test private void suspend_with_purchase_ppv_role() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs @@ -358,7 +358,7 @@ private void suspend_with_purchase_ppv_role() { @Test private void suspend_with_playback_ppv_role() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs @@ -419,7 +419,7 @@ private void suspend_with_renew_subscription_role_before_wait() { household_suspendTests_beforeClass(); // set household - householdSlowTest = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + householdSlowTest = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(householdSlowTest); // set masterUserKs @@ -511,7 +511,7 @@ private void suspend_with_renew_subscription_role_after_wait() { @Test(enabled = true) private void suspend_with_purchase_service_role() { // set household - Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + Household household = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(household); // set masterUserKs diff --git a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java new file mode 100644 index 000000000..904e039e4 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java @@ -0,0 +1,73 @@ +package com.kaltura.client.test.utils; + + +import javax.mail.*; +import javax.mail.search.SearchTerm; +import java.util.Properties; + +public class EmailUtils extends BaseUtils { + + private static final String username = "alonbasin.kaltura@gmail.com"; + private static final String password = "aloNisab2986!"; + + + public static void searchEmail(final String keyword) { + Properties properties = new Properties(); + + // server setting + properties.put("mail.imap.host", "imap.gmail.com"); + properties.put("mail.imap.port", "993"); + + // SSL setting + properties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); + properties.setProperty("mail.imap.socketFactory.fallback", "false"); + properties.setProperty("mail.imap.socketFactory.port", "993"); + + Session session = Session.getDefaultInstance(properties); + + try { + // connects to the message store + Store store = session.getStore("imap"); + store.connect(username, password); + + // opens the inbox folder + Folder folderInbox = store.getFolder("INBOX"); + folderInbox.open(Folder.READ_ONLY); + + // creates a search criterion + SearchTerm searchCondition = new SearchTerm() { + @Override + public boolean match(Message message) { + try { + if (message.getSubject().contains(keyword)) { + return true; + } + } catch (MessagingException ex) { + ex.printStackTrace(); + } + return false; + } + }; + + // performs search through the folder + Message[] foundMessages = folderInbox.search(searchCondition); + + for (int i = 0; i < foundMessages.length; i++) { + Message message = foundMessages[i]; + String subject = message.getSubject(); + System.out.println("Found message #" + i + ": " + subject); + } + + // disconnect + folderInbox.close(false); + store.close(); + } catch (NoSuchProviderException ex) { + System.out.println("No provider."); + ex.printStackTrace(); + } catch (MessagingException ex) { + System.out.println("Could not connect to the message store."); + ex.printStackTrace(); + } + } + +} From 613df0d8e9d899c0d27864786eeedbf0b7e04c7a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 1 Aug 2018 12:16:59 +0300 Subject: [PATCH 439/605] no message --- .../householdTests/HouseholdSuspendTests.java | 12 +++++++- .../kaltura/client/test/utils/AssetUtils.java | 30 ++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index cba1d6312..157ddad4f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -15,6 +15,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; import java.util.Optional; import java.util.concurrent.TimeUnit; @@ -61,7 +62,8 @@ private void household_suspendTests_beforeClass() { fiveMinRenewSubscriptionSlowTest = get5MinRenewableSubscription(); // set asset - asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty(), false).get(0); + List assets = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(subscription.getId()), Optional.empty(), false); + asset = AssetUtils.getAssetByPurchaeStatus(assets, PurchaseStatus.FOR_PURCHASE); } @Severity(SeverityLevel.CRITICAL) @@ -121,6 +123,7 @@ private void suspend_with_login_role() { // create role UserRole role = new UserRole(); +// role.setPermissionNames(""); role.setExcludedPermissionNames(Permissions.LOGIN.name()); role.setName(Permissions.LOGIN.name()); @@ -163,6 +166,7 @@ private void suspend_with_purchase_subscription_role() { // create role UserRole role = new UserRole(); +// role.setPermissionNames(""); role.setExcludedPermissionNames(Permissions.PURCHASE_SUBSCRIPTION.name()); role.setName(Permissions.PURCHASE_SUBSCRIPTION.name()); @@ -218,6 +222,7 @@ private void suspend_with_cancel_subscription_role() { // create role UserRole role = new UserRole(); +// role.setPermissionNames(""); role.setExcludedPermissionNames(Permissions.CANCEL_SUBSCRIPTION.name()); role.setName(Permissions.CANCEL_SUBSCRIPTION.name()); @@ -265,6 +270,7 @@ private void suspend_with_playback_subscription_role() { // create role UserRole role = new UserRole(); +// role.setPermissionNames(""); role.setExcludedPermissionNames(Permissions.PLAYBACK_SUBSCRIPTION.name()); role.setName(Permissions.PLAYBACK_SUBSCRIPTION.name()); @@ -317,6 +323,7 @@ private void suspend_with_purchase_ppv_role() { // create role UserRole role = new UserRole(); +// role.setPermissionNames(""); role.setExcludedPermissionNames(Permissions.PURCHASE_PPV.name()); role.setName(Permissions.PURCHASE_PPV.name()); @@ -367,6 +374,7 @@ private void suspend_with_playback_ppv_role() { // create role UserRole role = new UserRole(); +// role.setPermissionNames(""); role.setExcludedPermissionNames(Permissions.PLAYBACK_PPV.name()); role.setName(Permissions.PLAYBACK_PPV.name()); @@ -428,6 +436,7 @@ private void suspend_with_renew_subscription_role_before_wait() { // create role roleSlowTest = new UserRole(); + roleSlowTest.setPermissionNames(""); roleSlowTest.setExcludedPermissionNames(Permissions.RENEW_SUBSCRIPTION.name()); roleSlowTest.setName(Permissions.RENEW_SUBSCRIPTION.name()); @@ -520,6 +529,7 @@ private void suspend_with_purchase_service_role() { // create role UserRole role = new UserRole(); +// role.setPermissionNames(""); role.setExcludedPermissionNames(Permissions.PURCHASE_SERVICE.name()); role.setName(Permissions.PURCHASE_SERVICE.name()); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 04aa890b3..4ad328bc7 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -1,12 +1,10 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Logger; -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.SocialActionType; +import com.kaltura.client.enums.*; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.BookmarkService; +import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.services.SocialActionService; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.types.*; @@ -27,6 +25,7 @@ import static com.kaltura.client.test.tests.enums.KsqlKey.ASSET_TYPE; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; public class AssetUtils extends BaseUtils { @@ -186,6 +185,29 @@ public static List getPrograms(int numOfAssets) { .setKs(getOperatorKs())).results.getObjects(); } + public static Asset getAssetByPurchaeStatus(List assets, PurchaseStatus purchaseStatus) { + Asset asset = null; + ProductPriceFilter filter = new ProductPriceFilter(); + + for (Asset a : assets) { + filter.setFileIdIn(String.valueOf(a.getMediaFiles().get(0).getId())); + ProductPrice productPrice = executor.executeSync(ProductPriceService.list(filter) + .setKs(getOperatorKs())) + .results.getObjects().get(0); + + if (productPrice.getPurchaseStatus().equals(purchaseStatus)) { + asset = a; + break; + } + } + + if (asset == null) { + fail("No asset in the provided status in assets list"); + } + + return asset; + } + public static String getCoguid(Asset asset) { // TODO: 7/1/2018 finsih util return null; From 1f3d8d23f1d345ae19e3d12abea8d944821ea2bd Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 5 Aug 2018 13:32:04 +0300 Subject: [PATCH 440/605] add emailUtils --- pom.xml | 21 ++- .../householdTests/HouseholdSuspendTests.java | 4 +- .../kaltura/client/test/utils/EmailUtils.java | 170 ++++++++++++++---- 3 files changed, 149 insertions(+), 46 deletions(-) diff --git a/pom.xml b/pom.xml index bb19c3833..c66d557f8 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 4.0.0 com.kaltura KalturaOttApiClient - 5.0.1.43116-SNAPSHOT + 4.9.10.22390-SNAPSHOT jar @@ -134,13 +134,20 @@ + + com.sun.mail + javax.mail + 1.6.1 + test + + junit junit 4.12 test - - + + org.testng testng @@ -227,14 +234,6 @@ 1.18.0 provided - - - com.sun.mail - javax.mail - 1.6.0 - - - diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 157ddad4f..a5a445c27 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -298,9 +298,9 @@ private void suspend_with_playback_subscription_role() { .setKs(masterUserKs); Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); - assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); + assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); // cleanup - delete role executor.executeSync(UserRoleService.delete(role.getId()).setKs(getOperatorKs())); @@ -403,9 +403,9 @@ private void suspend_with_playback_ppv_role() { .setKs(masterUserKs); Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); - assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); assertThat(playbackContextResponse.results.getMessages().get(0).getMessage()).isEqualTo("Not entitled"); assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("NotEntitled"); + assertThat(playbackContextResponse.results.getActions().get(0).getType()).isEqualTo(RuleActionType.BLOCK); // purchase subscription in order to verify suspend is specific to role Response transactionResponse = PurchaseUtils.purchaseSubscription(masterUserKs, Integer.parseInt(subscription.getId()), Optional.empty()); diff --git a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java index 904e039e4..d9fd9f6e0 100644 --- a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java @@ -3,36 +3,34 @@ import javax.mail.*; import javax.mail.search.SearchTerm; +import java.io.IOException; import java.util.Properties; public class EmailUtils extends BaseUtils { - private static final String username = "alonbasin.kaltura@gmail.com"; - private static final String password = "aloNisab2986!"; + private static final String username = "alonbasin.kaltura@gmail.com"; + private static final String password = "ottbeqa2018"; - - public static void searchEmail(final String keyword) { - Properties properties = new Properties(); + public static boolean isEmailReceived(final String keyword, boolean isClean) { + boolean isReceived = false; // server setting - properties.put("mail.imap.host", "imap.gmail.com"); - properties.put("mail.imap.port", "993"); + Properties props = System.getProperties(); + props.setProperty("mail.store.protocol", "imaps"); - // SSL setting - properties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); - properties.setProperty("mail.imap.socketFactory.fallback", "false"); - properties.setProperty("mail.imap.socketFactory.port", "993"); - - Session session = Session.getDefaultInstance(properties); + Session session = Session.getDefaultInstance(props); + Folder inbox = null; + Store store = null; + Folder trash = null; try { // connects to the message store - Store store = session.getStore("imap"); - store.connect(username, password); + store = session.getStore("imaps"); + store.connect("imap.gmail.com", username, password); // opens the inbox folder - Folder folderInbox = store.getFolder("INBOX"); - folderInbox.open(Folder.READ_ONLY); + inbox = store.getFolder("INBOX"); + inbox.open(Folder.READ_ONLY); // creates a search criterion SearchTerm searchCondition = new SearchTerm() { @@ -49,25 +47,131 @@ public boolean match(Message message) { } }; - // performs search through the folder - Message[] foundMessages = folderInbox.search(searchCondition); - - for (int i = 0; i < foundMessages.length; i++) { - Message message = foundMessages[i]; - String subject = message.getSubject(); - System.out.println("Found message #" + i + ": " + subject); + Message[] foundMessages = inbox.search(searchCondition); + System.out.println(foundMessages.length); + if (foundMessages.length > 0) { + isReceived = true; } - // disconnect - folderInbox.close(false); - store.close(); - } catch (NoSuchProviderException ex) { - System.out.println("No provider."); - ex.printStackTrace(); - } catch (MessagingException ex) { - System.out.println("Could not connect to the message store."); - ex.printStackTrace(); + Message message[] = inbox.getMessages(); + System.out.println(message.length); +// for (Message aMessage : message) { +// System.out.println(aMessage.getSubject()); +// } + + } catch (MessagingException e) { + e.printStackTrace(); + } finally { + try { + if (inbox != null) { + inbox.close(true); + } + } catch (MessagingException e) { + e.printStackTrace(); + } + try { + if (store != null) { + store.close(); + } + } catch (MessagingException e) { + e.printStackTrace(); + } } + return isReceived; } + public static void searchEmail(final String keyword) { + Properties properties = new Properties(); + +// props.setProperty("mail.imaps.host", "imap.gmail.com"); +// props.setProperty("mail.imaps.user", username); +// props.setProperty("mail.imaps.password", password); +// props.setProperty("mail.imaps.port", "993"); +// props.setProperty("mail.imaps.auth", "true"); +// props.setProperty("mail.debug", "true"); + + // server setting + properties.put("mail.imap.host", "imap.gmail.com"); + properties.put("mail.imap.port", "993"); + + // SSL setting + properties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); + properties.setProperty("mail.imap.socketFactory.fallback", "false"); + properties.setProperty("mail.imap.socketFactory.port", "993"); + properties.setProperty("mail.store.protocol", "imaps"); + properties.setProperty("mail.debug", "true"); + +// props.put("mail.smtp.host", "smtp.gmail.com"); +// props.put("mail.smtp.socketFactory.port","465"); +// props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory"); +// props.put("mail.smtp.auth","true"); +// props.put("mail.smtp.port","465"); +// props.setProperty("mail.debug", "true"); + + Store store = null; + Folder inbox = null; + Folder trash = null; + + try { + Session session = Session.getInstance(properties); + store = session.getStore("imaps"); + store.connect("imap.gmail.com", username, password); + System.out.println("Connections is opened"); + + trash = store.getFolder("[Gmail]/Trash"); + trash.open(Folder.READ_WRITE); + + inbox = store.getFolder("INBOX"); + inbox.open(Folder.READ_WRITE); + + int messageCount = inbox.getMessageCount(); + //log.info("Total Messages: " + messageCount); + Message[] messages = inbox.getMessages(); + Message[] messages2Remove = new Message[1]; + + boolean isMessageFound = false; + for (int i = 0; i < messageCount; i++) { + + if (messages[i].getContentType().toLowerCase().startsWith("text")) { + if (messages[i].getContent().toString().contains(keyword)) { + isMessageFound = true; + messages2Remove[0] = messages[i]; + break; + } + } else if (messages[i].getContentType().toLowerCase().startsWith("multipart")) { + Multipart multipart = (Multipart) messages[i].getContent(); + for (int j = 0; j < multipart.getCount(); j++) { + if (((Multipart) messages[i].getContent()).getBodyPart(j).getContent().toString().contains(keyword)) { + isMessageFound = true; + messages2Remove[0] = messages[i]; + break; + } + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } catch (NoSuchProviderException e) { + e.printStackTrace(); + } catch (MessagingException e) { + e.printStackTrace(); + } finally { + try { + inbox.close(true); // to close folder + } catch (MessagingException e) { + e.printStackTrace(); + } + try { + trash.close(true); // to close folder + } catch (MessagingException e) { + e.printStackTrace(); + } + try { + store.close(); // to close connection + } catch (MessagingException e) { + e.printStackTrace(); + } + //log.info("Connections is closed") + } + } } From 8c9863c29e3f19d4f03abf1b362767a76de62e7f Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 5 Aug 2018 13:38:46 +0300 Subject: [PATCH 441/605] no message --- pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 32f12ec5e..fd4cfc66c 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,14 @@ - + + com.sun.mail + javax.mail + 1.6.1 + test + + + junit junit 4.12 From 11b50e8a67d56a837305e9f86b5a012e4d13f411 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 5 Aug 2018 14:01:40 +0300 Subject: [PATCH 442/605] update pom --- pom.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pom.xml b/pom.xml index fd4cfc66c..0378acda3 100644 --- a/pom.xml +++ b/pom.xml @@ -208,6 +208,35 @@ com.fasterxml.jackson.core jackson-databind 2.9.5 + test + + + + com.google.guava + guava + 25.0-jre + test + + + + commons-dbutils + commons-dbutils + 1.7 + test + + + + org.apache.commons + commons-vfs2 + 2.2 + test + + + + org.projectlombok + lombok + 1.18.0 + provided From 9c52c32b3cc01bc44f45830f15f6a0a2c1a80d18 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Sun, 5 Aug 2018 15:39:24 +0300 Subject: [PATCH 443/605] Refactored "addViewToAsset" util --- .../kaltura/client/test/utils/AssetUtils.java | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 04aa890b3..6bcf9d22a 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -1,10 +1,7 @@ package com.kaltura.client.test.utils; import com.kaltura.client.Logger; -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.SocialActionType; +import com.kaltura.client.enums.*; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.SocialActionService; @@ -19,11 +16,13 @@ import static com.kaltura.client.services.AssetService.*; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; +import static com.kaltura.client.services.BookmarkService.add; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.SocialActionService.AddSocialActionBuilder; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.executor; import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; +import static com.kaltura.client.test.tests.BaseTest.getSharedCommonSubscription; import static com.kaltura.client.test.tests.enums.KsqlKey.ASSET_TYPE; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; @@ -89,34 +88,31 @@ public static List getAssetsByType(String typeIn) { } // TODO - need to make util more efficient (creating too many HH) - public static void addViewsToAsset(Long assetId, int numOfActions, AssetType assetType) { - if (numOfActions <= 0) { - Logger.getLogger("Value must be equal or greater than 0"); - } else { - for (int i = 0; i < numOfActions; i++) { - int j = 1; - Household household = HouseholdUtils.createHousehold(j, j, false); - HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); - - Bookmark bookmark = BookmarkUtils.addBookmark( - 0, - String.valueOf(assetId), - AssetUtils.getAssetFileIds(String.valueOf(assetId)).get(0), - assetType, - BookmarkActionType.FIRST_PLAY - ); - - AddBookmarkBuilder bookmarkBuilder = BookmarkService.add(bookmark) - .setKs(getOperatorKs()) - .setUserId(Integer.valueOf(householdUser.getUserId())); - executor.executeSync(bookmarkBuilder); - - // cleanup - delete household - executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getOperatorKs())); - } - } + public static void addViewToAsset(Asset asset, AssetType assetType) { + //Create HH with 1 user and 1 device + Household household = HouseholdUtils.createHousehold(1, 1, true); + HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); + + // Login user + String ks = OttUserUtils.getKs(Integer.parseInt(householdUser.getUserId())); + + // Purchase PPV (to allow bookmark + PurchaseUtils.purchasePpv(ks,Optional.of(Math.toIntExact(asset.getId())),Optional.empty(),Optional.empty()); + PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); + playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); + + //asset/action/getPlaybackContext + AssetService.getPlaybackContext(String.valueOf(asset.getId()),assetType, playbackContextOptions) + .setKs(ks); + Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(asset.getId()), asset.getMediaFiles().get(0).getId(), assetType, BookmarkActionType.FIRST_PLAY); + + //bookmark/action/add + AddBookmarkBuilder addBookmarkBuilder = add(bookmark) + .setKs(getSharedMasterUserKs()); + executor.executeSync(addBookmarkBuilder); } + public static void addLikesToAsset(Long assetId, int numOfActions, AssetType assetType) { if (numOfActions <= 0) { Logger.getLogger("Value must be equal or greater than 0"); From 36c845d807e03c0ec5ee496bb27942fa99b37034 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Sun, 5 Aug 2018 15:40:19 +0300 Subject: [PATCH 444/605] Fixed test class - "orderVodAssetsByViews" --- .../SearchAssetFilterTests.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 45749f4ad..7550b0f9f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -3,11 +3,11 @@ import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; +import com.kaltura.client.enums.PlaybackContextType; +import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.KsqlKey; -import com.kaltura.client.test.utils.HouseholdUtils; -import com.kaltura.client.test.utils.KsqlBuilder; -import com.kaltura.client.test.utils.PurchaseUtils; +import com.kaltura.client.test.utils.*; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -319,9 +319,25 @@ private void listVodAssetsFilteredByType() { @Description("asset/action/list - VOD - order by VIEWS") @Test private void orderVodAssetsByViews() { - addViewsToAsset(asset.getId(), 3, AssetType.MEDIA); - addViewsToAsset(asset2.getId(), 2, AssetType.MEDIA); - addViewsToAsset(asset3.getId(), 1, AssetType.MEDIA); + + int numOfActionsAsset = 3; + int numOfActionsAsset2 = 2; + int numOfActionsAsset3 = 1; + + // Add 3 views to asset + for (int i = 0; i < numOfActionsAsset; i++) { + addViewToAsset(asset, AssetType.MEDIA); + } + + // Add 2 views to asset2 + for (int i = 0; i < numOfActionsAsset2; i++) { + addViewToAsset(asset2, AssetType.MEDIA); + } + + // Add 1 view to asset3 + for (int i = 0; i < numOfActionsAsset3; i++) { + addViewToAsset(asset3, AssetType.MEDIA); + } String query = new KsqlBuilder() .openOr() From 64113084816ac28031d32806ffb11119fabd4b8e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 5 Aug 2018 17:32:55 +0300 Subject: [PATCH 445/605] fix emailUtils --- .../AnnouncementAddTest.java | 61 ++++++++++++- .../kaltura/client/test/utils/BaseUtils.java | 13 +-- .../kaltura/client/test/utils/EmailUtils.java | 47 +++++----- src/test/resources/WORK_PLAN.md | 2 +- src/test/resources/schemas/Announcement.json | 88 +++++++++++++++++++ 5 files changed, 179 insertions(+), 32 deletions(-) create mode 100644 src/test/resources/schemas/Announcement.json diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java index f0a2903ef..5b24a2081 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java @@ -1,13 +1,26 @@ package com.kaltura.client.test.tests.servicesTests.announcementTests; +import com.kaltura.client.enums.AnnouncementRecipientsType; +import com.kaltura.client.enums.AnnouncementStatus; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.Announcement; +import com.kaltura.client.types.AnnouncementFilter; +import com.kaltura.client.types.FilterPager; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static com.kaltura.client.services.AnnouncementService.add; +import static com.kaltura.client.services.AnnouncementService.list; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInUtcTime; +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; + public class AnnouncementAddTest extends BaseTest { @BeforeClass @@ -17,10 +30,52 @@ private void announcement_add_tests_before_class() { @Severity(SeverityLevel.CRITICAL) @Description("announcement/action/add") - @Test + @Test(enabled = false) private void addAnnouncement() { + // set announcement + long epoch = getEpochInUtcTime(1); Announcement announcement = new Announcement(); -// announcement.set -// AnnouncementService.add().setKs(getOperatorKs()); + announcement.setName("Announcement_" + epoch); + announcement.setMailSubject(announcement.getName()); + announcement.setMessage(announcement.getName()); + announcement.setEnabled(true); + announcement.setStartTime(epoch); + announcement.setTimezone("UTC"); + announcement.setRecipients(AnnouncementRecipientsType.ALL); + + // add announcement + announcement = executor.executeSync(add(announcement) + .setKs(getOperatorKs())) + .results; + + // wait until announcement will be send + await() + .atMost(3, TimeUnit.MINUTES) + .pollInterval(30, TimeUnit.SECONDS) + .until(() -> getEpochInUtcTime(0) > epoch + 30); + + // get list of announcements + AnnouncementFilter filter = new AnnouncementFilter(); + filter.setOrderBy("NONE"); + + FilterPager pager = new FilterPager(); + pager.setPageSize(10); + pager.setPageIndex(1); + + List announcements = executor.executeSync(list(filter, pager) + .setKs(getOperatorKs())) + .results + .getObjects(); + + // get created announcement from list + Announcement finalAnnouncement = announcement; + announcement = announcements.stream(). + filter(a -> a.getId().equals(finalAnnouncement.getId())). + findFirst() + .orElse(null); + + // assertions + assertThat(announcement).isNotNull(); + assertThat(announcement.getStatus()).isEqualTo(AnnouncementStatus.SENT); } } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index c4d470ed0..3ce2224fb 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -79,11 +79,14 @@ public static long getEpochInLocalTime() { } public static long getEpochInUtcTime(int offSetInMinutes) { - Calendar calendar = Calendar.getInstance(); - int timeZoneOffset = TimeZone.getDefault().getRawOffset() / 60000; - calendar.add(Calendar.MINUTE, offSetInMinutes + timeZoneOffset); - - return calendar.toInstant().getEpochSecond(); + long time = new Date().getTime() / 1000; + return time + (offSetInMinutes * 60); + +// Calendar calendar = Calendar.getInstance(); +// int timeZoneOffset = TimeZone.getDefault().getRawOffset() / 60000; +// calendar.add(Calendar.MINUTE, offSetInMinutes + timeZoneOffset); +// +// return calendar.toInstant().getEpochSecond(); } public static Date getDateFromEpoch(long epoch) { diff --git a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java index d9fd9f6e0..643c9e79e 100644 --- a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java @@ -8,10 +8,10 @@ public class EmailUtils extends BaseUtils { - private static final String username = "alonbasin.kaltura@gmail.com"; + private static final String username = "ottbeqa@gmail.com"; private static final String password = "ottbeqa2018"; - public static boolean isEmailReceived(final String keyword, boolean isClean) { + public static boolean isEmailReceived(final String keyword, boolean deleteEmails) { boolean isReceived = false; // server setting @@ -20,8 +20,8 @@ public static boolean isEmailReceived(final String keyword, boolean isClean) { Session session = Session.getDefaultInstance(props); Folder inbox = null; - Store store = null; Folder trash = null; + Store store = null; try { // connects to the message store @@ -30,7 +30,7 @@ public static boolean isEmailReceived(final String keyword, boolean isClean) { // opens the inbox folder inbox = store.getFolder("INBOX"); - inbox.open(Folder.READ_ONLY); + inbox.open(Folder.READ_WRITE); // creates a search criterion SearchTerm searchCondition = new SearchTerm() { @@ -47,35 +47,36 @@ public boolean match(Message message) { } }; + // check if email found Message[] foundMessages = inbox.search(searchCondition); - System.out.println(foundMessages.length); if (foundMessages.length > 0) { isReceived = true; } - Message message[] = inbox.getMessages(); - System.out.println(message.length); -// for (Message aMessage : message) { -// System.out.println(aMessage.getSubject()); -// } + // delete emails + if (deleteEmails) { + // delete inbox + Message inboxMessages[] = inbox.getMessages(); + for (Message m : inboxMessages) { + m.setFlag(Flags.Flag.DELETED, true); + } + // delete trash + trash = store.getFolder("[Gmail]/Trash"); + trash.open(Folder.READ_WRITE); + Message trashMessages[] = trash.getMessages(); + for (Message m : trashMessages) { + m.setFlag(Flags.Flag.DELETED, true); + } + } } catch (MessagingException e) { e.printStackTrace(); } finally { try { - if (inbox != null) { - inbox.close(true); - } - } catch (MessagingException e) { - e.printStackTrace(); - } - try { - if (store != null) { - store.close(); - } - } catch (MessagingException e) { - e.printStackTrace(); - } + if (inbox != null) { inbox.close(true); } + if (trash != null) { trash.close(true); } + if (store != null) { store.close(); } + } catch (MessagingException e) { e.printStackTrace(); } } return isReceived; } diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 69c452d16..1ab183d87 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -9,7 +9,7 @@ Migrate features tests from ReadyAPI | Service | Status | |------------------------------|--------| -| announcement | | +| announcement | Alon - in progress | | appToken | Done | | asset | Shmulik - in progress | | assetComment | Done | diff --git a/src/test/resources/schemas/Announcement.json b/src/test/resources/schemas/Announcement.json new file mode 100644 index 000000000..8ddfea914 --- /dev/null +++ b/src/test/resources/schemas/Announcement.json @@ -0,0 +1,88 @@ +{ + "$id": "Announcement", + "type": "object", + "properties": { + "executionTime": { + "type": "number", + "minimum": 0 + }, + "result": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "enabled": { + "type": "boolean" + }, + "id": { + "type": "integer", + "minimum": 0 + }, + "imageUrl": { + "type": "string", + "minLength": 0 + }, + "includeMail": { + "type": "boolean" + }, + "includeSms": { + "type": "boolean" + }, + "mailSubject": { + "type": "string", + "minLength": 0 + }, + "mailTemplate": { + "type": "string", + "minLength": 0 + }, + "message": { + "type": "string", + "minLength": 0 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "recipients": { + "type": "string", + "minLength": 0 + }, + "startTime": { + "type": "integer", + "minimum": 0 + }, + "status": { + "type": "string", + "minLength": 0 + }, + "timezone": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "objectType", + "enabled", + "id", + "imageUrl", + "includeMail", + "includeSms", + "mailSubject", + "mailTemplate", + "message", + "name", + "recipients", + "startTime", + "status", + "timezone" + ] + } + }, + "required": [ + "executionTime", + "result" + ] +} \ No newline at end of file From ba5b7e71cfa060862ff12c69740e330055d821cd Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 6 Aug 2018 11:37:51 +0300 Subject: [PATCH 446/605] updated util PerformanceAppLogUtils.java --- .../com/kaltura/client/test/utils/PerformanceAppLogUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 1f25a1abb..de4a45980 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -149,8 +149,9 @@ private static void createSummaryFile(Map methodsAndSlowRatio try (FileWriter fw = new FileWriter(summaryTemporaryFileName, true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out = new PrintWriter(bw)) { - out.println("Report of slow methods on " + getCurrentDateInFormat("dd/MM/yyyy HH:mm")); + out.println("Report of slow methods on " + getCurrentDateInFormat("dd/MM/yyyy HH:mm") + " (" + getProperty(API_VERSION) + ")"); out.println("Max allowed percentage: " + getProperty(MAX_ALLOWED_PERCENTAGE)); + out.println("Max allowed execution time in seconds: " + getProperty(MAX_ALLOWED_EXECUTION_TIME_IN_SEC)); out.println(); for (String method : methodsAndSlowRatioData.keySet()) { if (methodsAndSlowRatioData.get(method).slowCount > 0) { From d82a3cbcb70afbe1e253daa87e583e78259fd20e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 6 Aug 2018 15:56:18 +0300 Subject: [PATCH 447/605] fix emailUtils to support await for x sec --- pom.xml | 4 +- .../kaltura/client/test/tests/BaseTest.java | 33 +++-- .../AnnouncementAddTest.java | 66 +++++---- .../kaltura/client/test/utils/EmailUtils.java | 138 +++++------------- .../test/utils/PerformanceAppLogUtils.java | 8 +- .../client/test/utils/SubscriptionUtils.java | 17 --- .../test/utils/dbUtils/DBConstants.java | 5 +- .../client/test/utils/dbUtils/DBUtils.java | 16 ++ .../test/utils/dbUtils/IngestFixtureData.java | 15 +- 9 files changed, 121 insertions(+), 181 deletions(-) diff --git a/pom.xml b/pom.xml index 0378acda3..93b6f4f4d 100644 --- a/pom.xml +++ b/pom.xml @@ -172,7 +172,7 @@ org.awaitility awaitility - 3.1.0 + 3.1.2 test @@ -214,7 +214,7 @@ com.google.guava guava - 25.0-jre + 26.0-jre test diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 1a487b8a2..57a221e82 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -1,14 +1,10 @@ package com.kaltura.client.test.tests; -import com.google.common.base.Verify; import com.kaltura.client.Client; import com.kaltura.client.Configuration; import com.kaltura.client.Logger; -import com.kaltura.client.services.ChannelService; import com.kaltura.client.services.ChannelService.AddChannelBuilder; import com.kaltura.client.services.OttUserService; -import com.kaltura.client.services.SubscriptionService; -import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.PerformanceAppLogUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; @@ -24,7 +20,11 @@ import java.util.*; import java.util.concurrent.TimeUnit; +import static com.google.common.base.Verify.verify; +import static com.kaltura.client.services.ChannelService.add; +import static com.kaltura.client.services.ChannelService.get; import static com.kaltura.client.services.OttUserService.login; +import static com.kaltura.client.services.SubscriptionService.list; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; import static com.kaltura.client.test.utils.BaseUtils.deleteFile; @@ -416,7 +416,7 @@ public static Subscription get5MinRenewableSubscription() { // it should have at least 1 VOD DynamicChannel channel = loadDefaultChannel(); channel.setKSql("name='" + getSharedMediaAsset().getName() + "'"); - AddChannelBuilder addChannelBuilder = ChannelService.add(channel); + AddChannelBuilder addChannelBuilder = add(channel); Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); if (channelResponse.results != null && channelResponse.results.getName() != null) { MppData mppData = new MppData() @@ -433,24 +433,31 @@ private static void ingestVODIntoSubscription(Subscription subscription) { // getting channel SubscriptionFilter filter = new SubscriptionFilter(); filter.setSubscriptionIdIn(subscription.getId()); - ListSubscriptionBuilder listSubscriptionBuilder = SubscriptionService.list(filter); - Response> listResponse = executor.executeSync(listSubscriptionBuilder.setKs(getOperatorKs())); - Verify.verify(listResponse.results.getObjects().get(0).getChannels().size() > 0); + Response> listResponse = executor.executeSync(list(filter) + .setKs(getOperatorKs())); + + verify(listResponse.results.getObjects().get(0).getChannels().size() > 0); int channelId = listResponse.results.getObjects().get(0).getChannels().get(0).getId().intValue(); - DynamicChannel channel = IngestFixtureData.getChannel(channelId); + // get channel + DynamicChannel channel = (DynamicChannel) executor.executeSync(get(channelId) + .setKs(getOperatorKs())) + .results; + String[] parameters; - String tag = null, name = null; - if (null == channel.getKSql()) { + String tag = null; + String name = null; + + if (channel.getKSql() == null || channel.getKSql().equals("")) { // automatic channel String automaticChannelExpression = IngestFixtureData.getAutomaticChannelExpression(channelId); parameters = automaticChannelExpression.split(":"); - Verify.verify(parameters.length == 2); + verify(parameters.length == 2); tag = parameters[0]; } else { // KSQL channel parameters = channel.getKSql().split("="); - Verify.verify(parameters.length == 2); + verify(parameters.length == 2); if ("name".equals(parameters[0].toLowerCase())) { // ingest VOD with mentioned name name = parameters[0]; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java index 5b24a2081..3a5200517 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java @@ -13,11 +13,13 @@ import org.testng.annotations.Test; import java.util.List; +import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.services.AnnouncementService.add; -import static com.kaltura.client.services.AnnouncementService.list; +import static com.kaltura.client.services.AnnouncementService.*; +import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.test.utils.BaseUtils.getEpochInUtcTime; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAnnouncementResultMessageId; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -25,12 +27,12 @@ public class AnnouncementAddTest extends BaseTest { @BeforeClass private void announcement_add_tests_before_class() { - + executor.executeSync(login(partnerId, "alon2986", "alon2986")); } @Severity(SeverityLevel.CRITICAL) @Description("announcement/action/add") - @Test(enabled = false) + @Test(enabled = true) private void addAnnouncement() { // set announcement long epoch = getEpochInUtcTime(1); @@ -48,12 +50,6 @@ private void addAnnouncement() { .setKs(getOperatorKs())) .results; - // wait until announcement will be send - await() - .atMost(3, TimeUnit.MINUTES) - .pollInterval(30, TimeUnit.SECONDS) - .until(() -> getEpochInUtcTime(0) > epoch + 30); - // get list of announcements AnnouncementFilter filter = new AnnouncementFilter(); filter.setOrderBy("NONE"); @@ -62,20 +58,40 @@ private void addAnnouncement() { pager.setPageSize(10); pager.setPageIndex(1); - List announcements = executor.executeSync(list(filter, pager) - .setKs(getOperatorKs())) - .results - .getObjects(); - - // get created announcement from list - Announcement finalAnnouncement = announcement; - announcement = announcements.stream(). - filter(a -> a.getId().equals(finalAnnouncement.getId())). - findFirst() - .orElse(null); - - // assertions - assertThat(announcement).isNotNull(); - assertThat(announcement.getStatus()).isEqualTo(AnnouncementStatus.SENT); + ListAnnouncementBuilder listAnnouncementBuilder = list(filter, pager).setKs(getOperatorKs()); + + // wait until announcement will be send + await() + .atMost(5, TimeUnit.MINUTES) + .pollInterval(30, TimeUnit.SECONDS) + .until(isAnnouncementSent(listAnnouncementBuilder, announcement.getId())); + + // assert confirmation from Amazon + List ids = getAnnouncementResultMessageId(announcement.getId()); + assertThat(ids).isNotNull(); + assertThat(ids.size()).isGreaterThan(0); + + // assert email sent +// assertThat(isEmailReceived(announcement.getMessage(), true)).isTrue(); + } + + // helper methods + private static Callable isAnnouncementSent(ListAnnouncementBuilder listAnnouncementBuilder, int announcementId) { + return () -> { + // get announcement list + List announcements = executor.executeSync(listAnnouncementBuilder) + .results + .getObjects(); + + // get created announcement from list + Announcement announcement = announcements.stream(). + filter(a -> a.getId().equals(announcementId)). + findFirst() + .orElse(null); + + // check if announcement sent + return announcement != null && + announcement.getStatus().equals(AnnouncementStatus.SENT); + }; } } diff --git a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java index 643c9e79e..9a6a65ff4 100644 --- a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java @@ -1,10 +1,15 @@ package com.kaltura.client.test.utils; +import org.awaitility.core.ConditionTimeoutException; + import javax.mail.*; import javax.mail.search.SearchTerm; -import java.io.IOException; import java.util.Properties; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.awaitility.Awaitility.await; public class EmailUtils extends BaseUtils { @@ -12,7 +17,7 @@ public class EmailUtils extends BaseUtils { private static final String password = "ottbeqa2018"; public static boolean isEmailReceived(final String keyword, boolean deleteEmails) { - boolean isReceived = false; + AtomicBoolean isReceived = new AtomicBoolean(false); // server setting Properties props = System.getProperties(); @@ -47,11 +52,19 @@ public boolean match(Message message) { } }; - // check if email found - Message[] foundMessages = inbox.search(searchCondition); - if (foundMessages.length > 0) { - isReceived = true; - } + // check if email found for 30 sec + Folder finalInbox = inbox; + await() + .atMost(40, TimeUnit.SECONDS) + .pollInterval(5, TimeUnit.SECONDS) + .until(() -> { + System.out.println("until " + getLocalTimeFormatted(0)); + Message[] foundMessages = finalInbox.search(searchCondition); + if (foundMessages.length > 0) { + isReceived.set(true); + } + return isReceived.get(); + }); // delete emails if (deleteEmails) { @@ -69,110 +82,25 @@ public boolean match(Message message) { m.setFlag(Flags.Flag.DELETED, true); } } - } catch (MessagingException e) { - e.printStackTrace(); - } finally { - try { - if (inbox != null) { inbox.close(true); } - if (trash != null) { trash.close(true); } - if (store != null) { store.close(); } - } catch (MessagingException e) { e.printStackTrace(); } - } - return isReceived; - } - - public static void searchEmail(final String keyword) { - Properties properties = new Properties(); - -// props.setProperty("mail.imaps.host", "imap.gmail.com"); -// props.setProperty("mail.imaps.user", username); -// props.setProperty("mail.imaps.password", password); -// props.setProperty("mail.imaps.port", "993"); -// props.setProperty("mail.imaps.auth", "true"); -// props.setProperty("mail.debug", "true"); - - // server setting - properties.put("mail.imap.host", "imap.gmail.com"); - properties.put("mail.imap.port", "993"); - - // SSL setting - properties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); - properties.setProperty("mail.imap.socketFactory.fallback", "false"); - properties.setProperty("mail.imap.socketFactory.port", "993"); - properties.setProperty("mail.store.protocol", "imaps"); - properties.setProperty("mail.debug", "true"); - -// props.put("mail.smtp.host", "smtp.gmail.com"); -// props.put("mail.smtp.socketFactory.port","465"); -// props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory"); -// props.put("mail.smtp.auth","true"); -// props.put("mail.smtp.port","465"); -// props.setProperty("mail.debug", "true"); - - Store store = null; - Folder inbox = null; - Folder trash = null; - - try { - Session session = Session.getInstance(properties); - store = session.getStore("imaps"); - store.connect("imap.gmail.com", username, password); - System.out.println("Connections is opened"); - - trash = store.getFolder("[Gmail]/Trash"); - trash.open(Folder.READ_WRITE); - - inbox = store.getFolder("INBOX"); - inbox.open(Folder.READ_WRITE); - - int messageCount = inbox.getMessageCount(); - //log.info("Total Messages: " + messageCount); - Message[] messages = inbox.getMessages(); - Message[] messages2Remove = new Message[1]; - - boolean isMessageFound = false; - for (int i = 0; i < messageCount; i++) { - - if (messages[i].getContentType().toLowerCase().startsWith("text")) { - if (messages[i].getContent().toString().contains(keyword)) { - isMessageFound = true; - messages2Remove[0] = messages[i]; - break; - } - } else if (messages[i].getContentType().toLowerCase().startsWith("multipart")) { - Multipart multipart = (Multipart) messages[i].getContent(); - for (int j = 0; j < multipart.getCount(); j++) { - if (((Multipart) messages[i].getContent()).getBodyPart(j).getContent().toString().contains(keyword)) { - isMessageFound = true; - messages2Remove[0] = messages[i]; - break; - } - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } catch (NoSuchProviderException e) { - e.printStackTrace(); - } catch (MessagingException e) { - e.printStackTrace(); - } finally { - try { - inbox.close(true); // to close folder - } catch (MessagingException e) { - e.printStackTrace(); - } - try { - trash.close(true); // to close folder - } catch (MessagingException e) { + } catch (Exception e) { + if (e.getClass() != ConditionTimeoutException.class) { e.printStackTrace(); } + } finally { try { - store.close(); // to close connection + if (inbox != null) { + inbox.close(true); + } + if (trash != null) { + trash.close(true); + } + if (store != null) { + store.close(); + } } catch (MessagingException e) { e.printStackTrace(); } - //log.info("Connections is closed") } + return isReceived.get(); } } diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 1f25a1abb..d21c6105e 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -155,7 +155,8 @@ private static void createSummaryFile(Map methodsAndSlowRatio for (String method : methodsAndSlowRatioData.keySet()) { if (methodsAndSlowRatioData.get(method).slowCount > 0) { out.println(method + " was slow " + String.format("%.2f", methodsAndSlowRatioData.get(method).slowCount * - 1.0 / methodsAndSlowRatioData.get(method).totalCount * 100) + "% of executions"); + 1.0 / methodsAndSlowRatioData.get(method).totalCount * 100) + "% of executions (" + + methodsAndSlowRatioData.get(method).slowCount * 1.0 + "/" + methodsAndSlowRatioData.get(method).totalCount + ")"); } } @@ -175,7 +176,8 @@ private static void writeReport2File(String method, String xKalturaSession, doub // we want to see only data where code time is less than 100% if (timeOfCB > 0 || timeOfDB > 0 || timeOfES > 0 || timeOfRabbit > 0) { out.println(method); - out.println("\"" + xKalturaSession + "\""); + out.println(xKalturaSession); + out.println("Execution Time: " + totalTime); out.println("Code: " + String.format("%.2f", codeTimePercentage) + "% (" + timeOfCode + ")"); writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime); writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime); @@ -246,6 +248,8 @@ private static List getRemoteAppLogFileNames() throws IOException { if (fileObject.exists()) { fileNames.add(sourceFileName); + } else { + Logger.getLogger(PerformanceAppLogUtils.class).error("getRemoteAppLogFileNames(): file not found!"); } int idx = 1; while (fileObject.exists()) { diff --git a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java index f2d6b96e9..9bfbc9b2e 100644 --- a/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/SubscriptionUtils.java @@ -5,8 +5,6 @@ import com.kaltura.client.services.AssetService; import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.services.SubscriptionService.ListSubscriptionBuilder; -import com.kaltura.client.test.tests.enums.ChannelType; -import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -56,21 +54,6 @@ public static List getAssetsListBySubscription(int subscriptionId, Option return assets; } - public static Channel loadAutomaticOrKsqlChannel(String subscriptionId) { - List channels = getChannelsListBySubscription(subscriptionId); - String channelType; - Channel result; - for (BaseChannel channel: channels) { - result = IngestFixtureData.getChannel(channel.getId().intValue()); - channelType = result.toParams().get("channel_type").toString(); - if (ChannelType.AUTOMATIC_CHANNEL_TYPE.getValue().equals(channelType) || - ChannelType.KSQL_CHANNEL_TYPE.getValue().equals(channelType)) { - return result; - } - } - return null; - } - public static List getChannelsListBySubscription(String subscriptionId) { SubscriptionFilter filter = new SubscriptionFilter(); filter.setSubscriptionIdIn(subscriptionId); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 12dbc73c7..e53cacf05 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -25,7 +25,7 @@ public class DBConstants { static final String SERV_ID = "serv_id"; static final String SUBSCRIPTION_ONLY = "subscription_only"; static final String SUB_ID = "sub_id"; - static final String TAG_TYPE = "tag_type"; + static final String TAG_NAME = "tag_name"; static final String TAG_VALUE = "tag_value"; static final String USERNAME = "username"; static final String VIEW_LIFE_CYCLE_MINUTES = "view_life_cycle_min"; @@ -223,11 +223,10 @@ public class DBConstants { "order by m.id desc"; static final String MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where (GROUP_ID = ? OR GROUP_ID = ?) and name = ?"; - static final String OPC_MEDIA_TYPE_ID_SELECT = "SELECT [ID] ,[NAME] FROM [TVinci].[dbo].[media_types] where GROUP_ID = ? and name = ?"; - static final String MEDIA_FILE_TYPE_ID_SELECT = "SELECT [NAME] FROM [TVinci].[dbo].[groups_media_type] where GROUP_ID = ? and ID = ?"; + static final String RESULT_MESSAGE_ID_SELECT = "SELECT result_message_id FROM [MessageBox].[dbo].[message_announcements] WHERE group_id = ? AND ID = ?"; // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 99a9fa4f5..72022d688 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -10,12 +10,14 @@ import com.kaltura.client.types.SubscriptionFilter; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; +import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.sql.*; import java.util.Arrays; +import java.util.List; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; @@ -254,4 +256,18 @@ public static String getMediaFileTypeName(int mediaFileId) { .getJSONObject(0) .getString("name"); } + + public static List getAnnouncementResultMessageId(int announcementId) { + List ids = null; + + String s = getJsonArrayFromQueryResult(RESULT_MESSAGE_ID_SELECT, partnerId, announcementId) + .getJSONObject(0) + .getString("result_message_id"); + + if (StringUtils.isNotEmpty(s)) { + ids = Arrays.asList(s.split("\\s*,\\s*")); + } + + return ids; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index a61a49f52..7d6a477cb 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -2,8 +2,6 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.SubscriptionDependencyType; -import com.kaltura.client.services.ChannelService; -import com.kaltura.client.services.ChannelService.GetChannelBuilder; import com.kaltura.client.services.PriceDetailsService; import com.kaltura.client.services.PriceDetailsService.ListPriceDetailsBuilder; import com.kaltura.client.services.PricePlanService; @@ -168,23 +166,12 @@ public static Subscription loadShared5MinutesRenewableSubscription() { return subscription; } - public static DynamicChannel getChannel(int id) { - Logger.getLogger(IngestFixtureData.class).debug("getChannel(): id = " + id); - - JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_SELECT, id); - GetChannelBuilder getChannelBuilder = ChannelService.get(jsonArray.getJSONObject(0).getInt(ID)); - Response channelResponse = executor.executeSync(getChannelBuilder - .setKs(getOperatorKs())); - - return (DynamicChannel) channelResponse.results; - } - public static String getAutomaticChannelExpression(int channelId) { Logger.getLogger(IngestFixtureData.class).debug("getAutomaticChannelExpression(): channelId = " + channelId); JSONArray jsonArray = getJsonArrayFromQueryResult(CHANNEL_EXPRESSION_SELECT, channelId); - return jsonArray.getJSONObject(0).getString(TAG_TYPE) + ":" + + return jsonArray.getJSONObject(0).getInt(TAG_NAME) + ":" + jsonArray.getJSONObject(0).getString(TAG_VALUE); } } From 5d5eca9cde830d4b97c3d4552a37844c49cde441 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 7 Aug 2018 10:17:50 +0300 Subject: [PATCH 448/605] no message --- .../announcementTests/AnnouncementAddTest.java | 2 ++ .../transactionTests/TransactionPurchaseTests.java | 10 +++------- src/test/resources/WORK_PLAN.md | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java index 3a5200517..78fffdae4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java @@ -75,6 +75,8 @@ private void addAnnouncement() { // assertThat(isEmailReceived(announcement.getMessage(), true)).isTrue(); } + + // helper methods private static Callable isAnnouncementSent(ListAnnouncementBuilder listAnnouncementBuilder, int announcementId) { return () -> { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index 98dea91e1..d9d19687a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -15,7 +15,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; @@ -38,14 +37,11 @@ public void beforeClass(){ // masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); // userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); - PaymentGatewayProfile paymentGatewayProfile = new PaymentGatewayProfile(); - - } @Test(enabled = false) - private void purchasePpvWithDefaultPG() { + public void purchasePpvWithDefaultPG() { ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.setFileIdIn(getSharedWebMediaFile().getId().toString()); ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter).setKs(masterUserKs); @@ -80,9 +76,9 @@ private void purchasePpvWithDefaultPG() { } @Test (enabled = false) - private void purchaseSubscriptionWithDefaultPG() { + public void purchaseSubscriptionWithDefaultPG() { ProductPriceFilter productPriceFilter = new ProductPriceFilter(); - productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId().toString()); + productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter).setKs(masterUserKs); listResponse = executor.executeSync(listProductPriceBuilder); assertThat(listResponse.results).isNotNull(); diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 1ab183d87..c4578e90e 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -92,7 +92,7 @@ Migrate features tests from ReadyAPI | system | | | timeShiftedTvPartnerSettings | | | topic | | -| transaction | | +| transaction | Alon - in progress | | transactionHistory | Michael - in progress | | unifiedPayment | | | userAssetRule | | From 45555c8fc3212b925956e8560a9dcfb40217ff14 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 7 Aug 2018 14:07:13 +0300 Subject: [PATCH 449/605] added searchTerms to emailUtils --- .../kaltura/client/test/utils/EmailUtils.java | 125 +++++++++++++++--- 1 file changed, 107 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java index 9a6a65ff4..41ebb10cc 100644 --- a/src/test/java/com/kaltura/client/test/utils/EmailUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/EmailUtils.java @@ -4,7 +4,10 @@ import org.awaitility.core.ConditionTimeoutException; import javax.mail.*; +import javax.mail.internet.MimeBodyPart; import javax.mail.search.SearchTerm; +import java.io.IOException; +import java.util.Date; import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -16,7 +19,7 @@ public class EmailUtils extends BaseUtils { private static final String username = "ottbeqa@gmail.com"; private static final String password = "ottbeqa2018"; - public static boolean isEmailReceived(final String keyword, boolean deleteEmails) { + public static boolean isEmailReceived(SearchTerm term, boolean deleteEmails) { AtomicBoolean isReceived = new AtomicBoolean(false); // server setting @@ -37,29 +40,14 @@ public static boolean isEmailReceived(final String keyword, boolean deleteEmails inbox = store.getFolder("INBOX"); inbox.open(Folder.READ_WRITE); - // creates a search criterion - SearchTerm searchCondition = new SearchTerm() { - @Override - public boolean match(Message message) { - try { - if (message.getSubject().contains(keyword)) { - return true; - } - } catch (MessagingException ex) { - ex.printStackTrace(); - } - return false; - } - }; - // check if email found for 30 sec Folder finalInbox = inbox; + await() .atMost(40, TimeUnit.SECONDS) .pollInterval(5, TimeUnit.SECONDS) .until(() -> { - System.out.println("until " + getLocalTimeFormatted(0)); - Message[] foundMessages = finalInbox.search(searchCondition); + Message[] foundMessages = finalInbox.search(term); if (foundMessages.length > 0) { isReceived.set(true); } @@ -103,4 +91,105 @@ public boolean match(Message message) { } return isReceived.get(); } + + // custom search terms + public static class SentDateSearchTerm extends SearchTerm { + private Date afterDate; + + public SentDateSearchTerm(Date afterDate) { + this.afterDate = afterDate; + } + + @Override + public boolean match(Message message) { + try { + if (message.getSentDate().after(afterDate)) { + return true; + } + } catch (MessagingException ex) { + ex.printStackTrace(); + } + return false; + } + } + + public static class SubjectSearchTerm extends SearchTerm { + private String subject; + + public SubjectSearchTerm(String subject) { + this.subject = subject; + } + + @Override + public boolean match(Message message) { + try { + if (message.getSubject().contains(subject)) { + return true; + } + } catch (MessagingException ex) { + ex.printStackTrace(); + } + return false; + } + } + + public static class FromFieldSearchTerm extends SearchTerm { + private String fromEmail; + + public FromFieldSearchTerm(String fromEmail) { + this.fromEmail = fromEmail; + } + + @Override + public boolean match(Message message) { + try { + Address[] fromAddress = message.getFrom(); + if (fromAddress != null && fromAddress.length > 0) { + if (fromAddress[0].toString().contains(fromEmail)) { + return true; + } + } + } catch (MessagingException ex) { + ex.printStackTrace(); + } + return false; + } + } + + public static class ContentSearchTerm extends SearchTerm { + private String content; + + public ContentSearchTerm(String content) { + this.content = content; + } + + @Override + public boolean match(Message message) { + try { + String contentType = message.getContentType().toLowerCase(); + + if (contentType.contains("text/plain") || contentType.contains("text/html")) { + String messageContent = message.getContent().toString(); + if (messageContent.contains(content)) { + return true; + } + } + + if (contentType.contains("multipart")) { + Multipart multiPart = (Multipart) message.getContent(); + int numberOfParts = multiPart.getCount(); + for (int partCount = 0; partCount < numberOfParts; partCount++) { + MimeBodyPart part = (MimeBodyPart) multiPart.getBodyPart(partCount); + String messageContent = part.getContent().toString(); + if (messageContent.contains(content)) { + return true; + } + } + } + } catch (MessagingException | IOException ex) { + ex.printStackTrace(); + } + return false; + } + } } From cf6d4a25cd82fe364ae727611cda4098a7eb4349 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 7 Aug 2018 16:15:20 +0300 Subject: [PATCH 450/605] no message --- pom.xml | 2 +- src/test/resources/testng.xml | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 93b6f4f4d..e7692d8fe 100644 --- a/pom.xml +++ b/pom.xml @@ -151,7 +151,7 @@ org.testng testng - 6.14.2 + 6.14.3 test diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index d7fbc2d00..19df6e11b 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -15,16 +15,16 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file From fd950e51cf8f7473e3b3e3313ffc5741380028ed Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Wed, 8 Aug 2018 10:50:15 +0300 Subject: [PATCH 451/605] Addede new class - "AssetCountTests " --- .../AssetTests/AssetCountTests.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java new file mode 100644 index 000000000..dd288a350 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -0,0 +1,81 @@ +package com.kaltura.client.test.tests.servicesTests.AssetTests; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.KsqlBuilder; + +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.HashMap; + +import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; +import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; +import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static org.assertj.core.api.Assertions.assertThat; + +public class AssetCountTests extends BaseTest { + + private MediaAsset asset, asset2; + private final String metaName = "synopsis"; + private final String metaValue1 = "A" + getRandomValue("_"); + + @BeforeClass + private void asset_count_before_class() { + + HashMap stringMetaMap1 = new HashMap<>(); + stringMetaMap1.put(metaName, metaValue1); + + // ingest asset 1 + IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() + .mediaType(MOVIE) + .strings(stringMetaMap1); + asset = insertVod(vodData1); + + // ingest asset 2 + IngestVodUtils.VodData vodData2 = new IngestVodUtils.VodData() + .mediaType(MOVIE) + .strings(stringMetaMap1); + + asset2 = insertVod(vodData2); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("Ingest 2 VOD assets with the same meta (synopsis) value and pass the meta name in the count request") + @Test + private void groupByVodMeta() { + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .closeOr() + .toString(); + + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(query); + searchAssetFilter.setTypeIn("425"); + + ArrayList arrayList = new ArrayList<>(); + AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); + assetMetaOrTagGroupBy.setValue(metaName); + arrayList.add(assetMetaOrTagGroupBy); + + searchAssetFilter.setGroupBy(arrayList); + AssetService.CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + + // asset/action/count + Response assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(2); + + } + + +} From f1760e4e2ce280be3c18675dafcff71e60482f92 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Wed, 8 Aug 2018 11:28:39 +0300 Subject: [PATCH 452/605] Added "AssetCount" schema to project --- src/test/resources/schemas/AssetCount.json | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/test/resources/schemas/AssetCount.json diff --git a/src/test/resources/schemas/AssetCount.json b/src/test/resources/schemas/AssetCount.json new file mode 100644 index 000000000..bed7656bd --- /dev/null +++ b/src/test/resources/schemas/AssetCount.json @@ -0,0 +1,75 @@ +{ + "$id": "AssetCount", + "definitions": { + "AssetCount": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "count": { + "type": "integer", + "minimum": 0 + }, + "subs": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "field": { + "type": "string", + "minLength": 0 + }, + "objects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "count": { + "type": "integer", + "minimum": 0 + }, + "subs": { + "type": "array" + }, + "value": { + "type": "string", + "minLength": 0 + } + } + } + } + } + } + } + }, + "required": [ + "objectType", + "count", + "subs" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/AssetCount" + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} \ No newline at end of file From 9b23b3bcd9ea7cb2c7caf81356e090b7137d43c9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 8 Aug 2018 11:38:08 +0300 Subject: [PATCH 453/605] edit API_SCHEMA_URL --- src/test/java/com/kaltura/client/test/utils/BaseUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 3ce2224fb..4a175ff59 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -18,6 +18,7 @@ import java.util.*; import java.util.concurrent.ThreadLocalRandom; +import static com.kaltura.client.test.Properties.API_BASE_URL; import static com.kaltura.client.test.Properties.API_VERSION; import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.tests.BaseTest.config; @@ -25,7 +26,7 @@ public class BaseUtils { - private static final String API_SCHEMA_URL = "https://api-preprod.ott.kaltura.com/" + getProperty(API_VERSION) + "/clientlibs/KalturaClient.xml"; + private static final String API_SCHEMA_URL = getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION) + "/clientlibs/KalturaClient.xml"; private static List exceptions; // to get e.g. yesterday date in specific date format need call the method so: getOffsetDateInFormat(-1, pattern); From 3bc1ce54c1b7cca848252213fcd839e3f7408a04 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 8 Aug 2018 13:10:21 +0300 Subject: [PATCH 454/605] change testng.xml for testing purpose --- src/test/resources/testng.xml | 54 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 19df6e11b..a07f3a2d2 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,29 +2,37 @@ - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 70f9df66a6f5f239de384a747a1a8492d654f70a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 8 Aug 2018 15:02:27 +0300 Subject: [PATCH 455/605] no message --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7692d8fe..bdd81be71 100644 --- a/pom.xml +++ b/pom.xml @@ -276,7 +276,7 @@ usedefaultlisteners - false + true From 08daa2f913c393abf032e1556d70e2265773ecb5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Wed, 8 Aug 2018 16:00:33 +0300 Subject: [PATCH 456/605] Refactored EPG util to allow inserting dynamic metas/tags --- .../test/utils/ingestUtils/IngestEpgUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index ccc1dea03..0fd294649 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -22,6 +22,7 @@ import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @@ -63,6 +64,9 @@ public static class EpgData { private Long startDate; private DurationPeriod programDurationPeriod; + + private Map metas; + private Map tags; } public static List insertEpg(EpgData epgData) { @@ -237,6 +241,20 @@ private static Element getProgrammeNode(Document doc, int episodeNum, int season // episode num meta programme.appendChild(generateMetasNode(doc, "episode_num", String.valueOf(episodeNum))); + // custom metas + if (epgData.metas != null) { + for (Map.Entry entry : epgData.metas.entrySet()) { + programme.appendChild(generateMetasNode(doc, entry.getKey(), entry.getValue())); + } + } + + // custom tags + if (epgData.tags != null) { + for (Map.Entry entry : epgData.tags.entrySet()) { + programme.appendChild(generateTagsNode(doc, entry.getKey(), entry.getValue())); + } + } + // TODO: 6/19/2018 add missing parameters according to needed tests return programme; From 02223beb22d14fc5233cea11996967be64a264f0 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Wed, 8 Aug 2018 16:01:49 +0300 Subject: [PATCH 457/605] Added overload method (getRandomValue()) to VaseUtils --- src/test/java/com/kaltura/client/test/utils/BaseUtils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 3ce2224fb..32b2f99e9 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -109,6 +109,12 @@ public static String getRandomValue(String prefix) { return prefix + randomLongValue; } + public static String getRandomValue() { + long max = 9999999999L; + long randomLongValue = ThreadLocalRandom.current().nextLong(max); + return String.valueOf(randomLongValue); + } + // generate random string public static String getRandomString() { String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; From f4154e0bfaac97101b7b917093276404439a334b Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Wed, 8 Aug 2018 16:02:19 +0300 Subject: [PATCH 458/605] Added additional test to class "AssetCountTests" --- .../AssetTests/AssetCountTests.java | 92 ++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index dd288a350..2969b2774 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -1,37 +1,55 @@ package com.kaltura.client.test.tests.servicesTests.AssetTests; import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.KsqlBuilder; +import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.json.JSONArray; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; + +import static com.kaltura.client.services.AssetService.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; +import static com.kaltura.client.test.tests.enums.KsqlKey.EPG_ID; import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; public class AssetCountTests extends BaseTest { + private ProgramAsset program, program2; private MediaAsset asset, asset2; + private final String metaName = "synopsis"; - private final String metaValue1 = "A" + getRandomValue("_"); + private final String metaValue1 = metaName + getRandomValue("_"); + private final String tagName = "Studio"; + private final String tagValue = tagName + getRandomValue("_"); + private final String epgMetaName = "Country"; + private final String epgMetaValue = epgMetaName + getRandomValue("_"); @BeforeClass private void asset_count_before_class() { HashMap stringMetaMap1 = new HashMap<>(); stringMetaMap1.put(metaName, metaValue1); + stringMetaMap1.put(tagName,tagValue); // ingest asset 1 IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() @@ -45,6 +63,19 @@ private void asset_count_before_class() { .strings(stringMetaMap1); asset2 = insertVod(vodData2); + + HashMap metas = new HashMap<>(); + metas.put(epgMetaName, epgMetaValue); + + // ingest epg programs + EpgData epgData = new EpgData(getSharedEpgChannelName()); + epgData.seasonsNum(1); + epgData.episodesNum(2); + epgData.metas(metas); + + List programsList = IngestEpgUtils.insertEpg(epgData); + program = programsList.get(0); + program2 = programsList.get(1); } @Severity(SeverityLevel.CRITICAL) @@ -60,7 +91,7 @@ private void groupByVodMeta() { SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); searchAssetFilter.setKSql(query); - searchAssetFilter.setTypeIn("425"); + searchAssetFilter.setTypeIn(String.valueOf(DBUtils.getMediaTypeId(MediaType.MOVIE))); ArrayList arrayList = new ArrayList<>(); AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); @@ -77,5 +108,62 @@ private void groupByVodMeta() { } + @Severity(SeverityLevel.CRITICAL) + @Description("Ingest 2 VOD assets with the same tag (Genre) value and pass the tag name in the count request") + @Test + private void groupByVodTag() { + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .closeOr() + .toString(); + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(query); + searchAssetFilter.setTypeIn(String.valueOf(DBUtils.getMediaTypeId(MediaType.MOVIE))); + + ArrayList arrayList = new ArrayList<>(); + AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); + assetMetaOrTagGroupBy.setValue(tagName); + arrayList.add(assetMetaOrTagGroupBy); + + searchAssetFilter.setGroupBy(arrayList); + AssetService.CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + + // asset/action/count + Response assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(2); + + } + + @Severity(SeverityLevel.CRITICAL) + @Description("") + @Test + private void groupByEPGMeta() { + String query = new KsqlBuilder() + .openOr() + .equal(EPG_ID.getValue(), String.valueOf(program.getId())) + .equal(EPG_ID.getValue(),String.valueOf(program2.getId())) + .closeOr() + .toString(); + + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(query); + searchAssetFilter.setTypeIn("0"); + + ArrayList arrayList = new ArrayList<>(); + AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); + assetMetaOrTagGroupBy.setValue(epgMetaName); + arrayList.add(assetMetaOrTagGroupBy); + + searchAssetFilter.setGroupBy(arrayList); + CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + + // asset/action/count + Response assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(2); + } } From 71d685990c0788f69fd298771987befb0425d34d Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Wed, 8 Aug 2018 16:02:45 +0300 Subject: [PATCH 459/605] Removed unnssery imports from class AssetCountTests --- .../test/tests/servicesTests/AssetTests/AssetCountTests.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index 2969b2774..2d96e3db9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -12,7 +12,6 @@ import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import org.json.JSONArray; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -27,8 +26,6 @@ import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.getLinearAssetIdAndEpgChannelNameJsonArray; -import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; From 0dde26f29bdef7ef7e9c950045090c5d17f7c557 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Wed, 8 Aug 2018 16:50:21 +0300 Subject: [PATCH 460/605] Added additional tests to class "AssetCountTests" --- .../AssetTests/AssetCountTests.java | 108 +++++++++++++++--- 1 file changed, 93 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index 2d96e3db9..5f59f58c4 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -34,41 +34,59 @@ public class AssetCountTests extends BaseTest { private ProgramAsset program, program2; private MediaAsset asset, asset2; - private final String metaName = "synopsis"; - private final String metaValue1 = metaName + getRandomValue("_"); + private final String metaName1 = "synopsis"; + private final String metaValue1 = metaName1 + getRandomValue("_"); + + private final String metaName2 = "runtime"; + private final String metaValue2 = metaName2 + getRandomValue("_"); + private final String metaValue3 = metaName2 + getRandomValue("_"); + private final String tagName = "Studio"; private final String tagValue = tagName + getRandomValue("_"); + private final String epgMetaName = "Country"; private final String epgMetaValue = epgMetaName + getRandomValue("_"); + private final String epgTagName = "Director"; + private final String epgTagValue = epgTagName + getRandomValue("_"); @BeforeClass private void asset_count_before_class() { - HashMap stringMetaMap1 = new HashMap<>(); - stringMetaMap1.put(metaName, metaValue1); - stringMetaMap1.put(tagName,tagValue); + HashMap stringMetaMap = new HashMap<>(); + stringMetaMap.put(metaName1, metaValue1); + stringMetaMap.put(metaName2,metaValue2); + stringMetaMap.put(tagName,tagValue); // ingest asset 1 IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() .mediaType(MOVIE) - .strings(stringMetaMap1); + .strings(stringMetaMap); asset = insertVod(vodData1); + HashMap stringMetaMap2 = new HashMap<>(); + stringMetaMap2.put(metaName1, metaValue1); + stringMetaMap2.put(metaName2,metaValue3); + stringMetaMap2.put(tagName,tagValue); + // ingest asset 2 IngestVodUtils.VodData vodData2 = new IngestVodUtils.VodData() .mediaType(MOVIE) - .strings(stringMetaMap1); + .strings(stringMetaMap2); asset2 = insertVod(vodData2); - HashMap metas = new HashMap<>(); - metas.put(epgMetaName, epgMetaValue); + HashMap epgMetas = new HashMap<>(); + epgMetas.put(epgMetaName, epgMetaValue); + + HashMap epgTags = new HashMap<>(); + epgTags.put(epgTagName,epgTagValue); // ingest epg programs EpgData epgData = new EpgData(getSharedEpgChannelName()); epgData.seasonsNum(1); epgData.episodesNum(2); - epgData.metas(metas); + epgData.metas(epgMetas); + epgData.tags(epgTags); List programsList = IngestEpgUtils.insertEpg(epgData); program = programsList.get(0); @@ -76,7 +94,7 @@ private void asset_count_before_class() { } @Severity(SeverityLevel.CRITICAL) - @Description("Ingest 2 VOD assets with the same meta (synopsis) value and pass the meta name in the count request") + @Description("2 VOD assets with the same meta (synopsis) value and pass the meta name in the count request") @Test private void groupByVodMeta() { String query = new KsqlBuilder() @@ -92,7 +110,7 @@ private void groupByVodMeta() { ArrayList arrayList = new ArrayList<>(); AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); - assetMetaOrTagGroupBy.setValue(metaName); + assetMetaOrTagGroupBy.setValue(metaName1); arrayList.add(assetMetaOrTagGroupBy); searchAssetFilter.setGroupBy(arrayList); @@ -102,11 +120,10 @@ private void groupByVodMeta() { // asset/action/count Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); - } @Severity(SeverityLevel.CRITICAL) - @Description("Ingest 2 VOD assets with the same tag (Genre) value and pass the tag name in the count request") + @Description("2 VOD assets with the same tag (Genre) value and pass the tag name in the count request") @Test private void groupByVodTag() { String query = new KsqlBuilder() @@ -132,11 +149,43 @@ private void groupByVodTag() { // asset/action/count Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("2 VOD assets with different meta (Runtime) value and pass the meta name in the count request") + @Test + private void groupByVodMetaWithDifferentValues() { + String query = new KsqlBuilder() + .openOr() + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) + .equal(MEDIA_ID.getValue(), Math.toIntExact(asset2.getId())) + .closeOr() + .toString(); + + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(query); + searchAssetFilter.setTypeIn(String.valueOf(DBUtils.getMediaTypeId(MediaType.MOVIE))); + + ArrayList arrayList = new ArrayList<>(); + AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); + assetMetaOrTagGroupBy.setValue(metaName2); + arrayList.add(assetMetaOrTagGroupBy); + + searchAssetFilter.setGroupBy(arrayList); + AssetService.CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + // asset/action/count + Response assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(2); + assertThat(assetCountResponse.results.getSubs().get(0).getObjects().get(0).getCount()).isEqualTo(1); + assertThat(assetCountResponse.results.getSubs().get(0).getObjects().get(0).getValue()).isEqualTo(metaValue3); + assertThat(assetCountResponse.results.getSubs().get(0).getObjects().get(1).getCount()).isEqualTo(1); + assertThat(assetCountResponse.results.getSubs().get(0).getObjects().get(1).getValue()).isEqualTo(metaValue2); } @Severity(SeverityLevel.CRITICAL) - @Description("") + @Description("2 EPG programs with the same meta (Country) value and pass the meta name in the count request") @Test private void groupByEPGMeta() { String query = new KsqlBuilder() @@ -163,4 +212,33 @@ private void groupByEPGMeta() { Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); } + + // TODO + @Description("2 EPG programs with the same tag (Director) value and pass the tag name in the count request") + @Test + private void groupByEPGTag() { + String query = new KsqlBuilder() + .openOr() + .equal(EPG_ID.getValue(), String.valueOf(program.getId())) + .equal(EPG_ID.getValue(),String.valueOf(program2.getId())) + .closeOr() + .toString(); + + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(query); + searchAssetFilter.setTypeIn("0"); + + ArrayList arrayList = new ArrayList<>(); + AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); + assetMetaOrTagGroupBy.setValue(epgTagName); + arrayList.add(assetMetaOrTagGroupBy); + + searchAssetFilter.setGroupBy(arrayList); + CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + + // asset/action/count + Response assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(2); + } } From f9d43c17448bd88da732d97ca302d8489381c59e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 8 Aug 2018 17:18:16 +0300 Subject: [PATCH 461/605] no message --- src/test/resources/testng.xml | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index a07f3a2d2..58cfe8a48 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,37 +2,37 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file From a410aafb5a299f38a1767589ec12af4307a0dabe Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 9 Aug 2018 15:05:25 +0300 Subject: [PATCH 462/605] fix bug in ingestEpg util - epgData,startTime --- .../client/test/utils/KsqlBuilder.java | 5 +++++ .../test/utils/PerformanceAppLogUtils.java | 5 ----- .../utils/ingestUtils/IngestEpgUtils.java | 20 +++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java index c29a33540..0b67563f8 100644 --- a/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java +++ b/src/test/java/com/kaltura/client/test/utils/KsqlBuilder.java @@ -33,6 +33,11 @@ public KsqlBuilder greaterOrEqual(String key, int value) { return this; } + public KsqlBuilder greaterOrEqual(String key, long value) { + sb.append(key).append(">=").append("'").append(String.valueOf(value)).append("' "); + return this; + } + public KsqlBuilder lessOrEqual(String key, int value) { sb.append(key).append("<=").append("'").append(String.valueOf(value)).append("' "); return this; diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index d21c6105e..268146efc 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -7,15 +7,12 @@ import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; import java.io.*; -import java.io.FileNotFoundException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.stream.Stream; import static com.kaltura.client.test.Properties.*; -import static com.kaltura.client.test.Properties.API_VERSION; -import static com.kaltura.client.test.Properties.getProperty; public class PerformanceAppLogUtils extends BaseUtils { @@ -339,8 +336,6 @@ private static void calcTimeExecution(String appFileName, String kalturaSession) } } } - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 0fd294649..8445bd715 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -19,19 +19,14 @@ import org.w3c.dom.Element; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.tests.enums.KsqlKey.END_DATE; -import static com.kaltura.client.test.tests.enums.KsqlKey.EPG_CHANNEL_ID; -import static com.kaltura.client.test.tests.enums.KsqlKey.START_DATE; +import static com.kaltura.client.test.tests.enums.KsqlKey.*; import static com.kaltura.client.test.utils.BaseUtils.*; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; @@ -75,6 +70,8 @@ public static List insertEpg(EpgData epgData) { final int DEFAULT_PROGRAMMES_COUNT = 2; final int DEFAULT_PROGRAM_DURATION = 30; + df.setTimeZone(TimeZone.getDefault()); + // TODO: complete one-by-one needed fields to cover util ingest_epg from old project epgData.coguid = getCurrentDateInFormat(coguidDatePattern); @@ -82,27 +79,28 @@ public static List insertEpg(EpgData epgData) { if (epgData.seriesId == null) { epgData.seriesId = epgData.coguid; } if (epgData.episodesNum == 0) { epgData.episodesNum = DEFAULT_PROGRAMMES_COUNT; } if (epgData.seasonsNum == 0) { epgData.seasonsNum = DEFAULT_SEASONS_COUNT; } - if (epgData.startDate == null) { epgData.startDate = getEpochInLocalTime(); } + if (epgData.startDate == null) { epgData.startDate = getEpochInUtcTime(0); } if (epgData.programDuration == 0) { epgData.programDuration = DEFAULT_PROGRAM_DURATION; } if (epgData.programDurationPeriod == null) { epgData.programDurationPeriod = DurationPeriod.MINUTES; } if (epgData.thumb == null) { epgData.thumb = DEFAULT_THUMB; } if (epgData.programNamePrefix == null) { epgData.programNamePrefix = "Program"; } + long firstProgramStartDateEpoch = epgData.startDate; + epgChannelId = IngestFixtureData.getEpgChannelId(epgData.epgChannelName); String reqBody = buildIngestEpgXml(epgData); executeIngestEpgRequest(reqBody); // TODO: create method getting epoch value from String and pattern - String firstProgramStartDateEpoch = String.valueOf(epgData.startDate); SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setOrderBy(AssetOrderBy.START_DATE_ASC.getValue()); String query = new KsqlBuilder() .openAnd() .equal(EPG_CHANNEL_ID.getValue(), epgChannelId) - .greaterOrEqual(START_DATE.getValue(), Integer.valueOf(firstProgramStartDateEpoch)) + .greaterOrEqual(START_DATE.getValue(), firstProgramStartDateEpoch) .equal("Series_ID", epgData.seriesId) - .greaterOrEqual(END_DATE.getValue(), Integer.valueOf(firstProgramStartDateEpoch)) + .greaterOrEqual(END_DATE.getValue(), firstProgramStartDateEpoch) .closeAnd() .toString(); assetFilter.setKSql(query); From 4185bff4455b2329468afbccc619e6218d9f9770 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 13 Aug 2018 15:57:36 +0300 Subject: [PATCH 463/605] no message --- .../TransactionPurchaseTests.java | 89 ++++++++++++------- .../test/utils/PerformanceAppLogUtils.java | 34 +++++-- 2 files changed, 82 insertions(+), 41 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index d9d19687a..992dc8a89 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -3,54 +3,62 @@ import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionAdapterStatus; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.ProductPriceService; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; -import com.kaltura.client.services.TransactionService; import com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.kaltura.client.services.ProductPriceService.list; +import static com.kaltura.client.services.TransactionService.purchase; +import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; +import static com.kaltura.client.test.utils.HouseholdUtils.*; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; public class TransactionPurchaseTests extends BaseTest { - private int numberOfUsersInDomain = 2; - private int numberOfDevicesInDomain = 2; - private Response> listResponse; + private final int numOfUsers = 2; + private final int numOfDevices = 2; + private Household household; private String masterUserKs; private String userKs; - - @BeforeClass (enabled = false) - public void beforeClass(){ + @BeforeClass (enabled = true) + public void transaction_purchas_before_class(){ // Prepare household with users and devices - household = HouseholdUtils.createHousehold(numberOfUsersInDomain, numberOfDevicesInDomain, false); -// HouseholdUser masterUser = HouseholdUtils.getMasterUserFromHousehold(household); -// masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid()); -// userKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(1).getUdid()); + household = createHousehold(numOfUsers, numOfDevices, true); + + String masterUserUdid = getDevicesList(household).get(0).getUdid(); + masterUserKs = getHouseholdMasterUserKs(household, masterUserUdid); - PaymentGatewayProfile paymentGatewayProfile = new PaymentGatewayProfile(); + String userUdid = getDevicesList(household).get(1).getUdid(); + userKs = getHouseholdUserKs(household, userUdid); } - @Test(enabled = false) + @Test(enabled = true) public void purchasePpvWithDefaultPG() { + // set product price filter ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.setFileIdIn(getSharedWebMediaFile().getId().toString()); - ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter).setKs(masterUserKs); - listResponse = executor.executeSync(listProductPriceBuilder); + + // product price list + Response> listResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); assertThat(listResponse.results).isNotNull(); + + // get ppv PpvPrice productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + // purchase ppv Purchase purchase = new Purchase(); purchase.setProductType(TransactionType.PPV); purchase.setProductId(Integer.valueOf(productPricePpv.getPpvModuleId())); @@ -58,19 +66,25 @@ public void purchasePpvWithDefaultPG() { purchase.setCurrency(productPricePpv.getPrice().getCurrency()); purchase.setPrice(productPricePpv.getPrice().getAmount()); - PurchaseTransactionBuilder purchaseTransactionBuilder = TransactionService.purchase(purchase).setKs(masterUserKs); - Response purchaseTransaction = executor.executeSync(purchaseTransactionBuilder); - Transaction purchasePpv = purchaseTransaction.results; - assertThat(purchasePpv).isNotNull(); - assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)BaseUtils.getEpochInLocalTime(0), within(15)); - assertThat(purchasePpv.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); - assertThat(purchasePpv.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); - assertThat(purchasePpv.getFailReasonCode()).isEqualTo(0); - assertThat(purchasePpv.getRelatedObjects()).isNull(); + Transaction purchasePpvTransaction = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)) + .results; + + // assert transaction + assertThat(purchasePpvTransaction).isNotNull(); + assertThat(purchasePpvTransaction.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(), within(120)); + assertThat(purchasePpvTransaction.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(purchasePpvTransaction.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(purchasePpvTransaction.getFailReasonCode()).isEqualTo(0); + assertThat(purchasePpvTransaction.getRelatedObjects()).isNull(); + + // assert product price list + listResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); - listResponse = executor.executeSync(listProductPriceBuilder); assertThat(listResponse.results).isNotNull(); productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); + assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); } @@ -79,8 +93,8 @@ public void purchasePpvWithDefaultPG() { public void purchaseSubscriptionWithDefaultPG() { ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); - ListProductPriceBuilder listProductPriceBuilder = ProductPriceService.list(productPriceFilter).setKs(masterUserKs); - listResponse = executor.executeSync(listProductPriceBuilder); + ListProductPriceBuilder listProductPriceBuilder = list(productPriceFilter).setKs(masterUserKs); + Response> listResponse = executor.executeSync(listProductPriceBuilder); assertThat(listResponse.results).isNotNull(); PpvPrice productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); @@ -93,11 +107,11 @@ public void purchaseSubscriptionWithDefaultPG() { purchase.setCurrency(productPricePpv.getPrice().getCurrency()); purchase.setPrice(productPricePpv.getPrice().getAmount()); - PurchaseTransactionBuilder purchaseTransactionBuilder = TransactionService.purchase(purchase).setKs(masterUserKs); + PurchaseTransactionBuilder purchaseTransactionBuilder = purchase(purchase).setKs(masterUserKs); Response purchaseTransaction = executor.executeSync(purchaseTransactionBuilder); Transaction purchasePpv = purchaseTransaction.results; assertThat(purchasePpv).isNotNull(); - assertThat(purchasePpv.getCreatedAt()).isCloseTo((int)BaseUtils.getEpochInLocalTime(0), within(15)); + assertThat(purchasePpv.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(0), within(15)); assertThat(purchasePpv.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpv.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpv.getFailReasonCode()).isEqualTo(0); @@ -109,4 +123,15 @@ public void purchaseSubscriptionWithDefaultPG() { assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); } + + @Test (enabled = false) + public void purchaseCollectionWithDefaultPG() { + + } + + @AfterClass + public void transaction_purchas_after_class() { + // cleanup + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 268146efc..c75a21dbd 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -29,9 +29,9 @@ static class SlowRatio { private static final String domain = getProperty(PHOENIX_SERVER_DOMAIN_NAME); private static final String userName = getProperty(PHOENIX_SERVER_USER_NAME); private static final String password = getProperty(PHOENIX_SERVER_PASSWORD); + private static final String remoteSourceFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY) + getProperty(API_VERSION) + "\\"; private static final UserAuthenticator auth = new StaticUserAuthenticator(domain, userName, password); private static final FileSystemOptions options = new FileSystemOptions(); - private static final String remoteSourceFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY) + getProperty(API_VERSION) + "\\"; private static final String COUCHBASE_LOG_DATA = "\"e\":\"cb\""; private static final String DB_LOG_DATA = "\"e\":\"db\""; @@ -55,14 +55,20 @@ static class SlowRatio { private static double timeOfRabbit; private static double totalTime; private static boolean isKalturaSessionFoundInAppLogFile; + private static int countOfCB; + private static int countOfDB; + private static int countOfES; + private static int countOfRabbit; public static void createPerformanceCodeReport() { try { + // copy log files to local machine List appRemoteFileNames = getRemoteAppLogFileNames(); for (String fileName : appRemoteFileNames) { copyRemoteFile2LocalMachine(fileName); } + // aggregeted last regression results Map> methodsAndKalturaSessions = loadMethodsAndSessionsFromTestFile(); Map methodsAndSlowRatioData = new HashMap<>(); @@ -84,10 +90,16 @@ public static void createPerformanceCodeReport() { timeOfRabbit = 0.0; totalTime = 0.0; + countOfCB = 0; + countOfDB = 0; + countOfES = 0; + countOfRabbit = 0; + calcTimeExecution(appFileName, xKalturaSession); if (isKalturaSessionFoundInAppLogFile) { double percentageCodeTime2TotalTime = timeOfCode / totalTime * 100; + // include in report only relevant cases if (percentageCodeTime2TotalTime > maxAllowedPercentage && totalTime > Double.parseDouble(getProperty(MAX_ALLOWED_EXECUTION_TIME_IN_SEC))) { @@ -176,10 +188,10 @@ private static void writeReport2File(String method, String xKalturaSession, doub out.println(xKalturaSession); out.println("Execution Time: " + totalTime); out.println("Code: " + String.format("%.2f", codeTimePercentage) + "% (" + timeOfCode + ")"); - writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime); - writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime); - writeIfValueMoreThanZero(out, "Elastic: ", timeOfES, totalTime); - writeIfValueMoreThanZero(out, "Rabbit: ", timeOfRabbit, totalTime); + writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime, countOfCB); + writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime, countOfDB); + writeIfValueMoreThanZero(out, "Elastic: ", timeOfES, totalTime, countOfES); + writeIfValueMoreThanZero(out, "Rabbit: ", timeOfRabbit, totalTime, countOfRabbit); out.println(); } } catch (IOException e) { @@ -187,9 +199,9 @@ private static void writeReport2File(String method, String xKalturaSession, doub } } - private static void writeIfValueMoreThanZero(PrintWriter out, String title, double timeOfEvent, double totalTime) { + private static void writeIfValueMoreThanZero(PrintWriter out, String title, double timeOfEvent, double totalTime, int countOfEvent) { if (timeOfEvent > 0) { - out.println(title + " " + String.format("%.2f", timeOfEvent / totalTime * 100) + "% (" + timeOfEvent + ")"); + out.println(title + " " + String.format("%.2f", timeOfEvent / totalTime * 100) + "% (" + timeOfEvent + ") [" + countOfEvent + " query(-ies)]"); } } @@ -231,7 +243,7 @@ private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IO Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine(): completed"); } - private static List getRemoteAppLogFileNames() throws IOException { + public static List getRemoteAppLogFileNames() throws IOException { Logger.getLogger(PerformanceAppLogUtils.class).debug("getRemoteAppLogFileNames(): started"); List fileNames = new ArrayList<>(); String sourceFileName = getProperty(PHOENIX_SERVER_LOG_FILE_NAME_PREFIX) + getProperty(API_VERSION) + @@ -324,15 +336,19 @@ private static void calcTimeExecution(String appFileName, String kalturaSession) } if (line.contains(COUCHBASE_LOG_DATA)) { timeOfCB = timeOfCB + Double.valueOf(executionTimeString); + countOfCB++; } if (line.contains(DB_LOG_DATA)) { timeOfDB = timeOfDB + Double.valueOf(executionTimeString); + countOfDB++; } if (line.contains(ELASTIC_SEARCH_LOG_DATA)) { timeOfES = timeOfES + Double.valueOf(executionTimeString); + countOfES++; } if (line.contains(RABBIT_LOG_DATA)) { timeOfRabbit = timeOfRabbit + Double.valueOf(executionTimeString); + countOfRabbit++; } } } @@ -353,4 +369,4 @@ public static void removeCopiedAppLogFiles() { deleteFile(file); } } -} +} \ No newline at end of file From 020a5fe2a336577bcf1b9f0251cbf334f8ecda2d Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 13 Aug 2018 16:53:47 +0300 Subject: [PATCH 464/605] TransactionPurchaseTests --- .../TransactionPurchaseTests.java | 134 +++++++++++------- 1 file changed, 86 insertions(+), 48 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index 992dc8a89..2d699f614 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -4,8 +4,6 @@ import com.kaltura.client.enums.TransactionAdapterStatus; import com.kaltura.client.enums.TransactionType; import com.kaltura.client.services.HouseholdService; -import com.kaltura.client.services.ProductPriceService.ListProductPriceBuilder; -import com.kaltura.client.services.TransactionService.PurchaseTransactionBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -22,18 +20,16 @@ public class TransactionPurchaseTests extends BaseTest { - private final int numOfUsers = 2; - private final int numOfDevices = 2; - - private Household household; private String masterUserKs; private String userKs; - - @BeforeClass (enabled = true) + @BeforeClass () public void transaction_purchas_before_class(){ // Prepare household with users and devices - household = createHousehold(numOfUsers, numOfDevices, true); + int numOfUsers = 2; + int numOfDevices = 2; + + Household household = createHousehold(numOfUsers, numOfDevices, true); String masterUserUdid = getDevicesList(household).get(0).getUdid(); masterUserKs = getHouseholdMasterUserKs(household, masterUserUdid); @@ -42,19 +38,20 @@ public void transaction_purchas_before_class(){ userKs = getHouseholdUserKs(household, userUdid); } - @Test(enabled = true) + @Test() public void purchasePpvWithDefaultPG() { // set product price filter ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.setFileIdIn(getSharedWebMediaFile().getId().toString()); - // product price list - Response> listResponse = executor.executeSync(list(productPriceFilter) + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) .setKs(masterUserKs)); - assertThat(listResponse.results).isNotNull(); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); // get ppv - PpvPrice productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); + PpvPrice productPricePpv = (PpvPrice) productPriceResponse.results.getObjects().get(0); assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); @@ -78,55 +75,96 @@ public void purchasePpvWithDefaultPG() { assertThat(purchasePpvTransaction.getFailReasonCode()).isEqualTo(0); assertThat(purchasePpvTransaction.getRelatedObjects()).isNull(); - // assert product price list - listResponse = executor.executeSync(list(productPriceFilter) - .setKs(masterUserKs)); - - assertThat(listResponse.results).isNotNull(); - productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); + // assert productPrice list with regular userKs + productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(userKs)); + assertThat(productPriceResponse.results).isNotNull(); + productPricePpv = (PpvPrice) productPriceResponse.results.getObjects().get(0); assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); } - @Test (enabled = false) + @Test () public void purchaseSubscriptionWithDefaultPG() { + // set product price filter ProductPriceFilter productPriceFilter = new ProductPriceFilter(); productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); - ListProductPriceBuilder listProductPriceBuilder = list(productPriceFilter).setKs(masterUserKs); - Response> listResponse = executor.executeSync(listProductPriceBuilder); - assertThat(listResponse.results).isNotNull(); - PpvPrice productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); - assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); - assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase subscription Purchase purchase = new Purchase(); - purchase.setProductType(TransactionType.PPV); - purchase.setProductId(Integer.valueOf(productPricePpv.getPpvModuleId())); - purchase.setContentId(getSharedWebMediaFile().getId()); - purchase.setCurrency(productPricePpv.getPrice().getCurrency()); - purchase.setPrice(productPricePpv.getPrice().getAmount()); + purchase.setProductType(TransactionType.SUBSCRIPTION); + purchase.setContentId(0); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setProductId(Integer.valueOf(getSharedCommonSubscription().getId())); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); - PurchaseTransactionBuilder purchaseTransactionBuilder = purchase(purchase).setKs(masterUserKs); - Response purchaseTransaction = executor.executeSync(purchaseTransactionBuilder); - Transaction purchasePpv = purchaseTransaction.results; - assertThat(purchasePpv).isNotNull(); - assertThat(purchasePpv.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(0), within(15)); - assertThat(purchasePpv.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); - assertThat(purchasePpv.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); - assertThat(purchasePpv.getFailReasonCode()).isEqualTo(0); - assertThat(purchasePpv.getRelatedObjects()).isNull(); - - listResponse = executor.executeSync(listProductPriceBuilder); - assertThat(listResponse.results).isNotNull(); - productPricePpv = (PpvPrice) listResponse.results.getObjects().get(0); - assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); - assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + Transaction subscriptionTransaction = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)) + .results; + + // assert transaction + assertThat(subscriptionTransaction).isNotNull(); + assertThat(subscriptionTransaction.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(0), within(120)); + assertThat(subscriptionTransaction.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(subscriptionTransaction.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(subscriptionTransaction.getFailReasonCode()).isEqualTo(0); + assertThat(subscriptionTransaction.getRelatedObjects()).isNull(); + + // assert productPrice list with regular userKs + productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(userKs)); + assertThat(productPriceResponse.results).isNotNull(); + + SubscriptionPrice subscriptionPrice = (SubscriptionPrice) productPriceResponse.results.getObjects().get(0); + assertThat(subscriptionPrice.getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); } - @Test (enabled = false) + @Test () public void purchaseCollectionWithDefaultPG() { + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setCollectionIdIn(getSharedCommonCollection().getId()); + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase collection + Purchase purchase = new Purchase(); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); + purchase.setContentId(0); + purchase.setProductId(Integer.valueOf(getSharedCommonCollection().getId())); + purchase.setProductType(TransactionType.COLLECTION); + + Transaction collectionTransaction = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)) + .results; + + // assert transaction + assertThat(collectionTransaction).isNotNull(); + assertThat(collectionTransaction.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(0), within(120)); + assertThat(collectionTransaction.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(collectionTransaction.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); + assertThat(collectionTransaction.getFailReasonCode()).isEqualTo(0); + assertThat(collectionTransaction.getRelatedObjects()).isNull(); + + // assert productPrice list with regular userKs + productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(userKs)); + assertThat(productPriceResponse.results).isNotNull(); + + CollectionPrice collectionPrice = (CollectionPrice) productPriceResponse.results.getObjects().get(0); + assertThat(collectionPrice.getPurchaseStatus()).isEqualTo(PurchaseStatus.COLLECTION_PURCHASED); } @AfterClass From b7a7f6c692402b721264dd78063d087a6d4c1e95 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 14 Aug 2018 15:46:26 +0300 Subject: [PATCH 465/605] purchaseSubscriptionOnlyPpv() and purchaseCollectionWithPGWithoutChargeId() --- .../com/kaltura/client/test/Properties.java | 3 + .../kaltura/client/test/tests/BaseTest.java | 46 ++--- .../TransactionPurchaseTests.java | 165 +++++++++++++++++- .../schemas/PaymentGatewayProfile.json | 4 +- 4 files changed, 189 insertions(+), 29 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index fac8fc62f..2dba5857f 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -43,6 +43,9 @@ public class Properties { // maximum objects at list response for validating JSON schema public static final int MAX_OBJECTS_AT_LIST_RESPONSE = 20; + // paymentGateway adapter url + public static final String PAYMENT_GATEWAY_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; + // price plans // INGEST doesn't allow create PP with multi-currencies // TODO: should we document it as requirement? price plan having few locales (EUR + few others) with different prices diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 57a221e82..514e94bdc 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -12,6 +12,7 @@ import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; @@ -61,7 +62,6 @@ public class BaseTest { // shared common params public static int partnerId; -// public static int opcPartnerId; public static String defaultUserPassword; // shared ks's @@ -124,20 +124,38 @@ public void baseTest_beforeSuite() { // set client client = new Client(config); -// client.setLanguage("*"); // set default awaitility timeout setDefaultTimeout(Long.parseLong(getProperty(DEFAULT_TIMEOUT_IN_SEC)), TimeUnit.SECONDS); // set shared common params partnerId = Integer.parseInt(getProperty(PARTNER_ID)); -// opcPartnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); + + // set performance report + if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { + // Before execution of regression we have to delete log file created during previous regression execution + // to not affect results of current check + String regressionLogsFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(REGRESSION_LOGS_LOCAL_FILE); + deleteFile(regressionLogsFileName); + + // Before execution of regression we have to delete report file created during previous regression execution + // to not affect results of current check + String codePerformanceReportFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + + getProperty(CODE_PERFORMANCE_REPORT_FILE); + deleteFile(codePerformanceReportFileName); + } } @BeforeMethod public void baseTest_beforeMethod(Method method) { - Logger.getLogger(BaseTest.class).debug("Class: " + getClass().getSimpleName() + ", Test: " + method.getName()); + Logger.getLogger(BaseTest.class).debug("Start test >>> Class: " + getClass().getSimpleName() + ", Test: " + method.getName()); + } + + @AfterMethod + public void baseTest_afterMethod(Method method) { + Logger.getLogger(BaseTest.class).debug("End test >>> Class: " + getClass().getSimpleName() + ", Test: " + method.getName()); } /** @@ -553,7 +571,6 @@ public static HouseholdUser getSharedUser() { } } - // as we have only 1 suite it helps do cleaning after regression execution @AfterSuite public void tearDownSuite() { if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { @@ -561,23 +578,8 @@ public void tearDownSuite() { PerformanceAppLogUtils.createPerformanceCodeReport(); PerformanceAppLogUtils.removeCopiedAppLogFiles(); } - } - - // as we have only 1 suite it helps process fixture etc before regression execution - @BeforeSuite - public void setupSuite() { - if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { - // Before execution of regression we have to delete log file created during previous regression execution - // to not affect results of current check - String regressionLogsFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(REGRESSION_LOGS_LOCAL_FILE); - deleteFile(regressionLogsFileName); - // Before execution of regression we have to delete report file created during previous regression execution - // to not affect results of current check - String codePerformanceReportFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(CODE_PERFORMANCE_REPORT_FILE); - deleteFile(codePerformanceReportFileName); - } + // TODO: 8/14/2018 cleanup: delete generated shared resources and data! } + } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index 2d699f614..7cf1aef4b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -3,18 +3,30 @@ import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionAdapterStatus; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.HouseholdService; +import com.kaltura.client.services.HouseholdPaymentGatewayService; +import com.kaltura.client.services.PaymentGatewayProfileService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.ProductPriceService.list; import static com.kaltura.client.services.TransactionService.purchase; +import static com.kaltura.client.test.Properties.PAYMENT_GATEWAY_ADAPTER_URL; import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpvUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; @@ -23,7 +35,7 @@ public class TransactionPurchaseTests extends BaseTest { private String masterUserKs; private String userKs; - @BeforeClass () + @BeforeClass() public void transaction_purchas_before_class(){ // Prepare household with users and devices int numOfUsers = 2; @@ -38,6 +50,8 @@ public void transaction_purchas_before_class(){ userKs = getHouseholdUserKs(household, userUdid); } + @Severity(SeverityLevel.CRITICAL) + @Description("transaction/action/purchase - ppv with default PG") @Test() public void purchasePpvWithDefaultPG() { // set product price filter @@ -85,7 +99,9 @@ public void purchasePpvWithDefaultPG() { assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); } - @Test () + @Severity(SeverityLevel.CRITICAL) + @Description("transaction/action/purchase - subscription with default PG") + @Test() public void purchaseSubscriptionWithDefaultPG() { // set product price filter ProductPriceFilter productPriceFilter = new ProductPriceFilter(); @@ -126,7 +142,9 @@ public void purchaseSubscriptionWithDefaultPG() { assertThat(subscriptionPrice.getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); } - @Test () + @Severity(SeverityLevel.CRITICAL) + @Description("transaction/action/purchase - collection with default PG") + @Test() public void purchaseCollectionWithDefaultPG() { // set product price filter ProductPriceFilter productPriceFilter = new ProductPriceFilter(); @@ -167,9 +185,146 @@ public void purchaseCollectionWithDefaultPG() { assertThat(collectionPrice.getPurchaseStatus()).isEqualTo(PurchaseStatus.COLLECTION_PURCHASED); } + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - subscription with household without PG - error 6007") + @Test() + public void purchaseSubscriptionWithoutPG() { + // Prepare household with users and devices + Household household = createHousehold(1, 1, false); + String masterUserUdid = getDevicesList(household).get(0).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, masterUserUdid); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setCollectionIdIn(getSharedCommonSubscription().getId()); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase collection + Purchase purchase = new Purchase(); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); + purchase.setContentId(0); + purchase.setProductId(Integer.valueOf(getSharedCommonSubscription().getId())); + purchase.setProductType(TransactionType.SUBSCRIPTION); + + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6007).getCode()); + + //cleanup - delete hh + executor.executeSync(delete().setKs(masterUserKs)); + } + + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - collection with household with PG without charge id - error 6009") + @Test() + public void purchaseCollectionWithPGWithoutChargeId() { + // Prepare household with users and devices + Household household = createHousehold(1, 1, false); + String masterUserUdid = getDevicesList(household).get(0).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, masterUserUdid); + + // create paymentGateway + DateFormat df = new SimpleDateFormat("yyMMddHHmmssSS"); + String externalIdentifier = df.format(new Date()); + + PaymentGatewayProfile pg = new PaymentGatewayProfile(); + pg.setName("paymentGateway_" + getEpochInLocalTime()); + pg.setIsActive(1); + pg.setIsDefault(false); + pg.setRenewStartMinutes(-5); + pg.setRenewIntervalMinutes(15); + pg.setPendingRetries(0); + pg.setPendingInterval(0); + pg.setSharedSecret("123456"); + pg.setExternalIdentifier(externalIdentifier); + pg.setRenewUrl(PAYMENT_GATEWAY_ADAPTER_URL + "?StateCode=0"); + pg.setAdapterUrl(PAYMENT_GATEWAY_ADAPTER_URL); + + // add paymentGateway + pg = executor.executeSync(PaymentGatewayProfileService.add(pg) + .setKs(getOperatorKs())) + .results; + + // enable pg for hh + Response booleanResponse = executor.executeSync(HouseholdPaymentGatewayService.enable(pg.getId()) + .setKs(masterUserKs)); + assertThat(booleanResponse.results).isTrue(); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setCollectionIdIn(getSharedCommonCollection().getId()); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase collection + Purchase purchase = new Purchase(); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); + purchase.setContentId(0); + purchase.setProductId(Integer.valueOf(getSharedCommonCollection().getId())); + purchase.setProductType(TransactionType.COLLECTION); + + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6009).getCode()); + + //cleanup - delete hh and pg + executor.executeSync(delete().setKs(masterUserKs)); + executor.executeSync(PaymentGatewayProfileService.delete(pg.getId()).setKs(getOperatorKs())); + } + + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - ppv configured to 'Subscription Only' - error 3023") + @Test() + public void purchaseSubscriptionOnlyPpv() { + // ingest ppv configured to 'Subscription Only' + PpvData ppvData = new PpvData().isSubscriptionOnly(true); + Ppv ppv = insertPpv(ppvData); + + VodData vodData = new VodData() + .ppvWebName(ppv.getName()) + .ppvMobileName(ppv.getName()); + MediaAsset mediaAsset = insertVod(vodData); + + // purchase ppv + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.PPV); + purchase.setProductId(Integer.valueOf(ppv.getId())); + purchase.setContentId(mediaAsset.getMediaFiles().get(0).getId()); + purchase.setCurrency(ppv.getPrice().getPrice().getCurrency()); + purchase.setPrice(ppv.getPrice().getPrice().getAmount()); + + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3023).getCode()); + + //cleanup - delete ppv + deletePpv(ppv.getName()); + deleteVod(mediaAsset.getName()); + } + @AfterClass public void transaction_purchas_after_class() { // cleanup - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(delete().setKs(masterUserKs)); } } diff --git a/src/test/resources/schemas/PaymentGatewayProfile.json b/src/test/resources/schemas/PaymentGatewayProfile.json index 7fa72748a..c43a11126 100644 --- a/src/test/resources/schemas/PaymentGatewayProfile.json +++ b/src/test/resources/schemas/PaymentGatewayProfile.json @@ -15,7 +15,7 @@ "pendingRetries": {"type": "integer","minimum": 0}, "sharedSecret": {"type": "string","minLength": 0}, "renewIntervalMinutes": {"type": "integer","minimum": 0}, - "renewStartMinutes": {"type": "integer","minimum": 0}, + "renewStartMinutes": {"type": "integer"}, "externalVerification": {"type": "boolean"}, "id": {"type": "integer","minimum": 0}, "name": {"type": "string","minLength": 0}, @@ -24,7 +24,7 @@ "objectType": {"type": "string","minLength": 0} }, "required": ["isActive", "adapterUrl", "transactUrl", "statusUrl","renewUrl","paymentGatewaySettings","externalIdentifier","pendingInterval","pendingRetries","sharedSecret", - "renewIntervalMinutes","renewStartMinutes","externalVerification","id","name","isDefault","paymentMethods","objectType"] + "renewIntervalMinutes","renewStartMinutes","externalVerification","id","name","isDefault","objectType"] } }, "type": "object", From 88178586d41f8cecca18315f2154aede9b81f04e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 14 Aug 2018 17:30:28 +0300 Subject: [PATCH 466/605] added tests: purchasePpvTwice(), purchaseCollectionTwice(), purchasePpvWithInvalidPpvModuleId(), purchaseSubscriptionTwice() --- .../TransactionPurchaseTests.java | 234 +++++++++++++++++- 1 file changed, 231 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java index 7cf1aef4b..644a5b2f9 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java @@ -18,6 +18,7 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.ProductPriceService.list; @@ -36,7 +37,7 @@ public class TransactionPurchaseTests extends BaseTest { private String userKs; @BeforeClass() - public void transaction_purchas_before_class(){ + public void transaction_purchase_before_class(){ // Prepare household with users and devices int numOfUsers = 2; int numOfDevices = 2; @@ -196,7 +197,7 @@ public void purchaseSubscriptionWithoutPG() { // set product price filter ProductPriceFilter productPriceFilter = new ProductPriceFilter(); - productPriceFilter.setCollectionIdIn(getSharedCommonSubscription().getId()); + productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); // productPrice list Response> productPriceResponse = executor.executeSync(list(productPriceFilter) @@ -322,8 +323,235 @@ public void purchaseSubscriptionOnlyPpv() { deleteVod(mediaAsset.getName()); } + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - subscription with invalid price - error 6000") + @Test() + public void purchaseSubscriptionWithInvalidPrice() { + // Prepare household with users and devices + Household household = createHousehold(1, 1, true); + String masterUserUdid = getDevicesList(household).get(0).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, masterUserUdid); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase subscription + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.SUBSCRIPTION); + purchase.setContentId(0); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setProductId(Integer.valueOf(getSharedCommonSubscription().getId())); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount() + 1); + + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6000).getCode()); + + //cleanup - delete hh + executor.executeSync(delete().setKs(masterUserKs)); + } + + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - ppv with invalid ppv moduleId - error 6001") + @Test() + public void purchasePpvWithInvalidPpvModuleId() { + // Prepare household with users and devices + Household household = createHousehold(1, 1, true); + String masterUserUdid = getDevicesList(household).get(0).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, masterUserUdid); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setFileIdIn(getSharedWebMediaFile().getId().toString()); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // get ppv + PpvPrice productPricePpv = (PpvPrice) productPriceResponse.results.getObjects().get(0); + assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + + // purchase ppv + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.PPV); + purchase.setProductId(1); + purchase.setContentId(getSharedWebMediaFile().getId()); + purchase.setCurrency(productPricePpv.getPrice().getCurrency()); + purchase.setPrice(productPricePpv.getPrice().getAmount()); + + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(6001).getCode()); + + //cleanup - delete hh + executor.executeSync(delete().setKs(masterUserKs)); + } + + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - same collection twice - error 3021") + @Test() + public void purchaseCollectionTwice() { + // Prepare household with users and devices + Household household = createHousehold(2, 2, true); + List devices = getDevicesList(household); + String masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); + String userKs = getHouseholdUserKs(household, devices.get(1).getUdid()); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setCollectionIdIn(getSharedCommonCollection().getId()); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase collection + Purchase purchase = new Purchase(); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); + purchase.setContentId(0); + purchase.setProductId(Integer.valueOf(getSharedCommonCollection().getId())); + purchase.setProductType(TransactionType.COLLECTION); + + // purchase collection - first time + executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // purchase collection - second time + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(userKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3027).getCode()); + + //cleanup - delete hh + executor.executeSync(delete().setKs(masterUserKs)); + } + + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - same ppv twice - error 3021") + @Test() + public void purchasePpvTwice() { + // Prepare household with users and devices + Household household = createHousehold(2, 2, true); + List devices = getDevicesList(household); + String masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); + String userKs = getHouseholdUserKs(household, devices.get(1).getUdid()); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setFileIdIn(getSharedWebMediaFile().getId().toString()); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // get ppv + PpvPrice productPricePpv = (PpvPrice) productPriceResponse.results.getObjects().get(0); + assertThat(productPricePpv.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPricePpv.getFileId()).isEqualTo(getSharedWebMediaFile().getId()); + + // purchase ppv + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.PPV); + purchase.setProductId(Integer.valueOf(productPricePpv.getPpvModuleId())); + purchase.setContentId(getSharedWebMediaFile().getId()); + purchase.setCurrency(productPricePpv.getPrice().getCurrency()); + purchase.setPrice(productPricePpv.getPrice().getAmount()); + + // purchase ppv - first time + executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // purchase ppv - second time + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(userKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3021).getCode()); + + //cleanup - delete hh + executor.executeSync(delete().setKs(masterUserKs)); + } + + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - same subscription twice - error 3024") + @Test() + public void purchaseSubscriptionTwice() { + // Prepare household with users and devices + Household household = createHousehold(2, 2, true); + List devices = getDevicesList(household); + String masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); + String userKs = getHouseholdUserKs(household, devices.get(1).getUdid()); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase subscription + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.SUBSCRIPTION); + purchase.setContentId(0); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setProductId(Integer.valueOf(getSharedCommonSubscription().getId())); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); + + // purchase subscription - first time + executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // purchase subscription - second time - because of beo-5249 + executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // purchase subscription - third time + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(userKs)); + + // assert transaction + assertThat(transactionResponse.results).isNull(); + assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3024).getCode()); + + //cleanup - delete hh + executor.executeSync(delete().setKs(masterUserKs)); + } + + // TODO: 8/14/2018 purchase free product + // TODO: 8/14/2018 purchase with coupon (also not valid coupon) + // + // + @AfterClass - public void transaction_purchas_after_class() { + public void transaction_purchase_after_class() { // cleanup executor.executeSync(delete().setKs(masterUserKs)); } From 2ac98e9a5324d4be49f633e98265e50c1772ba43 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 15 Aug 2018 10:29:03 +0300 Subject: [PATCH 467/605] change testng.xml for testign purposes --- src/test/resources/testng.xml | 56 ++++++++++++++++------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 58cfe8a48..c1c83fa32 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,37 +2,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file From 652da7d6eee707c28bfa45442a3e8e92393ae127 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 15 Aug 2018 11:00:44 +0300 Subject: [PATCH 468/605] no message --- src/test/resources/testng.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index c1c83fa32..259440b7f 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -15,7 +15,7 @@ - + From e8facf2ac783998914114a0f07c424fbf24e6aac Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 15 Aug 2018 17:51:18 +0300 Subject: [PATCH 469/605] no message --- .../com/kaltura/client/test/Properties.java | 3 + .../kaltura/client/test/tests/BaseTest.java | 4 +- .../TransactionPurchaseTests.java | 14 ++- .../TransactionPurchaseWithCouponTests.java | 108 ++++++++++++++++++ .../transactionPurchaseWithDiscountTests.java | 8 ++ ...sactionPurchaseWithMultiCurrencyTests.java | 8 ++ src/test/resources/schemas/CouponsGroup.json | 75 ++++++++++++ .../resources/schemas/StringValueArray.json | 33 ++++++ 8 files changed, 246 insertions(+), 7 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/{ => transactionPurchaseTests}/TransactionPurchaseTests.java (98%) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithDiscountTests.java create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithMultiCurrencyTests.java create mode 100644 src/test/resources/schemas/CouponsGroup.json create mode 100644 src/test/resources/schemas/StringValueArray.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 2dba5857f..37fcc7805 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -36,6 +36,9 @@ public class Properties { // collections public static final String DEFAULT_COLLECTION = "default_collection"; + // discount code id + public static final String DISCOUNT_CODE_ID = "discount_code_id"; + // price codes values public static final String PRICE_CODE_AMOUNT = "price_code_amount"; // 4.99 public static final String COMMON_PRICE_CODE_AMOUNT = "5"; // TODO: should we document it as requirement? diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 514e94bdc..e0f130f3a 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -4,7 +4,6 @@ import com.kaltura.client.Configuration; import com.kaltura.client.Logger; import com.kaltura.client.services.ChannelService.AddChannelBuilder; -import com.kaltura.client.services.OttUserService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.PerformanceAppLogUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; @@ -24,6 +23,7 @@ import static com.google.common.base.Verify.verify; import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.services.ChannelService.get; +import static com.kaltura.client.services.OttUserService.anonymousLogin; import static com.kaltura.client.services.OttUserService.login; import static com.kaltura.client.services.SubscriptionService.list; import static com.kaltura.client.test.Properties.*; @@ -358,7 +358,7 @@ public static String getManagerKs() { public static String getAnonymousKs() { if (anonymousKs == null) { - Response loginSession = executor.executeSync(OttUserService.anonymousLogin(partnerId)); + Response loginSession = executor.executeSync(anonymousLogin(partnerId)); anonymousKs = loginSession.results.getKs(); } return anonymousKs; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java similarity index 98% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java index 644a5b2f9..d0f9bf8ed 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java @@ -1,4 +1,4 @@ -package com.kaltura.client.test.tests.servicesTests.transactionTests; +package com.kaltura.client.test.tests.servicesTests.transactionTests.transactionPurchaseTests; import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionAdapterStatus; @@ -545,10 +545,14 @@ public void purchaseSubscriptionTwice() { executor.executeSync(delete().setKs(masterUserKs)); } - // TODO: 8/14/2018 purchase free product - // TODO: 8/14/2018 purchase with coupon (also not valid coupon) - // - // + // TODO: 8/15/2018 complete below scenarios: + // ppv with expired file + // ppv with file off + // asset with future start date + // asset with off ppv + // asset with expired / off file + // + // @AfterClass public void transaction_purchase_after_class() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java new file mode 100644 index 000000000..fc7a7e0e9 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java @@ -0,0 +1,108 @@ +package com.kaltura.client.test.tests.servicesTests.transactionTests.transactionPurchaseTests; + +import com.kaltura.client.enums.CouponGroupType; +import com.kaltura.client.services.CouponsGroupService; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.CouponsGroup; +import com.kaltura.client.types.DiscountDetails; +import com.kaltura.client.types.RandomCouponGenerationOptions; +import com.kaltura.client.types.StringValue; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.CouponsGroupService.add; +import static com.kaltura.client.test.Properties.DISCOUNT_CODE_ID; +import static com.kaltura.client.test.Properties.getProperty; + +public class TransactionPurchaseWithCouponTests extends BaseTest { + + public DiscountDetails discount; + + @BeforeClass + public void TransactionPurchaseWithCouponTests_beforeClass() { +// // get discount +// DiscountDetails discount = executor.executeSync(list() +// .setKs(getOperatorKs())) +// .results +// .getObjects() +// .get(0); + } + + @Severity(SeverityLevel.NORMAL) + @Description("transaction/action/purchase - subscription with coupon") + @Test() + public void purchaseSubscriptionWithCoupon() { + // add coupon group + CouponsGroup cg = new CouponsGroup(); + cg.setCouponGroupType(CouponGroupType.COUPON); + cg.setName("Coupon_" + BaseUtils.getEpochInLocalTime()); + cg.setDiscountId(Long.parseLong(getProperty(DISCOUNT_CODE_ID))); + cg.setMaxUsesNumber(1); + + cg = executor.executeSync(add(cg) + .setKs(getOperatorKs())) + .results; + + RandomCouponGenerationOptions options = new RandomCouponGenerationOptions(); + options.setNumberOfCoupons(1); + options.setUseLetters(true); + options.setUseNumbers(true); + options.setUseSpecialCharacters(true); + + StringValue stringValue = executor.executeSync(CouponsGroupService.generate(Long.parseLong(cg.getId()), options) + .setKs(getOperatorKs())) + .results + .getObjects() + .get(0); + + // Prepare household with users and devices +// Household household = createHousehold(2, 2, true); +// List devices = getDevicesList(household); +// String masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); +// String userKs = getHouseholdUserKs(household, devices.get(1).getUdid()); +// +// // set product price filter +// ProductPriceFilter productPriceFilter = new ProductPriceFilter(); +// productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); +// +// // productPrice list +// Response> productPriceResponse = executor.executeSync(list(productPriceFilter) +// .setKs(masterUserKs)); +// assertThat(productPriceResponse.results).isNotNull(); +// assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); +// +// // purchase subscription +// Purchase purchase = new Purchase(); +// purchase.setProductType(TransactionType.SUBSCRIPTION); +// purchase.setContentId(0); +// purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); +// purchase.setProductId(Integer.valueOf(getSharedCommonSubscription().getId())); +// purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); +// +// // purchase subscription - first time +// executor.executeSync(purchase(purchase) +// .setKs(masterUserKs)); +// +// // purchase subscription - second time - because of beo-5249 +// executor.executeSync(purchase(purchase) +// .setKs(masterUserKs)); +// +// // purchase subscription - third time +// Response transactionResponse = executor.executeSync(purchase(purchase) +// .setKs(userKs)); +// +// // assert transaction +// assertThat(transactionResponse.results).isNull(); +// assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3024).getCode()); +// + // cleanup + executor.executeSync(CouponsGroupService.delete(Long.parseLong(cg.getId())).setKs(getOperatorKs())); +// executor.executeSync(delete().setKs(masterUserKs)); + } + + // TODO: 8/14/2018 purchase with coupon (also not valid coupon) +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithDiscountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithDiscountTests.java new file mode 100644 index 000000000..727ddcaad --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithDiscountTests.java @@ -0,0 +1,8 @@ +package com.kaltura.client.test.tests.servicesTests.transactionTests.transactionPurchaseTests; + +import com.kaltura.client.test.tests.BaseTest; + +public class transactionPurchaseWithDiscountTests extends BaseTest { + + // TODO: 8/15/2018 purchase with discount +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithMultiCurrencyTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithMultiCurrencyTests.java new file mode 100644 index 000000000..a2bb366a3 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/transactionPurchaseWithMultiCurrencyTests.java @@ -0,0 +1,8 @@ +package com.kaltura.client.test.tests.servicesTests.transactionTests.transactionPurchaseTests; + +import com.kaltura.client.test.tests.BaseTest; + +public class transactionPurchaseWithMultiCurrencyTests extends BaseTest { + + // TODO: 8/15/2018 purchase with multi-currency +} diff --git a/src/test/resources/schemas/CouponsGroup.json b/src/test/resources/schemas/CouponsGroup.json new file mode 100644 index 000000000..9d9eddde1 --- /dev/null +++ b/src/test/resources/schemas/CouponsGroup.json @@ -0,0 +1,75 @@ +{ + "$id": "CouponsGroup", + "definitions": { + "CouponsGroup": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "couponGroupType": { + "type": "string", + "minLength": 0 + }, + "discountId": { + "type": "integer", + "minimum": 0 + }, + "endDate": { + "type": "integer", + "minimum": 0 + }, + "id": { + "type": "string", + "minLength": 0 + }, + "maxHouseholdUses": { + "type": "integer", + "minimum": 0 + }, + "maxUsesNumber": { + "type": "integer", + "minimum": 0 + }, + "maxUsesNumberOnRenewableSub": { + "type": "integer", + "minimum": 0 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "startDate": { + "type": "integer", + "minimum": 0 + } + }, + "required": [ + "objectType", + "couponGroupType", + "discountId", + "endDate", + "id", + "maxHouseholdUses", + "maxUsesNumber", + "maxUsesNumberOnRenewableSub", + "name", + "startDate" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/CouponsGroup" + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} \ No newline at end of file diff --git a/src/test/resources/schemas/StringValueArray.json b/src/test/resources/schemas/StringValueArray.json new file mode 100644 index 000000000..b2ec7fbe2 --- /dev/null +++ b/src/test/resources/schemas/StringValueArray.json @@ -0,0 +1,33 @@ +{ + "$id": "StringValueArray", + "definitions": { + "StringValueArray": { + "$id": "StringValueArray", + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "objects": { + "type": "array", + "items": { + "$ref": "StringValue.json" + } + } + }, + "required": [ + "objectType", + "objects" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/StringValueArray" + }, + "executionTime": {"type": "number"} + }, + "required": ["result", "executionTime"] +} \ No newline at end of file From 8d20c594ef4dcb4a45a249e143b47d14a6f37d95 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 16 Aug 2018 02:51:04 +0300 Subject: [PATCH 470/605] Added more logs --- .../client/test/utils/PerformanceAppLogUtils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 2c364111c..c5aba4f85 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -121,6 +121,7 @@ public static void createPerformanceCodeReport() { } private static void addSummary2Report(Map methodsAndSlowRatioData) throws IOException { + Logger.getLogger(PerformanceAppLogUtils.class).debug("addSummary2Report started"); if (methodsAndSlowRatioData.keySet().size() > 0) { String reportFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(CODE_PERFORMANCE_REPORT_FILE); @@ -139,9 +140,11 @@ private static void addSummary2Report(Map methodsAndSlowRatio } Logger.getLogger(PerformanceAppLogUtils.class).debug("Report was successfully created: [" + reportFileName + "]"); } + Logger.getLogger(PerformanceAppLogUtils.class).debug("addSummary2Report completed"); } private static void addReportDataIntoSummaryFile(String fromFile, String toFile) { + Logger.getLogger(PerformanceAppLogUtils.class).debug("addReportDataIntoSummaryFile started"); try (BufferedReader br = Files.newBufferedReader(Paths.get(fromFile)); FileWriter fw = new FileWriter(toFile, true); BufferedWriter bw = new BufferedWriter(fw); @@ -151,10 +154,13 @@ private static void addReportDataIntoSummaryFile(String fromFile, String toFile) lines.close(); } catch (IOException e) { e.printStackTrace(); + } finally { + Logger.getLogger(PerformanceAppLogUtils.class).debug("addReportDataIntoSummaryFile completed"); } } private static void createSummaryFile(Map methodsAndSlowRatioData, String summaryTemporaryFileName) { + Logger.getLogger(PerformanceAppLogUtils.class).debug("createSummaryFile started"); try (FileWriter fw = new FileWriter(summaryTemporaryFileName, true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out = new PrintWriter(bw)) { @@ -175,6 +181,8 @@ private static void createSummaryFile(Map methodsAndSlowRatio out.println(); } catch (IOException e) { e.printStackTrace(); + } finally { + Logger.getLogger(PerformanceAppLogUtils.class).debug("createSummaryFile completed"); } } @@ -250,6 +258,7 @@ public static List getRemoteAppLogFileNames() throws IOException { String sourceFileName = getProperty(PHOENIX_SERVER_LOG_FILE_NAME_PREFIX) + getProperty(API_VERSION) + getProperty(PHOENIX_SERVER_LOG_FILE_EXTENSION); String remoteFilePath = remoteSourceFileDir + sourceFileName; + Logger.getLogger(PerformanceAppLogUtils.class).debug("remoteFilePath: " + remoteFilePath); //domain, username, password DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); @@ -279,6 +288,7 @@ public static List getRemoteAppLogFileNames() throws IOException { } } } + Logger.getLogger(PerformanceAppLogUtils.class).debug("getRemoteAppLogFileNames(): completed"); return fileNames; } @@ -290,6 +300,7 @@ public static List getRemoteAppLogFileNames() throws IOException { * @return map contains all methods and kaltura sessions related to regression */ private static Map> loadMethodsAndSessionsFromTestFile() { + Logger.getLogger(PerformanceAppLogUtils.class).debug("loadMethodsAndSessionsFromTestFile(): started"); Map> result = new HashMap<>(); String[] values; try { @@ -311,6 +322,7 @@ private static Map> loadMethodsAndSessionsFromTestFile() { } catch (IOException e) { e.printStackTrace(); } finally { + Logger.getLogger(PerformanceAppLogUtils.class).debug("loadMethodsAndSessionsFromTestFile(): completed"); return result; } } From e8121df37457ad610151c5d1aec3942193788975 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 16 Aug 2018 02:54:51 +0300 Subject: [PATCH 471/605] updated testng for test reasones --- src/test/resources/testng.xml | 56 ++++++++++++++++------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 58cfe8a48..6fb6854ff 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,37 +2,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file From 380f6dc1a101084dfa52ac32ac5e7047b54fc845 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 16 Aug 2018 07:05:07 +0300 Subject: [PATCH 472/605] added more logs --- .../com/kaltura/client/test/utils/PerformanceAppLogUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index c5aba4f85..067523d36 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -145,6 +145,7 @@ private static void addSummary2Report(Map methodsAndSlowRatio private static void addReportDataIntoSummaryFile(String fromFile, String toFile) { Logger.getLogger(PerformanceAppLogUtils.class).debug("addReportDataIntoSummaryFile started"); + Logger.getLogger(PerformanceAppLogUtils.class).debug(Paths.get(fromFile)); try (BufferedReader br = Files.newBufferedReader(Paths.get(fromFile)); FileWriter fw = new FileWriter(toFile, true); BufferedWriter bw = new BufferedWriter(fw); From 69c42561859cb2122b2570c6334e0a2f5c264279 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 16 Aug 2018 11:58:44 +0300 Subject: [PATCH 473/605] updated report --- .../client/test/utils/PerformanceAppLogUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 067523d36..c3022176e 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -169,11 +169,13 @@ private static void createSummaryFile(Map methodsAndSlowRatio out.println("Max allowed percentage: " + getProperty(MAX_ALLOWED_PERCENTAGE)); out.println("Max allowed execution time in seconds: " + getProperty(MAX_ALLOWED_EXECUTION_TIME_IN_SEC)); out.println(); + out.println("Summary of slow methods are below:"); + out.println(); for (String method : methodsAndSlowRatioData.keySet()) { if (methodsAndSlowRatioData.get(method).slowCount > 0) { out.println(method + " was slow " + String.format("%.2f", methodsAndSlowRatioData.get(method).slowCount * 1.0 / methodsAndSlowRatioData.get(method).totalCount * 100) + "% of executions (" + - methodsAndSlowRatioData.get(method).slowCount * 1.0 + "/" + methodsAndSlowRatioData.get(method).totalCount + ")"); + methodsAndSlowRatioData.get(method).slowCount + "/" + methodsAndSlowRatioData.get(method).totalCount + ")"); } } @@ -196,8 +198,8 @@ private static void writeReport2File(String method, String xKalturaSession, doub if (timeOfCB > 0 || timeOfDB > 0 || timeOfES > 0 || timeOfRabbit > 0) { out.println(method); out.println(xKalturaSession); - out.println("Execution Time: " + totalTime); - out.println("Code: " + String.format("%.2f", codeTimePercentage) + "% (" + timeOfCode + ")"); + out.println("Execution Time: " + String.format("%.3f", totalTime)); + out.println("Code: " + String.format("%.2f", codeTimePercentage) + "% (" + String.format("%.3f", timeOfCode) + ")"); writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime, countOfCB); writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime, countOfDB); writeIfValueMoreThanZero(out, "Elastic: ", timeOfES, totalTime, countOfES); @@ -211,7 +213,7 @@ private static void writeReport2File(String method, String xKalturaSession, doub private static void writeIfValueMoreThanZero(PrintWriter out, String title, double timeOfEvent, double totalTime, int countOfEvent) { if (timeOfEvent > 0) { - out.println(title + " " + String.format("%.2f", timeOfEvent / totalTime * 100) + "% (" + timeOfEvent + ") [" + countOfEvent + " query(-ies)]"); + out.println(title + " " + String.format("%.2f", timeOfEvent / totalTime * 100) + "% (" + String.format("%.3f", timeOfEvent) + ") [" + countOfEvent + " queries]"); } } From ae2f9ed93f850b25b8c0ee720243ad87f58770cf Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 19 Aug 2018 08:04:36 +0300 Subject: [PATCH 474/605] updated logic related performance app report --- .../com/kaltura/client/test/Properties.java | 1 + .../test/utils/PerformanceAppLogUtils.java | 81 +++++++++++++------ src/test/resources/test.template.properties | 1 + 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index fac8fc62f..71db932e3 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -80,6 +80,7 @@ public class Properties { public static final String PHOENIX_SERVER_USER_NAME = "phoenix_server_user_name"; public static final String PHOENIX_SERVER_PASSWORD = "phoenix_server_password"; public static final String PHOENIX_SERVER_LOGS_DIRECTORY = "phoenix_server_logs_directory"; + public static final String PHOENIX_SERVER_LOGS_DIRECTORY_URL = "phoenix_server_logs_directory_url"; public static final String PHOENIX_SERVER_LOG_FILE_NAME_PREFIX = "phoenix_server_logs_file_name_prefix"; public static final String PHOENIX_SERVER_LOG_FILE_EXTENSION = "phoenix_server_logs_file_extension"; public static final String PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH = "phoenix_server_logs_local_folder_path"; diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index c3022176e..9d894d328 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -2,11 +2,14 @@ import com.kaltura.client.Logger; import lombok.Data; +import org.apache.commons.io.FileUtils; import org.apache.commons.vfs2.*; import org.apache.commons.vfs2.auth.StaticUserAuthenticator; import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; @@ -29,7 +32,8 @@ static class SlowRatio { private static final String domain = getProperty(PHOENIX_SERVER_DOMAIN_NAME); private static final String userName = getProperty(PHOENIX_SERVER_USER_NAME); private static final String password = getProperty(PHOENIX_SERVER_PASSWORD); - private static final String remoteSourceFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY) + getProperty(API_VERSION) + "\\"; + private static final String remoteSourceFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY) + getProperty(API_VERSION) + "/"; + private static final String remoteSourceUrlFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY_URL) + getProperty(API_VERSION) + "\\"; private static final UserAuthenticator auth = new StaticUserAuthenticator(domain, userName, password); private static final FileSystemOptions options = new FileSystemOptions(); @@ -68,7 +72,7 @@ public static void createPerformanceCodeReport() { copyRemoteFile2LocalMachine(fileName); } - // aggregeted last regression results + // aggregated last regression results Map> methodsAndKalturaSessions = loadMethodsAndSessionsFromTestFile(); Map methodsAndSlowRatioData = new HashMap<>(); @@ -228,7 +232,7 @@ private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IO getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "] was created == [" + isDirCreated + "]"); } - String remoteFilePath = remoteSourceFileDir + remoteFileName; + String remoteFilePathUrl = remoteSourceUrlFileDir + remoteFileName; String localTargetFilePath = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "copied-" + remoteFileName; appLogLocalFileNames.add(localTargetFilePath); @@ -238,20 +242,22 @@ private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IO targetFile.delete(); } targetFile.createNewFile(); - FileObject destination = VFS.getManager().resolveFile(targetFile.getAbsolutePath()); + //FileObject destination = VFS.getManager().resolveFile(targetFile.getAbsolutePath()); //domain, username, password - DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); + //DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); - FileObject fileObject = VFS.getManager().resolveFile(remoteFilePath, options); + //FileObject fileObject = VFS.getManager().resolveFile(remoteFilePath, options); // copy file from remote to local folder - if (fileObject.exists()) { - destination.copyFrom(fileObject, Selectors.SELECT_SELF); +// if (fileObject.exists()) { +// destination.copyFrom(fileObject, Selectors.SELECT_SELF); +// } + if (isUrlExists(remoteFilePathUrl)) { + FileUtils.copyURLToFile(new URL(remoteFilePathUrl), targetFile); } - destination.close(); - Logger.getLogger(PerformanceAppLogUtils.class).debug("File [" + remoteFilePath + "] was copied into [" + localTargetFilePath + "]"); - + //destination.close(); + Logger.getLogger(PerformanceAppLogUtils.class).debug("File [" + remoteFilePathUrl + "] was copied into [" + localTargetFilePath + "]"); Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine(): completed"); } @@ -260,33 +266,39 @@ public static List getRemoteAppLogFileNames() throws IOException { List fileNames = new ArrayList<>(); String sourceFileName = getProperty(PHOENIX_SERVER_LOG_FILE_NAME_PREFIX) + getProperty(API_VERSION) + getProperty(PHOENIX_SERVER_LOG_FILE_EXTENSION); - String remoteFilePath = remoteSourceFileDir + sourceFileName; - Logger.getLogger(PerformanceAppLogUtils.class).debug("remoteFilePath: " + remoteFilePath); - - //domain, username, password - DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); - - FileObject fileObject = VFS.getManager().resolveFile(remoteFilePath, options); - - if (fileObject.exists()) { + String remoteFilePathUrl = remoteSourceUrlFileDir + sourceFileName; + Logger.getLogger(PerformanceAppLogUtils.class).debug("remoteFilePathUrl: " + remoteFilePathUrl); + +// //domain, username, password +// DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); +// +// FileObject fileObject = VFS.getManager().resolveFile(remoteFilePathUrl, options); + +// if (fileObject.exists()) { +// fileNames.add(sourceFileName); +// } else { +// Logger.getLogger(PerformanceAppLogUtils.class).error("getRemoteAppLogFileNames(): file not found!"); +// } + if (isUrlExists(remoteFilePathUrl)) { fileNames.add(sourceFileName); } else { Logger.getLogger(PerformanceAppLogUtils.class).error("getRemoteAppLogFileNames(): file not found!"); } int idx = 1; - while (fileObject.exists()) { - // all files related needed logs have the same name as value from sourceFileName and additionally they have suffix looks like ".1", ".2", etc + while (isUrlExists(remoteFilePathUrl)) { + // all files related needed logs have the same name as value from sourceFileName and additionally they have + // suffixes that looks like ".1", ".2", etc... String name = sourceFileName + "." + idx; - fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); + //fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); idx++; // sometimes file can be removed and it means we should one more time check names - if (fileObject.exists()) { + if (isUrlExists(remoteSourceUrlFileDir + name)) { fileNames.add(name); } else { + // to handle case when next file has difference in suffixes bigger than 1 name = sourceFileName + "." + idx; - fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); idx++; - if (fileObject.exists()) { + if (isUrlExists(remoteSourceUrlFileDir + name)) { fileNames.add(name); } } @@ -295,6 +307,23 @@ public static List getRemoteAppLogFileNames() throws IOException { return fileNames; } + /*If the connection to a URL (made with HttpURLConnection) returns with HTTP status code 200 then the file exists. + Since we only care it exists or not there is no need to request the entire document. + We can just request the header using the HTTP HEAD request method to check if it exists.*/ + private static boolean isUrlExists(String fileUrl) { + try { + HttpURLConnection.setFollowRedirects(false); + // note : you may also need HttpURLConnection.setInstanceFollowRedirects(false) + HttpURLConnection con = (HttpURLConnection) new URL(fileUrl).openConnection(); + con.setRequestMethod("HEAD"); + return (con.getResponseCode() == HttpURLConnection.HTTP_OK); + } + catch (Exception e) { + e.printStackTrace(); + return false; + } + } + /** * We have file with name getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(REGRESSION_LOGS_LOCAL_FILE) * that saves information about all executed methods and their kaltura sessions. diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index 3b59996bb..813de1664 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -40,6 +40,7 @@ phoenix_server_domain_name=@PHOENIX_SERVER_DOMAIN_NAME@ phoenix_server_user_name=@PHOENIX_SERVER_USER_NAME@ phoenix_server_password=@PHOENIX_SERVER_PASSWORD@ phoenix_server_logs_directory=@PHOENIX_SERVER_LOGS_DIRECTORY@ +phoenix_server_logs_directory_url=@PHOENIX_SERVER_LOGS_DIRECTORY_URL@ phoenix_server_logs_file_name_prefix=@PHOENIX_SERVER_LOGS_FILE_NAME_PREFIX@ phoenix_server_logs_file_extension=@PHOENIX_SERVER_LOGS_FILE_EXTENSION@ phoenix_server_logs_local_folder_path=@PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH@ From 76939210ac8cd6de1eacf1bcfae8d0e806c7a9ca Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 19 Aug 2018 11:37:54 +0300 Subject: [PATCH 475/605] Added more entitlementCancel tests --- .../EntitlementCancelTests.java | 74 +++++++++---------- .../test/utils/dbUtils/DBConstants.java | 5 ++ .../client/test/utils/dbUtils/DBUtils.java | 13 ++++ src/test/resources/WORK_PLAN.md | 2 +- 4 files changed, 53 insertions(+), 41 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 40c248f00..236ee3d7b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -14,6 +14,7 @@ import com.kaltura.client.test.utils.OttUserUtils; import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -22,10 +23,8 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import java.util.List; import java.util.Optional; - import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.services.EntitlementService.*; import static com.kaltura.client.services.HouseholdService.delete; @@ -33,6 +32,8 @@ import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; public class EntitlementCancelTests extends BaseTest { @@ -53,7 +54,7 @@ public void cancelTestBeforeClass() { subscriptionId = Integer.valueOf(getSharedCommonSubscription().getId()); // set household - testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, false); + testSharedHousehold = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); testSharedMasterUser = HouseholdUtils.getMasterUser(testSharedHousehold); playerData = new BookmarkPlayerData(); @@ -192,47 +193,19 @@ public void cancelPlayedSubscription() { @Severity(SeverityLevel.NORMAL) @Description("entitlement/action/cancel - cancel subscription in cancellation window - error 3001") - @Test(enabled = false) //TODO: as not completed + @Test public void cancelSubscriptionInCancellationWindow() { -/* // create mpp having at least 1 media on its channel - sharedChannel.setFilterExpression("name='" + getSharedMediaAsset().getName() + "'"); - AddChannelBuilder addChannelBuilder = ChannelService.add(sharedChannel); - Response channelResponse = executor.executeSync(addChannelBuilder.setKs(getManagerKs())); - sharedChannel.setId(channelResponse.results.getId());*/ + // create MPP with enabled cancellation window PricePlan pricePlan = DBUtils.loadPPWithoutWaiver(); - MppData mppData = new MppData() .pricePlanCode1(pricePlan.getName()) .isRenewable(true); Subscription subscription = insertMpp(mppData); - // set household - /*Household household = HouseholdUtils.createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); - String masterKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesListFromHouseHold(household).get(0).getUdid());*/ + // purchase ingested MPP using shared HH String masterKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId()), null); - PurchaseUtils.purchaseSubscription(masterKs, Integer.valueOf(subscription.getId()), Optional.empty()); - /*// get CDN code for media - MediaFile mediaFile = getMediaFileByType(getSharedMediaAsset(), getProperty(WEB_FILE_TYPE)); - String cdnCode = mediaFile.getUrl(); - - // check license for play - LicensedUrlMediaRequest licensedUrlRequest = new LicensedUrlMediaRequest(); - licensedUrlRequest.setAssetId(String.valueOf(getSharedMediaAsset().getId())); - licensedUrlRequest.setContentId(mediaFile.getId()); - licensedUrlRequest.setBaseUrl(cdnCode); - GetLicensedUrlBuilder licensedUrlBuilder = LicensedUrlService.get(licensedUrlRequest); - Response urlResponse = executor.executeSync(licensedUrlBuilder.setKs(masterKs)); - assertThat(urlResponse.results).isNotNull(); - // play - playerData.setFileId(mediaFile.getId().longValue()); - bookmark.setPlayerData(playerData); - bookmark.setId(String.valueOf(getSharedMediaAsset().getId())); - AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark); - Response booleanResponse = executor.executeSync(addBookmarkBuilder.setKs(masterKs)); - assertThat(booleanResponse.results.booleanValue()).isTrue();*/ - // try cancel CancelEntitlementBuilder cancelEntitlementBuilder = cancel(Integer.valueOf(subscription.getId()), TransactionType.SUBSCRIPTION); @@ -240,14 +213,36 @@ public void cancelSubscriptionInCancellationWindow() { assertThat(booleanResponse.results).isNull(); assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3001).getCode()); - // delete household for cleanup - //executor.executeSync(delete(Math.toIntExact(household.getId())).setKs(getAdministratorKs())); - //delete subscription deleteMpp(subscription.getName()); + } - // delete channel - //executor.executeSync(ChannelService.delete(Math.toIntExact(sharedChannel.getId())).setKs(getManagerKs())); + // TODO: 5/22/2018 add cancel ppv test with dynamic data + @Severity(SeverityLevel.NORMAL) + @Description("entitlement/action/cancel - cancel ppv in cancellation window - error 3001") + @Test + public void cancelPpvInCancellationWindow() { + // ingest VOD having PPV with price plan without waiver + Ppv ppv = DBUtils.loadPPVByPPWithoutWaiver(); + IngestVodUtils.VodData vodData = new IngestVodUtils.VodData() + .ppvWebName(ppv.getName()) + .ppvMobileName(ppv.getName()); + MediaAsset mediaAsset = insertVod(vodData); + + String masterKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId()), null); + // purchase ppv + Integer mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); + Response transactionResponse = PurchaseUtils.purchasePpv(masterKs, Optional.of(Math.toIntExact(mediaAsset.getId())), + Optional.of(mediaFileId), Optional.empty()); + + // try cancel + CancelEntitlementBuilder cancelEntitlementBuilder = cancel(mediaFileId, TransactionType.PPV); + Response booleanResponse = executor.executeSync(cancelEntitlementBuilder.setKs(masterKs)); + assertThat(booleanResponse.results).isNull(); + assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3001).getCode()); + + //delete Vod + deleteVod(mediaAsset.getName()); } @AfterClass @@ -255,5 +250,4 @@ public void cancelTestAfterClass() { // delete shared household for cleanup executor.executeSync(delete(Math.toIntExact(testSharedHousehold.getId())).setKs(getAdministratorKs())); } - // TODO: 5/22/2018 add cancel ppv test with dynamic data } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index e53cacf05..6253907f6 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -98,6 +98,11 @@ public class DBConstants { static final String PRICE_PLAN_WITHOUT_WAVER_SELECT = "SELECT TOP 1 * FROM [Pricing].[dbo].[usage_modules]\n" + "WHERE group_id=? AND WAIVER=0 AND IS_ACTIVE=1 AND [STATUS]=1 AND EXT_DISCOUNT_ID IS NOT NULL AND INTERNAL_DISCOUNT_ID IS NOT NULL"; + static final String PPV_SELECT_BY_PRICE_PLAN_WITHOUT_WAIVER = "select top 1 * from [Pricing].[dbo].[ppv_modules] as ppvm\n" + + "join [Pricing].[dbo].[usage_modules] um on um.id=ppvm.usage_module_code\n" + + "where um.WAIVER=0 and um.group_id=? and ppvm.[status]=1 and ppvm.is_active=1 and \n" + + "um.[status]=1 and um.is_active=1"; + static final String PRICE_PLAN_5_MIN_RENEW_SELECT = "select top 1 * from [Pricing].[dbo].[usage_modules]\n" + "where [status]=1 and is_active=1\n" + "and view_life_cycle_min = 5\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 72022d688..665059ce0 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -5,6 +5,7 @@ import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.tests.enums.PremiumService; import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.types.Ppv; import com.kaltura.client.types.PricePlan; import com.kaltura.client.types.Subscription; import com.kaltura.client.types.SubscriptionFilter; @@ -232,6 +233,18 @@ public static PricePlan loadPPWithoutWaiver() { return loadFirstPricePlanFromJsonArray(jsonArray); } + public static Ppv loadPPVByPPWithoutWaiver() { + JSONArray jsonArray = getJsonArrayFromQueryResult(PPV_SELECT_BY_PRICE_PLAN_WITHOUT_WAIVER, partnerId); + + Ppv ppv = new Ppv(); + ppv.setId(String.valueOf(jsonArray.getJSONObject(0).getInt(ID))); + ppv.setName(jsonArray.getJSONObject(0).getString(NAME)); + ppv.setIsSubscriptionOnly(jsonArray.getJSONObject(0).getInt(SUBSCRIPTION_ONLY) == 0); + // TODO: add more data in case it needed + + return ppv; + } + public static JSONObject getHouseholdById(int householdId) { return getJsonArrayFromQueryResult(HOUSEHOLD_BY_ID_SELECT, partnerId, householdId) .getJSONObject(0); diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index c4578e90e..855a16172 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -38,7 +38,7 @@ Migrate features tests from ReadyAPI | email | | | engagement | | | engagementAdapter | | -| entitlement | Maksim - in progress, actions: cancel - CHECK, cancelRenewal, cancelScheduledSubscription, externalReconcile, forceCancel, getNextRenewal, grant - CHECK, list - done, swap, update +| entitlement | Maksim - in progress, actions: cancel - done, cancelRenewal, cancelScheduledSubscription, externalReconcile, forceCancel, getNextRenewal, grant - CHECK, list - done, swap, update | exportTask | | | externalChannelProfile | | | favorite | | From e4dd9c1732275da4b9b7c18dc71a707684dce024 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 19 Aug 2018 12:42:21 +0300 Subject: [PATCH 476/605] fixed logic related processing of log files --- .../kaltura/client/test/utils/PerformanceAppLogUtils.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index 9d894d328..ab7a28439 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -291,14 +291,16 @@ public static List getRemoteAppLogFileNames() throws IOException { String name = sourceFileName + "." + idx; //fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); idx++; + remoteFilePathUrl = remoteSourceUrlFileDir + name; // sometimes file can be removed and it means we should one more time check names - if (isUrlExists(remoteSourceUrlFileDir + name)) { + if (isUrlExists(remoteFilePathUrl)) { fileNames.add(name); } else { // to handle case when next file has difference in suffixes bigger than 1 name = sourceFileName + "." + idx; idx++; - if (isUrlExists(remoteSourceUrlFileDir + name)) { + remoteFilePathUrl = remoteSourceUrlFileDir + name; + if (isUrlExists(remoteFilePathUrl)) { fileNames.add(name); } } From c9fa116742385aecd4c24aa93e7d5daa57fa3685 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 19 Aug 2018 13:02:46 +0300 Subject: [PATCH 477/605] returned back testng.xml --- src/test/resources/testng.xml | 56 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 6fb6854ff..b328fc2b2 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,33 +2,31 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + From 3e39adf11da6303bf53dcb2c8fe17dbea4e0b199 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 20 Aug 2018 12:12:03 +0300 Subject: [PATCH 478/605] added purchaseSubscriptionWithCoupon() --- .../PermissionsManagementTests.java | 19 +-- .../AssetListTests/BundleFilterTests.java | 5 +- .../AssetListTests/ChannelFilterTests.java | 4 +- .../ScheduledRecordingProgramFilterTests.java | 9 +- .../SearchAssetFilterTests.java | 21 ++- .../AnnouncementAddTest.java | 5 +- .../appTokenTests/AppTokenAddTests.java | 7 +- .../appTokenTests/AppTokenGetTests.java | 4 +- .../AppTokenStartSessionTests.java | 4 +- .../AssetCommentAddTests.java | 4 +- .../AssetHistoryListTests.java | 4 +- .../channelTests/ChannelAddTests.java | 18 +-- .../channelTests/ChannelDeleteTests.java | 4 +- .../OttUserLoginWithPinTests.java | 2 +- .../ProductPriceListTests.java | 2 +- .../TransactionPurchaseTests.java | 9 +- .../TransactionPurchaseWithCouponTests.java | 129 ++++++++++-------- .../kaltura/client/test/utils/BaseUtils.java | 78 ++++++----- .../utils/ingestUtils/IngestEpgUtils.java | 2 +- .../utils/ingestUtils/IngestMppUtils.java | 81 ++++++++++- .../ingest_xml_templates/ingestMPP.xml | 4 +- src/test/resources/testng.xml | 52 +++---- 22 files changed, 282 insertions(+), 185 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index ffa0c7f81..860f4bab1 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -7,12 +7,13 @@ import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + import java.io.File; import java.util.ArrayList; import java.util.List; + import static com.kaltura.client.test.utils.BaseUtils.deleteFile; import static com.kaltura.client.test.utils.BaseUtils.getFileContent; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -98,7 +99,7 @@ public void runningDeleteWithoutFile() { @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") public void export() { // prepare data inserting them in DB using stored procedures - String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); + String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix); @@ -168,7 +169,7 @@ public void runningDeleteUsingEmptyFile() { @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") public void importFromFile() { - String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); + String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -207,14 +208,14 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { deleteFile(path2Log); // insert data in DB - String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)) + "inserted"; + String suffix = String.valueOf(BaseUtils.getEpoch()) + "inserted"; PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); // generate import file data - suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); + suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -235,7 +236,7 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") public void deleteFromDB() { - String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); + String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -289,7 +290,7 @@ public void deleteFromDB() { @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") public void importAlreadyExistedFromFile() { - String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); + String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5); @@ -328,7 +329,7 @@ public void importAlreadyExistedFromFile() { @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") public void runningDeleteUsingFileWithInvalidTags() { // insert role in DB - String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); + String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); @@ -349,7 +350,7 @@ public void runningDeleteUsingFileWithInvalidTags() { @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") public void deleteOnlyFromOneTable() { // insert role in DB - String suffix = String.valueOf(BaseUtils.getEpochInLocalTime(0)); + String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java index a5d1126b5..8d70fff54 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/BundleFilterTests.java @@ -23,7 +23,6 @@ import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.*; import static com.kaltura.client.test.utils.AssetUtils.getAssets; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.dbUtils.DBUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.MppData; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.insertMpp; @@ -75,7 +74,7 @@ private void asset_list_bundleFilter_before_class() { // add channel1 channel1 = new DynamicChannel(); - channel1.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); + channel1.setMultilingualName(setTranslationToken("channel_" + getEpoch())); channel1.setMultilingualDescription(setTranslationToken("Description of " + channel1.getName())); channel1.setSystemName(channel1.getMultilingualName().get(0).getValue() + getRandomValue("")); channel1.setIsActive(true); @@ -88,7 +87,7 @@ private void asset_list_bundleFilter_before_class() { // add channel2 channel2 = new DynamicChannel(); - channel2.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); + channel2.setMultilingualName(setTranslationToken("channel_" + getEpoch())); channel2.setMultilingualDescription(setTranslationToken("Description of " + channel2.getName())); channel2.setSystemName(channel2.getMultilingualName().get(0).getValue() + getRandomValue("")); channel2.setIsActive(true); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java index c24a5bcb4..f0a0248e5 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ChannelFilterTests.java @@ -18,7 +18,7 @@ import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.utils.AssetUtils.getAssets; import static com.kaltura.client.test.utils.AssetUtils.getPrograms; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; +import static com.kaltura.client.test.utils.BaseUtils.getEpoch; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAPIExceptionFromList; import static com.kaltura.client.test.utils.dbUtils.DBUtils.setTranslationToken; import static org.assertj.core.api.Assertions.assertThat; @@ -56,7 +56,7 @@ private void asset_list_channelFilter_before_class() { // add channel channel = new DynamicChannel(); - channel.setMultilingualName(setTranslationToken("channel_" + getEpochInLocalTime())); + channel.setMultilingualName(setTranslationToken("channel_" + getEpoch())); channel.setMultilingualDescription(setTranslationToken("Description of " + channel.getName())); channel.setSystemName(channel.getMultilingualName().get(0).getValue()); channel.setIsActive(true); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java index 9ed90fd3e..3e5f549bc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/ScheduledRecordingProgramFilterTests.java @@ -17,6 +17,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Calendar; import java.util.List; import java.util.Optional; @@ -64,12 +65,12 @@ private void asset_list_scheduledRecordingProgramFilter_before_class() { // ingest epg's EpgData epgData1 = new EpgData(linearAssetJsonObject1.getString("name")) - .startDate(getEpochInLocalTime(5)); + .startDate(getEpoch(Calendar.MINUTE, 5)); programAssets1 = insertEpg(epgData1); // String seriesId = String.valueOf(getEpochInLocalTime()); EpgData epgData2 = new EpgData(linearAssetJsonObject2.getString("name")) - .startDate(getEpochInLocalTime(360)); + .startDate(getEpoch(Calendar.HOUR, 6)); // .seriesId(seriesId) // .seasonsNum(3); programAssets2 = insertEpg(epgData2); @@ -135,7 +136,7 @@ private void list_assets_with_channelFilter_by_startDateGreaterThanOrNull() { ScheduledRecordingProgramFilter filter = new ScheduledRecordingProgramFilter(); filter.setChannelsIn(channelsIn); - filter.setStartDateGreaterThanOrNull(getEpochInUtcTime(180)); + filter.setStartDateGreaterThanOrNull(getEpoch(Calendar.HOUR, 3)); // get list Response> assetListResponse = executor.executeSync(AssetService.list(filter) @@ -157,7 +158,7 @@ private void list_assets_with_channelFilter_by_setEndDateLessThanOrNull() { ScheduledRecordingProgramFilter filter = new ScheduledRecordingProgramFilter(); filter.setChannelsIn(channelsIn); - filter.setEndDateLessThanOrNull(getEpochInUtcTime(60)); + filter.setEndDateLessThanOrNull(getEpoch(Calendar.HOUR, 1)); // get list Response> assetListResponse = executor.executeSync(AssetService.list(filter) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 234bdfae1..3d1a55b14 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -3,11 +3,11 @@ import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; -import com.kaltura.client.enums.PlaybackContextType; -import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.KsqlKey; -import com.kaltura.client.test.utils.*; +import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.KsqlBuilder; +import com.kaltura.client.test.utils.PurchaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -18,18 +18,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; +import java.util.*; import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; - -import static com.kaltura.client.test.tests.enums.KsqlKey.ENTITLED_ASSETS; -import static com.kaltura.client.test.tests.enums.KsqlKey.GEO_BLOCK; -import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; +import static com.kaltura.client.test.tests.enums.KsqlKey.*; import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.AssetUtils.*; @@ -39,6 +33,7 @@ import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.insertEpg; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; +import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; public class SearchAssetFilterTests extends BaseTest { @@ -87,7 +82,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 2 VodData vodData2 = new VodData() .mediaType(MOVIE) - .catalogStartDate(getUtcTimeFormatted(-100)) + .catalogStartDate(getFormattedTime(Calendar.MINUTE,-100, getTimeZone("UTC"))) .tags(tagMap) .strings(stringMetaMap1) .geoBlockRule(geoBlockRule); @@ -97,7 +92,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 3 VodData vodData3 = new VodData() .mediaType(EPISODE) - .catalogStartDate(getUtcTimeFormatted(-10)) + .catalogStartDate(getFormattedTime(Calendar.MINUTE,-10, getTimeZone("UTC"))) .tags(tagMap) .strings(stringMetaMap2); asset3 = insertVod(vodData3); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java index 78fffdae4..ee53d5937 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/announcementTests/AnnouncementAddTest.java @@ -12,13 +12,14 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Calendar; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.AnnouncementService.*; import static com.kaltura.client.services.OttUserService.login; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInUtcTime; +import static com.kaltura.client.test.utils.BaseUtils.getEpoch; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getAnnouncementResultMessageId; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -35,7 +36,7 @@ private void announcement_add_tests_before_class() { @Test(enabled = true) private void addAnnouncement() { // set announcement - long epoch = getEpochInUtcTime(1); + long epoch = getEpoch(Calendar.MINUTE, 1); Announcement announcement = new Announcement(); announcement.setName("Announcement_" + epoch); announcement.setMailSubject(announcement.getName()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 4841e5842..207ad40b8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -4,7 +4,6 @@ import com.kaltura.client.services.AppTokenService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AppTokenUtils; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.APIException; import com.kaltura.client.types.AppToken; import com.kaltura.client.utils.response.base.Response; @@ -14,12 +13,14 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Calendar; import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.AppTokenService.AddAppTokenBuilder; import static com.kaltura.client.services.AppTokenService.GetAppTokenBuilder; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.BaseUtils.getEpoch; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -94,7 +95,7 @@ private void addAppTokenWithExpiryDate_before() { // setup for test add_tests_before_class(); // prepare token with expiration after 1 minute - Long expiryDate = BaseUtils.getEpochInLocalTime(1); + Long expiryDate = getEpoch(Calendar.MINUTE, 1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); AddAppTokenBuilder addAppTokenBuilder = AppTokenService.add(appToken) @@ -142,7 +143,7 @@ private void addAppTokenWithNoExpiryDate() { .setKs(getSharedMasterUserKs()); Response addAppTokenResponse = executor.executeSync(addAppTokenBuilder); - assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(BaseUtils.getEpochInLocalTime(0))); + assertThat(addAppTokenResponse.results.getExpiry()).isGreaterThan(Math.toIntExact(getEpoch())); } @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java index c96e88c49..f1b9249c8 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenGetTests.java @@ -13,6 +13,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Calendar; + import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedUser; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; @@ -30,7 +32,7 @@ public class AppTokenGetTests extends BaseTest { @BeforeClass private void get_tests_before_class() { sessionUserId = getSharedUser().getUserId(); - expiryDate = BaseUtils.getEpochInLocalTime(offSetInMinutes); + expiryDate = BaseUtils.getEpoch(Calendar.MINUTE, offSetInMinutes); } @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java index 71c9b01da..334dafbcc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenStartSessionTests.java @@ -16,6 +16,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Calendar; + import static com.kaltura.client.services.AppTokenService.StartSessionAppTokenBuilder; import static com.kaltura.client.services.OttUserService.AnonymousLoginOttUserBuilder; import static com.kaltura.client.services.OttUserService.anonymousLogin; @@ -41,7 +43,7 @@ private void add_tests_before_class() { AnonymousLoginOttUserBuilder anonymousLoginOttUserBuilder = anonymousLogin(partnerId, udid1); Response loginSessionResponse = executor.executeSync(anonymousLoginOttUserBuilder); anonymousKs = loginSessionResponse.results.getKs(); - expiryDate = BaseUtils.getEpochInLocalTime(1); + expiryDate = BaseUtils.getEpoch(Calendar.MINUTE, 1); } @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 0e45611b6..799373c19 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -62,7 +62,7 @@ private void addCommentForVod() { assertThat(assetCommentResponse.results.getText()).isEqualTo(text); assertThat(assetCommentResponse.results.getSubHeader()).isEqualTo(subHeader); assertThat(assetCommentResponse.results.getHeader()).isEqualTo(header); - assertThat(assetCommentResponse.results.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); + assertThat(assetCommentResponse.results.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpoch()); //Initialize assetCommentFilter object @@ -83,7 +83,7 @@ private void addCommentForVod() { assertThat(assetCommentObjectResponse.getHeader()).isEqualTo(assetCommentResponse.results.getHeader()); assertThat(assetCommentObjectResponse.getText()).isEqualTo(assetCommentResponse.results.getText()); assertThat(assetCommentObjectResponse.getWriter()).isEqualTo(assetCommentResponse.results.getWriter()); - assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); + assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpoch()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 1eff0685d..db8d39e76 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -128,7 +128,7 @@ private void assetHistory_vod_with_one_device_and_two_media() { // Verify that flag is set to false (user hasn't finish watching the asset) assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); - assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); + assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getEpoch()); // Assertions for second object returned assertThat(assetHistoryObject2.getAssetId()).isEqualTo(movie.getId()); @@ -175,7 +175,7 @@ private void assetHistory_vod_with_two_devices_and_one_media() { assertThat(assetHistoryObject1.getPosition()).isEqualTo(position2); assertThat(assetHistoryObject1.getAssetId()).isEqualTo(movie.getId()); assertThat(assetHistoryObject1.getFinishedWatching()).isFalse(); - assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getEpochInLocalTime(0)); + assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getEpoch()); // cleanup - delete household executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index e5c0a769e..b229617dc 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -23,7 +23,7 @@ import static com.kaltura.client.services.ChannelService.add; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; +import static com.kaltura.client.test.utils.BaseUtils.getEpoch; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; @@ -40,7 +40,7 @@ public class ChannelAddTests extends BaseTest { @BeforeClass private void channel_addTests_before_class() { - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; } @@ -52,7 +52,7 @@ private void addChannel() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); @@ -82,7 +82,7 @@ private void addChannelWithAssetType() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); @@ -112,7 +112,7 @@ private void addDynamicChannelWithNotSupportedOpcPartnerId() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); @@ -147,7 +147,7 @@ private void checkOrderOfAssetsInChannel() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.NAME_DESC); - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); @@ -189,7 +189,7 @@ private void addChannelWithInvalidAssetType() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, assetTypes); @@ -214,7 +214,7 @@ private void addChannelWithoutMultilingualName() { DynamicChannel channel = new DynamicChannel(); channel.setIsActive(true); channel.setOrderBy(channelOrder); - channel.setSystemName("systemName " + getEpochInLocalTime()); + channel.setSystemName("systemName " + getEpoch()); //channel/action/add Response channelResponse = executor.executeSync(add(channel) @@ -234,7 +234,7 @@ private void addChannelWithSyntaxErrorInFilterExpression() { ChannelOrder channelOrder = new ChannelOrder(); channelOrder.setOrderBy(ChannelOrderBy.LIKES_DESC); - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; channel = ChannelUtils.addDynamicChannel(channelName, description, isActive, ksqlExpression, channelOrder, null); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java index 6ddb22da5..66bf4cf3c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelDeleteTests.java @@ -13,7 +13,7 @@ import static com.kaltura.client.services.ChannelService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; +import static com.kaltura.client.test.utils.BaseUtils.getEpoch; import static org.assertj.core.api.Assertions.assertThat; public class ChannelDeleteTests extends BaseTest { @@ -25,7 +25,7 @@ public class ChannelDeleteTests extends BaseTest { @Description("channel/action/delete") @Test private void DeleteChannel() { - String channelName = "Channel_" + getEpochInLocalTime(); + String channelName = "Channel_" + getEpoch(); String description = "description of " + channelName; String ksqlExpression = "name ~ 'movie'"; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index 07234ec86..eb4d0bbb2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -104,7 +104,7 @@ private void loginWithPin_with_expired_pinCode_after() { .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(() -> { long expire = userLoginPinResponse.results.getExpirationTime() + 120; - long now = BaseUtils.getEpochInLocalTime(0); + long now = BaseUtils.getEpoch(); return now > expire; }); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 16453d560..8bf730d33 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -77,7 +77,7 @@ public void beforeClass() { sharedChannel.setMultilingualDescription(setTranslationToken("Description of " + sharedChannel.getName())); sharedChannel.setIsActive(true); sharedChannel.setAssetTypes(null); - sharedChannel.setSystemName(sharedChannel.getMultilingualName().get(0).getValue() + "_" + getEpochInLocalTime()); + sharedChannel.setSystemName(sharedChannel.getMultilingualName().get(0).getValue() + "_" + getEpoch()); MppData mppData = new MppData() .isRenewable(true) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java index d0f9bf8ed..f5e807f5c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java @@ -24,7 +24,6 @@ import static com.kaltura.client.services.ProductPriceService.list; import static com.kaltura.client.services.TransactionService.purchase; import static com.kaltura.client.test.Properties.PAYMENT_GATEWAY_ADAPTER_URL; -import static com.kaltura.client.test.utils.BaseUtils.getEpochInLocalTime; import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestPpvUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; @@ -84,7 +83,7 @@ public void purchasePpvWithDefaultPG() { // assert transaction assertThat(purchasePpvTransaction).isNotNull(); - assertThat(purchasePpvTransaction.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(), within(120)); + assertThat(purchasePpvTransaction.getCreatedAt()).isCloseTo((int) getEpoch(), within(120)); assertThat(purchasePpvTransaction.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpvTransaction.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(purchasePpvTransaction.getFailReasonCode()).isEqualTo(0); @@ -128,7 +127,7 @@ public void purchaseSubscriptionWithDefaultPG() { // assert transaction assertThat(subscriptionTransaction).isNotNull(); - assertThat(subscriptionTransaction.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(0), within(120)); + assertThat(subscriptionTransaction.getCreatedAt()).isCloseTo((int) getEpoch(), within(120)); assertThat(subscriptionTransaction.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(subscriptionTransaction.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(subscriptionTransaction.getFailReasonCode()).isEqualTo(0); @@ -171,7 +170,7 @@ public void purchaseCollectionWithDefaultPG() { // assert transaction assertThat(collectionTransaction).isNotNull(); - assertThat(collectionTransaction.getCreatedAt()).isCloseTo((int) getEpochInLocalTime(0), within(120)); + assertThat(collectionTransaction.getCreatedAt()).isCloseTo((int) getEpoch(), within(120)); assertThat(collectionTransaction.getPaymentGatewayResponseId()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(collectionTransaction.getState()).isEqualTo(TransactionAdapterStatus.OK.getValue()); assertThat(collectionTransaction.getFailReasonCode()).isEqualTo(0); @@ -238,7 +237,7 @@ public void purchaseCollectionWithPGWithoutChargeId() { String externalIdentifier = df.format(new Date()); PaymentGatewayProfile pg = new PaymentGatewayProfile(); - pg.setName("paymentGateway_" + getEpochInLocalTime()); + pg.setName("paymentGateway_" + getEpoch()); pg.setIsActive(1); pg.setIsDefault(false); pg.setRenewStartMinutes(-5); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java index fc7a7e0e9..e6a89417c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java @@ -1,35 +1,38 @@ package com.kaltura.client.test.tests.servicesTests.transactionTests.transactionPurchaseTests; import com.kaltura.client.enums.CouponGroupType; +import com.kaltura.client.enums.PurchaseStatus; +import com.kaltura.client.enums.TransactionType; import com.kaltura.client.services.CouponsGroupService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.types.CouponsGroup; -import com.kaltura.client.types.DiscountDetails; -import com.kaltura.client.types.RandomCouponGenerationOptions; -import com.kaltura.client.types.StringValue; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; + import static com.kaltura.client.services.CouponsGroupService.add; +import static com.kaltura.client.services.HouseholdService.delete; +import static com.kaltura.client.services.ProductPriceService.list; +import static com.kaltura.client.services.TransactionService.purchase; import static com.kaltura.client.test.Properties.DISCOUNT_CODE_ID; import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; +import static org.assertj.core.api.Java6Assertions.assertThat; public class TransactionPurchaseWithCouponTests extends BaseTest { - public DiscountDetails discount; - @BeforeClass public void TransactionPurchaseWithCouponTests_beforeClass() { -// // get discount -// DiscountDetails discount = executor.executeSync(list() -// .setKs(getOperatorKs())) -// .results -// .getObjects() -// .get(0); + } @Severity(SeverityLevel.NORMAL) @@ -39,9 +42,11 @@ public void purchaseSubscriptionWithCoupon() { // add coupon group CouponsGroup cg = new CouponsGroup(); cg.setCouponGroupType(CouponGroupType.COUPON); - cg.setName("Coupon_" + BaseUtils.getEpochInLocalTime()); + cg.setName("Coupon_" + BaseUtils.getEpoch()); cg.setDiscountId(Long.parseLong(getProperty(DISCOUNT_CODE_ID))); cg.setMaxUsesNumber(1); + cg.setStartDate(getEpoch(Calendar.MONTH, -1)); + cg.setEndDate(getEpoch(Calendar.YEAR, 10)); cg = executor.executeSync(add(cg) .setKs(getOperatorKs())) @@ -53,55 +58,65 @@ public void purchaseSubscriptionWithCoupon() { options.setUseNumbers(true); options.setUseSpecialCharacters(true); - StringValue stringValue = executor.executeSync(CouponsGroupService.generate(Long.parseLong(cg.getId()), options) + // ingest mpp with coupon group + List couponsGroups = Arrays.asList(cg); + + MppData mppData = new MppData() + .pricePlanCode1(getSharedCommonPricePlan().getName()) + .couponGroups(couponsGroups); + Subscription subscription = insertMpp(mppData); + + // Prepare household + Household household = createHousehold(); + List devices = getDevicesList(household); + String masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); + + // get coupon value + String couponValue = executor.executeSync(CouponsGroupService.generate(Long.parseLong(cg.getId()), options) .setKs(getOperatorKs())) .results .getObjects() - .get(0); - - // Prepare household with users and devices -// Household household = createHousehold(2, 2, true); -// List devices = getDevicesList(household); -// String masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); -// String userKs = getHouseholdUserKs(household, devices.get(1).getUdid()); -// -// // set product price filter -// ProductPriceFilter productPriceFilter = new ProductPriceFilter(); -// productPriceFilter.setSubscriptionIdIn(getSharedCommonSubscription().getId()); -// -// // productPrice list -// Response> productPriceResponse = executor.executeSync(list(productPriceFilter) -// .setKs(masterUserKs)); -// assertThat(productPriceResponse.results).isNotNull(); -// assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); -// -// // purchase subscription -// Purchase purchase = new Purchase(); -// purchase.setProductType(TransactionType.SUBSCRIPTION); -// purchase.setContentId(0); -// purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); -// purchase.setProductId(Integer.valueOf(getSharedCommonSubscription().getId())); -// purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); -// -// // purchase subscription - first time -// executor.executeSync(purchase(purchase) -// .setKs(masterUserKs)); -// -// // purchase subscription - second time - because of beo-5249 -// executor.executeSync(purchase(purchase) -// .setKs(masterUserKs)); -// -// // purchase subscription - third time -// Response transactionResponse = executor.executeSync(purchase(purchase) -// .setKs(userKs)); -// -// // assert transaction -// assertThat(transactionResponse.results).isNull(); -// assertThat(transactionResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(3024).getCode()); -// + .get(0) + .getValue(); + + // set product price filter + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setSubscriptionIdIn(subscription.getId()); + productPriceFilter.setCouponCodeEqual(couponValue); + + // productPrice list + Response> productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + + // purchase subscription + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.SUBSCRIPTION); + purchase.setContentId(0); + purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); + purchase.setProductId(Integer.valueOf(subscription.getId())); + purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); + purchase.setCoupon(couponValue); + + // purchase subscription - first time + Response transactionResponse = executor.executeSync(purchase(purchase) + .setKs(masterUserKs)); + + // assert transaction + assertThat(transactionResponse.error).isNull(); + assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // assert purchase status + productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); + // cleanup executor.executeSync(CouponsGroupService.delete(Long.parseLong(cg.getId())).setKs(getOperatorKs())); -// executor.executeSync(delete().setKs(masterUserKs)); + executor.executeSync(delete().setKs(masterUserKs)); + deleteMpp(subscription.getName()); } // TODO: 8/14/2018 purchase with coupon (also not valid coupon) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 390c79400..8d73aa072 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -18,9 +18,7 @@ import java.util.*; import java.util.concurrent.ThreadLocalRandom; -import static com.kaltura.client.test.Properties.API_BASE_URL; -import static com.kaltura.client.test.Properties.API_VERSION; -import static com.kaltura.client.test.Properties.getProperty; +import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.config; import static io.restassured.RestAssured.given; @@ -45,49 +43,65 @@ public static String getCurrentDateInFormat(String pattern) { } // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) - public static String getTimeFormatted(int offSetInMinutes, TimeZone timeZone) { +// public static String getTimeFormatted(int offSetInMinutes, TimeZone timeZone) { +// DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); +// dateFormat.setTimeZone(timeZone); +// +// Date dNow = new Date(); +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(dNow); +// calendar.add(Calendar.MINUTE, offSetInMinutes); +// dNow = calendar.getTime(); +// +// return dateFormat.format(dNow); +// } +// +// // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) +// public static String getLocalTimeFormatted(int offSetInMinutes) { +// return getTimeFormatted(offSetInMinutes, TimeZone.getDefault()); +// } +// +// public static String getUtcTimeFormatted(int offSetInMinutes) { +// return getTimeFormatted(offSetInMinutes, TimeZone.getTimeZone("UTC")); +// } + + // Get epoch time in seconds according to off set parameter provided (in minutes) +// public static long getEpochInLocalTime(int offSetInMinutes) { +// Calendar calendar = Calendar.getInstance(); +// calendar.add(Calendar.MINUTE, offSetInMinutes); +// +// return calendar.toInstant().getEpochSecond(); +// } + + public static String getFormattedTime(int calendarType, int amount, TimeZone timeZone) { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); dateFormat.setTimeZone(timeZone); - Date dNow = new Date(); + Date d = new Date(); Calendar calendar = Calendar.getInstance(); - calendar.setTime(dNow); - calendar.add(Calendar.MINUTE, offSetInMinutes); - dNow = calendar.getTime(); + calendar.setTime(d); + calendar.add(calendarType, amount); + d = calendar.getTime(); - return dateFormat.format(dNow); + return dateFormat.format(d); } - // Get Date time according to offset parameter provided (with the pattern: dd/MM/yyyy HH:mm:ss) - public static String getLocalTimeFormatted(int offSetInMinutes) { - return getTimeFormatted(offSetInMinutes, TimeZone.getDefault()); - } - - public static String getUtcTimeFormatted(int offSetInMinutes) { - return getTimeFormatted(offSetInMinutes, TimeZone.getTimeZone("UTC")); - } - - // Get epoch time in seconds according to off set parameter provided (in minutes) - public static long getEpochInLocalTime(int offSetInMinutes) { - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.MINUTE, offSetInMinutes); + public static String getFormattedTime(long epoch, TimeZone timeZone) { + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + dateFormat.setTimeZone(timeZone); - return calendar.toInstant().getEpochSecond(); + return dateFormat.format(getDateFromEpoch(epoch)); } - public static long getEpochInLocalTime() { + public static long getEpoch() { return Calendar.getInstance().toInstant().getEpochSecond(); } - public static long getEpochInUtcTime(int offSetInMinutes) { - long time = new Date().getTime() / 1000; - return time + (offSetInMinutes * 60); + public static long getEpoch(int calendarType, int amount) { + Calendar c = Calendar.getInstance(); + c.add(calendarType, amount); -// Calendar calendar = Calendar.getInstance(); -// int timeZoneOffset = TimeZone.getDefault().getRawOffset() / 60000; -// calendar.add(Calendar.MINUTE, offSetInMinutes + timeZoneOffset); -// -// return calendar.toInstant().getEpochSecond(); + return c.toInstant().getEpochSecond(); } public static Date getDateFromEpoch(long epoch) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 8445bd715..339c0d0c0 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -79,7 +79,7 @@ public static List insertEpg(EpgData epgData) { if (epgData.seriesId == null) { epgData.seriesId = epgData.coguid; } if (epgData.episodesNum == 0) { epgData.episodesNum = DEFAULT_PROGRAMMES_COUNT; } if (epgData.seasonsNum == 0) { epgData.seasonsNum = DEFAULT_SEASONS_COUNT; } - if (epgData.startDate == null) { epgData.startDate = getEpochInUtcTime(0); } + if (epgData.startDate == null) { epgData.startDate = getEpoch(); } if (epgData.programDuration == 0) { epgData.programDuration = DEFAULT_PROGRAM_DURATION; } if (epgData.programDurationPeriod == null) { epgData.programDurationPeriod = DurationPeriod.MINUTES; } if (epgData.thumb == null) { epgData.thumb = DEFAULT_THUMB; } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index 8b2e04069..f1032d8cb 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -3,6 +3,8 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.SubscriptionService; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.types.CouponsGroup; +import com.kaltura.client.types.ProductCode; import com.kaltura.client.types.Subscription; import com.kaltura.client.types.SubscriptionFilter; import io.restassured.response.Response; @@ -13,11 +15,15 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import java.util.List; + import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.utils.BaseUtils.getFormattedTime; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; +import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; public class IngestMppUtils extends BaseIngestUtils { @@ -69,8 +75,9 @@ public static class MppData { private String channel2; private String fileType1; private String fileType2; - private String couponGroup; - private String productCodes; + + private List couponGroups; + private List productCodes; private Integer gracePeriodMinute; } @@ -98,8 +105,8 @@ public static Subscription insertMpp(MppData mppData) { if (mppData.gracePeriodMinute == null) { mppData.gracePeriodMinute = DEFAULT_GRACE_PERIOD; } if (mppData.pricePlanCode1 == null) { mppData.pricePlanCode1 = getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP); } if (mppData.channel1 == null) { mppData.channel1 = getProperty(DEFAULT_CHANNEL); } - if (mppData.couponGroup == null) { mppData.couponGroup = DEFAULT_COUPON_GROUP; } - if (mppData.productCodes == null) { mppData.productCodes = DEFAULT_PRODUCT_CODES; } +// if (mppData.couponGroup == null) { mppData.couponGroup = DEFAULT_COUPON_GROUP; } +// if (mppData.productCodes == null) { mppData.productCodes = DEFAULT_PRODUCT_CODES; } String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_INSERT); Response resp = executeIngestMppRequest(reqBody); @@ -230,12 +237,74 @@ private static String buildIngestMppXml(MppData mppData, String action) { mpp.getElementsByTagName("file_type").item(1).setTextContent(mppData.fileType2); // subscription coupon group - mpp.getElementsByTagName("subscription_coupon_group").item(0).setTextContent(mppData.couponGroup); + if (mppData.couponGroups != null && mppData.couponGroups.size() > 0) { + Element subscriptionCouponGroup = (Element) mpp.getElementsByTagName("subscription_coupon_group").item(0); + + for (CouponsGroup cg : mppData.couponGroups) { + subscriptionCouponGroup.appendChild(addCouponsGroup(doc, cg)); + } + } // product codes - mpp.getElementsByTagName("product_codes").item(0).setTextContent(mppData.productCodes); + if (mppData.productCodes != null && mppData.productCodes.size() > 0) { + Element productCodes = (Element) mpp.getElementsByTagName("product_codes").item(0); + + for (ProductCode pc : mppData.productCodes) { + productCodes.appendChild(addProductCode(doc, pc)); + } + } // uncomment cdata return uncommentCdataSection(docToString(doc)); } + + private static Element addCouponsGroup(Document doc, CouponsGroup cg) { + // coupon_group_id node + Element couponsGroup = doc.createElement("coupon_group_id"); + + // start_date node + if (cg.getStartDate() != null) { + Element startDate = doc.createElement("start_date"); + startDate.setTextContent(getFormattedTime(cg.getStartDate(), getTimeZone("UTC"))); + couponsGroup.appendChild(startDate); + } + + // end_date node + if (cg.getEndDate() != null) { + Element endDate = doc.createElement("end_date"); + endDate.setTextContent(getFormattedTime(cg.getEndDate(), getTimeZone("UTC"))); + couponsGroup.appendChild(endDate); + } + + // code node + if (cg.getName() != null) { + Element code = doc.createElement("code"); + code.setTextContent(cg.getName()); + couponsGroup.appendChild(code); + } + + // TODO: 8/16/2018 add relevant CouponsGroup fields in case needed + return couponsGroup; + } + + private static Element addProductCode(Document doc, ProductCode pc) { + // product_code node + Element productCode = doc.createElement("product_code"); + + // code node + if (pc.getCode() != null) { + Element code = doc.createElement("code"); + code.setTextContent(pc.getCode()); + productCode.appendChild(code); + } + + // verification_payment_gateway node + if (pc.getInappProvider() != null) { + Element verificationPaymentGateway = doc.createElement("verification_payment_gateway"); + verificationPaymentGateway.setTextContent(pc.getInappProvider()); + productCode.appendChild(verificationPaymentGateway); + } + + return productCode; + } } diff --git a/src/test/resources/ingest_xml_templates/ingestMPP.xml b/src/test/resources/ingest_xml_templates/ingestMPP.xml index 8f5cfcd0a..5321fcaaf 100644 --- a/src/test/resources/ingest_xml_templates/ingestMPP.xml +++ b/src/test/resources/ingest_xml_templates/ingestMPP.xml @@ -38,9 +38,7 @@ - - - + diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 259440b7f..d610e8064 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,33 +2,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file From 2e061afd00ca54614dc7d41e44db87eda5d5c345 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 20 Aug 2018 15:42:45 +0300 Subject: [PATCH 479/605] Added logic related checking ingest VOD on OPC account --- .../com/kaltura/client/test/Properties.java | 1 + .../kaltura/client/test/tests/BaseTest.java | 25 +++- .../five_zero_two/IngestVodTests.java | 75 +++++++++++ .../AssetTests/AssetCountTests.java | 4 +- .../SearchAssetFilterTests.java | 8 +- .../AssetCommentListTests.java | 2 +- .../channelTests/ChannelAddTests.java | 4 +- .../EntitlementCancelTests.java | 2 +- .../EntitlementListTests.java | 2 +- .../ProductPriceListTests.java | 8 +- .../utils/ingestUtils/IngestVodUtils.java | 126 +++++++++++++----- src/test/resources/test.template.properties | 1 + 12 files changed, 198 insertions(+), 60 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 71db932e3..5c8d8933b 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -19,6 +19,7 @@ public class Properties { // Request properties public static final String PARTNER_ID = "partner_id"; + public static final String IS_OPC_GROUP = "is_opc_group"; // public static final String OPC_PARTNER_ID = "opc_partner_id"; public static final String DEFAULT_TIMEOUT_IN_SEC = "default_timeout_in_sec"; diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 57a221e82..770309a55 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -62,6 +62,7 @@ public class BaseTest { // shared common params public static int partnerId; // public static int opcPartnerId; + public static boolean isOprGroup; public static String defaultUserPassword; // shared ks's @@ -131,8 +132,10 @@ public void baseTest_beforeSuite() { // set shared common params partnerId = Integer.parseInt(getProperty(PARTNER_ID)); + isOprGroup = "true".equals(getProperty(IS_OPC_GROUP)); // opcPartnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); + } @BeforeMethod @@ -276,7 +279,9 @@ public static String getIngestBusinessModuleUserPassword() { public static String getIngestAssetUserName() { if (ingestAssetUserUsername == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 1); + String userInfo = isOprGroup + ? IngestFixtureData.getIngestItemUserData(partnerId) + : IngestFixtureData.getIngestItemUserData(partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } @@ -285,7 +290,9 @@ public static String getIngestAssetUserName() { public static String getIngestAssetUserPassword() { if (ingestAssetUserPassword == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 1); + String userInfo = isOprGroup + ? IngestFixtureData.getIngestItemUserData(partnerId) + : IngestFixtureData.getIngestItemUserData(partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; ingestAssetUserPassword = userInfo.split(":")[1]; } @@ -294,7 +301,9 @@ public static String getIngestAssetUserPassword() { public static String getIngestVirualAssetUserName() { if (ingestVirtualAssetUserUsername == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 2); + String userInfo = isOprGroup + ? IngestFixtureData.getIngestItemUserData(partnerId) + : IngestFixtureData.getIngestItemUserData(partnerId + 2); ingestVirtualAssetUserUsername = userInfo.split(":")[0]; ingestVirtualAssetUserPassword = userInfo.split(":")[1]; } @@ -303,7 +312,9 @@ public static String getIngestVirualAssetUserName() { public static String getIngestVirualAssetUserPassword() { if (ingestVirtualAssetUserPassword == null) { - String userInfo = IngestFixtureData.getIngestItemUserData(partnerId + 2); + String userInfo = isOprGroup + ? IngestFixtureData.getIngestItemUserData(partnerId) + : IngestFixtureData.getIngestItemUserData(partnerId + 2); ingestVirtualAssetUserUsername = userInfo.split(":")[0]; ingestVirtualAssetUserPassword = userInfo.split(":")[1]; } @@ -349,7 +360,7 @@ public static String getAnonymousKs() { public static MediaAsset getSharedMediaAsset() { if (mediaAsset == null) { VodData vodData = new VodData(); - mediaAsset = insertVod(vodData); + mediaAsset = insertVod(vodData, true); } return mediaAsset; } @@ -469,7 +480,7 @@ private static void ingestVODIntoSubscription(Subscription subscription) { if (name != null) { // ingest VOD by name VodData vodData = new VodData(); - MediaAsset mediaAsset = insertVod(vodData); + MediaAsset mediaAsset = insertVod(vodData, true); vodData.name(name); updateVod(mediaAsset.getName(), vodData); @@ -482,7 +493,7 @@ private static void ingestVODIntoSubscription(Subscription subscription) { tags.put(tag, values); VodData vodData = new VodData().tags(tags); - insertVod(vodData); + insertVod(vodData, true); } } diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java new file mode 100644 index 000000000..4dbd5d599 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -0,0 +1,75 @@ +package com.kaltura.client.test.tests.featuresTests.versions.five_zero_two; + +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; +import com.kaltura.client.types.MediaAsset; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; +import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static org.assertj.core.api.Assertions.assertThat; + +/** + * + * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-5428 + */ +public class IngestVodTests extends BaseTest { + + private static final int assetStructId = 1883; // TODO: update on property (or if possible on another type) + private static final String textFieldName = "BoxOffice"; + private static final String dateFieldName = "ReleaseDate"; + private static final String numberFieldName = "Runtime2"; + private static final String booleanFieldName = "IsAgeLimited"; + private static final String tagFieldName = "Actors"; + + private String name; + private String description; + private HashMap stringMetaMap = new HashMap<>(); + private HashMap numberMetaMap = new HashMap<>(); + private HashMap datesMetaMap = new HashMap<>(); + private HashMap> tagsMetaMap = new HashMap<>(); + + @BeforeClass + public void setUp() { + String prefix = "Movie_"; + name = prefix + "Name_" + getCurrentDateInFormat("yyMMddHHmmssSS"); + description = prefix + "Description_" + getCurrentDateInFormat("yyMMddHHmmssSS"); + + stringMetaMap.put(textFieldName, textFieldName + "value1"); + numberMetaMap.put(numberFieldName, 1234); + datesMetaMap.put(dateFieldName, "12/12/2012"); + List actors = new ArrayList<>(); + actors.add("Jack Nicholson"); + actors.add("Natalie Portman"); + tagsMetaMap.put(tagFieldName, actors); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with filled base meta fields") + public void insertVodBaseFields() { + String testSuffix = "1"; + + IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() + .name(name + testSuffix) + .description(description + testSuffix) + .mediaType(MOVIE) + .strings(stringMetaMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + /*.ppvWebName(null) + .ppvMobileName(null)*/; + + MediaAsset asset = insertVod(vodData1, false); + + } + +} diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index 5f59f58c4..26862aeac 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -61,7 +61,7 @@ private void asset_count_before_class() { IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() .mediaType(MOVIE) .strings(stringMetaMap); - asset = insertVod(vodData1); + asset = insertVod(vodData1, true); HashMap stringMetaMap2 = new HashMap<>(); stringMetaMap2.put(metaName1, metaValue1); @@ -73,7 +73,7 @@ private void asset_count_before_class() { .mediaType(MOVIE) .strings(stringMetaMap2); - asset2 = insertVod(vodData2); + asset2 = insertVod(vodData2, true); HashMap epgMetas = new HashMap<>(); epgMetas.put(epgMetaName, epgMetaValue); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 234bdfae1..ea5554172 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -3,8 +3,6 @@ import com.kaltura.client.enums.AssetOrderBy; import com.kaltura.client.enums.AssetType; import com.kaltura.client.enums.MetaTagOrderBy; -import com.kaltura.client.enums.PlaybackContextType; -import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.KsqlKey; import com.kaltura.client.test.utils.*; @@ -82,7 +80,7 @@ private void asset_list_searchAssetFilter_before_class() { // ingest asset 1 VodData vodData1 = new VodData() .mediaType(MOVIE); - asset = insertVod(vodData1); + asset = insertVod(vodData1, true); // ingest asset 2 VodData vodData2 = new VodData() @@ -92,7 +90,7 @@ private void asset_list_searchAssetFilter_before_class() { .strings(stringMetaMap1) .geoBlockRule(geoBlockRule); - asset2 = insertVod(vodData2); + asset2 = insertVod(vodData2, true); // ingest asset 3 VodData vodData3 = new VodData() @@ -100,7 +98,7 @@ private void asset_list_searchAssetFilter_before_class() { .catalogStartDate(getUtcTimeFormatted(-10)) .tags(tagMap) .strings(stringMetaMap2); - asset3 = insertVod(vodData3); + asset3 = insertVod(vodData3, true); // ingest epg 1 EpgData epgData1 = new EpgData(epgChannelName).episodesNum(1); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java index d56ac09e0..67452fc9b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentListTests.java @@ -46,7 +46,7 @@ private void checkCommentsOrder() { VodData vodData = new VodData() .mediaType(MediaType.MOVIE); - Long assetId = insertVod(vodData).getId(); + Long assetId = insertVod(vodData, true).getId(); // Initialize assetComment object AssetComment assetComment = AssetCommentUtils.assetComment(Math.toIntExact(assetId), AssetType.MEDIA, writer, text, createDate, subHeader, header); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java index e5c0a769e..9b0d2743a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/channelTests/ChannelAddTests.java @@ -135,13 +135,13 @@ private void checkOrderOfAssetsInChannel() { VodData vodData = new VodData() .name(asset1Name) .mediaType(MediaType.MOVIE); - MediaAsset movieAsset = insertVod(vodData); + MediaAsset movieAsset = insertVod(vodData, true); // Ingest second asset VodData vodData1 = new VodData() .name(asset2Name) .mediaType(MediaType.EPISODE); - MediaAsset episodeAsset = insertVod(vodData1); + MediaAsset episodeAsset = insertVod(vodData1, true); String ksqlExpression = "(or name = '" + movieAsset.getName() + "' name = '" + episodeAsset.getName() + "')"; ChannelOrder channelOrder = new ChannelOrder(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java index 236ee3d7b..78b31bbc1 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementCancelTests.java @@ -227,7 +227,7 @@ public void cancelPpvInCancellationWindow() { IngestVodUtils.VodData vodData = new IngestVodUtils.VodData() .ppvWebName(ppv.getName()) .ppvMobileName(ppv.getName()); - MediaAsset mediaAsset = insertVod(vodData); + MediaAsset mediaAsset = insertVod(vodData, true); String masterKs = OttUserUtils.getKs(Integer.parseInt(testSharedMasterUser.getUserId()), null); // purchase ppv diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java index 0957df3bb..410c1df14 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementListTests.java @@ -197,7 +197,7 @@ public void entitlementListWithPaging() { Optional.of(getSharedWebMediaFile().getId()), Optional.empty()); VodData vodData = new VodData(); - MediaAsset mediaAsset = insertVod(vodData); + MediaAsset mediaAsset = insertVod(vodData, true); int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(mediaAsset.getId())), diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index 16453d560..c775e9b1d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -616,7 +616,7 @@ public void productPricePpvWithPercentageDiscountAndSpecifiedCurrencyTest() { VodData vodData = new VodData() .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS) .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_DISCOUNT_PERCENTS); - MediaAsset mediaAsset = insertVod(vodData); + MediaAsset mediaAsset = insertVod(vodData, true); int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); @@ -676,7 +676,7 @@ public void productPricePpvWithFixedDiscountAndSpecifiedCurrencyTest() { VodData vodData = new VodData() .ppvWebName(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT) .ppvMobileName(PPV_WITH_MULTI_CURRENCIES_AND_FIXED_DISCOUNT); - MediaAsset mediaAsset = insertVod(vodData); + MediaAsset mediaAsset = insertVod(vodData, true); int mediaFileId = mediaAsset.getMediaFiles().get(0).getId(); int assetWithMultiCurrencyId = Math.toIntExact(mediaAsset.getId()); @@ -733,7 +733,7 @@ public void productPriceWithPassedPpvTest() { VodData vodData = new VodData() .ppvMobileName(ppvMobileModule); - MediaAsset mediaAssetWith2Ppv1Expired = insertVod(vodData); + MediaAsset mediaAssetWith2Ppv1Expired = insertVod(vodData, true); ProductPriceFilter ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); @@ -750,7 +750,7 @@ public void productPriceWithPassedPpvTest() { ppvMobileModule = getSharedCommonPpv().getName() + ppvWithExpiredDate; VodData vodData1 = new VodData() .ppvMobileName(ppvMobileModule); - mediaAssetWith2Ppv1Expired = insertVod(vodData1); + mediaAssetWith2Ppv1Expired = insertVod(vodData1, true); ppFilter = new ProductPriceFilter(); ppFilter.setFileIdIn(String.valueOf(mediaAssetWith2Ppv1Expired.getMediaFiles().get(1).getId())); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 21c0b9014..61a21ba7a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -67,7 +67,7 @@ public static class VodData { /** IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" **/ - public static MediaAsset insertVod(VodData vodData) { + public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequired) { final String coguidDatePattern = "yyMMddHHmmssSS"; final String datePattern = "dd/MM/yyyy hh:mm:ss"; final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); @@ -76,20 +76,50 @@ public static MediaAsset insertVod(VodData vodData) { vodData.coguid = getCurrentDateInFormat(coguidDatePattern); - if (vodData.name == null) { vodData.name = vodData.coguid; } - if (vodData.description == null) { vodData.description = "description of " + vodData.coguid; } - if (vodData.thumbUrl == null) { vodData.thumbUrl = DEFAULT_THUMB; } - if (vodData.catalogStartDate == null) { vodData.catalogStartDate = offsetDateValue; } - if (vodData.catalogEndDate == null) { vodData.catalogEndDate = endDateValue; } - if (vodData.startDate == null) { vodData.startDate = offsetDateValue; } - if (vodData.endDate == null) { vodData.endDate = endDateValue; } - if (vodData.mediaType == null) { vodData.mediaType = MediaType.MOVIE; } - if (vodData.ppvWebName == null) { vodData.ppvWebName = ppvModuleName; } - if (vodData.ppvMobileName == null) { vodData.ppvMobileName = ppvModuleName; } - if (vodData.tags == null) { vodData.tags = getDefaultTags(); } - if (vodData.strings == null) { vodData.strings = getDefaultStrings(); } - if (vodData.dates == null) { vodData.dates = getDefaultDates(); } - if (vodData.numbers == null) { vodData.numbers = getDefaultNumbers(); } + if (areDefaultValuesRequired) { + if (vodData.name == null) { + vodData.name = vodData.coguid; + } + if (vodData.description == null) { + vodData.description = "description of " + vodData.coguid; + } + if (vodData.thumbUrl == null) { + vodData.thumbUrl = DEFAULT_THUMB; + } + if (vodData.catalogStartDate == null) { + vodData.catalogStartDate = offsetDateValue; + } + if (vodData.catalogEndDate == null) { + vodData.catalogEndDate = endDateValue; + } + if (vodData.startDate == null) { + vodData.startDate = offsetDateValue; + } + if (vodData.endDate == null) { + vodData.endDate = endDateValue; + } + if (vodData.mediaType == null) { + vodData.mediaType = MediaType.MOVIE; + } + if (vodData.ppvWebName == null) { + vodData.ppvWebName = ppvModuleName; + } + if (vodData.ppvMobileName == null) { + vodData.ppvMobileName = ppvModuleName; + } + if (vodData.tags == null) { + vodData.tags = getDefaultTags(); + } + if (vodData.strings == null) { + vodData.strings = getDefaultStrings(); + } + if (vodData.dates == null) { + vodData.dates = getDefaultDates(); + } + if (vodData.numbers == null) { + vodData.numbers = getDefaultNumbers(); + } + } String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); @@ -180,29 +210,45 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // name - Element nameElement = (Element) media.getElementsByTagName("name").item(0); - nameElement.getElementsByTagName("value").item(0).setTextContent(vodData.name()); + if (vodData.name() != null) { + Element nameElement = (Element) media.getElementsByTagName("name").item(0); + nameElement.getElementsByTagName("value").item(0).setTextContent(vodData.name()); + } // thumb - Element thumb = (Element) media.getElementsByTagName("thumb").item(0); - thumb.setAttribute("ingestUrl", vodData.thumbUrl()); + if (vodData.thumbUrl() != null) { + Element thumb = (Element) media.getElementsByTagName("thumb").item(0); + thumb.setAttribute("ingestUrl", vodData.thumbUrl()); + } // description - Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); - descriptionElement.getElementsByTagName("value").item(0).setTextContent(vodData.description()); + if (vodData.description() != null) { + Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); + descriptionElement.getElementsByTagName("value").item(0).setTextContent(vodData.description()); + } // dates Element datesElement = (Element) media.getElementsByTagName("dates").item(0); - datesElement.getElementsByTagName("catalog_start").item(0).setTextContent(vodData.catalogStartDate()); - datesElement.getElementsByTagName("start").item(0).setTextContent(vodData.startDate()); - datesElement.getElementsByTagName("catalog_end").item(0).setTextContent(vodData.catalogEndDate()); - datesElement.getElementsByTagName("end").item(0).setTextContent(vodData.endDate()); + if (vodData.catalogStartDate() != null) { + datesElement.getElementsByTagName("catalog_start").item(0).setTextContent(vodData.catalogStartDate()); + } + if (vodData.startDate() != null) { + datesElement.getElementsByTagName("start").item(0).setTextContent(vodData.startDate()); + } + if (vodData.catalogEndDate() != null) { + datesElement.getElementsByTagName("catalog_end").item(0).setTextContent(vodData.catalogEndDate()); + } + if (vodData.endDate() != null) { + datesElement.getElementsByTagName("end").item(0).setTextContent(vodData.endDate()); + } // pic_ratios Element picRatios = (Element) media.getElementsByTagName("pic_ratios").item(0); for (Node n : asList(picRatios.getElementsByTagName("ratio"))) { - Element e = (Element) n; - e.setAttribute("thumb", vodData.thumbUrl()); + if (vodData.thumbUrl() != null) { + Element e = (Element) n; + e.setAttribute("thumb", vodData.thumbUrl()); + } } // media type @@ -211,7 +257,9 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // geo block rule - media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.geoBlockRule()); + if (vodData.geoBlockRule() != null) { + media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.geoBlockRule()); + } // strings if (vodData.strings() != null) { @@ -271,15 +319,19 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // file types - Element file1 = (Element) media.getElementsByTagName("file").item(0); - file1.setAttribute("type", getProperty(WEB_FILE_TYPE)); - file1.setAttribute("co_guid", "web_" + vodData.coguid()); - file1.setAttribute("PPV_MODULE", vodData.ppvWebName()); - - Element file2 = (Element) media.getElementsByTagName("file").item(1); - file2.setAttribute("type", getProperty(MOBILE_FILE_TYPE)); - file2.setAttribute("co_guid", "ipad_" + vodData.coguid()); - file2.setAttribute("PPV_MODULE", vodData.ppvMobileName()); + if (vodData.ppvWebName() != null) { + Element file1 = (Element) media.getElementsByTagName("file").item(0); + file1.setAttribute("type", getProperty(WEB_FILE_TYPE)); + file1.setAttribute("co_guid", "web_" + vodData.coguid()); + file1.setAttribute("PPV_MODULE", vodData.ppvWebName()); + } + + if (vodData.ppvMobileName() != null) { + Element file2 = (Element) media.getElementsByTagName("file").item(1); + file2.setAttribute("type", getProperty(MOBILE_FILE_TYPE)); + file2.setAttribute("co_guid", "ipad_" + vodData.coguid()); + file2.setAttribute("PPV_MODULE", vodData.ppvMobileName()); + } // uncomment cdata String docAsString = docToString(doc); diff --git a/src/test/resources/test.template.properties b/src/test/resources/test.template.properties index 813de1664..a6ce2efa8 100644 --- a/src/test/resources/test.template.properties +++ b/src/test/resources/test.template.properties @@ -2,6 +2,7 @@ api_base_url=@API_BASE_URL@ api_version=@API_VERSION@ partner_id=@PARTNER_ID@ +is_opc_group=@IS_OPC@ ingest_base_url=@INGEST_BASE_URL@ ingest_report_url=@INGEST_REPORT_URL@ default_timeout_in_sec=@DEFAULT_TIMEOUT_IN_SEC@ From 75e6e6a59430eccd11740eef732e5ca1d735bddb Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Mon, 20 Aug 2018 17:06:11 +0300 Subject: [PATCH 480/605] added more logic for ingest VOD with files into OPC account (not working yet) --- .../five_zero_two/IngestVodTests.java | 36 +++++++- .../utils/ingestUtils/IngestVodUtils.java | 84 ++++++++++++++----- .../ingest_xml_templates/ingestVOD.xml | 19 +---- 3 files changed, 98 insertions(+), 41 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index 4dbd5d599..62a30876e 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -36,12 +36,14 @@ public class IngestVodTests extends BaseTest { private HashMap numberMetaMap = new HashMap<>(); private HashMap datesMetaMap = new HashMap<>(); private HashMap> tagsMetaMap = new HashMap<>(); + private List assetFiles = new ArrayList<>(); @BeforeClass public void setUp() { String prefix = "Movie_"; - name = prefix + "Name_" + getCurrentDateInFormat("yyMMddHHmmssSS"); - description = prefix + "Description_" + getCurrentDateInFormat("yyMMddHHmmssSS"); + String localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); + name = prefix + "Name_" + localCoguid; + description = prefix + "Description_" + localCoguid; stringMetaMap.put(textFieldName, textFieldName + "value1"); numberMetaMap.put(numberFieldName, 1234); @@ -50,6 +52,33 @@ public void setUp() { actors.add("Jack Nicholson"); actors.add("Natalie Portman"); tagsMetaMap.put(tagFieldName, actors); + + IngestVodUtils.VODFile file1 = new IngestVodUtils.VODFile() + .assetDuration("1000") + .quality("HIGH") + .handling_type("CLIP") + .cdn_name("Default CDN") + .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .billing_type("Tvinci") + .product_code("productExampleCode") + .type("Test130301") + .coguid("Test130301_" + localCoguid) + .ppvModule("Shai_Regression_PPV"); + IngestVodUtils.VODFile file2 = new IngestVodUtils.VODFile() + .assetDuration("1000") + .quality("HIGH") + .handling_type("CLIP") + .cdn_name("Default CDN") + .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .billing_type("Tvinci") + .product_code("productExampleCode") + .type("new file type1") + .coguid("new file type1_" + localCoguid) + .ppvModule("Subscription_only_PPV"); + assetFiles.add(file1); + assetFiles.add(file2); } @Severity(SeverityLevel.CRITICAL) @@ -65,8 +94,7 @@ public void insertVodBaseFields() { .numbers(numberMetaMap) .dates(datesMetaMap) .tags(tagsMetaMap) - /*.ppvWebName(null) - .ppvMobileName(null)*/; + .assetFiles(assetFiles); MediaAsset asset = insertVod(vodData1, false); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 61a21ba7a..d0c7b15a9 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -39,6 +39,22 @@ public class IngestVodUtils extends BaseIngestUtils { private static final String ingestStatusMessagePath = ingestDataResultPath + "Status.Message"; private static final String ingestAssetIdPath = ingestDataResultPath + "InternalAssetId"; + @Accessors(fluent = true) + @Data + public static class VODFile { + private String assetDuration; + private String quality; + private String handling_type; + private String cdn_name; + private String cdn_code; + private String alt_cdn_code; + private String billing_type; + private String product_code; + private String type; + private String coguid; + private String ppvModule; + } + @Accessors(fluent = true) @Data public static class VodData { @@ -63,6 +79,8 @@ public static class VodData { private Map strings; private Map dates; private Map numbers; + + private List assetFiles; } /** IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" **/ @@ -72,7 +90,6 @@ public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequ final String datePattern = "dd/MM/yyyy hh:mm:ss"; final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); final String endDateValue = "14/10/2099 17:00:00"; - final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value vodData.coguid = getCurrentDateInFormat(coguidDatePattern); @@ -101,12 +118,6 @@ public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequ if (vodData.mediaType == null) { vodData.mediaType = MediaType.MOVIE; } - if (vodData.ppvWebName == null) { - vodData.ppvWebName = ppvModuleName; - } - if (vodData.ppvMobileName == null) { - vodData.ppvMobileName = ppvModuleName; - } if (vodData.tags == null) { vodData.tags = getDefaultTags(); } @@ -318,19 +329,13 @@ private static String buildIngestVodXml(VodData vodData, String action) { } } - // file types - if (vodData.ppvWebName() != null) { - Element file1 = (Element) media.getElementsByTagName("file").item(0); - file1.setAttribute("type", getProperty(WEB_FILE_TYPE)); - file1.setAttribute("co_guid", "web_" + vodData.coguid()); - file1.setAttribute("PPV_MODULE", vodData.ppvWebName()); - } + // files + if (vodData.assetFiles != null && vodData.assetFiles.size() > 0) { + Element files = (Element) media.getElementsByTagName("files").item(0); - if (vodData.ppvMobileName() != null) { - Element file2 = (Element) media.getElementsByTagName("file").item(1); - file2.setAttribute("type", getProperty(MOBILE_FILE_TYPE)); - file2.setAttribute("co_guid", "ipad_" + vodData.coguid()); - file2.setAttribute("PPV_MODULE", vodData.ppvMobileName()); + for (VODFile vodFile : vodData.assetFiles) { + files.appendChild(addFile(doc, vodFile)); + } } // uncomment cdata @@ -339,6 +344,47 @@ private static String buildIngestVodXml(VodData vodData, String action) { return uncommentCdataSection(docAsString); } + private static Element addFile(Document doc, VODFile vodFile) { + // file node + Element file = doc.createElement("file"); + + if (vodFile.assetDuration != null) { + file.setAttribute("assetDuration", vodFile.assetDuration); + } + if (vodFile.quality != null) { + file.setAttribute("quality", vodFile.quality); + } + if (vodFile.handling_type != null) { + file.setAttribute("handling_type", vodFile.handling_type); + } + if (vodFile.cdn_name != null) { + file.setAttribute("cdn_name", vodFile.cdn_name); + } + if (vodFile.cdn_code != null) { + file.setAttribute("cdn_code", vodFile.cdn_code); + } + if (vodFile.alt_cdn_code != null) { + file.setAttribute("alt_cdn_code", vodFile.alt_cdn_code); + } + if (vodFile.billing_type != null) { + file.setAttribute("billing_type", vodFile.billing_type); + } + if (vodFile.product_code != null) { + file.setAttribute("product_code", vodFile.product_code); + } + if (vodFile.coguid != null) { + file.setAttribute("co_guid", vodFile.coguid); + } + if (vodFile.type != null) { + file.setAttribute("type", vodFile.type); + } + if (vodFile.ppvModule != null) { + file.setAttribute("PPV_MODULE", vodFile.ppvModule); + } + + return file; + } + private static Element generateAndAppendMetaNode(Document doc, Element rootElement, String name) { // meta node Element meta = doc.createElement("meta"); diff --git a/src/test/resources/ingest_xml_templates/ingestVOD.xml b/src/test/resources/ingest_xml_templates/ingestVOD.xml index 99b688f2d..53dec33da 100644 --- a/src/test/resources/ingest_xml_templates/ingestVOD.xml +++ b/src/test/resources/ingest_xml_templates/ingestVOD.xml @@ -43,24 +43,7 @@ - - - - + From 471c3fded4ddce49c18871339b2038bf78bc1e85 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 21 Aug 2018 14:59:54 +0300 Subject: [PATCH 481/605] added purchasePpvWithCoupon() --- .../com/kaltura/client/test/Properties.java | 8 +- .../kaltura/client/test/tests/BaseTest.java | 6 +- .../TransactionPurchaseTests.java | 2 + .../TransactionPurchaseWithCouponTests.java | 164 ++++++++++++++---- .../test/utils/dbUtils/DBConstants.java | 5 + .../test/utils/dbUtils/IngestFixtureData.java | 13 +- .../utils/ingestUtils/IngestMppUtils.java | 3 +- .../test/utils/ingestUtils/IngestPpUtils.java | 2 +- .../utils/ingestUtils/IngestPpvUtils.java | 25 ++- .../ingest_xml_templates/ingestPPV.xml | 4 +- .../resources/schemas/DiscountDetails.json | 79 +++++++++ src/test/resources/schemas/ListResponse.json | 6 +- src/test/resources/schemas/Ppv.json | 1 - 13 files changed, 257 insertions(+), 61 deletions(-) create mode 100644 src/test/resources/schemas/DiscountDetails.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 16d2ec916..4086e146f 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -82,10 +82,10 @@ public class Properties { public static final String PAYMENT_GATEWAY_EXTERNAL_ID = "payment_gateway_external_id"; // processing apps logs from remote connection - public static final String PHOENIX_SERVER_DOMAIN_NAME = "phoenix_server_domain_name"; - public static final String PHOENIX_SERVER_USER_NAME = "phoenix_server_user_name"; - public static final String PHOENIX_SERVER_PASSWORD = "phoenix_server_password"; - public static final String PHOENIX_SERVER_LOGS_DIRECTORY = "phoenix_server_logs_directory"; +// public static final String PHOENIX_SERVER_DOMAIN_NAME = "phoenix_server_domain_name"; +// public static final String PHOENIX_SERVER_USER_NAME = "phoenix_server_user_name"; +// public static final String PHOENIX_SERVER_PASSWORD = "phoenix_server_password"; +// public static final String PHOENIX_SERVER_LOGS_DIRECTORY = "phoenix_server_logs_directory"; public static final String PHOENIX_SERVER_LOGS_DIRECTORY_URL = "phoenix_server_logs_directory_url"; public static final String PHOENIX_SERVER_LOG_FILE_NAME_PREFIX = "phoenix_server_logs_file_name_prefix"; public static final String PHOENIX_SERVER_LOG_FILE_EXTENSION = "phoenix_server_logs_file_extension"; diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index e0f130f3a..07265461f 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -178,7 +178,7 @@ public static PricePlan getSharedCommonPricePlan() { .maxViews(0) .price(COMMON_PRICE_CODE_AMOUNT) .currency(EUR.getValue()) - .discount(IngestFixtureData.getDiscount(EUR.getValue(), getSharedCommonDiscount().getPercent().intValue())) + .discount(IngestFixtureData.getDiscountByPercentAndCurrency(EUR.getValue(), getSharedCommonDiscount().getPercent().intValue())) .isRenewable(true) .recurringPeriods(0); @@ -220,7 +220,7 @@ public static Subscription getSharedCommonSubscription() { if (sharedCommonSubscription == null) { MppData mppData = new MppData() .pricePlanCode1(getSharedCommonPricePlan().getName()) - .internalDiscount(IngestFixtureData.getDiscount(EUR.getValue(), (int) defaultDiscountPercentValue)); + .internalDiscount(IngestFixtureData.getDiscountByPercentAndCurrency(EUR.getValue(), (int) defaultDiscountPercentValue)); sharedCommonSubscription = insertMpp(mppData); } @@ -266,7 +266,7 @@ public static Ppv getSharedCommonPpv(){ sharedCommonPpv = IngestFixtureData.loadSharedCommonPpv(getSharedCommonPricePlan()); if (sharedCommonPpv == null) { PpvData ppvData = new PpvData() - .discount(IngestFixtureData.getDiscount(EUR.getValue(), (int) discountPercentValue)) + .discountCode(IngestFixtureData.getDiscountByPercentAndCurrency(EUR.getValue(), (int) discountPercentValue)) .usageModule(getSharedCommonPricePlan().getName()); sharedCommonPpv = insertPpv(ppvData); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java index f5e807f5c..c44d98d1e 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java @@ -545,6 +545,7 @@ public void purchaseSubscriptionTwice() { } // TODO: 8/15/2018 complete below scenarios: + // with discount // ppv with expired file // ppv with file off // asset with future start date @@ -552,6 +553,7 @@ public void purchaseSubscriptionTwice() { // asset with expired / off file // // + // check mpp @AfterClass public void transaction_purchase_after_class() { diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java index e6a89417c..a4e8828b2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseWithCouponTests.java @@ -3,14 +3,17 @@ import com.kaltura.client.enums.CouponGroupType; import com.kaltura.client.enums.PurchaseStatus; import com.kaltura.client.enums.TransactionType; -import com.kaltura.client.services.CouponsGroupService; +import com.kaltura.client.services.*; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestPpvUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -19,45 +22,70 @@ import java.util.List; import static com.kaltura.client.services.CouponsGroupService.add; -import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.ProductPriceService.list; -import static com.kaltura.client.services.TransactionService.purchase; import static com.kaltura.client.test.Properties.DISCOUNT_CODE_ID; import static com.kaltura.client.test.Properties.getProperty; import static com.kaltura.client.test.utils.HouseholdUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestMppUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpvUtils.deletePpv; +import static com.kaltura.client.test.utils.ingestUtils.IngestPpvUtils.insertPpv; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Java6Assertions.assertThat; public class TransactionPurchaseWithCouponTests extends BaseTest { + private static CouponsGroup cg; + private static List coupons; + private static String masterUserKs; + private static Integer discountPercentage; + @BeforeClass public void TransactionPurchaseWithCouponTests_beforeClass() { + // create household + Household household = createHousehold(); + List devices = getDevicesList(household); + masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); - } - - @Severity(SeverityLevel.NORMAL) - @Description("transaction/action/purchase - subscription with coupon") - @Test() - public void purchaseSubscriptionWithCoupon() { // add coupon group - CouponsGroup cg = new CouponsGroup(); + cg = new CouponsGroup(); cg.setCouponGroupType(CouponGroupType.COUPON); cg.setName("Coupon_" + BaseUtils.getEpoch()); cg.setDiscountId(Long.parseLong(getProperty(DISCOUNT_CODE_ID))); - cg.setMaxUsesNumber(1); + cg.setMaxUsesNumber(100); cg.setStartDate(getEpoch(Calendar.MONTH, -1)); - cg.setEndDate(getEpoch(Calendar.YEAR, 10)); + cg.setEndDate(getEpoch(Calendar.YEAR, 100)); cg = executor.executeSync(add(cg) .setKs(getOperatorKs())) .results; + // get discount details + DiscountDetailsFilter filter = new DiscountDetailsFilter(); + filter.setIdIn(getProperty(DISCOUNT_CODE_ID)); + DiscountDetails discountDetails = executor.executeSync(DiscountDetailsService.list(filter) + .setKs(getOperatorKs()) + .setCurrency("*")) + .results.getObjects().get(0); + discountPercentage = discountDetails.getMultiCurrencyDiscount().get(0).getPercentage(); + + // generate coupons RandomCouponGenerationOptions options = new RandomCouponGenerationOptions(); - options.setNumberOfCoupons(1); + options.setNumberOfCoupons(10); options.setUseLetters(true); options.setUseNumbers(true); options.setUseSpecialCharacters(true); + coupons = executor.executeSync(CouponsGroupService.generate(Long.parseLong(cg.getId()), options) + .setKs(getOperatorKs())) + .results + .getObjects(); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("transaction/action/purchase - subscription with coupon") + @Test() + public void purchaseSubscriptionWithCoupon() { // ingest mpp with coupon group List couponsGroups = Arrays.asList(cg); @@ -66,18 +94,8 @@ public void purchaseSubscriptionWithCoupon() { .couponGroups(couponsGroups); Subscription subscription = insertMpp(mppData); - // Prepare household - Household household = createHousehold(); - List devices = getDevicesList(household); - String masterUserKs = getHouseholdMasterUserKs(household, devices.get(0).getUdid()); - - // get coupon value - String couponValue = executor.executeSync(CouponsGroupService.generate(Long.parseLong(cg.getId()), options) - .setKs(getOperatorKs())) - .results - .getObjects() - .get(0) - .getValue(); + // generate coupon + String couponValue = coupons.get(0).getValue(); // set product price filter ProductPriceFilter productPriceFilter = new ProductPriceFilter(); @@ -88,36 +106,110 @@ public void purchaseSubscriptionWithCoupon() { Response> productPriceResponse = executor.executeSync(list(productPriceFilter) .setKs(masterUserKs)); assertThat(productPriceResponse.results).isNotNull(); - assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + ProductPrice productPrice = productPriceResponse.results.getObjects().get(0); + assertThat(productPrice.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPrice.getPrice().getAmount()).isEqualTo(subscription.getPrice().getPrice().getAmount() * discountPercentage / 100); + assertThat(productPrice.getPrice().getCurrency()).isEqualTo(subscription.getPrice().getPrice().getCurrency()); // purchase subscription Purchase purchase = new Purchase(); purchase.setProductType(TransactionType.SUBSCRIPTION); - purchase.setContentId(0); - purchase.setCurrency(productPriceResponse.results.getObjects().get(0).getPrice().getCurrency()); purchase.setProductId(Integer.valueOf(subscription.getId())); - purchase.setPrice(productPriceResponse.results.getObjects().get(0).getPrice().getAmount()); + purchase.setContentId(0); + purchase.setCurrency(productPrice.getPrice().getCurrency()); + purchase.setPrice(productPrice.getPrice().getAmount()); purchase.setCoupon(couponValue); - // purchase subscription - first time - Response transactionResponse = executor.executeSync(purchase(purchase) + // purchase subscription + Response transactionResponse = executor.executeSync(TransactionService.purchase(purchase) .setKs(masterUserKs)); - // assert transaction assertThat(transactionResponse.error).isNull(); assertThat(transactionResponse.results.getState()).isEqualTo("OK"); - // assert purchase status + // productPrice list - assert purchase status productPriceResponse = executor.executeSync(list(productPriceFilter) .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED); // cleanup - executor.executeSync(CouponsGroupService.delete(Long.parseLong(cg.getId())).setKs(getOperatorKs())); - executor.executeSync(delete().setKs(masterUserKs)); deleteMpp(subscription.getName()); } - // TODO: 8/14/2018 purchase with coupon (also not valid coupon) + @Severity(SeverityLevel.CRITICAL) + @Description("transaction/action/purchase - ppv with coupon") + @Test() + public void purchasePpvWithCoupon() { + IngestPpvUtils.PpvData ppvData = new IngestPpvUtils.PpvData().couponGroup(cg); + Ppv ppv = insertPpv(ppvData); + + IngestVodUtils.VodData vodData = new IngestVodUtils.VodData() + .ppvWebName(ppv.getName()) + .ppvMobileName(ppv.getName()); + MediaAsset mediaAsset = insertVod(vodData); + + // generate coupon + String couponValue = coupons.get(1).getValue(); + + // set product price filter - get full price + ProductPriceFilter productPriceFilter = new ProductPriceFilter(); + productPriceFilter.setFileIdIn(String.valueOf(mediaAsset.getMediaFiles().get(0).getId())); + productPriceFilter.setCouponCodeEqual(couponValue); + + // productPrice list + Response> productPriceResponse = executor.executeSync(ProductPriceService + .list(productPriceFilter) + .setKs(getAnonymousKs())); + assertThat(productPriceResponse.results).isNotNull(); + ProductPrice productPrice = productPriceResponse.results.getObjects().get(0); + assertThat(productPrice.getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPrice.getPrice().getAmount()).isEqualTo(ppv.getPrice().getPrice().getAmount() * discountPercentage / 100); + assertThat(productPrice.getPrice().getCurrency()).isEqualTo(ppv.getPrice().getPrice().getCurrency()); + + // purchase ppv + Purchase purchase = new Purchase(); + purchase.setProductType(TransactionType.PPV); + purchase.setProductId(Integer.valueOf(ppv.getId())); + purchase.setContentId(mediaAsset.getMediaFiles().get(0).getId()); + purchase.setCurrency(productPrice.getPrice().getCurrency()); + purchase.setPrice(productPrice.getPrice().getAmount()); + purchase.setCoupon(couponValue); + + // purchase subscription + Response transactionResponse = executor.executeSync(TransactionService.purchase(purchase) + .setKs(masterUserKs)); + assertThat(transactionResponse.error).isNull(); + assertThat(transactionResponse.results.getState()).isEqualTo("OK"); + + // productPrice list - assert purchase status + productPriceResponse = executor.executeSync(list(productPriceFilter) + .setKs(masterUserKs)); + assertThat(productPriceResponse.results).isNotNull(); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + + // cleanup + deletePpv(ppv.getName()); + deleteVod(mediaAsset.getName()); + } + + @AfterClass + public void TransactionPurchaseWithCouponTests_afterClass() { + // delete couponGroup + executor.executeSync(CouponsGroupService.delete(Long.parseLong(cg.getId())) + .setKs(getOperatorKs())); + + // delete hh + executor.executeSync(HouseholdService.delete() + .setKs(masterUserKs)); + } + + // TODO: 8/20/2018 purchase ppv / collection with coupon + // TODO: 8/14/2018 purchase with not valid coupon + // TODO: 8/20/2018 purchase with not valid coupon - diffrent coupon group + // TODO: 8/20/2018 coupon end date expired + // TODO: 8/20/2018 coupon start date expired + // TODO: 8/20/2018 deleted coupon group + // TODO: 8/20/2018 cg.setCouponGroupType(CouponGroupType.COUPON); giftcard } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 6253907f6..79de10c80 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -72,6 +72,11 @@ public class DBConstants { "and price=?\n" + // price amount "and discount_percent=?"; // percent amount + static final String DISCOUNT_BY_ID = "select CODE\n" + + "from [Pricing].[dbo].[discount_codes]\n" + + "where GROUP_ID = ? \n" + + "and id = ?"; + static final String EPG_CHANNEL_ID_SELECT = "SELECT [ID] FROM [TVinci].[dbo].[epg_channels] WHERE [GROUP_ID] = ? AND [NAME] = ?"; static final String INGEST_ITEMS_DATA_SELECT = "select TOP (1) *\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java index 7d6a477cb..eaa394ba7 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/IngestFixtureData.java @@ -98,16 +98,21 @@ public static Collection loadSharedCommonCollection(PricePlan pricePlan) { return collection; } - public static String getDiscount(String currency, int percent) { - Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): currency = " + currency + " percent = " + percent); + public static String getDiscountByPercentAndCurrency(String currency, int percent) { + Logger.getLogger(IngestFixtureData.class).debug("getDiscountByPercent(): currency = " + currency + " percent = " + percent); JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT_AND_CURRENCY, currency, percent, partnerId); return jsonArray.getJSONObject(0).getString(CODE); } - public static DiscountModule getDiscount(int percent) { - Logger.getLogger(IngestFixtureData.class).debug("getDiscount(): percent = " + percent); + public static String getDiscountById(String id) { + JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_ID, partnerId, id); + return jsonArray.getJSONObject(0).getString(CODE); + } + + public static DiscountModule getDiscountByPercent(int percent) { + Logger.getLogger(IngestFixtureData.class).debug("getDiscountByPercent(): percent = " + percent); JSONArray jsonArray = getJsonArrayFromQueryResult(DISCOUNT_BY_PERCENT, percent, partnerId); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index f1032d8cb..8576a6813 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -101,7 +101,8 @@ public static Subscription insertMpp(MppData mppData) { if (mppData.description == null) { mppData.description = "Description of " + mppData.mppCode; } if (mppData.startDate == null) { mppData.startDate = DEFAULT_START_DATE; } if (mppData.endDate == null) { mppData.endDate = DEFAULT_END_DATE; } - if (mppData.internalDiscount == null) { mppData.internalDiscount = IngestFixtureData.getDiscount(currencyOfDiscount, percentageOfDiscount); } + if (mppData.internalDiscount == null) { mppData.internalDiscount = IngestFixtureData + .getDiscountByPercentAndCurrency(currencyOfDiscount, percentageOfDiscount); } if (mppData.gracePeriodMinute == null) { mppData.gracePeriodMinute = DEFAULT_GRACE_PERIOD; } if (mppData.pricePlanCode1 == null) { mppData.pricePlanCode1 = getProperty(DEFAULT_USAGE_MODULE_4_INGEST_MPP); } if (mppData.channel1 == null) { mppData.channel1 = getProperty(DEFAULT_CHANNEL); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 548db233a..3ce7528fd 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -54,7 +54,7 @@ public static PricePlan insertPp(PpData ppData) { final int DEFAULT_RECURRING_PERIODS = 1; final int defaultPercentageOfDiscount = 100; - DiscountModule discountModule = IngestFixtureData.getDiscount(defaultPercentageOfDiscount); + DiscountModule discountModule = IngestFixtureData.getDiscountByPercent(defaultPercentageOfDiscount); ppData.ppCode = getRandomValue("AUTOPricePlan_"); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 1f18696a2..997ef6cc4 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.Logger; -import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; +import com.kaltura.client.types.CouponsGroup; import com.kaltura.client.types.Ppv; import io.restassured.response.Response; import lombok.AccessLevel; @@ -36,7 +36,7 @@ public static class PpvData { private boolean isFirstDeviceLimitation = false; private String description; - private String discount; + private String discountCode; private String currency; private String usageModule; private String productCode; @@ -44,19 +44,17 @@ public static class PpvData { private String secondFileType; private Double price; + + private CouponsGroup couponGroup; } /** IMPORTANT: In order to update or delete existed ppv use ppv.getName() as "ppvCode" */ public static Ppv insertPpv(PpvData ppvData) { - String currencyOfDiscount = "ILS"; - int percentageOfDiscount = 50; - ppvData.ppvCode = getRandomValue("PPV_"); if (ppvData.description == null) { ppvData.description = ppvData.ppvCode; } - if (ppvData.discount == null) { ppvData.discount = IngestFixtureData.getDiscount(currencyOfDiscount, percentageOfDiscount); } - if (ppvData.price == null) { ppvData.price = Double.valueOf(getProperty(PRICE_CODE_AMOUNT)); } + if (ppvData.price == null) { ppvData.price = Double.valueOf(COMMON_PRICE_CODE_AMOUNT); } if (ppvData.currency == null) { ppvData.currency = EUR.getValue(); } if (ppvData.usageModule == null) { ppvData.usageModule = getProperty(DEFAULT_USAGE_MODULE_4_INGEST_PPV); } if (ppvData.productCode == null) { ppvData.productCode = getProperty(DEFAULT_PRODUCT_CODE); } @@ -157,8 +155,10 @@ private static String buildIngestPpvXml(PpvData ppvData, String action) { // usage module ppv.getElementsByTagName("usage_module").item(0).setTextContent(ppvData.usageModule); - // discount - ppv.getElementsByTagName("discount").item(0).setTextContent(ppvData.discount); + // discount code + if (ppvData.discountCode != null) { + ppv.getElementsByTagName("discountCode").item(0).setTextContent(ppvData.discountCode); + } // subscription only ppv.getElementsByTagName("subscription_only").item(0).setTextContent(Boolean.toString(ppvData.isSubscriptionOnly)); @@ -173,6 +173,13 @@ private static String buildIngestPpvXml(PpvData ppvData, String action) { ppv.getElementsByTagName("file_type").item(0).setTextContent(ppvData.firstFileType); ppv.getElementsByTagName("file_type").item(1).setTextContent(ppvData.secondFileType); + + // coupon_group + if (ppvData.couponGroup != null) { + Element couponGroup = (Element) ppv.getElementsByTagName("coupon_group").item(0); + couponGroup.getElementsByTagName("code").item(0).setTextContent(ppvData.couponGroup.getName()); + } + // uncomment cdata return uncommentCdataSection(docToString(doc)); } diff --git a/src/test/resources/ingest_xml_templates/ingestPPV.xml b/src/test/resources/ingest_xml_templates/ingestPPV.xml index 6c4fe4262..de824c843 100644 --- a/src/test/resources/ingest_xml_templates/ingestPPV.xml +++ b/src/test/resources/ingest_xml_templates/ingestPPV.xml @@ -19,7 +19,9 @@ - + + + diff --git a/src/test/resources/schemas/DiscountDetails.json b/src/test/resources/schemas/DiscountDetails.json new file mode 100644 index 000000000..3bc814900 --- /dev/null +++ b/src/test/resources/schemas/DiscountDetails.json @@ -0,0 +1,79 @@ +{ + "$id": "DiscountDetails", + "definitions": { + "DiscountDetails": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "endDate": { + "type": "number", + "minimum": 0.0 + }, + "id": { + "type": "number", + "minimum": 0.0 + }, + "multiCurrencyDiscount": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "minLength": 0 + }, + "amount": { + "type": "number", + "minimum": 0.0 + }, + "currency": { + "type": "string", + "minLength": 0 + }, + "currencySign": { + "type": "string", + "minLength": 0 + }, + "percentage": { + "type": "number", + "minimum": 0.0 + } + } + } + }, + "name": { + "type": "string", + "minLength": 0 + }, + "startDate": { + "type": "number", + "minimum": 0.0 + } + }, + "required": [ + "objectType", + "endDate", + "id", + "multiCurrencyDiscount", + "name", + "startDate" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/DiscountDetails" + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 50d2fb0ab..54fa378ca 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -56,6 +56,9 @@ }, { "$ref": "DynamicChannel.json#/definitions/DynamicChannel" + }, + { + "$ref": "DiscountDetails.json#/definitions/DiscountDetails" } ] } @@ -82,7 +85,8 @@ "KalturaPaymentGatewayProfileListResponse", "KalturaPriceDetailsListResponse", "KalturaPricePlanListResponse", - "KalturaDynamicChannelListResponse" + "KalturaDynamicChannelListResponse", + "KalturaDiscountDetailsListResponse" ] } }, diff --git a/src/test/resources/schemas/Ppv.json b/src/test/resources/schemas/Ppv.json index a5b037586..09e5b2faa 100644 --- a/src/test/resources/schemas/Ppv.json +++ b/src/test/resources/schemas/Ppv.json @@ -176,7 +176,6 @@ "name", "price", "fileTypes", - "discountModule", "descriptions", "productCode", "isSubscriptionOnly", From 0e89d887910c16bc2cb44016f453ccde9738c9c5 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 22 Aug 2018 14:22:15 +0300 Subject: [PATCH 482/605] no message --- pom.xml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index bdd81be71..b1bd3d1b6 100644 --- a/pom.xml +++ b/pom.xml @@ -225,11 +225,17 @@ test + + + + + + + - org.apache.commons - commons-vfs2 - 2.2 - test + org.jsoup + jsoup + 1.11.3 From b5feda40d69a9e90cd89bffc391f493ba5a44c64 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 23 Aug 2018 18:31:53 +0300 Subject: [PATCH 483/605] added more tests to check ingest VOD on OPC account --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../five_zero_two/IngestVodTests.java | 527 ++++++++++++++++-- .../TransactionPurchaseTests.java | 6 +- .../kaltura/client/test/utils/BaseUtils.java | 15 +- .../utils/ingestUtils/IngestVodUtils.java | 103 +++- 5 files changed, 594 insertions(+), 59 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 41f29aa88..b09340aff 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -318,7 +318,7 @@ public static String getIngestAssetUserPassword() { return ingestAssetUserPassword; } - public static String getIngestVirualAssetUserName() { + public static String getIngestVirtualAssetUserName() { if (ingestVirtualAssetUserUsername == null) { String userInfo = isOprGroup ? IngestFixtureData.getIngestItemUserData(partnerId) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index 62a30876e..c20b0020e 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -1,20 +1,22 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_two; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; -import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.types.*; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import io.restassured.response.Response; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; - -import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; -import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import java.util.Map; +import static com.kaltura.client.test.utils.BaseUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; +import static io.restassured.path.xml.XmlPath.from; +import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; /** @@ -23,20 +25,125 @@ */ public class IngestVodTests extends BaseTest { - private static final int assetStructId = 1883; // TODO: update on property (or if possible on another type) - private static final String textFieldName = "BoxOffice"; - private static final String dateFieldName = "ReleaseDate"; - private static final String numberFieldName = "Runtime2"; - private static final String booleanFieldName = "IsAgeLimited"; - private static final String tagFieldName = "Actors"; + private static final String defaultThumbUrl = + "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - private String name; - private String description; + // media types + private static final String EPISODE = "Episode"; + private static final String MOVIE = "Movie"; + private static final String SERIES = "Series"; + + // TODO: how to get these data from DB or request? + //MEDIA fields + private static final String mediaTextFieldName = "BoxOffice"; + private static final String mediaDateFieldName = "ReleaseDate"; + private static final String mediaNumberFieldName = "Runtime2"; + private static final String mediaBooleanFieldName = "IsAgeLimited"; + private static final String mediaTagFieldName = "Actors"; + + //Episode fields + private static final String episodeTextFieldName = "TwitterHashtag"; + private static final String episodeDateFieldName = "Date"; + private static final String episodeNumberFieldName = "CommonIpAddress"; + private static final String episodeBooleanFieldName = "CyyNCAh"; + private static final String episodeTagFieldName = "Studio"; + + //Series fields + private static final String seriesTextFieldName = "SeriesID"; + private static final String seriesDateFieldName = "DateField"; + private static final String seriesNumberFieldName = "ReleaseYear"; + private static final String seriesBooleanFieldName = "IsWestern"; + private static final String seriesTagFieldName = "Studio"; + + // fields & values private HashMap stringMetaMap = new HashMap<>(); - private HashMap numberMetaMap = new HashMap<>(); + private HashMap numberMetaMap = new HashMap<>(); + private HashMap booleanHashMap = new HashMap<>(); private HashMap datesMetaMap = new HashMap<>(); private HashMap> tagsMetaMap = new HashMap<>(); private List assetFiles = new ArrayList<>(); + private String name; + private String description; + private String textValue; + private String dateValue; + private double doubleValue; + private boolean booleanValue; + private List tagValues; + + private static final String INGEST_VOD_XML = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Test_API_27_03\n" + + "Test_API_27_03\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Movie_Name_1808220925223281\n" + + "\n" + + "\n" + + "\n" + + "Movie_Description_1808220925223281\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Movie\n" + + "\n" + + "\n" + + "Parent Allowed\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "BoxOfficevalue\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "123456\n" + + "\n" + + "\n" + + "12/12/2012\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Jack Nicholson\n" + + "\n" + + "\n" + + "Natalie Portman\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "]]>\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""; @BeforeClass public void setUp() { @@ -45,14 +152,6 @@ public void setUp() { name = prefix + "Name_" + localCoguid; description = prefix + "Description_" + localCoguid; - stringMetaMap.put(textFieldName, textFieldName + "value1"); - numberMetaMap.put(numberFieldName, 1234); - datesMetaMap.put(dateFieldName, "12/12/2012"); - List actors = new ArrayList<>(); - actors.add("Jack Nicholson"); - actors.add("Natalie Portman"); - tagsMetaMap.put(tagFieldName, actors); - IngestVodUtils.VODFile file1 = new IngestVodUtils.VODFile() .assetDuration("1000") .quality("HIGH") @@ -63,7 +162,7 @@ public void setUp() { .billing_type("Tvinci") .product_code("productExampleCode") .type("Test130301") - .coguid("Test130301_" + localCoguid) + .coguid("Test130301_1" + localCoguid) .ppvModule("Shai_Regression_PPV"); IngestVodUtils.VODFile file2 = new IngestVodUtils.VODFile() .assetDuration("1000") @@ -75,7 +174,7 @@ public void setUp() { .billing_type("Tvinci") .product_code("productExampleCode") .type("new file type1") - .coguid("new file type1_" + localCoguid) + .coguid("new file type1_1" + localCoguid) .ppvModule("Subscription_only_PPV"); assetFiles.add(file1); assetFiles.add(file2); @@ -83,21 +182,375 @@ public void setUp() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") - public void insertVodBaseFields() { - String testSuffix = "1"; + public void insertVodMediaBaseFields() { + generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE); - IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() - .name(name + testSuffix) - .description(description + testSuffix) - .mediaType(MOVIE) - .strings(stringMetaMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) - .tags(tagsMetaMap) - .assetFiles(assetFiles); + MediaAsset asset = insertVod(vodData, true); + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with filled base meta fields") + public void insertVodEpisodeBaseFields() { + generateDefaultValues4Insert(EPISODE); + VodData vodData = getVodData(EPISODE); + + MediaAsset asset = insertVod(vodData, true); + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with filled base meta fields") + public void insertVodSeriesBaseFields() { + generateDefaultValues4Insert(SERIES); + VodData vodData = getVodData(SERIES); - MediaAsset asset = insertVod(vodData1, false); + MediaAsset asset = insertVod(vodData, true); + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD with filled base meta fields") + public void updateVodMediaBaseFields() { +// AssetFilter assetFilter = new AssetFilter(); +// assetFilter.setOrderBy(AssetOrderBy.CREATE_DATE_DESC.getValue()); +// FilterPager pager = new FilterPager(); +// pager.setPageSize(1); +// pager.setPageIndex(1); +// /*Map params = new HashMap<>(); +// params.put("orderBy", AssetOrderBy.CREATE_DATE_DESC);*/ +// com.kaltura.client.utils.response.base.Response> assetListResponse = +// executor.executeSync(list(assetFilter, pager) +// .setKs(getAnonymousKs())); +// assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + + // TODO: get previous value + generateDefaultValues4Update(true, MOVIE); + IngestVodUtils.VodData vodData = getVodData(MOVIE); + + String coguid = "180823143608237"; // TODO: update logic to get these data from + MediaAsset asset = updateVod(coguid, vodData); + + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD with filled base meta fields") + public void updateVodEpisodeBaseFields() { + // TODO: get previous value + generateDefaultValues4Update(false, EPISODE); + IngestVodUtils.VodData vodData = getVodData(EPISODE); + + String coguid = "180823171226961"; // TODO: update logic to get these data from + MediaAsset asset = updateVod(coguid, vodData); + + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD with filled base meta fields") + public void updateVodSeriesBaseFields() { + // TODO: get previous value + generateDefaultValues4Update(true, SERIES); + IngestVodUtils.VodData vodData = getVodData(SERIES); + + String coguid = "180823181201121"; // TODO: update logic to get these data from + MediaAsset asset = updateVod(coguid, vodData); + + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "delete") + public void deleteMovie() { + String coguid = "180823171226961"; // TODO: update logic to get these data from + deleteVod(coguid); + // TODO: add logic to check delete } + @Severity(SeverityLevel.CRITICAL) + @Test(description = "delete episode") + public void deleteEpisode() { + String coguid = "180823171226961"; // TODO: update logic to get these data from + deleteVod(coguid); + // TODO: add logic to check delete + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "delete episode") + public void deleteSeries() { + String coguid = "180823181201121"; // TODO: update logic to get these data from + deleteVod(coguid); + // TODO: add logic to check delete + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "try insert without coguid") + public void tryInsertWithEmptyCoguid() { + String invalidXml = INGEST_VOD_XML.replaceAll("co_guid=\"180822092522774\"", "co_guid=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert with invalid action") + public void tryInsertWithInvalidAction() { + // TODO: ask Shir why it returns 0 instead of tvmId + String invalidXml = INGEST_VOD_XML.replaceAll("action=\"insert\"", "action=\"linsert\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).doesNotContain("OK"); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert with empty entry_id") + public void tryInsertWithEmptyEntryId() { + String invalidXml = INGEST_VOD_XML.replaceAll("entry_id=\"entry_180822092522774\"", "entry_id=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); + } + + /* TODO: check the usual logic + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert inactive item") + public void tryInsertinactiveItem() { + String invalidXml = INGEST_VOD_XML.replaceAll("is_active=\"true\"", "is_active=\"false\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).doesNotContain("OK"); + }*/ + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert with empty isActive parameter") + public void tryInsertEmptyIsActive() { + String invalidXml = INGEST_VOD_XML.replaceAll("is_active=\"true\"", "is_active=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert with empty name") + public void tryInsertWithEmptyName() { + String invalidXml = INGEST_VOD_XML.replaceAll(">Movie_Name_1808220925223281<", "><"); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "try insert with invalid credentials") + public void tryInsertWithInvalidCredentials() { + String statusMessage = "Invalid credentials"; + String status = "ERROR"; + + // invalid user name + String invalidXml = INGEST_VOD_XML.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); + assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); + + // invalid password + invalidXml = INGEST_VOD_XML.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); + assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); + } + + VodData getVodData(String mediaType) { + switch (mediaType) { + case "Movie": + return new VodData() + .name(name) + .description(description) + .mediaType(MediaType.MOVIE) + .thumbUrl(defaultThumbUrl) + .strings(stringMetaMap) + .booleans(booleanHashMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + .isVirtual(false) + .assetFiles(assetFiles); + case "Episode": + return new VodData() + .name(name) + .description(description) + .mediaType(MediaType.EPISODE) + .thumbUrl(defaultThumbUrl) + .strings(stringMetaMap) + .booleans(booleanHashMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + .isVirtual(false) + .assetFiles(assetFiles); + case "Series": + return new VodData() + .name(name) + .description(description) + .mediaType(MediaType.SERIES) + .thumbUrl(defaultThumbUrl) + .strings(stringMetaMap) + .booleans(booleanHashMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + .isVirtual(true) + .assetFiles(assetFiles); + default: + return null; + } + } + + void fillMediaMapsWithData() { + stringMetaMap.put(mediaTextFieldName, textValue); + numberMetaMap.put(mediaNumberFieldName, doubleValue); + datesMetaMap.put(mediaDateFieldName, dateValue); + booleanHashMap.put(mediaBooleanFieldName, booleanValue); + tagsMetaMap.put(mediaTagFieldName, tagValues); + } + + void fillEpisodeMapsWithData() { + stringMetaMap.put(episodeTextFieldName, textValue); + numberMetaMap.put(episodeNumberFieldName, doubleValue); + datesMetaMap.put(episodeDateFieldName, dateValue); + booleanHashMap.put(episodeBooleanFieldName, booleanValue); + tagsMetaMap.put(episodeTagFieldName, tagValues); + } + + void fillSeriesMapsWithData() { + stringMetaMap.put(seriesTextFieldName, textValue); + numberMetaMap.put(seriesNumberFieldName, doubleValue); + datesMetaMap.put(seriesDateFieldName, dateValue); + booleanHashMap.put(seriesBooleanFieldName, booleanValue); + tagsMetaMap.put(seriesTagFieldName, tagValues); + } + + void generateDefaultValues4Update(boolean previousValue, String mediaType) { + textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy") + "_updated"; + dateValue = getOffsetDateInFormat(1,"MM/dd/yyyy"); + // to round up 2 decimal places + doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; + booleanValue = !previousValue; + tagValues = new ArrayList<>(); + tagValues.add("Jack NicholsonUpd"); + tagValues.add("Natalie PortmanUpd"); + tagValues.add(textValue); + + fillMapsWithData(mediaType); + } + + void generateDefaultValues4Insert(String mediaType) { + textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy"); + dateValue = getCurrentDateInFormat("MM/dd/yyyy"); + // to round up 2 decimal places + doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; + booleanValue = getRandomBooleanValue(); + tagValues = new ArrayList<>(); + tagValues.add("Jack Nicholson"); + tagValues.add("Natalie Portman"); + tagValues.add(textValue); + + fillMapsWithData(mediaType); + } + + private void fillMapsWithData(String mediaType) { + switch (mediaType) { + case MOVIE: + fillMediaMapsWithData(); + break; + case EPISODE: + fillEpisodeMapsWithData(); + break; + case SERIES: + fillSeriesMapsWithData(); + break; + default: + break; + } + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java index e159aba3c..15363a9a2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/transactionTests/transactionPurchaseTests/TransactionPurchaseTests.java @@ -289,7 +289,7 @@ public void purchaseCollectionWithPGWithoutChargeId() { executor.executeSync(PaymentGatewayProfileService.delete(pg.getId()).setKs(getOperatorKs())); } - /*@Severity(SeverityLevel.NORMAL) + @Severity(SeverityLevel.NORMAL) @Description("transaction/action/purchase - ppv configured to 'Subscription Only' - error 3023") @Test() public void purchaseSubscriptionOnlyPpv() { @@ -300,7 +300,7 @@ public void purchaseSubscriptionOnlyPpv() { VodData vodData = new VodData() .ppvWebName(ppv.getName()) .ppvMobileName(ppv.getName()); - MediaAsset mediaAsset = insertVod(vodData); + MediaAsset mediaAsset = insertVod(vodData, true); // purchase ppv Purchase purchase = new Purchase(); @@ -320,7 +320,7 @@ public void purchaseSubscriptionOnlyPpv() { //cleanup - delete ppv deletePpv(ppv.getName()); deleteVod(mediaAsset.getName()); - }*/ + } @Severity(SeverityLevel.NORMAL) @Description("transaction/action/purchase - subscription with invalid price - error 6000") diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 8d73aa072..e3f9bd9d7 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -87,7 +87,11 @@ public static String getFormattedTime(int calendarType, int amount, TimeZone tim } public static String getFormattedTime(long epoch, TimeZone timeZone) { - DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + return getFormattedDate(epoch, timeZone, "dd/MM/yyyy HH:mm:ss"); + } + + public static String getFormattedDate(long epoch, TimeZone timeZone, String format) { + DateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setTimeZone(timeZone); return dateFormat.format(getDateFromEpoch(epoch)); @@ -130,6 +134,15 @@ public static String getRandomValue() { return String.valueOf(randomLongValue); } + public static double getRandomDoubleValue() { + double max = 9999999.1; + return ThreadLocalRandom.current().nextDouble(max); + } + + public static boolean getRandomBooleanValue() { + return ThreadLocalRandom.current().nextBoolean(); + } + // generate random string public static String getRandomString() { String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index d0c7b15a9..dc7a39f8f 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -23,7 +23,6 @@ import static com.google.common.base.Verify.verify; import static com.kaltura.client.services.AssetService.GetAssetBuilder; import static com.kaltura.client.services.AssetService.get; -import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static com.kaltura.client.test.utils.BaseUtils.getOffsetDateInFormat; @@ -35,9 +34,15 @@ public class IngestVodUtils extends BaseIngestUtils { - private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult.AssetsStatus.IngestAssetStatus."; - private static final String ingestStatusMessagePath = ingestDataResultPath + "Status.Message"; - private static final String ingestAssetIdPath = ingestDataResultPath + "InternalAssetId"; + private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult."; + public static final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; + public static final String ingestStatusPath = ingestDataResultPath + "status"; + private static final String ingestAssetStatusPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus[0]."; + public static final String ingestAssetStatusMessagePath = ingestAssetStatusPath + "Status.Message"; + public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; + private static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; + + static boolean areDefaultValuesRequired; @Accessors(fluent = true) @Data @@ -78,7 +83,8 @@ public static class VodData { private Map> tags; private Map strings; private Map dates; - private Map numbers; + private Map numbers; + private Map booleans; private List assetFiles; } @@ -86,10 +92,12 @@ public static class VodData { /** IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" **/ public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequired) { + IngestVodUtils.areDefaultValuesRequired = areDefaultValuesRequired; final String coguidDatePattern = "yyMMddHHmmssSS"; final String datePattern = "dd/MM/yyyy hh:mm:ss"; final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); final String endDateValue = "14/10/2099 17:00:00"; + final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value vodData.coguid = getCurrentDateInFormat(coguidDatePattern); @@ -130,11 +138,20 @@ public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequ if (vodData.numbers == null) { vodData.numbers = getDefaultNumbers(); } + if (vodData.ppvWebName == null) { + vodData.ppvWebName = ppvModuleName; + } + if (vodData.ppvMobileName == null) { + vodData.ppvMobileName = ppvModuleName; + } + if (vodData.assetFiles == null) { + vodData.assetFiles = getDefaultAssetFiles(vodData.coguid, vodData.ppvWebName, vodData.ppvMobileName); + } } String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); - Response resp = executeIngestVodRequest(reqBody); + Response resp = getResponseBodyFromIngestVod(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); @@ -152,7 +169,7 @@ public static MediaAsset updateVod(String coguid, VodData vodData) { vodData.coguid = coguid; String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_UPDATE); - Response resp = executeIngestVodRequest(reqBody); + Response resp = getResponseBodyFromIngestVod(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); @@ -172,11 +189,11 @@ public static void deleteVod(String coguid) { String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_DELETE); Response resp = executeIngestVodRequest(reqBody); - assertThat(from(resp.asString()).getInt(ingestAssetIdPath)).isEqualTo(0); + // on delete it returns media id + // assertThat(from(resp.asString()).getInt(ingestAssetIdPath)).isEqualTo(0); } - // private methods - private static Response executeIngestVodRequest(String reqBody) { + public static Response getResponseBodyFromIngestVod(String reqBody) { Response resp = given() .header(contentTypeXml) .header(soapActionIngestTvinciData) @@ -187,8 +204,15 @@ private static Response executeIngestVodRequest(String reqBody) { Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); + return resp; + } + + // private methods + private static Response executeIngestVodRequest(String reqBody) { + Response resp = getResponseBodyFromIngestVod(reqBody); + assertThat(resp).isNotNull(); - assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); return resp; } @@ -198,7 +222,7 @@ private static String buildIngestVodXml(VodData vodData, String action) { // user and password if (vodData.isVirtual()) { - doc.getElementsByTagName("userName").item(0).setTextContent(getIngestVirualAssetUserName()); + doc.getElementsByTagName("userName").item(0).setTextContent(getIngestVirtualAssetUserName()); doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestVirualAssetUserPassword()); } else { doc.getElementsByTagName("userName").item(0).setTextContent(getIngestAssetUserName()); @@ -263,7 +287,8 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // media type - if (action.equals(INGEST_ACTION_INSERT)) { + // it is required for update tests too + if (action.equals(INGEST_ACTION_INSERT) || action.equals(INGEST_ACTION_UPDATE)) { media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType().getValue()); } @@ -287,10 +312,20 @@ private static String buildIngestVodXml(VodData vodData, String action) { } } + // booleans + if (vodData.booleans() != null) { + Element booleansElement = (Element) media.getElementsByTagName("booleans").item(0); + for (Map.Entry entry : vodData.booleans().entrySet()) { + // meta node + Element meta = generateAndAppendMetaNode(doc, booleansElement, entry.getKey()); + meta.setTextContent(String.valueOf(entry.getValue())); + } + } + // doubles if (vodData.numbers() != null) { Element doublesElement = (Element) media.getElementsByTagName("doubles").item(0); - for (Map.Entry entry : vodData.numbers().entrySet()) { + for (Map.Entry entry : vodData.numbers().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, doublesElement, entry.getKey()); meta.setTextContent(String.valueOf(entry.getValue())); @@ -433,9 +468,9 @@ private static Map getDefaultStrings() { } // TODO: these values should be get in another way than now - private static Map getDefaultNumbers() { - Map doubles = new HashMap<>(); - doubles.put("Release year", 1900); + private static Map getDefaultNumbers() { + Map doubles = new HashMap<>(); + doubles.put("Release year", 1900d); return doubles; } @@ -447,4 +482,38 @@ private static Map getDefaultDates() { return dates; } + + // TODO: these values should be get in another way than now + private static List getDefaultAssetFiles(String coguid, String ppvModuleName1, String ppvModuleName2) { + List assetFiles = new ArrayList<>(); + + VODFile file1 = new VODFile() + .assetDuration("1000") + .quality("HIGH") + .handling_type("CLIP") + .cdn_name("Default CDN") + .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .billing_type("Tvinci") + .product_code("productExampleCode") + .type("Web HD") + .coguid("web_" + coguid) + .ppvModule(ppvModuleName1); + IngestVodUtils.VODFile file2 = new IngestVodUtils.VODFile() + .assetDuration("1000") + .quality("HIGH") + .handling_type("CLIP") + .cdn_name("Default CDN") + .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .billing_type("Tvinci") + .product_code("productExampleCode") + .type("Mobile_Devices_Main_HD") + .coguid("ipad_" + coguid) + .ppvModule(ppvModuleName2); + assetFiles.add(file1); + assetFiles.add(file2); + + return assetFiles; + } } From e6c5ff83b8024d3e57b214ec82d1e0448229b195 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 26 Aug 2018 02:43:17 +0300 Subject: [PATCH 484/605] updated permission management tets. Added more tests related phase2 --- .../PermissionsManagementTests.java | 29 ++++++++++++++- .../test/utils/PermissionManagementUtils.java | 8 +++++ .../dbUtils/PermissionsManagementDBUtils.java | 35 ++++++++++--------- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 860f4bab1..30fddd4f9 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -27,7 +27,7 @@ public class PermissionsManagementTests { String mainFile = "PermissionsDeployment.exe"; // that file generated automatically String path2Log = "C:\\log\\permissions\\permissions.log"; - String path2Util = "C:\\123\\222\\"; + String path2Util = "C:\\123\\PermissionsExport\\bin\\Debug\\"; // these files are generated String dataFilePath = path2Util + "333\\" + "exp1.txt"; @@ -49,6 +49,8 @@ public void setUp() { public static final String EXPORT_KEY = "e="; public static final String IMPORT_KEY = "i="; public static final String DELETE_KEY = "d="; + public static final String EXPORT_JSON_KEY = "n="; + public static final String IMPORT_JSON_KEY = "l="; @Severity(SeverityLevel.MINOR) @Test(groups = {"Permission management"}, description = "execute console util without parameters") @@ -60,6 +62,9 @@ public void runningWithoutParameters() { assertThat(consoleOutput).contains("Permissions deployment tool"); assertThat(consoleOutput).contains("Shortcut: e"); assertThat(consoleOutput).contains("Shortcut: i"); + assertThat(consoleOutput).contains("Shortcut: d"); + assertThat(consoleOutput).contains("Shortcut: n"); + assertThat(consoleOutput).contains("Shortcut: l"); } @Severity(SeverityLevel.MINOR) @@ -366,4 +371,26 @@ public void deleteOnlyFromOneTable() { int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); assertThat(rowsInRolesHavingName).isEqualTo(0); } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to export in JSON without mentioned file") + public void runningExportJsonWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(EXPORT_JSON_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } + + @Severity(SeverityLevel.MINOR) + @Test(groups = {"Permission management"}, description = "execute console util to import in JSON without mentioned file") + public void runningImportJsonWithoutFile() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(IMPORT_JSON_KEY); + String consoleOutput = executeCommandsInColsole(commands); + + assertThat(consoleOutput).contains("The system cannot find the file specified"); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index be97f5558..99a8e6e18 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -1,5 +1,6 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.Logger; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import java.io.*; import java.util.List; @@ -60,7 +61,13 @@ public static void printRole(PrintWriter writer, Long roleId, String roleName) { } public static String executeCommandsInColsole(List commands) { + Logger.getLogger(PermissionManagementUtils.class).debug("started executeCommandsInColsole"); StringBuilder output = new StringBuilder(); + StringBuilder input = new StringBuilder(); + for(String command: commands){ + input.append(command + " "); + } + Logger.getLogger(PermissionManagementUtils.class).debug("INPUT: " + input.toString()); ProcessBuilder pb = new ProcessBuilder(commands); pb.redirectErrorStream(true); @@ -77,6 +84,7 @@ public static String executeCommandsInColsole(List commands) { output.append(e.getMessage()); } + Logger.getLogger(PermissionManagementUtils.class).debug("OUTPUT: " + output.toString()); return output.toString(); } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java index 3490fbce8..945513cfa 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java @@ -1,9 +1,12 @@ package com.kaltura.client.test.utils.dbUtils; +import com.kaltura.client.Logger; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; import java.sql.*; +import java.util.Arrays; + import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; public class PermissionsManagementDBUtils extends DBUtils { @@ -104,8 +107,8 @@ static void executeQuery(String query, Object... queryParams) { public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { int count = 0; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT, - name, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_ROLES_SELECT), + name, groupId); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } @@ -119,8 +122,8 @@ public static int getCountRowsHavingRoleNameInRoles(String name, int groupId) { public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { int id =-1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT, - name, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_ROLES_SELECT), + name, groupId); if (!jsonArray.isNull(0)) { id = jsonArray.getJSONObject(0).getInt(ID); } @@ -134,8 +137,8 @@ public static int getIdRecordHavingRoleNameInRoles(String name, int groupId) { public static int getCountRowsHavingRoleNameInPermissions(String name, int groupId) { int count = 0; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, - name, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_ROLE_NAME_IN_PERMISSIONS_SELECT), + name, groupId); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } @@ -149,8 +152,8 @@ public static int getCountRowsHavingRoleNameInPermissions(String name, int group public static int getIdRecordHavingRoleNameInPermissions(String name, int groupId) { int count =-1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT, - name, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT), + name, groupId); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } @@ -164,8 +167,8 @@ public static int getIdRecordHavingRoleNameInPermissions(String name, int groupI public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permissionId, int groupId) { int count = 0; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT, - roleId, permissionId, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_ROLES_PERMISSIONS_SELECT), + roleId, permissionId, groupId); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } @@ -179,8 +182,8 @@ public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permi public static int getCountRowsHavingNameInPermissionItems(String name, int groupId) { int count = 0; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT, - name, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT), + name, groupId); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } @@ -194,8 +197,8 @@ public static int getCountRowsHavingNameInPermissionItems(String name, int group public static int getIdRecordHavingNameInPermissionItems(String name, int groupId) { int count =-1; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT, - name, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT), + name, groupId); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } @@ -209,8 +212,8 @@ public static int getIdRecordHavingNameInPermissionItems(String name, int groupI public static int getCountSpecificRowsFromPermissionsPermissionsItems(int permissionId, int permissionItemId, int groupId) { int count = 0; try { - JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT, - permissionId, permissionItemId, groupId), true); + JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT), + permissionId, permissionItemId, groupId); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } From add3b33d32401bd96fe1ef7da859948c894e5c77 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 28 Aug 2018 03:10:36 +0300 Subject: [PATCH 485/605] Added more tests related ingestVod for opc Added testng.xml to run only opc related tests. --- .../com/kaltura/client/test/Properties.java | 2 +- .../kaltura/client/test/tests/BaseTest.java | 23 +- .../five_zero_two/IngestVodTests.java | 476 ++++++------------ .../utils/ingestUtils/BaseIngestUtils.java | 6 +- .../utils/ingestUtils/IngestVodOPCUtils.java | 368 ++++++++++++++ .../utils/ingestUtils/IngestVodUtils.java | 6 +- src/test/resources/AllSuitesTestng.xml | 8 + src/test/resources/testng.xml | 2 + src/test/resources/testngopc.xml | 16 + 9 files changed, 581 insertions(+), 326 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java create mode 100644 src/test/resources/AllSuitesTestng.xml create mode 100644 src/test/resources/testngopc.xml diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index abb04e81a..fddf59478 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -20,7 +20,7 @@ public class Properties { // Request properties public static final String PARTNER_ID = "partner_id"; public static final String IS_OPC_GROUP = "is_opc_group"; -// public static final String OPC_PARTNER_ID = "opc_partner_id"; + public static final String OPC_PARTNER_ID = "opc_partner_id"; public static final String DEFAULT_TIMEOUT_IN_SEC = "default_timeout_in_sec"; // global users diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index b09340aff..a9876291f 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -11,13 +11,11 @@ import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; +import org.testng.annotations.*; import java.lang.reflect.Method; import java.util.*; +import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.google.common.base.Verify.verify; @@ -116,8 +114,10 @@ public class BaseTest { Shared Test Params - end ================================================================================*/ - @BeforeSuite - public void baseTest_beforeSuite() { + @Parameters({"accountType"}) + @BeforeSuite(alwaysRun=true) + public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType) { + Logger.getLogger(BaseTest.class).debug("Start baseTest_beforeSuite"); // set configuration config = new Configuration(); config.setEndpoint(getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION)); @@ -131,9 +131,14 @@ public void baseTest_beforeSuite() { setDefaultTimeout(Long.parseLong(getProperty(DEFAULT_TIMEOUT_IN_SEC)), TimeUnit.SECONDS); // set shared common params - partnerId = Integer.parseInt(getProperty(PARTNER_ID)); - isOprGroup = "true".equals(getProperty(IS_OPC_GROUP)); -// opcPartnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); + if ("opc".equals(accountType)) { + isOprGroup = true; + partnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); + } else { + isOprGroup = false; + partnerId = Integer.parseInt(getProperty(PARTNER_ID)); + } + //opcPartnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); // set performance report diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index c20b0020e..3405a5b98 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_two; +import com.kaltura.client.services.AssetService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import io.qameta.allure.Severity; @@ -9,15 +9,17 @@ import io.restassured.response.Response; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; +import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.utils.BaseUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static io.restassured.path.xml.XmlPath.from; import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; /** * @@ -25,125 +27,14 @@ */ public class IngestVodTests extends BaseTest { - private static final String defaultThumbUrl = - "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - - // media types - private static final String EPISODE = "Episode"; - private static final String MOVIE = "Movie"; - private static final String SERIES = "Series"; - - // TODO: how to get these data from DB or request? - //MEDIA fields - private static final String mediaTextFieldName = "BoxOffice"; - private static final String mediaDateFieldName = "ReleaseDate"; - private static final String mediaNumberFieldName = "Runtime2"; - private static final String mediaBooleanFieldName = "IsAgeLimited"; - private static final String mediaTagFieldName = "Actors"; - - //Episode fields - private static final String episodeTextFieldName = "TwitterHashtag"; - private static final String episodeDateFieldName = "Date"; - private static final String episodeNumberFieldName = "CommonIpAddress"; - private static final String episodeBooleanFieldName = "CyyNCAh"; - private static final String episodeTagFieldName = "Studio"; - - //Series fields - private static final String seriesTextFieldName = "SeriesID"; - private static final String seriesDateFieldName = "DateField"; - private static final String seriesNumberFieldName = "ReleaseYear"; - private static final String seriesBooleanFieldName = "IsWestern"; - private static final String seriesTagFieldName = "Studio"; - - // fields & values - private HashMap stringMetaMap = new HashMap<>(); - private HashMap numberMetaMap = new HashMap<>(); - private HashMap booleanHashMap = new HashMap<>(); - private HashMap datesMetaMap = new HashMap<>(); - private HashMap> tagsMetaMap = new HashMap<>(); - private List assetFiles = new ArrayList<>(); - private String name; - private String description; - private String textValue; - private String dateValue; - private double doubleValue; - private boolean booleanValue; - private List tagValues; - - private static final String INGEST_VOD_XML = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Test_API_27_03\n" + - "Test_API_27_03\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Movie_Name_1808220925223281\n" + - "\n" + - "\n" + - "\n" + - "Movie_Description_1808220925223281\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Movie\n" + - "\n" + - "\n" + - "Parent Allowed\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "BoxOfficevalue\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "123456\n" + - "\n" + - "\n" + - "12/12/2012\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Jack Nicholson\n" + - "\n" + - "\n" + - "Natalie Portman\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "]]>\n" + - "\n" + - "\n" + - "\n" + - "\n" + - ""; + private MediaAsset movie; + private MediaAsset episode; + private MediaAsset series; + private int movieType; + private int episodeType; + private int seriesType; + + private String ingestXml; @BeforeClass public void setUp() { @@ -178,23 +69,47 @@ public void setUp() { .ppvModule("Subscription_only_PPV"); assetFiles.add(file1); assetFiles.add(file2); + + VodData vodData; + generateDefaultValues4Insert(MOVIE); + vodData = getVodData(MOVIE); + movie = insertVod(vodData, true); + movieType = movie.getType(); + + generateDefaultValues4Insert(EPISODE); + vodData = getVodData(EPISODE); + episode = insertVod(vodData, true); + episodeType = episode.getType(); + + generateDefaultValues4Insert(SERIES); + vodData = getVodData(SERIES); + series = insertVod(vodData, true); + seriesType = series.getType(); + + generateDefaultValues4Insert(MOVIE); + vodData = getVodData(MOVIE); + ingestXml = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); } @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with filled base meta fields") + @Test(groups = {"ingest VOD for OPC", "opc"}, priority =-1, description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { + // that should be called in case running from testng.xml as a group + // priority set to -1 to guarantee that setUp will be executed before all other tests as part of that test case. + setUp(); + generateDefaultValues4Insert(MOVIE); VodData vodData = getVodData(MOVIE); + MediaAsset movie = insertVod(vodData, true); - MediaAsset asset = insertVod(vodData, true); - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + assertThat(movie.getName()).isEqualTo(name); + assertThat(movie.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - Map tags = asset.getTags(); + Map tags = movie.getTags(); Map.Entry entry = tags.entrySet().iterator().next(); List tagsValues = entry.getValue().getObjects(); for (MultilingualStringValue tagValue: tagsValues) { @@ -204,20 +119,20 @@ public void insertVodMediaBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with filled base meta fields") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { generateDefaultValues4Insert(EPISODE); VodData vodData = getVodData(EPISODE); + MediaAsset episode = insertVod(vodData, true); - MediaAsset asset = insertVod(vodData, true); - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); + assertThat(episode.getName()).isEqualTo(name); + assertThat(episode.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); - Map tags = asset.getTags(); + Map tags = episode.getTags(); Map.Entry entry = tags.entrySet().iterator().next(); List tagsValues = entry.getValue().getObjects(); for (MultilingualStringValue tagValue: tagsValues) { @@ -227,20 +142,20 @@ public void insertVodEpisodeBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with filled base meta fields") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { generateDefaultValues4Insert(SERIES); VodData vodData = getVodData(SERIES); + MediaAsset series = insertVod(vodData, true); - MediaAsset asset = insertVod(vodData, true); - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); + assertThat(series.getName()).isEqualTo(name); + assertThat(series.getDescription()).isEqualTo(description); + assertThat(((StringValue)series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); - Map tags = asset.getTags(); + Map tags = series.getTags(); Map.Entry entry = tags.entrySet().iterator().next(); List tagsValues = entry.getValue().getObjects(); for (MultilingualStringValue tagValue: tagsValues) { @@ -250,25 +165,13 @@ public void insertVodSeriesBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD with filled base meta fields") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { -// AssetFilter assetFilter = new AssetFilter(); -// assetFilter.setOrderBy(AssetOrderBy.CREATE_DATE_DESC.getValue()); -// FilterPager pager = new FilterPager(); -// pager.setPageSize(1); -// pager.setPageIndex(1); -// /*Map params = new HashMap<>(); -// params.put("orderBy", AssetOrderBy.CREATE_DATE_DESC);*/ -// com.kaltura.client.utils.response.base.Response> assetListResponse = -// executor.executeSync(list(assetFilter, pager) -// .setKs(getAnonymousKs())); -// assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); - - // TODO: get previous value + String coguid = getCoguidOfActiveMediaAsset(movieType); + generateDefaultValues4Update(true, MOVIE); IngestVodUtils.VodData vodData = getVodData(MOVIE); - String coguid = "180823143608237"; // TODO: update logic to get these data from MediaAsset asset = updateVod(coguid, vodData); assertThat(asset.getName()).isEqualTo(name); @@ -287,14 +190,14 @@ public void updateVodMediaBaseFields() { assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); } + @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD with filled base meta fields") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { - // TODO: get previous value generateDefaultValues4Update(false, EPISODE); IngestVodUtils.VodData vodData = getVodData(EPISODE); - String coguid = "180823171226961"; // TODO: update logic to get these data from + String coguid = getCoguidOfActiveMediaAsset(episodeType); MediaAsset asset = updateVod(coguid, vodData); assertThat(asset.getName()).isEqualTo(name); @@ -314,13 +217,12 @@ public void updateVodEpisodeBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD with filled base meta fields") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { - // TODO: get previous value generateDefaultValues4Update(true, SERIES); IngestVodUtils.VodData vodData = getVodData(SERIES); - String coguid = "180823181201121"; // TODO: update logic to get these data from + String coguid = getCoguidOfActiveMediaAsset(seriesType); MediaAsset asset = updateVod(coguid, vodData); assertThat(asset.getName()).isEqualTo(name); @@ -340,87 +242,139 @@ public void updateVodSeriesBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(description = "delete") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "delete") public void deleteMovie() { - String coguid = "180823171226961"; // TODO: update logic to get these data from - deleteVod(coguid); - // TODO: add logic to check delete + String coguid = getCoguidOfActiveMediaAsset(movieType); + checkVODDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) - @Test(description = "delete episode") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "delete episode") public void deleteEpisode() { - String coguid = "180823171226961"; // TODO: update logic to get these data from - deleteVod(coguid); - // TODO: add logic to check delete + String coguid = getCoguidOfActiveMediaAsset(episodeType); + checkVODDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) - @Test(description = "delete episode") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "delete series") public void deleteSeries() { - String coguid = "180823181201121"; // TODO: update logic to get these data from - deleteVod(coguid); - // TODO: add logic to check delete + String coguid = getCoguidOfActiveMediaAsset(seriesType); + checkVODDeletion(coguid); } @Severity(SeverityLevel.NORMAL) - @Test(description = "try insert without coguid") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert without coguid") public void tryInsertWithEmptyCoguid() { String invalidXml = INGEST_VOD_XML.replaceAll("co_guid=\"180822092522774\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + + invalidXml = INGEST_VOD_XML.replaceAll("co_guid=\"180822092522774\"", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); } - @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with invalid action") - public void tryInsertWithInvalidAction() { - // TODO: ask Shir why it returns 0 instead of tvmId - String invalidXml = INGEST_VOD_XML.replaceAll("action=\"insert\"", "action=\"linsert\""); + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete without coguid") + public void tryDeleteWithEmptyCoguid() { + String invalidXml = DELETE_VOD_XML.replaceAll("co_guid=\"180822092522774\"", "co_guid=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + + invalidXml = DELETE_VOD_XML.replaceAll("co_guid=\"180822092522774\"", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + } + + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete with non-existed coguid") + public void tryDeleteWithNonexistedCoguid() { + String invalidXml = DELETE_VOD_XML.replaceAll("co_guid=\"180822092522774\"", "co_guid=\"123456\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); + } + + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"ingest VOD for OPC", "opc", "OPC"}, description = "try update with empty erase") + public void tryUpdateWithEmptyErase() { + // TODO: check and if it work then add logic related null erase and positive test related update + String coguid = getCoguidOfActiveMediaAsset(movieType); + String invalidXml = UPDATE_VOD_XML + .replaceAll("erase=\"false\"", "erase=\"\"") + .replaceAll("co_guid=\"180822092522774\"", "co_guid=\"" + coguid + "\""); Response resp = getResponseBodyFromIngestVod(invalidXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).doesNotContain("OK"); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); } @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with empty entry_id") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty entry_id") public void tryInsertWithEmptyEntryId() { String invalidXml = INGEST_VOD_XML.replaceAll("entry_id=\"entry_180822092522774\"", "entry_id=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); + + invalidXml = INGEST_VOD_XML.replaceAll("entry_id=\"entry_180822092522774\"", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); } - /* TODO: check the usual logic @Severity(SeverityLevel.MINOR) - @Test(description = "try insert inactive item") - public void tryInsertinactiveItem() { + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert inactive item") + public void tryInsertInactiveItem() { String invalidXml = INGEST_VOD_XML.replaceAll("is_active=\"true\"", "is_active=\"false\""); Response resp = getResponseBodyFromIngestVod(invalidXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).doesNotContain("OK"); - }*/ + String id = from(resp.asString()).get(ingestAssetIdPath).toString(); + + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setKSql("media_id='" + id + "'"); + com.kaltura.client.utils.response.base.Response> assetListResponse = + executor.executeSync(list(assetFilter) + .setKs(getAnonymousKs())); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(0); + } @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with empty isActive parameter") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty isActive parameter") public void tryInsertEmptyIsActive() { - String invalidXml = INGEST_VOD_XML.replaceAll("is_active=\"true\"", "is_active=\"\""); + String invalidXml = ingestXml;//.replaceAll("is_active=\"true\"", "is_active=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); + + invalidXml = ingestXml.replaceAll("is_active=\"true\"", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); } @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with empty name") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty name") public void tryInsertWithEmptyName() { String invalidXml = INGEST_VOD_XML.replaceAll(">Movie_Name_1808220925223281<", "><"); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); + + invalidXml = INGEST_VOD_XML + .replaceAll("", "") + .replaceAll("Movie_Name_1808220925223281", "") + .replaceAll("", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); } @Severity(SeverityLevel.NORMAL) - @Test(description = "try insert with invalid credentials") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with invalid credentials") public void tryInsertWithInvalidCredentials() { String statusMessage = "Invalid credentials"; String status = "ERROR"; @@ -440,117 +394,19 @@ public void tryInsertWithInvalidCredentials() { assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); } - VodData getVodData(String mediaType) { - switch (mediaType) { - case "Movie": - return new VodData() - .name(name) - .description(description) - .mediaType(MediaType.MOVIE) - .thumbUrl(defaultThumbUrl) - .strings(stringMetaMap) - .booleans(booleanHashMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) - .tags(tagsMetaMap) - .isVirtual(false) - .assetFiles(assetFiles); - case "Episode": - return new VodData() - .name(name) - .description(description) - .mediaType(MediaType.EPISODE) - .thumbUrl(defaultThumbUrl) - .strings(stringMetaMap) - .booleans(booleanHashMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) - .tags(tagsMetaMap) - .isVirtual(false) - .assetFiles(assetFiles); - case "Series": - return new VodData() - .name(name) - .description(description) - .mediaType(MediaType.SERIES) - .thumbUrl(defaultThumbUrl) - .strings(stringMetaMap) - .booleans(booleanHashMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) - .tags(tagsMetaMap) - .isVirtual(true) - .assetFiles(assetFiles); - default: - return null; - } - } - - void fillMediaMapsWithData() { - stringMetaMap.put(mediaTextFieldName, textValue); - numberMetaMap.put(mediaNumberFieldName, doubleValue); - datesMetaMap.put(mediaDateFieldName, dateValue); - booleanHashMap.put(mediaBooleanFieldName, booleanValue); - tagsMetaMap.put(mediaTagFieldName, tagValues); - } + void checkVODDeletion(String coguid) { + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setKSql("externalId='" + coguid + "'"); + com.kaltura.client.utils.response.base.Response> assetListResponse = + executor.executeSync(list(assetFilter) + .setKs(getAnonymousKs())); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); - void fillEpisodeMapsWithData() { - stringMetaMap.put(episodeTextFieldName, textValue); - numberMetaMap.put(episodeNumberFieldName, doubleValue); - datesMetaMap.put(episodeDateFieldName, dateValue); - booleanHashMap.put(episodeBooleanFieldName, booleanValue); - tagsMetaMap.put(episodeTagFieldName, tagValues); - } - - void fillSeriesMapsWithData() { - stringMetaMap.put(seriesTextFieldName, textValue); - numberMetaMap.put(seriesNumberFieldName, doubleValue); - datesMetaMap.put(seriesDateFieldName, dateValue); - booleanHashMap.put(seriesBooleanFieldName, booleanValue); - tagsMetaMap.put(seriesTagFieldName, tagValues); - } - - void generateDefaultValues4Update(boolean previousValue, String mediaType) { - textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy") + "_updated"; - dateValue = getOffsetDateInFormat(1,"MM/dd/yyyy"); - // to round up 2 decimal places - doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; - booleanValue = !previousValue; - tagValues = new ArrayList<>(); - tagValues.add("Jack NicholsonUpd"); - tagValues.add("Natalie PortmanUpd"); - tagValues.add(textValue); - - fillMapsWithData(mediaType); - } - - void generateDefaultValues4Insert(String mediaType) { - textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy"); - dateValue = getCurrentDateInFormat("MM/dd/yyyy"); - // to round up 2 decimal places - doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; - booleanValue = getRandomBooleanValue(); - tagValues = new ArrayList<>(); - tagValues.add("Jack Nicholson"); - tagValues.add("Natalie Portman"); - tagValues.add(textValue); - - fillMapsWithData(mediaType); - } - - private void fillMapsWithData(String mediaType) { - switch (mediaType) { - case MOVIE: - fillMediaMapsWithData(); - break; - case EPISODE: - fillEpisodeMapsWithData(); - break; - case SERIES: - fillSeriesMapsWithData(); - break; - default: - break; - } + deleteVod(coguid); + AssetService.ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> (executor.executeSync(listAssetBuilder).results.getTotalCount() == 0)); } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 7a406176a..9ee3b667e 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -32,13 +32,13 @@ public class BaseIngestUtils { static final Header soapActionIngestKalturaEpg = new Header("SOAPAction", "http://tempuri.org/IService/IngestKalturaEpg"); // actions - static final String INGEST_ACTION_INSERT = "insert"; + public static final String INGEST_ACTION_INSERT = "insert"; static final String INGEST_ACTION_UPDATE = "update"; static final String INGEST_ACTION_DELETE = "delete"; // wait configuration - static final int delayBetweenRetriesInSeconds = 5; - static final int maxTimeExpectingValidResponseInSeconds = 120; + public static final int delayBetweenRetriesInSeconds = 5; + public static final int maxTimeExpectingValidResponseInSeconds = 120; // life cycles periods public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java new file mode 100644 index 000000000..e673d8230 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java @@ -0,0 +1,368 @@ +package com.kaltura.client.test.utils.ingestUtils; + +import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.test.tests.enums.MediaType; +import com.kaltura.client.types.*; +import com.kaltura.client.utils.response.base.Response; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import static com.kaltura.client.services.AssetService.list; +import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.utils.BaseUtils.*; + +public class IngestVodOPCUtils extends BaseIngestUtils { + + public static String name; + public static String description; + public static String textValue; + public static String dateValue; + public static double doubleValue; + public static boolean booleanValue; + public static List tagValues; + + static final String defaultThumbUrl = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + + public static final String INGEST_VOD_XML = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Test_API_27_03\n" + + "Test_API_27_03\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Movie_Name_1808220925223281\n" + + "\n" + + "\n" + + "\n" + + "Movie_Description_1808220925223281\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Movie\n" + + "\n" + + "\n" + + "Parent Allowed\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "BoxOfficevalue\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "123456\n" + + "\n" + + "\n" + + "12/12/2012\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Jack Nicholson\n" + + "\n" + + "\n" + + "Natalie Portman\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "]]>\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + + public static final String UPDATE_VOD_XML = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Test_API_27_03\n" + + "Test_API_27_03\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Movie_Name_1808220925223281\n" + + "\n" + + "\n" + + "\n" + + "Movie_Description_1808220925223281\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Movie\n" + + "\n" + + "\n" + + "Parent Allowed\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "BoxOfficevalue\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "123456\n" + + "\n" + + "\n" + + "12/12/2012\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Jack Nicholson\n" + + "\n" + + "\n" + + "Natalie Portman\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "]]>\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + + public static final String DELETE_VOD_XML = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Test_API_27_03\n" + + "Test_API_27_03\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "]]>\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + + // media types + public static final String EPISODE = "Episode"; + public static final String MOVIE = "Movie"; + public static final String SERIES = "Series"; + + // TODO: how to get these data from DB or request? + //Movie fields + public static final String mediaTextFieldName = "BoxOffice"; + public static final String mediaDateFieldName = "ReleaseDate"; + public static final String mediaNumberFieldName = "Runtime2"; + public static final String mediaBooleanFieldName = "IsAgeLimited"; + public static final String mediaTagFieldName = "Actors"; + + //Episode fields + public static final String episodeTextFieldName = "TwitterHashtag"; + public static final String episodeDateFieldName = "Date"; + public static final String episodeNumberFieldName = "CommonIpAddress"; + public static final String episodeBooleanFieldName = "CyyNCAh"; + public static final String episodeTagFieldName = "Studio"; + + //Series fields + public static final String seriesTextFieldName = "SeriesID"; + public static final String seriesDateFieldName = "DateField"; + public static final String seriesNumberFieldName = "ReleaseYear"; + public static final String seriesBooleanFieldName = "IsWestern"; + public static final String seriesTagFieldName = "Studio"; + + // fields & values + public static HashMap stringMetaMap = new HashMap<>(); + public static HashMap numberMetaMap = new HashMap<>(); + public static HashMap booleanHashMap = new HashMap<>(); + public static HashMap datesMetaMap = new HashMap<>(); + public static HashMap> tagsMetaMap = new HashMap<>(); + public static List assetFiles = new ArrayList<>(); + + public static IngestVodUtils.VodData getVodData(String mediaType) { + switch (mediaType) { + case "Movie": + return new IngestVodUtils.VodData() + .name(name) + .description(description) + .mediaType(MediaType.MOVIE) + .thumbUrl(defaultThumbUrl) + .strings(stringMetaMap) + .booleans(booleanHashMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + .isVirtual(false) + .assetFiles(assetFiles); + case "Episode": + return new IngestVodUtils.VodData() + .name(name) + .description(description) + .mediaType(MediaType.EPISODE) + .thumbUrl(defaultThumbUrl) + .strings(stringMetaMap) + .booleans(booleanHashMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + .isVirtual(false) + .assetFiles(assetFiles); + case "Series": + return new IngestVodUtils.VodData() + .name(name) + .description(description) + .mediaType(MediaType.SERIES) + .thumbUrl(defaultThumbUrl) + .strings(stringMetaMap) + .booleans(booleanHashMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + .isVirtual(true) + .assetFiles(assetFiles); + default: + return null; + } + } + + static void fillMediaMapsWithData() { + stringMetaMap.put(mediaTextFieldName, textValue); + numberMetaMap.put(mediaNumberFieldName, doubleValue); + datesMetaMap.put(mediaDateFieldName, dateValue); + booleanHashMap.put(mediaBooleanFieldName, booleanValue); + tagsMetaMap.put(mediaTagFieldName, tagValues); + } + + static void fillEpisodeMapsWithData() { + stringMetaMap.put(episodeTextFieldName, textValue); + numberMetaMap.put(episodeNumberFieldName, doubleValue); + datesMetaMap.put(episodeDateFieldName, dateValue); + booleanHashMap.put(episodeBooleanFieldName, booleanValue); + tagsMetaMap.put(episodeTagFieldName, tagValues); + } + + static void fillSeriesMapsWithData() { + stringMetaMap.put(seriesTextFieldName, textValue); + numberMetaMap.put(seriesNumberFieldName, doubleValue); + datesMetaMap.put(seriesDateFieldName, dateValue); + booleanHashMap.put(seriesBooleanFieldName, booleanValue); + tagsMetaMap.put(seriesTagFieldName, tagValues); + } + + public static void generateDefaultValues4Update(boolean previousValue, String mediaType) { + textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy") + "_updated"; + dateValue = getOffsetDateInFormat(1,"MM/dd/yyyy"); + // to round up 2 decimal places + doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; + booleanValue = !previousValue; + tagValues = new ArrayList<>(); + tagValues.add("Jack NicholsonUpd"); + tagValues.add("Natalie PortmanUpd"); + tagValues.add(textValue); + + fillMapsWithData(mediaType); + } + + public static void generateDefaultValues4Insert(String mediaType) { + textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy"); + dateValue = getCurrentDateInFormat("MM/dd/yyyy"); + // to round up 2 decimal places + doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; + booleanValue = getRandomBooleanValue(); + tagValues = new ArrayList<>(); + tagValues.add("Jack Nicholson"); + tagValues.add("Natalie Portman"); + tagValues.add(textValue); + + fillMapsWithData(mediaType); + } + + private static void fillMapsWithData(String mediaType) { + clearMapsBeforeFilling(); + switch (mediaType) { + case MOVIE: + fillMediaMapsWithData(); + break; + case EPISODE: + fillEpisodeMapsWithData(); + break; + case SERIES: + fillSeriesMapsWithData(); + break; + default: + break; + } + } + + private static void clearMapsBeforeFilling() { + stringMetaMap = new HashMap<>(); + numberMetaMap = new HashMap<>(); + booleanHashMap = new HashMap<>(); + datesMetaMap = new HashMap<>(); + tagsMetaMap = new HashMap<>(); + } + + public static String getCoguidOfActiveMediaAsset(int assetType) { + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setOrderBy(AssetOrderBy.CREATE_DATE_DESC.getValue()); + assetFilter.setTypeIn(String.valueOf(assetType)); + FilterPager pager = new FilterPager(); + pager.setPageSize(1); + pager.setPageIndex(1); + + Response> assetListResponse = executor.executeSync(list(assetFilter, pager) + .setKs(getAnonymousKs())); + //assertThat(assetListResponse.results.getObjects().size()).isEqualTo(1); + + return assetListResponse.results.getObjects().get(0).getExternalId(); + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index dc7a39f8f..aec7f574b 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -40,7 +40,7 @@ public class IngestVodUtils extends BaseIngestUtils { private static final String ingestAssetStatusPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus[0]."; public static final String ingestAssetStatusMessagePath = ingestAssetStatusPath + "Status.Message"; public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; - private static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; + public static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; static boolean areDefaultValuesRequired; @@ -217,7 +217,7 @@ private static Response executeIngestVodRequest(String reqBody) { return resp; } - private static String buildIngestVodXml(VodData vodData, String action) { + public static String buildIngestVodXml(VodData vodData, String action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password @@ -253,7 +253,7 @@ private static String buildIngestVodXml(VodData vodData, String action) { // thumb if (vodData.thumbUrl() != null) { Element thumb = (Element) media.getElementsByTagName("thumb").item(0); - thumb.setAttribute("ingestUrl", vodData.thumbUrl()); + thumb.setAttribute("url", vodData.thumbUrl()); } // description diff --git a/src/test/resources/AllSuitesTestng.xml b/src/test/resources/AllSuitesTestng.xml new file mode 100644 index 000000000..846a9c9f8 --- /dev/null +++ b/src/test/resources/AllSuitesTestng.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 751e9b7d2..2adb1885d 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,12 +1,14 @@ + + diff --git a/src/test/resources/testngopc.xml b/src/test/resources/testngopc.xml new file mode 100644 index 000000000..d755103fd --- /dev/null +++ b/src/test/resources/testngopc.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + From 968564684f8f2e5a0e292249af2166485ff32818 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 28 Aug 2018 03:11:02 +0300 Subject: [PATCH 486/605] Updated permission management tests --- .../PermissionsManagementTests.java | 43 +++++++++++++------ .../test/utils/dbUtils/DBConstants.java | 4 +- .../dbUtils/PermissionsManagementDBUtils.java | 22 +++++----- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 30fddd4f9..431ded55d 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -3,6 +3,7 @@ import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.PermissionManagementUtils; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.BeforeClass; @@ -22,6 +23,8 @@ * * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 */ + + public class PermissionsManagementTests { String mainFile = "PermissionsDeployment.exe"; @@ -31,6 +34,7 @@ public class PermissionsManagementTests { // these files are generated String dataFilePath = path2Util + "333\\" + "exp1.txt"; + String path2JsonFolder = path2Util + "333\\JSON\\"; String generatedDataFilePath = path2Util + "333\\" + "import.txt"; // these files added into project @@ -68,6 +72,7 @@ public void runningWithoutParameters() { } @Severity(SeverityLevel.MINOR) + @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") public void runningExportWithoutFile() { List commands = new ArrayList<>(); @@ -79,6 +84,7 @@ public void runningExportWithoutFile() { } @Severity(SeverityLevel.MINOR) + @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") public void runningImportWithoutFile() { List commands = new ArrayList<>(); @@ -90,6 +96,7 @@ public void runningImportWithoutFile() { } @Severity(SeverityLevel.MINOR) + @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") public void runningDeleteWithoutFile() { List commands = new ArrayList<>(); @@ -197,9 +204,9 @@ public void importFromFile() { int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); assertThat(idRolePermission).isEqualTo(1); - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix); int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); @@ -229,13 +236,11 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { List commands = new ArrayList<>(); commands.add(path2Util + mainFile); commands.add(DELETE_KEY + path2EmptyFile); - executeCommandsInColsole(commands); + String outputInConsole = executeCommandsInColsole(commands); String fileContent = getFileContent(path2Log); - assertThat(fileContent).contains("!!NOT EXISTS IN SOURCE!! Table : role Id : " + idRoleHavingName + " Name : " + "MaxTest" + suffix); - assertThat(fileContent).contains("Asset_List_Max" + suffix); - assertThat(fileContent).contains("permissionItemObject" + suffix); - assertThat(fileContent).contains("parameter" + suffix); + assertThat(fileContent).contains("ex = System.Xml.XmlException: Root element is missing"); + assertThat(outputInConsole).contains("ex = System.Xml.XmlException: Root element is missing"); } @Severity(SeverityLevel.CRITICAL) @@ -264,9 +269,9 @@ public void deleteFromDB() { int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); assertThat(idRolePermission).isEqualTo(1); - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix); int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); @@ -288,7 +293,7 @@ public void deleteFromDB() { rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); assertThat(rowsInPermissionsHavingName).isEqualTo(0); - rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); } @@ -321,9 +326,9 @@ public void importAlreadyExistedFromFile() { int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); assertThat(idRolePermission).isEqualTo(1); - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix, 0); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix); int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); @@ -373,6 +378,7 @@ public void deleteOnlyFromOneTable() { } @Severity(SeverityLevel.MINOR) + @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to export in JSON without mentioned file") public void runningExportJsonWithoutFile() { List commands = new ArrayList<>(); @@ -384,6 +390,7 @@ public void runningExportJsonWithoutFile() { } @Severity(SeverityLevel.MINOR) + @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to import in JSON without mentioned file") public void runningImportJsonWithoutFile() { List commands = new ArrayList<>(); @@ -393,4 +400,16 @@ public void runningImportJsonWithoutFile() { assertThat(consoleOutput).contains("The system cannot find the file specified"); } + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"Permission management"}, description = "execute console util to export in JSON from DB") + public void runningExporttJson() { + List commands = new ArrayList<>(); + commands.add(path2Util + mainFile); + commands.add(EXPORT_JSON_KEY + path2JsonFolder); + String consoleOutput = executeCommandsInColsole(commands); + + //assertThat(consoleOutput).contains("The system cannot find the file specified"); + // TODO: add assertions + } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 6253907f6..7ff872f58 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -176,11 +176,11 @@ public class DBConstants { static final String COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[permission_items]\n" + - "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; + "where [NAME]=? and is_active=1 and [status]=1"; static final String ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT = "select " + ID + "\n" + "from [TVinci].[dbo].[permission_items]\n" + - "where [NAME]=? and is_active=1 and [status]=1 and group_id=?"; + "where [NAME]=? and is_active=1 and [status]=1"; static final String COUNT_RECORDS_IN_PERMISSIONS_PERMISSIONS_ITEMS_SELECT = "select count(*) as " + ROW_COUNT + "\n" + "from [TVinci].[dbo].[permissions_permission_items]\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java index 945513cfa..0f50ee71d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/PermissionsManagementDBUtils.java @@ -1,11 +1,9 @@ package com.kaltura.client.test.utils.dbUtils; -import com.kaltura.client.Logger; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.json.JSONArray; import java.sql.*; -import java.util.Arrays; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; @@ -150,18 +148,18 @@ public static int getCountRowsHavingRoleNameInPermissions(String name, int group } public static int getIdRecordHavingRoleNameInPermissions(String name, int groupId) { - int count =-1; + int id =-1; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_ROLE_NAME_IN_PERMISSIONS_SELECT), name, groupId); if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + id = jsonArray.getJSONObject(0).getInt(ID); } } catch (Exception e) { e.printStackTrace(); } - return count; + return id; } public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permissionId, int groupId) { @@ -179,11 +177,11 @@ public static int getCountSpecificRowsFromRolesPermissions(int roleId, int permi return count; } - public static int getCountRowsHavingNameInPermissionItems(String name, int groupId) { + public static int getCountRowsHavingNameInPermissionItems(String name) { int count = 0; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(COUNT_RECORDS_BY_NAME_IN_PERMISSION_ITEMS_SELECT), - name, groupId); + name); if (!jsonArray.isNull(0)) { count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); } @@ -194,19 +192,19 @@ public static int getCountRowsHavingNameInPermissionItems(String name, int group return count; } - public static int getIdRecordHavingNameInPermissionItems(String name, int groupId) { - int count =-1; + public static int getIdRecordHavingNameInPermissionItems(String name) { + int id =-1; try { JSONArray jsonArray = getJsonArrayFromQueryResult(String.format(ID_BY_NAME_IN_PERMISSION_ITEMS_SELECT), - name, groupId); + name); if (!jsonArray.isNull(0)) { - count = jsonArray.getJSONObject(0).getInt(ROW_COUNT); + id = jsonArray.getJSONObject(0).getInt(ID); } } catch (Exception e) { e.printStackTrace(); } - return count; + return id; } public static int getCountSpecificRowsFromPermissionsPermissionsItems(int permissionId, int permissionItemId, int groupId) { From 35a8de8afe8c88f302902d259882fc7ab9c29f08 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 28 Aug 2018 16:04:10 +0300 Subject: [PATCH 487/605] refactor performance report --- .../com/kaltura/client/test/Properties.java | 22 +- .../test/TestAPIOkRequestsExecutor.java | 34 +- .../kaltura/client/test/tests/BaseTest.java | 31 +- .../test/utils/PerformanceAppLogUtils.java | 815 +++++++++--------- .../client/test/utils/PerformanceUtils.java | 335 +++++++ 5 files changed, 780 insertions(+), 457 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 4086e146f..b42b5142b 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -81,20 +81,14 @@ public class Properties { // payment gateway external id public static final String PAYMENT_GATEWAY_EXTERNAL_ID = "payment_gateway_external_id"; - // processing apps logs from remote connection -// public static final String PHOENIX_SERVER_DOMAIN_NAME = "phoenix_server_domain_name"; -// public static final String PHOENIX_SERVER_USER_NAME = "phoenix_server_user_name"; -// public static final String PHOENIX_SERVER_PASSWORD = "phoenix_server_password"; -// public static final String PHOENIX_SERVER_LOGS_DIRECTORY = "phoenix_server_logs_directory"; - public static final String PHOENIX_SERVER_LOGS_DIRECTORY_URL = "phoenix_server_logs_directory_url"; - public static final String PHOENIX_SERVER_LOG_FILE_NAME_PREFIX = "phoenix_server_logs_file_name_prefix"; - public static final String PHOENIX_SERVER_LOG_FILE_EXTENSION = "phoenix_server_logs_file_extension"; - public static final String PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH = "phoenix_server_logs_local_folder_path"; - public static final String REGRESSION_LOGS_LOCAL_FILE = "regression_logs_local_file"; - public static final String SHOULD_REGRESSION_LOGS_BE_SAVED = "should_regression_logs_be_saved"; - public static final String MAX_ALLOWED_PERCENTAGE = "max_allowed_percentage"; - public static final String CODE_PERFORMANCE_REPORT_FILE = "code_performance_report_file"; - public static final String MAX_ALLOWED_EXECUTION_TIME_IN_SEC = "max_allowed_execution_time_in_sec"; + // performance report + public static final String LOGS_BASE_URL = "logs_base_url"; + public static final String LOGS_DIR = "logs_dir"; + public static final String REGRESSION_LOGS_FILE = "regression_logs_file"; + public static final String PERFORMANCE_REPORT_FILE = "performance_report_file"; + public static final String WRITE_REGRESSION_LOGS = "write_regression_logs"; + public static final String MAX_CODE_PERCENTAGE = "max_code_percentage"; + public static final String MAX_EXECUTION_TIME_IN_SEC = "max_execution_time_in_sec"; public static String getProperty(String propertyKey) { if (resourceBundle == null) { diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 96601c2b4..6c8d13d71 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -1,8 +1,6 @@ package com.kaltura.client.test; import com.google.common.primitives.Ints; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; import com.kaltura.client.APIOkRequestsExecutor; import com.kaltura.client.ILogger; import com.kaltura.client.Logger; @@ -13,20 +11,23 @@ import com.kaltura.client.utils.response.base.ApiCompletion; import com.kaltura.client.utils.response.base.Response; import com.kaltura.client.utils.response.base.ResponseElement; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.io.FileUtils; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; import java.util.concurrent.atomic.AtomicBoolean; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.LOG_HEADERS; import static com.kaltura.client.test.tests.BaseTest.client; -//import static com.kaltura.client.test.tests.BaseTest.objectType2JsonValidationSchemaFile4Lists; import static com.kaltura.client.utils.ErrorElement.*; import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; +//import static com.kaltura.client.test.tests.BaseTest.objectType2JsonValidationSchemaFile4Lists; + /** * @hide That class allows to validate json schemas of responses */ @@ -105,10 +106,10 @@ protected ResponseElement onGotResponse(okhttp3.Response okhttpResponse, Request /*date = new Date(); System.out.println("AFTER VALIDATION: " + formatter.format(date));*/ - if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { + if ("true".equals(getProperty(WRITE_REGRESSION_LOGS))) { String serviceMethod = action.getUrl().split("service")[1]; String kalturaSession = okhttpResponse.headers().get("X-Kaltura-Session"); - write2LogFile(serviceMethod, kalturaSession); + writeLogs(serviceMethod, kalturaSession); } } } @@ -124,15 +125,22 @@ private String getObjectType(String response) { return objectType.getAsString(); }*/ - private void write2LogFile(String serviceMethod, String kalturaSession) { - try(FileWriter fw = new FileWriter(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(REGRESSION_LOGS_LOCAL_FILE), true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) { - out.println(serviceMethod + " " + kalturaSession); + private void writeLogs(String serviceMethod, String kalturaSession) { + File logFile = new File(getProperty(LOGS_DIR) + getProperty(REGRESSION_LOGS_FILE)); + + try { + FileUtils.writeStringToFile(logFile, serviceMethod + ":" + kalturaSession + "\n", Charset.forName("UTF-8"), true); } catch (IOException e) { e.printStackTrace(); } + +// try(FileWriter fw = new FileWriter(getProperty(LOGS_DIR) + getProperty(REGRESSION_LOGS_FILE), true); +// BufferedWriter bw = new BufferedWriter(fw); +// PrintWriter out = new PrintWriter(bw)) { +// out.println(serviceMethod + " " + kalturaSession); +// } catch (IOException e) { +// e.printStackTrace(); +// } } public Response executeSync(RequestBuilder requestBuilder) { diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 07265461f..47c43a063 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -5,17 +5,20 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.ChannelService.AddChannelBuilder; import com.kaltura.client.test.TestAPIOkRequestsExecutor; -import com.kaltura.client.test.utils.PerformanceAppLogUtils; +import com.kaltura.client.test.utils.PerformanceUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; +import org.apache.commons.io.FileUtils; import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; +import java.io.File; +import java.io.IOException; import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.TimeUnit; @@ -28,7 +31,6 @@ import static com.kaltura.client.services.SubscriptionService.list; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; -import static com.kaltura.client.test.utils.BaseUtils.deleteFile; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static com.kaltura.client.test.utils.BaseUtils.setTranslationToken; import static com.kaltura.client.test.utils.HouseholdUtils.*; @@ -133,18 +135,12 @@ public void baseTest_beforeSuite() { defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); // set performance report - if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { - // Before execution of regression we have to delete log file created during previous regression execution - // to not affect results of current check - String regressionLogsFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(REGRESSION_LOGS_LOCAL_FILE); - deleteFile(regressionLogsFileName); - - // Before execution of regression we have to delete report file created during previous regression execution - // to not affect results of current check - String codePerformanceReportFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(CODE_PERFORMANCE_REPORT_FILE); - deleteFile(codePerformanceReportFileName); + if ("true".equals(getProperty(WRITE_REGRESSION_LOGS))) { + try { + FileUtils.cleanDirectory(new File(getProperty(LOGS_DIR))); + } catch (IOException e) { + e.printStackTrace(); + } } } @@ -573,10 +569,9 @@ public static HouseholdUser getSharedUser() { @AfterSuite public void tearDownSuite() { - if ("true".equals(getProperty(SHOULD_REGRESSION_LOGS_BE_SAVED))) { - // processing of logs and creation of app performance code report - PerformanceAppLogUtils.createPerformanceCodeReport(); - PerformanceAppLogUtils.removeCopiedAppLogFiles(); + // generate performance report + if ("true".equals(getProperty(WRITE_REGRESSION_LOGS))) { + PerformanceUtils.generatePerformanceReport(); } // TODO: 8/14/2018 cleanup: delete generated shared resources and data! diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java index ab7a28439..12398a583 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceAppLogUtils.java @@ -1,419 +1,410 @@ -package com.kaltura.client.test.utils; - -import com.kaltura.client.Logger; -import lombok.Data; -import org.apache.commons.io.FileUtils; -import org.apache.commons.vfs2.*; -import org.apache.commons.vfs2.auth.StaticUserAuthenticator; -import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.*; -import java.util.stream.Stream; - -import static com.kaltura.client.test.Properties.*; - -public class PerformanceAppLogUtils extends BaseUtils { - - /** - * class to save data about count of slow executions and count of total executions for methods checking in regression - */ - @Data - static class SlowRatio { - private int slowCount; - private int totalCount; - } - - private static final int maxAllowedPercentage = Integer.valueOf(getProperty(MAX_ALLOWED_PERCENTAGE)); - private static final String domain = getProperty(PHOENIX_SERVER_DOMAIN_NAME); - private static final String userName = getProperty(PHOENIX_SERVER_USER_NAME); - private static final String password = getProperty(PHOENIX_SERVER_PASSWORD); - private static final String remoteSourceFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY) + getProperty(API_VERSION) + "/"; - private static final String remoteSourceUrlFileDir = getProperty(PHOENIX_SERVER_LOGS_DIRECTORY_URL) + getProperty(API_VERSION) + "\\"; - private static final UserAuthenticator auth = new StaticUserAuthenticator(domain, userName, password); - private static final FileSystemOptions options = new FileSystemOptions(); - - private static final String COUCHBASE_LOG_DATA = "\"e\":\"cb\""; - private static final String DB_LOG_DATA = "\"e\":\"db\""; - private static final String ELASTIC_SEARCH_LOG_DATA = "\"e\":\"es\""; - private static final String RABBIT_LOG_DATA = "\"e\":\"rabbit\""; - - private static List appLogLocalFileNames = new ArrayList<>(); - - private static final List nonRelated2CodeStringsList = new ArrayList() {{ - add("\"e\":\"start_api\""); - add(COUCHBASE_LOG_DATA); - add(DB_LOG_DATA); - add(ELASTIC_SEARCH_LOG_DATA); - add(RABBIT_LOG_DATA); - }}; - - private static double timeOfCode; - private static double timeOfCB; - private static double timeOfDB; - private static double timeOfES; - private static double timeOfRabbit; - private static double totalTime; - private static boolean isKalturaSessionFoundInAppLogFile; - private static int countOfCB; - private static int countOfDB; - private static int countOfES; - private static int countOfRabbit; - - public static void createPerformanceCodeReport() { - try { - // copy log files to local machine - List appRemoteFileNames = getRemoteAppLogFileNames(); - for (String fileName : appRemoteFileNames) { - copyRemoteFile2LocalMachine(fileName); - } - - // aggregated last regression results - Map> methodsAndKalturaSessions = loadMethodsAndSessionsFromTestFile(); - - Map methodsAndSlowRatioData = new HashMap<>(); - SlowRatio slowRatio; - for (String method : methodsAndKalturaSessions.keySet()) { - methodsAndSlowRatioData.put(method, new SlowRatio()); - //Logger.getLogger(PerformanceAppLogUtils.class).debug("Method: [" + method + "]"); - for (String xKalturaSession : methodsAndKalturaSessions.get(method)) { - slowRatio = methodsAndSlowRatioData.get(method); - slowRatio.totalCount++; - methodsAndSlowRatioData.put(method, slowRatio); - //Logger.getLogger(PerformanceAppLogUtils.class).debug("xKalturaSession: [" + xKalturaSession + "]"); - for (String appFileName : appRemoteFileNames) { - isKalturaSessionFoundInAppLogFile = false; - timeOfCode = 0.0; - timeOfCB = 0.0; - timeOfDB = 0.0; - timeOfES = 0.0; - timeOfRabbit = 0.0; - totalTime = 0.0; - - countOfCB = 0; - countOfDB = 0; - countOfES = 0; - countOfRabbit = 0; - - calcTimeExecution(appFileName, xKalturaSession); - - if (isKalturaSessionFoundInAppLogFile) { - double percentageCodeTime2TotalTime = timeOfCode / totalTime * 100; - - // include in report only relevant cases - if (percentageCodeTime2TotalTime > maxAllowedPercentage && - totalTime > Double.parseDouble(getProperty(MAX_ALLOWED_EXECUTION_TIME_IN_SEC))) { - slowRatio = methodsAndSlowRatioData.get(method); - slowRatio.slowCount++; - methodsAndSlowRatioData.put(method, slowRatio); - - // save results - writeReport2File(method, xKalturaSession, percentageCodeTime2TotalTime); - } - } - } - } - } - addSummary2Report(methodsAndSlowRatioData); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void addSummary2Report(Map methodsAndSlowRatioData) throws IOException { - Logger.getLogger(PerformanceAppLogUtils.class).debug("addSummary2Report started"); - if (methodsAndSlowRatioData.keySet().size() > 0) { - String reportFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(CODE_PERFORMANCE_REPORT_FILE); - String summaryTemporaryFileName = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "SUMMARY" + - getProperty(CODE_PERFORMANCE_REPORT_FILE); - - createSummaryFile(methodsAndSlowRatioData, summaryTemporaryFileName); - addReportDataIntoSummaryFile(reportFileName, summaryTemporaryFileName); - - File source = new File(summaryTemporaryFileName); - File target = new File(reportFileName); - deleteFile(reportFileName); - boolean success = source.renameTo(target); - if (!success) { - throw new IOException("File can't be renamed"); - } - Logger.getLogger(PerformanceAppLogUtils.class).debug("Report was successfully created: [" + reportFileName + "]"); - } - Logger.getLogger(PerformanceAppLogUtils.class).debug("addSummary2Report completed"); - } - - private static void addReportDataIntoSummaryFile(String fromFile, String toFile) { - Logger.getLogger(PerformanceAppLogUtils.class).debug("addReportDataIntoSummaryFile started"); - Logger.getLogger(PerformanceAppLogUtils.class).debug(Paths.get(fromFile)); - try (BufferedReader br = Files.newBufferedReader(Paths.get(fromFile)); - FileWriter fw = new FileWriter(toFile, true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) { - Stream lines = br.lines(); - lines.forEach(out::println); - lines.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - Logger.getLogger(PerformanceAppLogUtils.class).debug("addReportDataIntoSummaryFile completed"); - } - } - - private static void createSummaryFile(Map methodsAndSlowRatioData, String summaryTemporaryFileName) { - Logger.getLogger(PerformanceAppLogUtils.class).debug("createSummaryFile started"); - try (FileWriter fw = new FileWriter(summaryTemporaryFileName, true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) { - out.println("Report of slow methods on " + getCurrentDateInFormat("dd/MM/yyyy HH:mm") + " (" + getProperty(API_VERSION) + ")"); - out.println("Max allowed percentage: " + getProperty(MAX_ALLOWED_PERCENTAGE)); - out.println("Max allowed execution time in seconds: " + getProperty(MAX_ALLOWED_EXECUTION_TIME_IN_SEC)); - out.println(); - out.println("Summary of slow methods are below:"); - out.println(); - for (String method : methodsAndSlowRatioData.keySet()) { - if (methodsAndSlowRatioData.get(method).slowCount > 0) { - out.println(method + " was slow " + String.format("%.2f", methodsAndSlowRatioData.get(method).slowCount * - 1.0 / methodsAndSlowRatioData.get(method).totalCount * 100) + "% of executions (" + - methodsAndSlowRatioData.get(method).slowCount + "/" + methodsAndSlowRatioData.get(method).totalCount + ")"); - } - } - - out.println(); - out.println("Details of slow methods are below:"); - out.println(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - Logger.getLogger(PerformanceAppLogUtils.class).debug("createSummaryFile completed"); - } - } - - private static void writeReport2File(String method, String xKalturaSession, double codeTimePercentage) { - try (FileWriter fw = new FileWriter(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(CODE_PERFORMANCE_REPORT_FILE), true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw)) { - // we want to see only data where code time is less than 100% - if (timeOfCB > 0 || timeOfDB > 0 || timeOfES > 0 || timeOfRabbit > 0) { - out.println(method); - out.println(xKalturaSession); - out.println("Execution Time: " + String.format("%.3f", totalTime)); - out.println("Code: " + String.format("%.2f", codeTimePercentage) + "% (" + String.format("%.3f", timeOfCode) + ")"); - writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime, countOfCB); - writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime, countOfDB); - writeIfValueMoreThanZero(out, "Elastic: ", timeOfES, totalTime, countOfES); - writeIfValueMoreThanZero(out, "Rabbit: ", timeOfRabbit, totalTime, countOfRabbit); - out.println(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void writeIfValueMoreThanZero(PrintWriter out, String title, double timeOfEvent, double totalTime, int countOfEvent) { - if (timeOfEvent > 0) { - out.println(title + " " + String.format("%.2f", timeOfEvent / totalTime * 100) + "% (" + String.format("%.3f", timeOfEvent) + ") [" + countOfEvent + " queries]"); - } - } - - private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IOException { - Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine() with [" + remoteFileName + "]: started"); - - // add local target folder in case it does not exist - File localTargetFolderPath = new File(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH)); - if (!localTargetFolderPath.exists()) { - boolean isDirCreated = localTargetFolderPath.mkdir(); - Logger.getLogger(PerformanceAppLogUtils.class).debug("Directory [" + - getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "] was created == [" + isDirCreated + "]"); - } - - String remoteFilePathUrl = remoteSourceUrlFileDir + remoteFileName; - String localTargetFilePath = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "copied-" + remoteFileName; - appLogLocalFileNames.add(localTargetFilePath); - - // remove local target file in case it exists and create it empty - File targetFile = new File(localTargetFilePath); - if (targetFile.exists()) { - targetFile.delete(); - } - targetFile.createNewFile(); - //FileObject destination = VFS.getManager().resolveFile(targetFile.getAbsolutePath()); - - //domain, username, password - //DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); - - //FileObject fileObject = VFS.getManager().resolveFile(remoteFilePath, options); - - // copy file from remote to local folder -// if (fileObject.exists()) { -// destination.copyFrom(fileObject, Selectors.SELECT_SELF); +//package com.kaltura.client.test.utils; +// +//import com.kaltura.client.Logger; +//import lombok.Data; +//import org.apache.commons.io.FileUtils; +// +//import java.io.*; +//import java.net.HttpURLConnection; +//import java.net.URL; +//import java.nio.file.Files; +//import java.nio.file.Paths; +//import java.util.*; +//import java.util.stream.Stream; +// +//import static com.kaltura.client.test.Properties.*; +// +//public class PerformanceAppLogUtils extends BaseUtils { +// +// /** +// * class to save data about count of slow executions and count of total executions for methods checking in regression +// */ +// @Data +// static class SlowRatio { +// private int slowCount; +// private int totalCount; +// } +// +// private static final int maxAllowedPercentage = Integer.valueOf(getProperty(MAX_CODE_PERCENTAGE)); +// private static final String remoteSourceUrlFileDir = getProperty(LOGS_BASE_URL) + getProperty(API_VERSION) + "\\"; +// +// private static final String COUCHBASE_LOG_DATA = "\"e\":\"cb\""; +// private static final String DB_LOG_DATA = "\"e\":\"db\""; +// private static final String ELASTIC_SEARCH_LOG_DATA = "\"e\":\"es\""; +// private static final String RABBIT_LOG_DATA = "\"e\":\"rabbit\""; +// +// private static List appLogLocalFileNames = new ArrayList<>(); +// +// private static final List nonRelated2CodeStringsList = new ArrayList() {{ +// add("\"e\":\"start_api\""); +// add(COUCHBASE_LOG_DATA); +// add(DB_LOG_DATA); +// add(ELASTIC_SEARCH_LOG_DATA); +// add(RABBIT_LOG_DATA); +// }}; +// +// private static double timeOfCode; +// private static double timeOfCB; +// private static double timeOfDB; +// private static double timeOfES; +// private static double timeOfRabbit; +// private static double totalTime; +// private static boolean isKalturaSessionFoundInAppLogFile; +// private static int countOfCB; +// private static int countOfDB; +// private static int countOfES; +// private static int countOfRabbit; +// +// public static void createPerformanceCodeReport() { +// try { +// // copy log files to local machine +// List appRemoteFileNames = getRemoteAppLogFileNames(); +// for (String fileName : appRemoteFileNames) { +// copyRemoteFile2LocalMachine(fileName); +// } +// +// // aggregated last regression results +// Map> methodsAndKalturaSessions = loadMethodsAndSessionsFromTestFile(); +// +// Map methodsAndSlowRatioData = new HashMap<>(); +// SlowRatio slowRatio; +// for (String method : methodsAndKalturaSessions.keySet()) { +// methodsAndSlowRatioData.put(method, new SlowRatio()); +// //Logger.getLogger(PerformanceAppLogUtils.class).debug("Method: [" + method + "]"); +// for (String xKalturaSession : methodsAndKalturaSessions.get(method)) { +// slowRatio = methodsAndSlowRatioData.get(method); +// slowRatio.totalCount++; +// methodsAndSlowRatioData.put(method, slowRatio); +// //Logger.getLogger(PerformanceAppLogUtils.class).debug("xKalturaSession: [" + xKalturaSession + "]"); +// for (String appFileName : appRemoteFileNames) { +// isKalturaSessionFoundInAppLogFile = false; +// timeOfCode = 0.0; +// timeOfCB = 0.0; +// timeOfDB = 0.0; +// timeOfES = 0.0; +// timeOfRabbit = 0.0; +// totalTime = 0.0; +// +// countOfCB = 0; +// countOfDB = 0; +// countOfES = 0; +// countOfRabbit = 0; +// +// calcTimeExecution(appFileName, xKalturaSession); +// +// if (isKalturaSessionFoundInAppLogFile) { +// double percentageCodeTime2TotalTime = timeOfCode / totalTime * 100; +// +// // include in report only relevant cases +// if (percentageCodeTime2TotalTime > maxAllowedPercentage && +// totalTime > Double.parseDouble(getProperty(MAX_EXECUTION_TIME_IN_SEC))) { +// slowRatio = methodsAndSlowRatioData.get(method); +// slowRatio.slowCount++; +// methodsAndSlowRatioData.put(method, slowRatio); +// +// // save results +// writeReport2File(method, xKalturaSession, percentageCodeTime2TotalTime); +// } +// } +// } +// } +// } +// addSummary2Report(methodsAndSlowRatioData); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// +// private static void addSummary2Report(Map methodsAndSlowRatioData) throws IOException { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("addSummary2Report started"); +// if (methodsAndSlowRatioData.keySet().size() > 0) { +// String reportFileName = getProperty(LOGS_DIR) + +// getProperty(PERFORMANCE_REPORT_FILE); +// String summaryTemporaryFileName = getProperty(LOGS_DIR) + "SUMMARY" + +// getProperty(PERFORMANCE_REPORT_FILE); +// +// createSummaryFile(methodsAndSlowRatioData, summaryTemporaryFileName); +// addReportDataIntoSummaryFile(reportFileName, summaryTemporaryFileName); +// +// File source = new File(summaryTemporaryFileName); +// File target = new File(reportFileName); +// deleteFile(reportFileName); +// boolean success = source.renameTo(target); +// if (!success) { +// throw new IOException("File can't be renamed"); +// } +// Logger.getLogger(PerformanceAppLogUtils.class).debug("Report was successfully created: [" + reportFileName + "]"); +// } +// Logger.getLogger(PerformanceAppLogUtils.class).debug("addSummary2Report completed"); +// } +// +// private static void addReportDataIntoSummaryFile(String fromFile, String toFile) { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("addReportDataIntoSummaryFile started"); +// Logger.getLogger(PerformanceAppLogUtils.class).debug(Paths.get(fromFile)); +// try (BufferedReader br = Files.newBufferedReader(Paths.get(fromFile)); +// FileWriter fw = new FileWriter(toFile, true); +// BufferedWriter bw = new BufferedWriter(fw); +// PrintWriter out = new PrintWriter(bw)) { +// Stream lines = br.lines(); +// lines.forEach(out::println); +// lines.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } finally { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("addReportDataIntoSummaryFile completed"); +// } +// } +// +// private static void createSummaryFile(Map methodsAndSlowRatioData, String summaryTemporaryFileName) { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("createSummaryFile started"); +// try (FileWriter fw = new FileWriter(summaryTemporaryFileName, true); +// BufferedWriter bw = new BufferedWriter(fw); +// PrintWriter out = new PrintWriter(bw)) { +// out.println("Report of slow methods on " + getCurrentDateInFormat("dd/MM/yyyy HH:mm") + " (" + getProperty(API_VERSION) + ")"); +// out.println("Max allowed percentage: " + getProperty(MAX_CODE_PERCENTAGE)); +// out.println("Max allowed execution time in seconds: " + getProperty(MAX_EXECUTION_TIME_IN_SEC)); +// out.println(); +// out.println("Summary of slow methods are below:"); +// out.println(); +// for (String method : methodsAndSlowRatioData.keySet()) { +// if (methodsAndSlowRatioData.get(method).slowCount > 0) { +// out.println(method + " was slow " + String.format("%.2f", methodsAndSlowRatioData.get(method).slowCount * +// 1.0 / methodsAndSlowRatioData.get(method).totalCount * 100) + "% of executions (" + +// methodsAndSlowRatioData.get(method).slowCount + "/" + methodsAndSlowRatioData.get(method).totalCount + ")"); +// } +// } +// +// out.println(); +// out.println("Details of slow methods are below:"); +// out.println(); +// } catch (IOException e) { +// e.printStackTrace(); +// } finally { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("createSummaryFile completed"); +// } +// } +// +// private static void writeReport2File(String method, String xKalturaSession, double codeTimePercentage) { +// try (FileWriter fw = new FileWriter(getProperty(LOGS_DIR) + +// getProperty(PERFORMANCE_REPORT_FILE), true); +// BufferedWriter bw = new BufferedWriter(fw); +// PrintWriter out = new PrintWriter(bw)) { +// // we want to see only data where code time is less than 100% +// if (timeOfCB > 0 || timeOfDB > 0 || timeOfES > 0 || timeOfRabbit > 0) { +// out.println(method); +// out.println(xKalturaSession); +// out.println("Execution Time: " + String.format("%.3f", totalTime)); +// out.println("Code: " + String.format("%.2f", codeTimePercentage) + "% (" + String.format("%.3f", timeOfCode) + ")"); +// writeIfValueMoreThanZero(out, "Couchbase: ", timeOfCB, totalTime, countOfCB); +// writeIfValueMoreThanZero(out, "DB: ", timeOfDB, totalTime, countOfDB); +// writeIfValueMoreThanZero(out, "Elastic: ", timeOfES, totalTime, countOfES); +// writeIfValueMoreThanZero(out, "Rabbit: ", timeOfRabbit, totalTime, countOfRabbit); +// out.println(); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// +// private static void writeIfValueMoreThanZero(PrintWriter out, String title, double timeOfEvent, double totalTime, int countOfEvent) { +// if (timeOfEvent > 0) { +// out.println(title + " " + String.format("%.2f", timeOfEvent / totalTime * 100) + "% (" + String.format("%.3f", timeOfEvent) + ") [" + countOfEvent + " queries]"); +// } +// } +// +// private static void copyRemoteFile2LocalMachine(String remoteFileName) throws IOException { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine() with [" + remoteFileName + "]: started"); +// +// // add local target folder in case it does not exist +// File localTargetFolderPath = new File(getProperty(LOGS_DIR)); +// if (!localTargetFolderPath.exists()) { +// boolean isDirCreated = localTargetFolderPath.mkdir(); +// Logger.getLogger(PerformanceAppLogUtils.class).debug("Directory [" + +// getProperty(LOGS_DIR) + "] was created == [" + isDirCreated + "]"); +// } +// +// String remoteFilePathUrl = remoteSourceUrlFileDir + remoteFileName; +// String localTargetFilePath = getProperty(LOGS_DIR) + "copied-" + remoteFileName; +// appLogLocalFileNames.add(localTargetFilePath); +// +// // remove local target file in case it exists and create it empty +// File targetFile = new File(localTargetFilePath); +// if (targetFile.exists()) { +// targetFile.delete(); // } - if (isUrlExists(remoteFilePathUrl)) { - FileUtils.copyURLToFile(new URL(remoteFilePathUrl), targetFile); - } - //destination.close(); - Logger.getLogger(PerformanceAppLogUtils.class).debug("File [" + remoteFilePathUrl + "] was copied into [" + localTargetFilePath + "]"); - Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine(): completed"); - } - - public static List getRemoteAppLogFileNames() throws IOException { - Logger.getLogger(PerformanceAppLogUtils.class).debug("getRemoteAppLogFileNames(): started"); - List fileNames = new ArrayList<>(); - String sourceFileName = getProperty(PHOENIX_SERVER_LOG_FILE_NAME_PREFIX) + getProperty(API_VERSION) + - getProperty(PHOENIX_SERVER_LOG_FILE_EXTENSION); - String remoteFilePathUrl = remoteSourceUrlFileDir + sourceFileName; - Logger.getLogger(PerformanceAppLogUtils.class).debug("remoteFilePathUrl: " + remoteFilePathUrl); - +// targetFile.createNewFile(); +// //FileObject destination = VFS.getManager().resolveFile(targetFile.getAbsolutePath()); +// // //domain, username, password -// DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); +// //DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); +// +// //FileObject fileObject = VFS.getManager().resolveFile(remoteFilePath, options); +// +// // copy file from remote to local folder +//// if (fileObject.exists()) { +//// destination.copyFrom(fileObject, Selectors.SELECT_SELF); +//// } +// if (isUrlExists(remoteFilePathUrl)) { +// FileUtils.copyURLToFile(new URL(remoteFilePathUrl), targetFile); +// } +// //destination.close(); +// Logger.getLogger(PerformanceAppLogUtils.class).debug("File [" + remoteFilePathUrl + "] was copied into [" + localTargetFilePath + "]"); +// Logger.getLogger(PerformanceAppLogUtils.class).debug("copyRemoteFile2LocalMachine(): completed"); +// } +// +// public static List getRemoteAppLogFileNames() throws IOException { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("getRemoteAppLogFileNames(): started"); +// List fileNames = new ArrayList<>(); +// String sourceFileName = getProperty(PHOENIX_SERVER_LOG_FILE_NAME_PREFIX) + getProperty(API_VERSION) + +// getProperty(PHOENIX_SERVER_LOG_FILE_EXTENSION); +// String remoteFilePathUrl = remoteSourceUrlFileDir + sourceFileName; +// Logger.getLogger(PerformanceAppLogUtils.class).debug("remoteFilePathUrl: " + remoteFilePathUrl); // -// FileObject fileObject = VFS.getManager().resolveFile(remoteFilePathUrl, options); - -// if (fileObject.exists()) { +//// //domain, username, password +//// DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth); +//// +//// FileObject fileObject = VFS.getManager().resolveFile(remoteFilePathUrl, options); +// +//// if (fileObject.exists()) { +//// fileNames.add(sourceFileName); +//// } else { +//// Logger.getLogger(PerformanceAppLogUtils.class).error("getRemoteAppLogFileNames(): file not found!"); +//// } +// if (isUrlExists(remoteFilePathUrl)) { // fileNames.add(sourceFileName); // } else { // Logger.getLogger(PerformanceAppLogUtils.class).error("getRemoteAppLogFileNames(): file not found!"); // } - if (isUrlExists(remoteFilePathUrl)) { - fileNames.add(sourceFileName); - } else { - Logger.getLogger(PerformanceAppLogUtils.class).error("getRemoteAppLogFileNames(): file not found!"); - } - int idx = 1; - while (isUrlExists(remoteFilePathUrl)) { - // all files related needed logs have the same name as value from sourceFileName and additionally they have - // suffixes that looks like ".1", ".2", etc... - String name = sourceFileName + "." + idx; - //fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); - idx++; - remoteFilePathUrl = remoteSourceUrlFileDir + name; - // sometimes file can be removed and it means we should one more time check names - if (isUrlExists(remoteFilePathUrl)) { - fileNames.add(name); - } else { - // to handle case when next file has difference in suffixes bigger than 1 - name = sourceFileName + "." + idx; - idx++; - remoteFilePathUrl = remoteSourceUrlFileDir + name; - if (isUrlExists(remoteFilePathUrl)) { - fileNames.add(name); - } - } - } - Logger.getLogger(PerformanceAppLogUtils.class).debug("getRemoteAppLogFileNames(): completed"); - return fileNames; - } - - /*If the connection to a URL (made with HttpURLConnection) returns with HTTP status code 200 then the file exists. - Since we only care it exists or not there is no need to request the entire document. - We can just request the header using the HTTP HEAD request method to check if it exists.*/ - private static boolean isUrlExists(String fileUrl) { - try { - HttpURLConnection.setFollowRedirects(false); - // note : you may also need HttpURLConnection.setInstanceFollowRedirects(false) - HttpURLConnection con = (HttpURLConnection) new URL(fileUrl).openConnection(); - con.setRequestMethod("HEAD"); - return (con.getResponseCode() == HttpURLConnection.HTTP_OK); - } - catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * We have file with name getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + getProperty(REGRESSION_LOGS_LOCAL_FILE) - * that saves information about all executed methods and their kaltura sessions. - * That file will be filled with data only in case test.properties has should_regression_logs_be_saved=true - * - * @return map contains all methods and kaltura sessions related to regression - */ - private static Map> loadMethodsAndSessionsFromTestFile() { - Logger.getLogger(PerformanceAppLogUtils.class).debug("loadMethodsAndSessionsFromTestFile(): started"); - Map> result = new HashMap<>(); - String[] values; - try { - InputStream is = new FileInputStream(getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + - getProperty(REGRESSION_LOGS_LOCAL_FILE)); - BufferedReader buf = new BufferedReader(new InputStreamReader(is)); - - String line; - List sessions; - while ((line = buf.readLine()) != null) { - values = line.split(" "); - sessions = result.get(values[0]); - if (sessions == null) { - sessions = new ArrayList<>(); - } - sessions.add(values[1]); - result.put(values[0], sessions); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - Logger.getLogger(PerformanceAppLogUtils.class).debug("loadMethodsAndSessionsFromTestFile(): completed"); - return result; - } - } - - private static void calcTimeExecution(String appFileName, String kalturaSession) { - String path2File = getProperty(PHOENIX_SERVER_LOGS_LOCAL_FOLDER_PATH) + "copied-" + appFileName; - - String[] nonRelated2CodeStringsArray = new String[nonRelated2CodeStringsList.size()]; - String executionTimeString; - try (BufferedReader br = new BufferedReader(new FileReader(path2File))) { - for (String line; (line = br.readLine()) != null; ) { - if (line.contains(kalturaSession)) { - isKalturaSessionFoundInAppLogFile = true; - // this is a usual position of time in the whole string - executionTimeString = line.split("\"")[3]; - // "e": "ws" should be ignored as it partially described in other events - if (stringContainsItemFromArray(line, nonRelated2CodeStringsList.toArray(nonRelated2CodeStringsArray))) { - timeOfCode = timeOfCode - Double.valueOf(executionTimeString); - } else { - if (line.contains("\"e\":\"end_api\"")) { - totalTime = Double.valueOf(executionTimeString); - timeOfCode = timeOfCode + totalTime; - } - } - if (line.contains(COUCHBASE_LOG_DATA)) { - timeOfCB = timeOfCB + Double.valueOf(executionTimeString); - countOfCB++; - } - if (line.contains(DB_LOG_DATA)) { - timeOfDB = timeOfDB + Double.valueOf(executionTimeString); - countOfDB++; - } - if (line.contains(ELASTIC_SEARCH_LOG_DATA)) { - timeOfES = timeOfES + Double.valueOf(executionTimeString); - countOfES++; - } - if (line.contains(RABBIT_LOG_DATA)) { - timeOfRabbit = timeOfRabbit + Double.valueOf(executionTimeString); - countOfRabbit++; - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static boolean stringContainsItemFromArray(String inputStr, String[] items) { - return Arrays.stream(items).parallel().anyMatch(inputStr::contains); - } - - /** - * method removes from local computer copied on it from remote machine app log files - */ - public static void removeCopiedAppLogFiles() { - for (String file : appLogLocalFileNames) { - deleteFile(file); - } - } -} \ No newline at end of file +// int idx = 1; +// while (isUrlExists(remoteFilePathUrl)) { +// // all files related needed logs have the same name as value from sourceFileName and additionally they have +// // suffixes that looks like ".1", ".2", etc... +// String name = sourceFileName + "." + idx; +// //fileObject = VFS.getManager().resolveFile(remoteSourceFileDir + name, options); +// idx++; +// remoteFilePathUrl = remoteSourceUrlFileDir + name; +// // sometimes file can be removed and it means we should one more time check names +// if (isUrlExists(remoteFilePathUrl)) { +// fileNames.add(name); +// } else { +// // to handle case when next file has difference in suffixes bigger than 1 +// name = sourceFileName + "." + idx; +// idx++; +// remoteFilePathUrl = remoteSourceUrlFileDir + name; +// if (isUrlExists(remoteFilePathUrl)) { +// fileNames.add(name); +// } +// } +// } +// Logger.getLogger(PerformanceAppLogUtils.class).debug("getRemoteAppLogFileNames(): completed"); +// return fileNames; +// } +// +// /*If the connection to a URL (made with HttpURLConnection) returns with HTTP status code 200 then the file exists. +// Since we only care it exists or not there is no need to request the entire document. +// We can just request the header using the HTTP HEAD request method to check if it exists.*/ +// private static boolean isUrlExists(String fileUrl) { +// try { +// HttpURLConnection.setFollowRedirects(false); +// // note : you may also need HttpURLConnection.setInstanceFollowRedirects(false) +// HttpURLConnection con = (HttpURLConnection) new URL(fileUrl).openConnection(); +// con.setRequestMethod("HEAD"); +// return (con.getResponseCode() == HttpURLConnection.HTTP_OK); +// } +// catch (Exception e) { +// e.printStackTrace(); +// return false; +// } +// } +// +// /** +// * We have file with name getProperty(LOGS_DIR) + getProperty(REGRESSION_LOGS_FILE) +// * that saves information about all executed methods and their kaltura sessions. +// * That file will be filled with data only in case test.properties has should_regression_logs_be_saved=true +// * +// * @return map contains all methods and kaltura sessions related to regression +// */ +// public static Map> loadMethodsAndSessionsFromTestFile() { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("loadMethodsAndSessionsFromTestFile(): started"); +// Map> result = new HashMap<>(); +// String[] values; +// try { +// InputStream is = new FileInputStream(getProperty(LOGS_DIR) + +// getProperty(REGRESSION_LOGS_FILE)); +// BufferedReader buf = new BufferedReader(new InputStreamReader(is)); +// +// String line; +// List sessions; +// while ((line = buf.readLine()) != null) { +// values = line.split(":"); +// sessions = result.get(values[0]); +// if (sessions == null) { +// sessions = new ArrayList<>(); +// } +// sessions.add(values[1]); +// result.put(values[0], sessions); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } finally { +// Logger.getLogger(PerformanceAppLogUtils.class).debug("loadMethodsAndSessionsFromTestFile(): completed"); +// return result; +// } +// } +// +// private static void calcTimeExecution(String appFileName, String kalturaSession) { +// String path2File = getProperty(LOGS_DIR) + "copied-" + appFileName; +// +// String[] nonRelated2CodeStringsArray = new String[nonRelated2CodeStringsList.size()]; +// String executionTimeString; +// try (BufferedReader br = new BufferedReader(new FileReader(path2File))) { +// for (String line; (line = br.readLine()) != null; ) { +// if (line.contains(kalturaSession)) { +// isKalturaSessionFoundInAppLogFile = true; +// // this is a usual position of time in the whole string +// executionTimeString = line.split("\"")[3]; +// // "e": "ws" should be ignored as it partially described in other events +// if (stringContainsItemFromArray(line, nonRelated2CodeStringsList.toArray(nonRelated2CodeStringsArray))) { +// timeOfCode = timeOfCode - Double.valueOf(executionTimeString); +// } else { +// if (line.contains("\"e\":\"end_api\"")) { +// totalTime = Double.valueOf(executionTimeString); +// timeOfCode = timeOfCode + totalTime; +// } +// } +// if (line.contains(COUCHBASE_LOG_DATA)) { +// timeOfCB = timeOfCB + Double.valueOf(executionTimeString); +// countOfCB++; +// } +// if (line.contains(DB_LOG_DATA)) { +// timeOfDB = timeOfDB + Double.valueOf(executionTimeString); +// countOfDB++; +// } +// if (line.contains(ELASTIC_SEARCH_LOG_DATA)) { +// timeOfES = timeOfES + Double.valueOf(executionTimeString); +// countOfES++; +// } +// if (line.contains(RABBIT_LOG_DATA)) { +// timeOfRabbit = timeOfRabbit + Double.valueOf(executionTimeString); +// countOfRabbit++; +// } +// } +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// +// private static boolean stringContainsItemFromArray(String inputStr, String[] items) { +// return Arrays.stream(items).parallel().anyMatch(inputStr::contains); +// } +// +// /** +// * method removes from local computer copied on it from remote machine app log files +// */ +// public static void removeCopiedAppLogFiles() { +// for (String file : appLogLocalFileNames) { +// deleteFile(file); +// } +// } +//} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java new file mode 100644 index 000000000..91f0dc01f --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -0,0 +1,335 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.ILogger; +import com.kaltura.client.Logger; +import com.kaltura.client.test.tests.Sandbox; +import lombok.AccessLevel; +import lombok.Getter; +import org.apache.commons.io.FileUtils; +import org.json.JSONObject; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static com.kaltura.client.test.Properties.*; + +public class PerformanceUtils extends BaseUtils { + + private static final ILogger logger = Logger.getLogger(Sandbox.class); + + private static final int maxAllowedPercentage = Integer.parseInt(getProperty(MAX_CODE_PERCENTAGE)); + private static final float maxAllowedTime = Float.parseFloat(getProperty(MAX_EXECUTION_TIME_IN_SEC)); + + private static final String logsUrl = getProperty(LOGS_BASE_URL) + getProperty(API_VERSION) + "/"; + private static final String filesCssQuery = "a:contains(tvp-api-rest-monitor-" + getProperty(API_VERSION) + ")"; + private static final String reportFilePath = getProperty(LOGS_DIR) + getProperty(PERFORMANCE_REPORT_FILE); + + + public static void generatePerformanceReport() { + logger.debug("start generate performance report..."); + + // get aggregate regression data sessions + List regressionSessions = getRegressionData().values() + .stream() + .flatMap(List::stream) + .collect(Collectors.toList()); + + // get sessions + List sessions = getSessions(regressionSessions); + + // write performance report + writeReport(sessions); + + logger.debug("finish generate performance report!"); + } + + private static Map> getRegressionData() { + File data = new File(getProperty(LOGS_DIR) + getProperty(REGRESSION_LOGS_FILE)); + List lines = null; + try { + lines = Files.readAllLines(data.toPath()); + } catch (IOException e) { + e.printStackTrace(); + } + + return lines + .stream() + .collect(Collectors.groupingBy( + s -> s.split(":")[0], + Collectors.mapping(s -> s.split(":")[1], + Collectors.toList()))); + } + + private static List getLogFilesUrls() { + Document doc = null; + try { + doc = Jsoup.connect(logsUrl).get(); + } catch (IOException e) { + e.printStackTrace(); + } + + List urls = new ArrayList<>(); + + doc.select(filesCssQuery).forEach(element -> { + try { + URL url = new URL(logsUrl + element.text()); + urls.add(url); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + }); + + return urls; + } + + private static List getLinesFromUrls(List urls) { + List> data = new ArrayList<>(); + + urls.forEach(url -> { + URLConnection conn = null; + try { + conn = url.openConnection(); + } catch (IOException e) { + e.printStackTrace(); + } + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) { + List lines = reader.lines().collect(Collectors.toList()); + data.add(lines); + } catch (IOException e) { + e.printStackTrace(); + } + }); + + return data + .stream() + .flatMap(Collection::stream) + .collect(Collectors.toList()); + } + + private static List getSessions(List sessionStrings) { + List lines = getLinesFromUrls(getLogFilesUrls()); + + List sessionList = new ArrayList<>(); + sessionStrings.forEach(s -> sessionList.add(getSession(lines, s))); + return sessionList; + } + + private static Session getSession(List lines, String session) { + List sessionData = new ArrayList<>(); + + lines.forEach(line -> { + if (line.contains(session)) { + JSONObject jo = new JSONObject(line.substring(line.indexOf("{"))); + sessionData.add(jo); + } + }); + + return new Session(sessionData); + } + + private static List getSlowSessions(List sessions) { + return sessions + .stream() + .filter(Session::isSlow) + .collect(Collectors.toList()); + } + + private static void writeReport(List sessions) { + List slowSessions = getSlowSessions(sessions); + + Map slowActionsCount = slowSessions.stream().collect(Collectors.groupingBy( + Session::getAction, + Collectors.counting() + )); + + Map actionsCount = sessions.stream().collect(Collectors.groupingBy( + Session::getAction, + Collectors.counting() + )); + + // write data to file + File file = new File(reportFilePath); + + if (file.exists()) { + file.delete(); + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + String reportSummary = "Performance Report - " + getCurrentDateInFormat("dd/MM/yyyy HH:mm") + " (" + getProperty(API_VERSION) + ")\n" + + "Max percentage: " + getProperty(MAX_CODE_PERCENTAGE) + "%\n" + + "Max execution time: " + getProperty(MAX_EXECUTION_TIME_IN_SEC) + " sec\n\n" + + "Slow Actions Summary:\n\n"; + + try { + FileUtils.writeStringToFile(file, reportSummary, Charset.defaultCharset(), true); + + slowActionsCount.forEach((s, aLong) -> { + long actionSlowCount = aLong; + long actionTotalCount = actionsCount.get(s); + double slowPercentage = (double) actionSlowCount / actionTotalCount * 100; + + try { + FileUtils.writeStringToFile(file, s + " - was slow " + String.format("%.0f", slowPercentage) + + "% of executions (" + actionSlowCount + "/" + actionTotalCount + ")\n", + Charset.defaultCharset(), true); + } catch (IOException e) { + e.printStackTrace(); + } + }); + + FileUtils.writeStringToFile(file, "\nSlow Actions Details: \n\n", Charset.defaultCharset(), true); + } catch (IOException e) { + e.printStackTrace(); + } + + slowSessions.forEach(session -> { + try { + FileUtils.writeStringToFile(file, session.toString() + "\n", Charset.defaultCharset(), true); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + + @Getter + private static class Session { + @Getter(AccessLevel.NONE) private final String numFormat = "%.3f"; + @Getter(AccessLevel.NONE) private final String newLine = "\n"; + + @Getter(AccessLevel.NONE) private final String CB_EVENT = "cb"; + @Getter(AccessLevel.NONE) private final String DB_EVENT = "db"; + @Getter(AccessLevel.NONE) private final String ES_EVENT = "elastic"; + @Getter(AccessLevel.NONE) private final String RABBIT_EVENT = "rabbit"; + @Getter(AccessLevel.NONE) private final String WS_EVENT = "ws"; + + @Getter(AccessLevel.NONE) private final String EVENT_KEY = "e"; + @Getter(AccessLevel.NONE) private final String EXECUTION_TIME_KEY = "x"; + + private String action; + private String session; + + private boolean isSlow; + + private long startTime; + private long endTime; + + private double totalTimeExcludeCode; + private double totalTime; + private double codeTime; + private double cbTime; + private double dbTime; + private double esTime; + private double rabbitTime; + private double wsTime; + private double codePercentage; + + private int cbCount; + private int dbCount; + private int esCount; + private int wsCount; + private int rabbitCount; + + Session(List sessionData) { + sessionData.forEach(line -> { + if (!line.getString(EVENT_KEY).equals("start_api") && !line.getString(EVENT_KEY).equals("end_api")) { + totalTimeExcludeCode = totalTimeExcludeCode + line.getFloat(EXECUTION_TIME_KEY); + } + + if (line.getString(EVENT_KEY).equals("start_api")) { + startTime = line.getLong("m"); + } + + if (line.getString(EVENT_KEY).equals("end_api")) { + endTime = line.getLong("m"); + } + + if (line.getString(EVENT_KEY).equals(CB_EVENT)) { + cbTime = cbTime + line.getDouble(EXECUTION_TIME_KEY); + cbCount++; + } + + if (line.getString(EVENT_KEY).equals(DB_EVENT)) { + dbTime = dbTime + line.getDouble(EXECUTION_TIME_KEY); + dbCount++; + } + + if (line.getString(EVENT_KEY).equals(ES_EVENT)) { + esTime = esTime + line.getDouble(EXECUTION_TIME_KEY); + esCount++; + } + + if (line.getString(EVENT_KEY).equals(RABBIT_EVENT)) { + rabbitTime = rabbitTime + line.getDouble(EXECUTION_TIME_KEY); + rabbitCount++; + } + + if (line.getString(EVENT_KEY).equals(WS_EVENT)) { + wsTime = wsTime + line.getDouble(EXECUTION_TIME_KEY); + wsCount++; + } + }); + + action = sessionData.get(0).getString("a"); + session = sessionData.get(0).getString("u"); + + totalTime = (double) (endTime - startTime) / 1000000; + codeTime = totalTime - totalTimeExcludeCode; + codePercentage = codeTime / totalTime * 100; + + + if ((totalTime > maxAllowedTime) && + (codePercentage > maxAllowedPercentage) && + (cbTime > 0 || dbTime > 0 || esTime > 0 || rabbitTime > 0 || wsTime > 0)) { + isSlow = true; + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder() + .append("action: ").append(this.getAction()).append(newLine) + .append("session: ").append(this.getSession()).append(newLine) + .append("total time: ").append(String.format(numFormat, this.getTotalTime())).append(newLine) + .append("code: ").append(String.format(numFormat, this.getCodePercentage())).append("% (" + String.format(numFormat, this.getCodeTime()) + ")").append(newLine); + + writeIfEventTimeGreaterThanZero(sb, this.getCbTime(), this.getCbCount(), this.CB_EVENT); + writeIfEventTimeGreaterThanZero(sb, this.getDbTime(), this.getDbCount(), this.DB_EVENT); + writeIfEventTimeGreaterThanZero(sb, this.getEsTime(), this.getEsCount(), this.ES_EVENT); + writeIfEventTimeGreaterThanZero(sb, this.getRabbitTime(), this.getRabbitCount(), this.RABBIT_EVENT); + writeIfEventTimeGreaterThanZero(sb, this.getWsTime(), this.getWsCount(), this.WS_EVENT); + + return sb.toString(); + } + + private void writeIfEventTimeGreaterThanZero(StringBuilder sb, double eventTime, int eventCount, String eventName) { + if (eventTime > 0) { + sb + .append(eventName + ": ") + .append(String.format(numFormat, eventTime / this.getTotalTime() * 100)) + .append("% (" + String.format(numFormat, eventTime) + ")") + .append(" [" + eventCount + " queries]") + .append("\n"); + } + } + } +} From ee6043a7de6826af168ae3da49366b991b95555c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 28 Aug 2018 16:08:52 +0300 Subject: [PATCH 488/605] change testng.xml for test --- src/test/resources/testng.xml | 47 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 751e9b7d2..1bf9981cc 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,16 +2,21 @@ - - - - - - - + + + + + + + + + + + + - - + + @@ -19,16 +24,16 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 6d2dd199d5849dc4f98db6363d50d51ac678265d Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 28 Aug 2018 16:14:21 +0300 Subject: [PATCH 489/605] no message --- .../java/com/kaltura/client/test/utils/PerformanceUtils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index 91f0dc01f..eea70def9 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -2,7 +2,6 @@ import com.kaltura.client.ILogger; import com.kaltura.client.Logger; -import com.kaltura.client.test.tests.Sandbox; import lombok.AccessLevel; import lombok.Getter; import org.apache.commons.io.FileUtils; @@ -30,7 +29,7 @@ public class PerformanceUtils extends BaseUtils { - private static final ILogger logger = Logger.getLogger(Sandbox.class); + private static final ILogger logger = Logger.getLogger(PerformanceUtils.class); private static final int maxAllowedPercentage = Integer.parseInt(getProperty(MAX_CODE_PERCENTAGE)); private static final float maxAllowedTime = Float.parseFloat(getProperty(MAX_EXECUTION_TIME_IN_SEC)); From e6e256fbd8292a5f9d70c16b281e840217bb97ac Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 28 Aug 2018 16:40:23 +0300 Subject: [PATCH 490/605] no message --- src/test/resources/testng.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 1bf9981cc..ad5733313 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -14,14 +14,14 @@ - - - - + + + + - - - + + + From 5f4bbb3cf6fc35f94407ccd5d8498798c0a6a742 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 28 Aug 2018 16:53:47 +0300 Subject: [PATCH 491/605] no message --- src/test/resources/testng.xml | 57 ++++++++++++++++------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index ad5733313..751e9b7d2 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,38 +2,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + From 25aeb99c088d0001399fe0e772c40be6322f539c Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 28 Aug 2018 19:05:36 +0300 Subject: [PATCH 492/605] Added more tests for ingest VOD in opc --- .../five_zero_two/IngestVodTests.java | 362 ++++++++++++++---- .../utils/ingestUtils/IngestVodOPCUtils.java | 51 ++- .../utils/ingestUtils/IngestVodUtils.java | 8 +- 3 files changed, 335 insertions(+), 86 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index 3405a5b98..eb02c50c3 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -1,17 +1,27 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_two; +import com.kaltura.client.Logger; +import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import io.restassured.response.Response; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; + +import static com.kaltura.client.enums.AssetType.MEDIA; +import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.*; @@ -34,73 +44,69 @@ public class IngestVodTests extends BaseTest { private int episodeType; private int seriesType; - private String ingestXml; + private String localCoguid = ""; + private String ingestInsertXml; + private String ingestUpdateXml; + private String ingestDeleteXml; + private static final String suffix4Coguid = "123"; + private static String coguid4NegativeTests = ""; + + private boolean wasNOTSetupExecuted = true; @BeforeClass public void setUp() { String prefix = "Movie_"; - String localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); - name = prefix + "Name_" + localCoguid; + localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); + name = prefix + "Name_" + localCoguid; description = prefix + "Description_" + localCoguid; - IngestVodUtils.VODFile file1 = new IngestVodUtils.VODFile() - .assetDuration("1000") - .quality("HIGH") - .handling_type("CLIP") - .cdn_name("Default CDN") - .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .billing_type("Tvinci") - .product_code("productExampleCode") - .type("Test130301") - .coguid("Test130301_1" + localCoguid) - .ppvModule("Shai_Regression_PPV"); - IngestVodUtils.VODFile file2 = new IngestVodUtils.VODFile() - .assetDuration("1000") - .quality("HIGH") - .handling_type("CLIP") - .cdn_name("Default CDN") - .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .billing_type("Tvinci") - .product_code("productExampleCode") - .type("new file type1") - .coguid("new file type1_1" + localCoguid) - .ppvModule("Subscription_only_PPV"); - assetFiles.add(file1); - assetFiles.add(file2); + movieAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_1" + localCoguid, + "new file type1_1" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); VodData vodData; generateDefaultValues4Insert(MOVIE); - vodData = getVodData(MOVIE); + vodData = getVodData(MOVIE, movieAssetFiles); movie = insertVod(vodData, true); movieType = movie.getType(); + // generate ingest XMLs for negative cases + coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; + ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); + ingestDeleteXml = DELETE_VOD_XML.replaceAll("180822092522774", movie.getExternalId()); + ingestUpdateXml = UPDATE_VOD_XML.replaceAll("180828080027358", movie.getExternalId()); + + episodeAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_2" + localCoguid, + "new file type1_2" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); generateDefaultValues4Insert(EPISODE); - vodData = getVodData(EPISODE); + vodData = getVodData(EPISODE, episodeAssetFiles); episode = insertVod(vodData, true); episodeType = episode.getType(); + seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_3" + localCoguid, + "new file type1_3" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); generateDefaultValues4Insert(SERIES); - vodData = getVodData(SERIES); + vodData = getVodData(SERIES, seriesAssetFiles); series = insertVod(vodData, true); seriesType = series.getType(); - generateDefaultValues4Insert(MOVIE); - vodData = getVodData(MOVIE); - ingestXml = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); + wasNOTSetupExecuted = false; } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, priority =-1, description = "ingest VOD with filled base meta fields") + @Test(groups = {"ingest VOD for OPC", "opc"}, priority =-2, description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { // that should be called in case running from testng.xml as a group - // priority set to -1 to guarantee that setUp will be executed before all other tests as part of that test case. - setUp(); + // priority set to -2 to guarantee that setUp will be executed before all other tests as part of that test case. + if (wasNOTSetupExecuted) { + setUp(); + } generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE); + List movieAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, + "new file type1_11" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); + VodData vodData = getVodData(MOVIE, movieAssetFiles); MediaAsset movie = insertVod(vodData, true); + String ingestRequest = ingestXmlRequest; assertThat(movie.getName()).isEqualTo(name); assertThat(movie.getDescription()).isEqualTo(description); @@ -116,13 +122,20 @@ public void insertVodMediaBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + checkFiles(movieAssetFiles, movie.getId().toString()); + + assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); + assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); } @Severity(SeverityLevel.CRITICAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { generateDefaultValues4Insert(EPISODE); - VodData vodData = getVodData(EPISODE); + List episodeAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_21" + localCoguid, + "new file type1_21" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); + VodData vodData = getVodData(EPISODE, episodeAssetFiles); MediaAsset episode = insertVod(vodData, true); assertThat(episode.getName()).isEqualTo(name); @@ -139,13 +152,17 @@ public void insertVodEpisodeBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + checkFiles(episodeAssetFiles, episode.getId().toString()); } @Severity(SeverityLevel.CRITICAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { generateDefaultValues4Insert(SERIES); - VodData vodData = getVodData(SERIES); + List seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_31" + localCoguid, + "new file type1_31" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); + VodData vodData = getVodData(SERIES, seriesAssetFiles); MediaAsset series = insertVod(vodData, true); assertThat(series.getName()).isEqualTo(name); @@ -162,17 +179,21 @@ public void insertVodSeriesBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + checkFiles(seriesAssetFiles, series.getId().toString()); } + @Issue("BEO-5516") @Severity(SeverityLevel.CRITICAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { String coguid = getCoguidOfActiveMediaAsset(movieType); - + // TODO: asked Shir if I can update file and if yes what fields generateDefaultValues4Update(true, MOVIE); - IngestVodUtils.VodData vodData = getVodData(MOVIE); + IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles); MediaAsset asset = updateVod(coguid, vodData); + String updateRequest = ingestXmlRequest; assertThat(asset.getName()).isEqualTo(name); assertThat(asset.getDescription()).isEqualTo(description); @@ -188,6 +209,27 @@ public void updateVodMediaBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + // check update with erase="true" + updateRequest = updateRequest + .replaceAll("erase=\"false\"", "erase=\"true\"") + // to remove description from XML + .replaceAll("", "") + .replaceAll("" + description + "", "") + .replaceAll("", "") + // to remove boolean meta from XML + .replaceAll("", "") + .replaceAll("" + doubleValue + "", "") + .replaceAll("", ""); + Response resp = getResponseBodyFromIngestVod(updateRequest); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); + + AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(movie.getId()), AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()); + com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); + assertThat(assetGetResponse.results.getId()).isEqualTo(movie.getId()); + assertThat(assetGetResponse.results.getDescription()).isEqualTo(null); + assertThat(assetGetResponse.results.getMetas().get(mediaNumberFieldName)).isEqualTo(null); } @@ -195,7 +237,7 @@ public void updateVodMediaBaseFields() { @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { generateDefaultValues4Update(false, EPISODE); - IngestVodUtils.VodData vodData = getVodData(EPISODE); + IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); String coguid = getCoguidOfActiveMediaAsset(episodeType); MediaAsset asset = updateVod(coguid, vodData); @@ -220,7 +262,7 @@ public void updateVodEpisodeBaseFields() { @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { generateDefaultValues4Update(true, SERIES); - IngestVodUtils.VodData vodData = getVodData(SERIES); + IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); String coguid = getCoguidOfActiveMediaAsset(seriesType); MediaAsset asset = updateVod(coguid, vodData); @@ -265,26 +307,26 @@ public void deleteSeries() { @Severity(SeverityLevel.NORMAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert without coguid") public void tryInsertWithEmptyCoguid() { - String invalidXml = INGEST_VOD_XML.replaceAll("co_guid=\"180822092522774\"", "co_guid=\"\""); + String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - invalidXml = INGEST_VOD_XML.replaceAll("co_guid=\"180822092522774\"", ""); + invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", ""); resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete without coguid") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete without coguid", priority =-1 ) public void tryDeleteWithEmptyCoguid() { - String invalidXml = DELETE_VOD_XML.replaceAll("co_guid=\"180822092522774\"", "co_guid=\"\""); + String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - invalidXml = DELETE_VOD_XML.replaceAll("co_guid=\"180822092522774\"", ""); + invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", ""); resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); @@ -293,34 +335,43 @@ public void tryDeleteWithEmptyCoguid() { @Severity(SeverityLevel.NORMAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete with non-existed coguid") public void tryDeleteWithNonexistedCoguid() { - String invalidXml = DELETE_VOD_XML.replaceAll("co_guid=\"180822092522774\"", "co_guid=\"123456\""); + int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); + int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); + int positionEndOfCoguid = ingestDeleteXml.indexOf("\"", positionBeginOfCoguid + 1); + String coguid = ingestDeleteXml.substring(positionBeginOfCoguid + 1, positionEndOfCoguid); + String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + coguid + "\"", "co_guid=\"123456\""); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); } + @Issue("BEO-5516") @Severity(SeverityLevel.NORMAL) @Test(groups = {"ingest VOD for OPC", "opc", "OPC"}, description = "try update with empty erase") public void tryUpdateWithEmptyErase() { - // TODO: check and if it work then add logic related null erase and positive test related update - String coguid = getCoguidOfActiveMediaAsset(movieType); - String invalidXml = UPDATE_VOD_XML - .replaceAll("erase=\"false\"", "erase=\"\"") - .replaceAll("co_guid=\"180822092522774\"", "co_guid=\"" + coguid + "\""); + String invalidXml = ingestUpdateXml + .replaceAll("erase=\"false\"", "erase=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("is missing"); + + // NO REASON TO CHECK AS DEFAULT VALUE IS FALSE and it allows to ingest + /*String invalidXml = ingestUpdateXml + .replaceAll("erase=\"false\"", ""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("is missing");*/ } @Severity(SeverityLevel.MINOR) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty entry_id") public void tryInsertWithEmptyEntryId() { - String invalidXml = INGEST_VOD_XML.replaceAll("entry_id=\"entry_180822092522774\"", "entry_id=\"\""); + String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); - invalidXml = INGEST_VOD_XML.replaceAll("entry_id=\"entry_180822092522774\"", ""); + invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", ""); resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); @@ -329,7 +380,7 @@ public void tryInsertWithEmptyEntryId() { @Severity(SeverityLevel.MINOR) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert inactive item") public void tryInsertInactiveItem() { - String invalidXml = INGEST_VOD_XML.replaceAll("is_active=\"true\"", "is_active=\"false\""); + String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); Response resp = getResponseBodyFromIngestVod(invalidXml); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); @@ -345,32 +396,27 @@ public void tryInsertInactiveItem() { @Severity(SeverityLevel.MINOR) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty isActive parameter") public void tryInsertEmptyIsActive() { - String invalidXml = ingestXml;//.replaceAll("is_active=\"true\"", "is_active=\"\""); + String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); - - invalidXml = ingestXml.replaceAll("is_active=\"true\"", ""); - resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); } @Severity(SeverityLevel.MINOR) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty name") + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty name", priority =-1) public void tryInsertWithEmptyName() { - String invalidXml = INGEST_VOD_XML.replaceAll(">Movie_Name_1808220925223281<", "><"); + String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); - invalidXml = INGEST_VOD_XML + invalidXml = ingestInsertXml .replaceAll("", "") - .replaceAll("Movie_Name_1808220925223281", "") + .replaceAll("" + movie.getName() + "", "") .replaceAll("", ""); resp = getResponseBodyFromIngestVod(invalidXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.Basic.Name cannot be empty"); } @Severity(SeverityLevel.NORMAL) @@ -380,20 +426,162 @@ public void tryInsertWithInvalidCredentials() { String status = "ERROR"; // invalid user name - String invalidXml = INGEST_VOD_XML.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); + String invalidXml = ingestInsertXml.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); Response resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); // invalid password - invalidXml = INGEST_VOD_XML.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); + invalidXml = ingestInsertXml.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); resp = getResponseBodyFromIngestVod(invalidXml); assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); } + @Issue("BEO-5520") + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with invalid meta or tag field") + public void tryInsertWithInvalidMetaOrTagField() { + String suffix = "UPDATE654987321"; + String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); + + String updatedField = mediaNumberFieldName + suffix; + String invalidXml = ingestXml.replaceAll(mediaNumberFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + + updatedField = mediaDateFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaDateFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + + updatedField = mediaBooleanFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaBooleanFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + + updatedField = mediaTagFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaTagFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "tag"); + + updatedField = mediaTextFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaTextFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + } + + @Issue("BEO-5521") + @Severity(SeverityLevel.NORMAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "insert multilingual fields") + public void ingestMultiLingualFields() { + // ingested Movie for checking multilanguage + final String JAP = "jap"; + final String ENG = "eng"; + String suffix = "multilingual"; + name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically + description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically + generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE, movieAssetFiles); + movie = insertVod(vodData, true); + String nameData = "" + movie.getName() + ""; + String descriptionData = "" + movie.getDescription() + ""; + String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); + String stringMetaData = "" + stringMetaDataValue + ""; + String tagData = "" + tagValue1 + ""; + + // to get xml having all fields supporting multilingual + String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); + ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) + .replaceAll(movie.getName(), movie.getName() + JAP)); + ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) + .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); + ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) + .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); + ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) + .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); + + Response resp = getResponseBodyFromIngestVod(ingestXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); + String id = from(resp.asString()).get(ingestAssetIdPath).toString(); + assertThat(id).isEqualTo(movie.getId().toString()); + + AssetService.GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()) + .setLanguage(JAP); + Asset asset = executor.executeSync(getAssetBuilder).results; + assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); + assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); + assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) + .isEqualTo(stringMetaDataValue + JAP); + // check tag value + boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); + assertThat(isTagValueFound).isEqualTo(true); + + getAssetBuilder = get(id, AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()) + .setLanguage(ENG); + asset = executor.executeSync(getAssetBuilder).results; + assertThat(asset.getName()).isEqualTo(movie.getName()); + assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); + assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); + // check tag value + isTagValueFound = isTagValueFound(tagValue1, asset); + assertThat(isTagValueFound).isEqualTo(true); + } + + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with different Ppv") + public void insertUpdateVodMediaPpv() { + generateDefaultValues4Insert(MOVIE); + List movieAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, + "new file type1_11" + localCoguid,"Shai_Regression_PPV;Subscription_only_PPV", "Subscription_only_PPV"); + VodData vodData = getVodData(MOVIE, movieAssetFiles); + MediaAsset movie = insertVod(vodData, true); + String ingestRequest = ingestXmlRequest; + + assertThat(movie.getName()).isEqualTo(name); + assertThat(movie.getDescription()).isEqualTo(description); + checkFiles(movieAssetFiles, movie.getId().toString()); + + Household household = HouseholdUtils.createHousehold(1, 1, true); + String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); + AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); + com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); + List getMediaFiles = assetGetResponse.results.getMediaFiles(); + int fileId1 = getMediaFiles.get(0).getId(); + int fileId2 = getMediaFiles.get(1).getId(); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setFileIdIn(String.valueOf(fileId1)); + ppFilter.setIsLowest(false); + ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + com.kaltura.client.utils.response.base.Response> productPriceResponse = + executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); + assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); + assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); + // TODO: complete + + } + + boolean isTagValueFound(String value2Found, Asset asset) { + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + if (value2Found.equals(tagValue.getValue())) { + return true; + } + } + return false; + } + + void validateInvalidMovieField(String ingestXml, String fieldName, String fieldType) { + Response resp = getResponseBodyFromIngestVod(ingestXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)) + .isEqualTo(fieldType + ": " + fieldName + " does not exist for group"); + } + void checkVODDeletion(String coguid) { SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setKSql("externalId='" + coguid + "'"); @@ -409,4 +597,30 @@ void checkVODDeletion(String coguid) { .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) .until(() -> (executor.executeSync(listAssetBuilder).results.getTotalCount() == 0)); } + + // to check that ingested file data are corresponding to getAsset file data + private void checkFiles(List ingestAssetFiles, String assetId) { + boolean isFileWasFound = false; + + AssetService.GetAssetBuilder assetBuilder = AssetService.get(assetId, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); + com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); + List getMediaFiles = assetGetResponse.results.getMediaFiles(); + + for (VODFile ingestFile: ingestAssetFiles) { + for (MediaFile getFile: getMediaFiles) { + if (getFile.getType().equals(ingestFile.type())) { + isFileWasFound = true; + assertThat(getFile.getDuration().toString()).isEqualTo(ingestFile.assetDuration()); + assertThat(getFile.getUrl()).isEqualTo(ingestFile.cdn_code()); + assertThat(getFile.getAltStreamingCode()).isEqualTo(ingestFile.alt_cdn_code()); + assertThat(getFile.getExternalStoreId()).isEqualTo(ingestFile.product_code()); + assertThat(getFile.getExternalId()).isEqualTo(ingestFile.coguid()); + } + } + } + assertThat(isFileWasFound).isEqualTo(true); + } + + // TODO: try empty files + // TODO: try empty images } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java index e673d8230..4d1370099 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java @@ -11,6 +11,7 @@ import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.BaseUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; public class IngestVodOPCUtils extends BaseIngestUtils { @@ -110,7 +111,7 @@ public class IngestVodOPCUtils extends BaseIngestUtils { "\n" + "\n" + - "\n" + + "\n" + "\n" + "\n" + "Movie_Name_1808220925223281\n" + @@ -226,9 +227,13 @@ public class IngestVodOPCUtils extends BaseIngestUtils { public static HashMap booleanHashMap = new HashMap<>(); public static HashMap datesMetaMap = new HashMap<>(); public static HashMap> tagsMetaMap = new HashMap<>(); - public static List assetFiles = new ArrayList<>(); + public static List movieAssetFiles = new ArrayList<>(); + public static List episodeAssetFiles = new ArrayList<>(); + public static List seriesAssetFiles = new ArrayList<>(); + public static String tagValue1 = "Jack Nicholson"; + public static String tagValue2 = "Natalie Portman"; - public static IngestVodUtils.VodData getVodData(String mediaType) { + public static IngestVodUtils.VodData getVodData(String mediaType, List mediaAssetFiles) { switch (mediaType) { case "Movie": return new IngestVodUtils.VodData() @@ -242,7 +247,7 @@ public static IngestVodUtils.VodData getVodData(String mediaType) { .dates(datesMetaMap) .tags(tagsMetaMap) .isVirtual(false) - .assetFiles(assetFiles); + .assetFiles(mediaAssetFiles); case "Episode": return new IngestVodUtils.VodData() .name(name) @@ -255,7 +260,7 @@ public static IngestVodUtils.VodData getVodData(String mediaType) { .dates(datesMetaMap) .tags(tagsMetaMap) .isVirtual(false) - .assetFiles(assetFiles); + .assetFiles(mediaAssetFiles); case "Series": return new IngestVodUtils.VodData() .name(name) @@ -268,7 +273,7 @@ public static IngestVodUtils.VodData getVodData(String mediaType) { .dates(datesMetaMap) .tags(tagsMetaMap) .isVirtual(true) - .assetFiles(assetFiles); + .assetFiles(mediaAssetFiles); default: return null; } @@ -305,8 +310,8 @@ public static void generateDefaultValues4Update(boolean previousValue, String me doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; booleanValue = !previousValue; tagValues = new ArrayList<>(); - tagValues.add("Jack NicholsonUpd"); - tagValues.add("Natalie PortmanUpd"); + tagValues.add(tagValue1 + "Upd"); + tagValues.add(tagValue2 + "Upd"); tagValues.add(textValue); fillMapsWithData(mediaType); @@ -319,8 +324,8 @@ public static void generateDefaultValues4Insert(String mediaType) { doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; booleanValue = getRandomBooleanValue(); tagValues = new ArrayList<>(); - tagValues.add("Jack Nicholson"); - tagValues.add("Natalie Portman"); + tagValues.add(tagValue1); + tagValues.add(tagValue2); tagValues.add(textValue); fillMapsWithData(mediaType); @@ -365,4 +370,30 @@ public static String getCoguidOfActiveMediaAsset(int assetType) { return assetListResponse.results.getObjects().get(0).getExternalId(); } + + public static VODFile loadFile(String fileType, String coguid, String ppvs) { + return new VODFile() + .assetDuration("1000") + .quality("HIGH") + .handling_type("CLIP") + .cdn_name("Default CDN") + .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") + .billing_type("Tvinci") + .product_code("productExampleCode") + .type(fileType) + .coguid(coguid) + .ppvModule(ppvs); + } + + public static List loadAssetFiles(String fileType1, String fileType2, String coguid1, + String coguid2, String ppvs1, String ppvs2) { + List result = new ArrayList<>(); + VODFile file1 = loadFile(fileType1, coguid1, ppvs1); + VODFile file2 = loadFile(fileType2, coguid2, ppvs2); + result.add(file1); + result.add(file2); + + return result; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index aec7f574b..238c0dee4 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -42,6 +42,8 @@ public class IngestVodUtils extends BaseIngestUtils { public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; public static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; + public static String ingestXmlRequest = ""; + static boolean areDefaultValuesRequired; @Accessors(fluent = true) @@ -217,7 +219,7 @@ private static Response executeIngestVodRequest(String reqBody) { return resp; } - public static String buildIngestVodXml(VodData vodData, String action) { + private static String buildIngestVodXml(VodData vodData, String action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password @@ -376,7 +378,9 @@ public static String buildIngestVodXml(VodData vodData, String action) { // uncomment cdata String docAsString = docToString(doc); - return uncommentCdataSection(docAsString); + ingestXmlRequest = uncommentCdataSection(docAsString); + //Logger.getLogger(IngestVodUtils.class).debug("ingestXmlRequest: " + ingestXmlRequest); + return ingestXmlRequest; } private static Element addFile(Document doc, VODFile vodFile) { From 743dd40a26db04daef264aad840bea64a061941e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 29 Aug 2018 12:06:22 +0300 Subject: [PATCH 493/605] change testng.xml for tests --- .../PermissionsManagementTests.java | 1 - .../client/test/utils/PerformanceUtils.java | 32 ++++++++---- src/test/resources/testng.xml | 52 +++++++++---------- 3 files changed, 48 insertions(+), 37 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 860f4bab1..e071de46d 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 */ public class PermissionsManagementTests { diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index eea70def9..be9de4412 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -5,6 +5,7 @@ import lombok.AccessLevel; import lombok.Getter; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.json.JSONObject; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -80,6 +81,12 @@ private static List getLogFilesUrls() { doc = Jsoup.connect(logsUrl).get(); } catch (IOException e) { e.printStackTrace(); + File file = getReportFile(); + try { + FileUtils.writeStringToFile(file, ExceptionUtils.getStackTrace(e), Charset.defaultCharset(), true); + } catch (IOException e1) { + e1.printStackTrace(); + } } List urls = new ArrayList<>(); @@ -149,6 +156,20 @@ private static List getSlowSessions(List sessions) { .collect(Collectors.toList()); } + private static File getReportFile() { + File file = new File(reportFilePath); + + if (file.exists()) { + file.delete(); + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return file; + } + private static void writeReport(List sessions) { List slowSessions = getSlowSessions(sessions); @@ -163,16 +184,7 @@ private static void writeReport(List sessions) { )); // write data to file - File file = new File(reportFilePath); - - if (file.exists()) { - file.delete(); - try { - file.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - } + File file = getReportFile(); String reportSummary = "Performance Report - " + getCurrentDateInFormat("dd/MM/yyyy HH:mm") + " (" + getProperty(API_VERSION) + ")\n" + "Max percentage: " + getProperty(MAX_CODE_PERCENTAGE) + "%\n" diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 751e9b7d2..3e77b9065 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,33 +2,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + From a4407a2226692406f6e24e3ffa9e8a27101eceaa Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 29 Aug 2018 15:13:57 +0300 Subject: [PATCH 494/605] add logs dir to project for performance report --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a1b4e5640..4870d616b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ src/test/java/com/kaltura/client/test/tests/Sandbox.java src/test/resources/db_utils_list.txt src/test/resources/utils_list.txt src/test/resources/testXml.xml +logs/ From 4b5ccd04a01960d48e4304448faf2ca9799e5a57 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 29 Aug 2018 15:29:41 +0300 Subject: [PATCH 495/605] no message --- .../java/com/kaltura/client/test/tests/BaseTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 47c43a063..30bc6e956 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Method; +import java.nio.file.Files; import java.util.*; import java.util.concurrent.TimeUnit; @@ -136,10 +137,13 @@ public void baseTest_beforeSuite() { // set performance report if ("true".equals(getProperty(WRITE_REGRESSION_LOGS))) { - try { - FileUtils.cleanDirectory(new File(getProperty(LOGS_DIR))); - } catch (IOException e) { - e.printStackTrace(); + File logsDir = new File(getProperty(LOGS_DIR)); + if (Files.exists(logsDir.toPath())) { + try { + FileUtils.cleanDirectory(new File(getProperty(LOGS_DIR))); + } catch (IOException e) { + e.printStackTrace(); + } } } } From 28404074cf879418ebd97fccae20357ad09df28a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 29 Aug 2018 15:34:27 +0300 Subject: [PATCH 496/605] no message --- src/test/resources/testng.xml | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 3e77b9065..751e9b7d2 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -2,33 +2,33 @@ - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + From c3a86d12d9ed178408f89f8b73ae399e1f8599eb Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 30 Aug 2018 09:42:52 +0300 Subject: [PATCH 497/605] no message --- .../kaltura/client/test/TestAPIOkRequestsExecutor.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java index 6c8d13d71..851ce5a8e 100644 --- a/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java +++ b/src/test/java/com/kaltura/client/test/TestAPIOkRequestsExecutor.java @@ -133,14 +133,6 @@ private void writeLogs(String serviceMethod, String kalturaSession) { } catch (IOException e) { e.printStackTrace(); } - -// try(FileWriter fw = new FileWriter(getProperty(LOGS_DIR) + getProperty(REGRESSION_LOGS_FILE), true); -// BufferedWriter bw = new BufferedWriter(fw); -// PrintWriter out = new PrintWriter(bw)) { -// out.println(serviceMethod + " " + kalturaSession); -// } catch (IOException e) { -// e.printStackTrace(); -// } } public Response executeSync(RequestBuilder requestBuilder) { From 320b2204251f100dfce083a7d022e8255b59e794 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 30 Aug 2018 10:24:05 +0300 Subject: [PATCH 498/605] Added more tests related ingest Vod for opc --- .../five_zero_two/IngestVodTests.java | 94 +++++++++++++------ .../utils/ingestUtils/IngestVodOPCUtils.java | 80 ++-------------- src/test/resources/schemas/MediaAsset.json | 2 +- 3 files changed, 71 insertions(+), 105 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index eb02c50c3..c20fe5488 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -82,12 +82,12 @@ public void setUp() { episode = insertVod(vodData, true); episodeType = episode.getType(); - seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_3" + localCoguid, - "new file type1_3" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); - generateDefaultValues4Insert(SERIES); - vodData = getVodData(SERIES, seriesAssetFiles); - series = insertVod(vodData, true); - seriesType = series.getType(); +// seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_3" + localCoguid, +// "new file type1_3" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); +// generateDefaultValues4Insert(SERIES); +// vodData = getVodData(SERIES, seriesAssetFiles); +// series = insertVod(vodData, true); +// seriesType = series.getType(); wasNOTSetupExecuted = false; } @@ -183,7 +183,6 @@ public void insertVodSeriesBaseFields() { checkFiles(seriesAssetFiles, series.getId().toString()); } - @Issue("BEO-5516") @Severity(SeverityLevel.CRITICAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { @@ -227,9 +226,22 @@ public void updateVodMediaBaseFields() { AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(movie.getId()), AssetReferenceType.MEDIA) .setKs(getAnonymousKs()); com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); - assertThat(assetGetResponse.results.getId()).isEqualTo(movie.getId()); - assertThat(assetGetResponse.results.getDescription()).isEqualTo(null); - assertThat(assetGetResponse.results.getMetas().get(mediaNumberFieldName)).isEqualTo(null); + MediaAsset asset2 = (MediaAsset)assetGetResponse.results; + assertThat(asset2.getId()).isEqualTo(movie.getId()); + assertThat(asset2.getName()).isEqualTo(name); + assertThat(asset2.getDescription()).isEqualTo(""); + assertThat(((MultilingualStringValue)asset2.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(asset2.getMetas().get(mediaNumberFieldName)).isEqualTo(null); + assertThat(getFormattedDate(((LongValue)asset2.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset2.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + tags = asset2.getTags(); + entry = tags.entrySet().iterator().next(); + tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); } @@ -345,24 +357,6 @@ public void tryDeleteWithNonexistedCoguid() { assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); } - @Issue("BEO-5516") - @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc", "OPC"}, description = "try update with empty erase") - public void tryUpdateWithEmptyErase() { - String invalidXml = ingestUpdateXml - .replaceAll("erase=\"false\"", "erase=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("is missing"); - - // NO REASON TO CHECK AS DEFAULT VALUE IS FALSE and it allows to ingest - /*String invalidXml = ingestUpdateXml - .replaceAll("erase=\"false\"", ""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("is missing");*/ - } - @Severity(SeverityLevel.MINOR) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty entry_id") public void tryInsertWithEmptyEntryId() { @@ -440,7 +434,6 @@ public void tryInsertWithInvalidCredentials() { assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); } - @Issue("BEO-5520") @Severity(SeverityLevel.NORMAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with invalid meta or tag field") public void tryInsertWithInvalidMetaOrTagField() { @@ -468,7 +461,6 @@ public void tryInsertWithInvalidMetaOrTagField() { validateInvalidMovieField(invalidXml, updatedField, "meta"); } - @Issue("BEO-5521") @Severity(SeverityLevel.NORMAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "insert multilingual fields") public void ingestMultiLingualFields() { @@ -526,6 +518,8 @@ public void ingestMultiLingualFields() { // check tag value isTagValueFound = isTagValueFound(tagValue1, asset); assertThat(isTagValueFound).isEqualTo(true); + + // TODO: update multilingual fields } @@ -623,4 +617,44 @@ private void checkFiles(List ingestAssetFiles, String assetId) { // TODO: try empty files // TODO: try empty images + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with emtpy images and files fields") + public void insertVodMediaBaseEmptyImagesAndFields() { + String suffix = "123"; + String ingestXmlWithEmptyFiles = ingestInsertXml + .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); + String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; + // check empty files + int positionBeginFiles = ingestXmlWithEmptyFiles.indexOf(""); + int positionEndFiles = ingestXmlWithEmptyFiles.indexOf(""); + String files = ingestXmlWithEmptyFiles.substring(positionBeginFiles, positionEndFiles + "".length()); + String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; + String ingestXml = ingestXmlWithEmptyFiles.replace(files, emptyFiles); + + Response resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); + + // check empty images + ingestXml = ingestXmlBeforeTransformations + .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); + int positionBeginImages = ingestXml.indexOf(""); + int positionEndImages = ingestXml.indexOf(""); + String images = ingestXml.substring(positionBeginImages, positionEndImages + "".length()); + String emptyImages = "" + EMPTY_IMAGE_TAG + ""; + ingestXml = ingestXml.replace(images, emptyImages); + + resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + + // checkEmptyThumb + ingestXml = ingestXmlBeforeTransformations + .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); + int positionBeginThumb = ingestXml.indexOf("", positionBeginThumb); + String thumb = ingestXml.substring(positionBeginThumb, positionEndThumb + "/>".length()); + ingestXml = ingestXml.replace(thumb, EMPTY_THUMB_TAG); + + resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java index 4d1370099..8c593c858 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java @@ -25,80 +25,12 @@ public class IngestVodOPCUtils extends BaseIngestUtils { static final String defaultThumbUrl = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - public static final String INGEST_VOD_XML = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Test_API_27_03\n" + - "Test_API_27_03\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Movie_Name_1808220925223281\n" + - "\n" + - "\n" + - "\n" + - "Movie_Description_1808220925223281\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Movie\n" + - "\n" + - "\n" + - "Parent Allowed\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "BoxOfficevalue\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "123456\n" + - "\n" + - "\n" + - "12/12/2012\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Jack Nicholson\n" + - "\n" + - "\n" + - "Natalie Portman\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "]]>\n" + - "\n" + - "\n" + - "\n" + - "\n" + - ""; + public static final String FILE_TYPE_1 = "Test130301"; + public static final String FILE_TYPE_2 = "new file type1"; + public static final String EMPTY_FILE_1_TAG = "\n"; + public static final String EMPTY_FILE_2_TAG = "\n"; + public static final String EMPTY_IMAGE_TAG = "\n"; + public static final String EMPTY_THUMB_TAG = "\n"; public static final String UPDATE_VOD_XML = "\n" + "\n" + diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index f9c21435b..780562cb0 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -34,7 +34,7 @@ }, "description": { "type": "string", - "minLength": 1 + "minLength": 0 }, "images": { "type": "array", From 8b1af004cbf533b776bbdb6a4c62358ebecf27a0 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 30 Aug 2018 10:54:47 +0300 Subject: [PATCH 499/605] removed useless property --- src/test/java/com/kaltura/client/test/Properties.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 2026ed970..ae0ef1957 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -19,7 +19,6 @@ public class Properties { // Request properties public static final String PARTNER_ID = "partner_id"; - public static final String IS_OPC_GROUP = "is_opc_group"; public static final String OPC_PARTNER_ID = "opc_partner_id"; public static final String DEFAULT_TIMEOUT_IN_SEC = "default_timeout_in_sec"; From adc021ff64e11acdab55b942fe57bab926f515c1 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 30 Aug 2018 11:21:55 +0300 Subject: [PATCH 500/605] fixed typo in variable --- .../com/kaltura/client/test/tests/BaseTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 15af90da1..1b9f6645f 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -19,9 +19,7 @@ import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; -import java.lang.reflect.Method; import java.nio.file.Files; -import java.util.*; import java.util.concurrent.TimeUnit; import static com.google.common.base.Verify.verify; @@ -66,7 +64,7 @@ public class BaseTest { // shared common params public static int partnerId; // public static int opcPartnerId; - public static boolean isOprGroup; + public static boolean isOpcGroup; public static String defaultUserPassword; // shared ks's @@ -137,10 +135,10 @@ public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String // set shared common params if ("opc".equals(accountType)) { - isOprGroup = true; + isOpcGroup = true; partnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); } else { - isOprGroup = false; + isOpcGroup = false; partnerId = Integer.parseInt(getProperty(PARTNER_ID)); } //opcPartnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); @@ -305,7 +303,7 @@ public static String getIngestBusinessModuleUserPassword() { public static String getIngestAssetUserName() { if (ingestAssetUserUsername == null) { - String userInfo = isOprGroup + String userInfo = isOpcGroup ? IngestFixtureData.getIngestItemUserData(partnerId) : IngestFixtureData.getIngestItemUserData(partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; @@ -316,7 +314,7 @@ public static String getIngestAssetUserName() { public static String getIngestAssetUserPassword() { if (ingestAssetUserPassword == null) { - String userInfo = isOprGroup + String userInfo = isOpcGroup ? IngestFixtureData.getIngestItemUserData(partnerId) : IngestFixtureData.getIngestItemUserData(partnerId + 1); ingestAssetUserUsername = userInfo.split(":")[0]; @@ -327,7 +325,7 @@ public static String getIngestAssetUserPassword() { public static String getIngestVirtualAssetUserName() { if (ingestVirtualAssetUserUsername == null) { - String userInfo = isOprGroup + String userInfo = isOpcGroup ? IngestFixtureData.getIngestItemUserData(partnerId) : IngestFixtureData.getIngestItemUserData(partnerId + 2); ingestVirtualAssetUserUsername = userInfo.split(":")[0]; @@ -338,7 +336,7 @@ public static String getIngestVirtualAssetUserName() { public static String getIngestVirualAssetUserPassword() { if (ingestVirtualAssetUserPassword == null) { - String userInfo = isOprGroup + String userInfo = isOpcGroup ? IngestFixtureData.getIngestItemUserData(partnerId) : IngestFixtureData.getIngestItemUserData(partnerId + 2); ingestVirtualAssetUserUsername = userInfo.split(":")[0]; From 54f219261b2056ef0a67476be1e24b73bdb9416b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 30 Aug 2018 13:10:53 +0300 Subject: [PATCH 501/605] Added more tests into ingest VOD for opc --- .../five_zero_two/IngestVodTests.java | 116 +++++++++--------- .../utils/ingestUtils/IngestVodOPCUtils.java | 81 +----------- 2 files changed, 59 insertions(+), 138 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index c20fe5488..810070aa4 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_two; -import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.ProductPriceService; @@ -8,19 +7,16 @@ import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; -import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import io.restassured.response.Response; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.enums.AssetType.MEDIA; import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.utils.BaseUtils.*; @@ -46,14 +42,13 @@ public class IngestVodTests extends BaseTest { private String localCoguid = ""; private String ingestInsertXml; - private String ingestUpdateXml; private String ingestDeleteXml; private static final String suffix4Coguid = "123"; private static String coguid4NegativeTests = ""; private boolean wasNOTSetupExecuted = true; - @BeforeClass + @BeforeClass(groups = {"ingest VOD for OPC", "opc"}) public void setUp() { String prefix = "Movie_"; localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); @@ -73,7 +68,6 @@ public void setUp() { coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); ingestDeleteXml = DELETE_VOD_XML.replaceAll("180822092522774", movie.getExternalId()); - ingestUpdateXml = UPDATE_VOD_XML.replaceAll("180828080027358", movie.getExternalId()); episodeAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_2" + localCoguid, "new file type1_2" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); @@ -82,25 +76,20 @@ public void setUp() { episode = insertVod(vodData, true); episodeType = episode.getType(); -// seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_3" + localCoguid, -// "new file type1_3" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); -// generateDefaultValues4Insert(SERIES); -// vodData = getVodData(SERIES, seriesAssetFiles); -// series = insertVod(vodData, true); -// seriesType = series.getType(); + seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_3" + localCoguid, + "new file type1_3" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); + generateDefaultValues4Insert(SERIES); + vodData = getVodData(SERIES, seriesAssetFiles); + series = insertVod(vodData, true); + seriesType = series.getType(); wasNOTSetupExecuted = false; } + // TODO: remove group "ingest VOD for OPC" if we can exclude class from testng.xml @Severity(SeverityLevel.CRITICAL) @Test(groups = {"ingest VOD for OPC", "opc"}, priority =-2, description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { - // that should be called in case running from testng.xml as a group - // priority set to -2 to guarantee that setUp will be executed before all other tests as part of that test case. - if (wasNOTSetupExecuted) { - setUp(); - } - generateDefaultValues4Insert(MOVIE); List movieAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, "new file type1_11" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); @@ -187,7 +176,6 @@ public void insertVodSeriesBaseFields() { @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { String coguid = getCoguidOfActiveMediaAsset(movieType); - // TODO: asked Shir if I can update file and if yes what fields generateDefaultValues4Update(true, MOVIE); IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles); @@ -518,10 +506,43 @@ public void ingestMultiLingualFields() { // check tag value isTagValueFound = isTagValueFound(tagValue1, asset); assertThat(isTagValueFound).isEqualTo(true); - // TODO: update multilingual fields } + @Severity(SeverityLevel.MINOR) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with emtpy images and files fields") + public void insertVodMediaBaseEmptyImagesAndFields() { + String suffix = "123"; + String ingestXmlWithEmptyFiles = ingestInsertXml + .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); + String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; + // check empty files + String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; + String ingestXml = getUpdatedIngestXml(ingestXmlWithEmptyFiles, "", "", emptyFiles); + + Response resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); + + /* TODO: Shir said that current logic should allow to ingest without any errors - that can be checked after Alon complete image update + // check empty images + ingestXml = ingestXmlBeforeTransformations + .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); + ingestXml = getIngestXmlWithoutFiles(ingestXml); + String emptyImages = "" + EMPTY_IMAGE_TAG + ""; + ingestXml = getUpdatedIngestXml(ingestXml, "", "", emptyImages); + + resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + + // checkEmptyThumb + ingestXml = ingestXmlBeforeTransformations + .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); + ingestXml = getIngestXmlWithoutFiles(ingestXml); + ingestXml = getUpdatedIngestXml(ingestXml, "", EMPTY_THUMB_TAG); + + resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique");*/ + } @Severity(SeverityLevel.CRITICAL) @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with different Ppv") @@ -554,7 +575,6 @@ public void insertUpdateVodMediaPpv() { assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); // TODO: complete - } boolean isTagValueFound(String value2Found, Asset asset) { @@ -615,46 +635,20 @@ private void checkFiles(List ingestAssetFiles, String assetId) { assertThat(isFileWasFound).isEqualTo(true); } - // TODO: try empty files - // TODO: try empty images - @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with emtpy images and files fields") - public void insertVodMediaBaseEmptyImagesAndFields() { - String suffix = "123"; - String ingestXmlWithEmptyFiles = ingestInsertXml - .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); - String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; - // check empty files - int positionBeginFiles = ingestXmlWithEmptyFiles.indexOf(""); - int positionEndFiles = ingestXmlWithEmptyFiles.indexOf(""); - String files = ingestXmlWithEmptyFiles.substring(positionBeginFiles, positionEndFiles + "".length()); - String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; - String ingestXml = ingestXmlWithEmptyFiles.replace(files, emptyFiles); - - Response resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); - - // check empty images - ingestXml = ingestXmlBeforeTransformations - .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); - int positionBeginImages = ingestXml.indexOf(""); - int positionEndImages = ingestXml.indexOf(""); - String images = ingestXml.substring(positionBeginImages, positionEndImages + "".length()); - String emptyImages = "" + EMPTY_IMAGE_TAG + ""; - ingestXml = ingestXml.replace(images, emptyImages); - - resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + private String getIngestXmlWithoutFiles(String ingestXml) { + return getUpdatedIngestXml(ingestXml, "", "", ""); + } - // checkEmptyThumb - ingestXml = ingestXmlBeforeTransformations - .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); - int positionBeginThumb = ingestXml.indexOf("", positionBeginThumb); - String thumb = ingestXml.substring(positionBeginThumb, positionEndThumb + "/>".length()); - ingestXml = ingestXml.replace(thumb, EMPTY_THUMB_TAG); + String getUpdatedIngestXml(String ingestXml, String openTag2Update, String closeTag2Update, String updateOnString) { + int positionBeginTag = ingestXml.indexOf(openTag2Update); + int positionEndTag; + if ("/>".equals(closeTag2Update)) { + positionEndTag = ingestXml.indexOf(closeTag2Update, positionBeginTag); + } else { + positionEndTag = ingestXml.indexOf(closeTag2Update); + } - resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + String string2Delete = ingestXml.substring(positionBeginTag, positionEndTag + closeTag2Update.length()); + return ingestXml.replace(string2Delete, updateOnString); } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java index 8c593c858..d0aab9d97 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java @@ -23,8 +23,6 @@ public class IngestVodOPCUtils extends BaseIngestUtils { public static boolean booleanValue; public static List tagValues; - static final String defaultThumbUrl = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - public static final String FILE_TYPE_1 = "Test130301"; public static final String FILE_TYPE_2 = "new file type1"; public static final String EMPTY_FILE_1_TAG = "\n"; @@ -32,78 +30,7 @@ public class IngestVodOPCUtils extends BaseIngestUtils { public static final String EMPTY_IMAGE_TAG = "\n"; public static final String EMPTY_THUMB_TAG = "\n"; - public static final String UPDATE_VOD_XML = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Test_API_27_03\n" + - "Test_API_27_03\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Movie_Name_1808220925223281\n" + - "\n" + - "\n" + - "\n" + - "Movie_Description_1808220925223281\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Movie\n" + - "\n" + - "\n" + - "Parent Allowed\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "BoxOfficevalue\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "123456\n" + - "\n" + - "\n" + - "12/12/2012\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Jack Nicholson\n" + - "\n" + - "\n" + - "Natalie Portman\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "]]>\n" + - "\n" + - "\n" + - "\n" + - "\n" + - ""; - + // TODO: remove it using util public static final String DELETE_VOD_XML = "\n" + "\n" + "\n" + @@ -172,7 +99,7 @@ public static IngestVodUtils.VodData getVodData(String mediaType, List .name(name) .description(description) .mediaType(MediaType.MOVIE) - .thumbUrl(defaultThumbUrl) + .thumbUrl(DEFAULT_THUMB) .strings(stringMetaMap) .booleans(booleanHashMap) .numbers(numberMetaMap) @@ -185,7 +112,7 @@ public static IngestVodUtils.VodData getVodData(String mediaType, List .name(name) .description(description) .mediaType(MediaType.EPISODE) - .thumbUrl(defaultThumbUrl) + .thumbUrl(DEFAULT_THUMB) .strings(stringMetaMap) .booleans(booleanHashMap) .numbers(numberMetaMap) @@ -198,7 +125,7 @@ public static IngestVodUtils.VodData getVodData(String mediaType, List .name(name) .description(description) .mediaType(MediaType.SERIES) - .thumbUrl(defaultThumbUrl) + .thumbUrl(DEFAULT_THUMB) .strings(stringMetaMap) .booleans(booleanHashMap) .numbers(numberMetaMap) From eb908135cfd417dd0d3d3273e471443c17abcb9b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 30 Aug 2018 17:35:41 +0300 Subject: [PATCH 502/605] Added JSON related tests --- .../PermissionsManagementTests.java | 45 ++++++++++--- .../test/utils/PermissionManagementUtils.java | 63 +++++++++++++++---- 2 files changed, 90 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 188a35294..337150f31 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -6,10 +6,12 @@ import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; +import org.apache.commons.io.FileUtils; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -113,7 +115,7 @@ public void export() { String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix); + "parameter" + suffix, false); // export from DB List commands = new ArrayList<>(); @@ -183,7 +185,7 @@ public void importFromFile() { String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); + "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB List commands = new ArrayList<>(); @@ -222,14 +224,14 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { String suffix = String.valueOf(BaseUtils.getEpoch()) + "inserted"; PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix); + "parameter" + suffix, false); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); // generate import file data suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); + "parameter" + suffix, 1, 2, 3, 4, 5, false); // try to import into DB List commands = new ArrayList<>(); @@ -248,7 +250,7 @@ public void deleteFromDB() { String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); + "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB List commands = new ArrayList<>(); @@ -302,7 +304,7 @@ public void importAlreadyExistedFromFile() { String suffix = String.valueOf(BaseUtils.getEpoch()); PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, 1, 2, 3, 4, 5); + "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB List commands = new ArrayList<>(); @@ -400,15 +402,44 @@ public void runningImportJsonWithoutFile() { assertThat(consoleOutput).contains("The system cannot find the file specified"); } + /* + + // export from DB + // checks that created file contains inserted data + String fileContent = getFileContent(dataFilePath); + assertThat(fileContent).contains("MaxTest" + suffix); + assertThat(fileContent).contains("Asset_List_Max" + suffix); + assertThat(fileContent).contains("permissionItemObject" + suffix); + assertThat(fileContent).contains("parameter" + suffix);*/ @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to export in JSON from DB") - public void runningExporttJson() { + public void runningExportJson() throws IOException { + // clean folder with logs + FileUtils.cleanDirectory(new File(path2JsonFolder)); + + // prepare data inserting them in DB using stored procedures + String suffix = String.valueOf(BaseUtils.getEpoch()); + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", + "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + "parameter" + suffix, true); + + // command List commands = new ArrayList<>(); commands.add(path2Util + mainFile); commands.add(EXPORT_JSON_KEY + path2JsonFolder); String consoleOutput = executeCommandsInColsole(commands); + String fileContent = getFileContent(generatedDataFilePath); + System.out.println("FILE: " + fileContent); + + + //assertThat(consoleOutput).contains("The system cannot find the file specified"); // TODO: add assertions + +// List commands = new ArrayList<>(); +// commands.add(path2Util + mainFile); +// commands.add(IMPORT_JSON_KEY + path2JsonFolder); +// String consoleOutput = executeCommandsInColsole(commands); } } diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index 99a8e6e18..51adc63b5 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -89,7 +89,7 @@ public static String executeCommandsInColsole(List commands) { } public static void insertDataInAllTables(String path2ResultFile, String role, String usersGroup, String permissionItemName, - String service, String action, String permissionItemObject, String parameter) { + String service, String action, String permissionItemObject, String parameter, boolean isJson) { long roleId = PermissionsManagementDBUtils.insertRole(role); long permissionId = PermissionsManagementDBUtils.insertPermission(role, 2, usersGroup); long permissionRoleId = PermissionsManagementDBUtils.insertPermissionRole(roleId, permissionId, 0); @@ -98,28 +98,69 @@ public static void insertDataInAllTables(String path2ResultFile, String role, St long permissionPermissionItemId = PermissionsManagementDBUtils.insertPermissionPermissionItem(permissionId, permissionItemId, 0); generateFileWithInsertedIntoDBData(path2ResultFile, role, usersGroup, permissionItemName, service, action, - permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId); + permissionItemObject, parameter, roleId, permissionId, permissionRoleId, permissionItemId, permissionPermissionItemId, isJson); } public static void generateFileWithInsertedIntoDBData(String path2ResultFile, String role, String usersGroup, String permissionItemName, - String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, - long permissionRoleId, long permissionItemId, long permissionPermissionItemId) { + String service, String action, String permissionItemObject, String parameter, long roleId, long permissionId, + long permissionRoleId, long permissionItemId, long permissionPermissionItemId, boolean isJson) { try { File file = new File(path2ResultFile); PrintWriter writer = new PrintWriter(file); - printOpenTag(writer); - printRole(writer, roleId, role); - printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); - printPermission(writer, permissionId, role, 2, usersGroup); - printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); - printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); - printCloseTag(writer); + if (isJson) { + printRolesFormat(writer, role); + // to separate + printRolesFormat(writer, ";"); + printPermissionsFormat(writer, role, usersGroup); + // to separate + printRolesFormat(writer, ";"); + printServiceFormat(writer, role, permissionItemName, service, action); + } else { + // XML + printOpenTag(writer); + printRole(writer, roleId, role); + printRolePermission(writer, permissionRoleId, roleId, permissionId, 0, role, role); + printPermission(writer, permissionId, role, 2, usersGroup); + printPermissionItem(writer, permissionItemId, permissionItemName, 1, service, action, permissionItemObject, parameter); + printPermissionPermissionItem(writer, permissionPermissionItemId, permissionId, permissionItemId, 0, permissionItemName, role); + printCloseTag(writer); + } writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } + private static void printServiceFormat(PrintWriter writer, String role, String permissionItemName, String service, String action) { + writer.println("{"); + writer.println("\"permissions\": ["); + writer.println("\"" + role + "\""); + writer.println("],"); + writer.println("\"excluded_permissions\": [],"); + writer.println("\"name\": \"" + permissionItemName + "\","); + writer.println("\"service\": \"" + service + "\","); + writer.println("\"action\": \"" + action + "\","); + writer.println("\"type\": \"Action\""); + writer.println("}"); + } + + private static void printPermissionsFormat(PrintWriter writer, String role, String usersGroup) { + writer.println("{"); + writer.println("\"name\": \"" + role + "\","); + writer.println("\"users_group\": \"" + usersGroup + "\""); + writer.println("}"); + } + + private static void printRolesFormat(PrintWriter writer, String role) { + writer.println("{"); + writer.println("\"permissions\": ["); + writer.println("\"" + role + "\""); + writer.println("],"); + writer.println("\"excluded_permissions\": [],"); + writer.println("\"name\": \"" + role + "\""); + writer.println("}"); + } + public static void generateFileWithInvalidTagForRole(String path2ResultFile, String roleName, int roleId) { try { File file = new File(path2ResultFile); From 2dd1f5d9e96eea6e61d304e08c69b2bd398648b6 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 30 Aug 2018 17:38:00 +0300 Subject: [PATCH 503/605] IngestVodTests - updateFiles() and updateImages() --- .../five_zero_two/IngestVodTests.java | 97 ++++++++++-- .../utils/ingestUtils/IngestVodOPCUtils.java | 33 ++-- .../utils/ingestUtils/IngestVodUtils.java | 144 +++++++++--------- .../ingest_xml_templates/ingestVOD.xml | 13 +- src/test/resources/schemas/MediaAsset.json | 4 +- 5 files changed, 175 insertions(+), 116 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index c20fe5488..7a8ec3ee0 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -1,6 +1,5 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_two; -import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; import com.kaltura.client.services.ProductPriceService; @@ -8,7 +7,6 @@ import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; -import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import io.restassured.response.Response; @@ -16,15 +14,17 @@ import org.testng.annotations.Test; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import static com.kaltura.client.enums.AssetType.MEDIA; import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.delayBetweenRetriesInSeconds; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.maxTimeExpectingValidResponseInSeconds; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static io.restassured.path.xml.XmlPath.from; import static java.util.TimeZone.getTimeZone; @@ -60,7 +60,7 @@ public void setUp() { name = prefix + "Name_" + localCoguid; description = prefix + "Description_" + localCoguid; - movieAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_1" + localCoguid, + movieAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_1" + localCoguid, "new file type1_1" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); VodData vodData; @@ -75,14 +75,14 @@ public void setUp() { ingestDeleteXml = DELETE_VOD_XML.replaceAll("180822092522774", movie.getExternalId()); ingestUpdateXml = UPDATE_VOD_XML.replaceAll("180828080027358", movie.getExternalId()); - episodeAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_2" + localCoguid, + episodeAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_2" + localCoguid, "new file type1_2" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); generateDefaultValues4Insert(EPISODE); vodData = getVodData(EPISODE, episodeAssetFiles); episode = insertVod(vodData, true); episodeType = episode.getType(); -// seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_3" + localCoguid, +// seriesAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_3" + localCoguid, // "new file type1_3" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); // generateDefaultValues4Insert(SERIES); // vodData = getVodData(SERIES, seriesAssetFiles); @@ -102,7 +102,7 @@ public void insertVodMediaBaseFields() { } generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, + List movieAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, "new file type1_11" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); VodData vodData = getVodData(MOVIE, movieAssetFiles); MediaAsset movie = insertVod(vodData, true); @@ -133,7 +133,7 @@ public void insertVodMediaBaseFields() { @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { generateDefaultValues4Insert(EPISODE); - List episodeAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_21" + localCoguid, + List episodeAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_21" + localCoguid, "new file type1_21" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); VodData vodData = getVodData(EPISODE, episodeAssetFiles); MediaAsset episode = insertVod(vodData, true); @@ -160,7 +160,7 @@ public void insertVodEpisodeBaseFields() { @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { generateDefaultValues4Insert(SERIES); - List seriesAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_31" + localCoguid, + List seriesAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_31" + localCoguid, "new file type1_31" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); VodData vodData = getVodData(SERIES, seriesAssetFiles); MediaAsset series = insertVod(vodData, true); @@ -527,7 +527,7 @@ public void ingestMultiLingualFields() { @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with different Ppv") public void insertUpdateVodMediaPpv() { generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = loadAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, + List movieAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, "new file type1_11" + localCoguid,"Shai_Regression_PPV;Subscription_only_PPV", "Subscription_only_PPV"); VodData vodData = getVodData(MOVIE, movieAssetFiles); MediaAsset movie = insertVod(vodData, true); @@ -593,14 +593,14 @@ void checkVODDeletion(String coguid) { } // to check that ingested file data are corresponding to getAsset file data - private void checkFiles(List ingestAssetFiles, String assetId) { + private void checkFiles(List ingestAssetFiles, String assetId) { boolean isFileWasFound = false; AssetService.GetAssetBuilder assetBuilder = AssetService.get(assetId, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); List getMediaFiles = assetGetResponse.results.getMediaFiles(); - for (VODFile ingestFile: ingestAssetFiles) { + for (VodFile ingestFile: ingestAssetFiles) { for (MediaFile getFile: getMediaFiles) { if (getFile.getType().equals(ingestFile.type())) { isFileWasFound = true; @@ -657,4 +657,77 @@ public void insertVodMediaBaseEmptyImagesAndFields() { resp = getResponseBodyFromIngestVod(ingestXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); } + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD images") + public void updateImages() { + // insert vod + generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE, movieAssetFiles); + MediaAsset mediaAsset = insertVod(vodData, true); + + // update vod images + List ratios = Arrays.asList("1:1", "2:1", "2:3"); + String fakeImageUrl = "https://picsum.photos/200/300/?random"; + + VodData updateVodData = new VodData() + .thumbUrl(fakeImageUrl) + .thumbRatios(ratios); + mediaAsset = updateVod(mediaAsset.getExternalId(), updateVodData); + + // assert update + List images = mediaAsset.getImages(); + + assertThat(images.size()).isEqualTo(6); + +// images.forEach(image -> assertThat(image.getUrl()).isEqualTo(fakeImageUrl)); +// assertThat(images).extracting("ratio").containsExactlyInAnyOrderElementsOf(ratios); + + // cleanup + deleteVod(movie.getExternalId()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD files") + public void updateFiles() { + List files = new ArrayList<>(); + + // insert vod + // TODO: 8/30/2018 remove hardcoded values + long e = getEpoch(); + VodFile file1 = new VodFile("Test130301", "Shai_Regression_PPV").coguid("file_1" + e); + VodFile file2 = new VodFile("new file type1", "Subscription_only_PPV").coguid("file_2" + e); + + files.add(file1); + files.add(file2); + + generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE, files); + + MediaAsset mediaAsset = insertVod(vodData, true); + mediaAsset.getMediaFiles().forEach(file -> assertThat(file.getDuration()).isEqualTo(1000)); + + // update vod images + e = getEpoch(); + String r = getRandomValue(); + + String coguid1 = "file_1" + e + "_" + r; + String coguid2 = "file_2" + e + "_" + r; + + file1.coguid(coguid1).assetDuration("5"); + file2.coguid(coguid2).assetDuration("5"); + + VodData updateVodData = new VodData() + .assetFiles(files); + List mediaFiles = updateVod(mediaAsset.getExternalId(), updateVodData).getMediaFiles(); + + assertThat(mediaFiles.size()).isEqualTo(4); + +// mediaFiles.forEach(file -> assertThat(file.getDuration()).isEqualTo(5)); +// assertThat(images).extracting("ratio").containsExactlyInAnyOrderElementsOf(ratios); + + // cleanup + deleteVod(movie.getExternalId()); + } + } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java index 8c593c858..8ef147d4f 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java @@ -159,13 +159,13 @@ public class IngestVodOPCUtils extends BaseIngestUtils { public static HashMap booleanHashMap = new HashMap<>(); public static HashMap datesMetaMap = new HashMap<>(); public static HashMap> tagsMetaMap = new HashMap<>(); - public static List movieAssetFiles = new ArrayList<>(); - public static List episodeAssetFiles = new ArrayList<>(); - public static List seriesAssetFiles = new ArrayList<>(); + public static List movieAssetFiles = new ArrayList<>(); + public static List episodeAssetFiles = new ArrayList<>(); + public static List seriesAssetFiles = new ArrayList<>(); public static String tagValue1 = "Jack Nicholson"; public static String tagValue2 = "Natalie Portman"; - public static IngestVodUtils.VodData getVodData(String mediaType, List mediaAssetFiles) { + public static IngestVodUtils.VodData getVodData(String mediaType, List mediaAssetFiles) { switch (mediaType) { case "Movie": return new IngestVodUtils.VodData() @@ -303,26 +303,13 @@ public static String getCoguidOfActiveMediaAsset(int assetType) { return assetListResponse.results.getObjects().get(0).getExternalId(); } - public static VODFile loadFile(String fileType, String coguid, String ppvs) { - return new VODFile() - .assetDuration("1000") - .quality("HIGH") - .handling_type("CLIP") - .cdn_name("Default CDN") - .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .billing_type("Tvinci") - .product_code("productExampleCode") - .type(fileType) - .coguid(coguid) - .ppvModule(ppvs); - } + public static List getAssetFiles(String fileType1, String fileType2, String coguid1, + String coguid2, String ppvs1, String ppvs2) { + List result = new ArrayList<>(); + + VodFile file1 = new VodFile(fileType1, ppvs1).coguid(coguid1); + VodFile file2 = new VodFile(fileType2, ppvs2).coguid(coguid2); - public static List loadAssetFiles(String fileType1, String fileType2, String coguid1, - String coguid2, String ppvs1, String ppvs2) { - List result = new ArrayList<>(); - VODFile file1 = loadFile(fileType1, coguid1, ppvs1); - VODFile file2 = loadFile(fileType2, coguid2, ppvs2); result.add(file1); result.add(file2); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 238c0dee4..86f8537aa 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -8,16 +8,13 @@ import io.restassured.response.Response; import lombok.AccessLevel; import lombok.Data; +import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; import static com.google.common.base.Verify.verify; @@ -25,8 +22,8 @@ import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; +import static com.kaltura.client.test.utils.BaseUtils.getEpoch; import static com.kaltura.client.test.utils.BaseUtils.getOffsetDateInFormat; -import static com.kaltura.client.test.utils.XmlUtils.asList; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; import static org.assertj.core.api.Assertions.assertThat; @@ -35,33 +32,16 @@ public class IngestVodUtils extends BaseIngestUtils { private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult."; + private static final String ingestAssetStatusPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus[0]."; + public static final String ingestStatusMessagePath = ingestDataResultPath + "IngestStatus.Message"; public static final String ingestStatusPath = ingestDataResultPath + "status"; - private static final String ingestAssetStatusPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus[0]."; public static final String ingestAssetStatusMessagePath = ingestAssetStatusPath + "Status.Message"; public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; public static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; public static String ingestXmlRequest = ""; - static boolean areDefaultValuesRequired; - - @Accessors(fluent = true) - @Data - public static class VODFile { - private String assetDuration; - private String quality; - private String handling_type; - private String cdn_name; - private String cdn_code; - private String alt_cdn_code; - private String billing_type; - private String product_code; - private String type; - private String coguid; - private String ppvModule; - } - @Accessors(fluent = true) @Data public static class VodData { @@ -72,6 +52,7 @@ public static class VodData { private String name; private String description; + private String lang; private String thumbUrl; private String catalogStartDate; private String catalogEndDate; @@ -88,13 +69,46 @@ public static class VodData { private Map numbers; private Map booleans; - private List assetFiles; + private List thumbRatios; + private List assetFiles; + } + + @Accessors(fluent = true) + @Getter + public static class VodFile { + private String quality; + private String handling_type; + private String cdn_name; + private String cdn_code; + private String alt_cdn_code; + private String billing_type; + private String product_code; + + @Setter private String coguid; + @Setter private String assetDuration; + @Setter private String type; + @Setter private String ppvModule; + + public VodFile(String type, String ppvModule) { + quality = "HIGH"; + handling_type = "CLIP"; + cdn_name = "Default CDN"; + cdn_code = "http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m"; + alt_cdn_code = "http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m"; + billing_type = "Tvinci"; + product_code = "productExampleCode"; + + assetDuration = "1000"; + coguid = "file_" + getEpoch(); + this.type = type; + this.ppvModule = ppvModule; + } } /** IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" **/ - public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequired) { - IngestVodUtils.areDefaultValuesRequired = areDefaultValuesRequired; + public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { + final String coguidDatePattern = "yyMMddHHmmssSS"; final String datePattern = "dd/MM/yyyy hh:mm:ss"; final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); @@ -103,13 +117,16 @@ public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequ vodData.coguid = getCurrentDateInFormat(coguidDatePattern); - if (areDefaultValuesRequired) { + if (useDefaultValues) { if (vodData.name == null) { vodData.name = vodData.coguid; } if (vodData.description == null) { vodData.description = "description of " + vodData.coguid; } + if (vodData.lang == null) { + vodData.lang = "eng"; + } if (vodData.thumbUrl == null) { vodData.thumbUrl = DEFAULT_THUMB; } @@ -147,7 +164,10 @@ public static MediaAsset insertVod(VodData vodData, boolean areDefaultValuesRequ vodData.ppvMobileName = ppvModuleName; } if (vodData.assetFiles == null) { - vodData.assetFiles = getDefaultAssetFiles(vodData.coguid, vodData.ppvWebName, vodData.ppvMobileName); + vodData.assetFiles = getDefaultAssetFiles(vodData.ppvWebName, vodData.ppvMobileName); + } + if (vodData.thumbRatios == null) { + vodData.thumbRatios = Arrays.asList("4:3", "16:9"); } } @@ -249,7 +269,10 @@ private static String buildIngestVodXml(VodData vodData, String action) { // name if (vodData.name() != null) { Element nameElement = (Element) media.getElementsByTagName("name").item(0); - nameElement.getElementsByTagName("value").item(0).setTextContent(vodData.name()); + Element value = doc.createElement("value"); + value.setAttribute("lang", vodData.lang != null ? vodData.lang : "eng"); + value.setTextContent(vodData.name); + nameElement.appendChild(value); } // thumb @@ -261,7 +284,10 @@ private static String buildIngestVodXml(VodData vodData, String action) { // description if (vodData.description() != null) { Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); - descriptionElement.getElementsByTagName("value").item(0).setTextContent(vodData.description()); + Element value = doc.createElement("value"); + value.setAttribute("lang", vodData.lang != null ? vodData.lang : "eng"); + value.setTextContent(vodData.description); + descriptionElement.appendChild(value); } // dates @@ -280,17 +306,18 @@ private static String buildIngestVodXml(VodData vodData, String action) { } // pic_ratios - Element picRatios = (Element) media.getElementsByTagName("pic_ratios").item(0); - for (Node n : asList(picRatios.getElementsByTagName("ratio"))) { - if (vodData.thumbUrl() != null) { - Element e = (Element) n; - e.setAttribute("thumb", vodData.thumbUrl()); - } + if (vodData.thumbRatios() != null && vodData.thumbRatios().size() > 0) { + Element picRatios = (Element) media.getElementsByTagName("pic_ratios").item(0); + vodData.thumbRatios().forEach(s -> { + Element ratio = doc.createElement("ratio"); + ratio.setAttribute("ratio", s); + ratio.setAttribute("thumb", vodData.thumbUrl() != null ? vodData.thumbUrl() : BaseIngestUtils.DEFAULT_THUMB); + picRatios.appendChild(ratio); + }); } // media type - // it is required for update tests too - if (action.equals(INGEST_ACTION_INSERT) || action.equals(INGEST_ACTION_UPDATE)) { + if (vodData.mediaType() != null) { media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType().getValue()); } @@ -370,7 +397,7 @@ private static String buildIngestVodXml(VodData vodData, String action) { if (vodData.assetFiles != null && vodData.assetFiles.size() > 0) { Element files = (Element) media.getElementsByTagName("files").item(0); - for (VODFile vodFile : vodData.assetFiles) { + for (VodFile vodFile : vodData.assetFiles) { files.appendChild(addFile(doc, vodFile)); } } @@ -383,7 +410,7 @@ private static String buildIngestVodXml(VodData vodData, String action) { return ingestXmlRequest; } - private static Element addFile(Document doc, VODFile vodFile) { + private static Element addFile(Document doc, VodFile vodFile) { // file node Element file = doc.createElement("file"); @@ -488,33 +515,12 @@ private static Map getDefaultDates() { } // TODO: these values should be get in another way than now - private static List getDefaultAssetFiles(String coguid, String ppvModuleName1, String ppvModuleName2) { - List assetFiles = new ArrayList<>(); - - VODFile file1 = new VODFile() - .assetDuration("1000") - .quality("HIGH") - .handling_type("CLIP") - .cdn_name("Default CDN") - .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .billing_type("Tvinci") - .product_code("productExampleCode") - .type("Web HD") - .coguid("web_" + coguid) - .ppvModule(ppvModuleName1); - IngestVodUtils.VODFile file2 = new IngestVodUtils.VODFile() - .assetDuration("1000") - .quality("HIGH") - .handling_type("CLIP") - .cdn_name("Default CDN") - .cdn_code("http://cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .alt_cdn_code("http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m") - .billing_type("Tvinci") - .product_code("productExampleCode") - .type("Mobile_Devices_Main_HD") - .coguid("ipad_" + coguid) - .ppvModule(ppvModuleName2); + private static List getDefaultAssetFiles(String ppvModuleName1, String ppvModuleName2) { + List assetFiles = new ArrayList<>(); + + VodFile file1 = new VodFile("Web HD", ppvModuleName1); + VodFile file2 = new VodFile("Mobile_Devices_Main_HD", ppvModuleName2); + assetFiles.add(file1); assetFiles.add(file2); diff --git a/src/test/resources/ingest_xml_templates/ingestVOD.xml b/src/test/resources/ingest_xml_templates/ingestVOD.xml index 53dec33da..1c048950c 100644 --- a/src/test/resources/ingest_xml_templates/ingestVOD.xml +++ b/src/test/resources/ingest_xml_templates/ingestVOD.xml @@ -12,23 +12,16 @@ - - - + - - - + - - - - + diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index 780562cb0..a6b07ae4a 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -55,7 +55,7 @@ }, "url": { "type": "string", - "minLength": 1 + "minLength": 0 }, "version": { "type": "integer", @@ -63,7 +63,7 @@ }, "id": { "type": "string", - "minLength": 1 + "minLength": 0 }, "isDefault": { "type": "boolean" From 3f123607129698336cb76e08ee7d35afb498e9eb Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 2 Sep 2018 06:04:25 +0300 Subject: [PATCH 504/605] added comments related cleaning process --- .../versions/five_zero_two/IngestVodTests.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index 08744a2ef..0e02e3d74 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -116,6 +116,8 @@ public void insertVodMediaBaseFields() { assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); + + // without cleanup as we have below tests that can delete ingested item } @Severity(SeverityLevel.CRITICAL) @@ -143,6 +145,8 @@ public void insertVodEpisodeBaseFields() { assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); checkFiles(episodeAssetFiles, episode.getId().toString()); + + // without cleanup as we have below tests that can delete ingested item } @Severity(SeverityLevel.CRITICAL) @@ -170,6 +174,7 @@ public void insertVodSeriesBaseFields() { assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); checkFiles(seriesAssetFiles, series.getId().toString()); + // without cleanup as we have below tests that can delete ingested item } @Severity(SeverityLevel.CRITICAL) @@ -319,7 +324,7 @@ public void tryInsertWithEmptyCoguid() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete without coguid", priority =-1 ) + @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete without coguid", priority =-1) public void tryDeleteWithEmptyCoguid() { String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); From f030bec2ba270524cf3130ea5fb8b136d39aedb3 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 2 Sep 2018 09:18:47 +0300 Subject: [PATCH 505/605] Removed useless group from tests Done small refactoring --- .../five_zero_two/IngestVodTests.java | 179 ++++++++---------- .../utils/ingestUtils/IngestVodOPCUtils.java | 30 +++ 2 files changed, 106 insertions(+), 103 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index 0e02e3d74..8bc18e413 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -7,6 +7,7 @@ import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; +import io.qameta.allure.Issue; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import io.restassured.response.Response; @@ -35,6 +36,8 @@ * * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-5428 */ +@Test(groups = { "ingest VOD for OPC" }) +// tag @Test allow to exclude class from testng using it's group name in form public class IngestVodTests extends BaseTest { private MediaAsset movie; @@ -50,7 +53,7 @@ public class IngestVodTests extends BaseTest { private static final String suffix4Coguid = "123"; private static String coguid4NegativeTests = ""; - @BeforeClass(groups = {"ingest VOD for OPC", "opc"}) + @BeforeClass(groups = {"opc"}) public void setUp() { String prefix = "Movie_"; localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); @@ -86,9 +89,8 @@ public void setUp() { seriesType = series.getType(); } - // TODO: remove group "ingest VOD for OPC" if we can exclude class from testng.xml @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, priority =-2, description = "ingest VOD with filled base meta fields") + @Test(groups = {"opc"}, priority =-2, description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { generateDefaultValues4Insert(MOVIE); List movieAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, @@ -121,7 +123,7 @@ public void insertVodMediaBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") + @Test(groups = {"opc"}, description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { generateDefaultValues4Insert(EPISODE); List episodeAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_21" + localCoguid, @@ -150,7 +152,7 @@ public void insertVodEpisodeBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with filled base meta fields") + @Test(groups = {"opc"}, description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { generateDefaultValues4Insert(SERIES); List seriesAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_31" + localCoguid, @@ -178,11 +180,11 @@ public void insertVodSeriesBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD with filled base meta fields") + @Test(groups = {"opc"}, description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { String coguid = getCoguidOfActiveMediaAsset(movieType); generateDefaultValues4Update(true, MOVIE); - IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles); + IngestVodUtils.VodData vodData = getVodData(MOVIE, new ArrayList<>()); MediaAsset asset = updateVod(coguid, vodData); String updateRequest = ingestXmlRequest; @@ -239,7 +241,7 @@ public void updateVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD episode with filled base meta fields") + @Test(groups = {"opc"}, description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { generateDefaultValues4Update(false, EPISODE); IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); @@ -264,7 +266,7 @@ public void updateVodEpisodeBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD series with filled base meta fields") + @Test(groups = {"opc"}, description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { generateDefaultValues4Update(true, SERIES); IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); @@ -289,28 +291,28 @@ public void updateVodSeriesBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "delete") + @Test(groups = {"opc"}, description = "delete") public void deleteMovie() { String coguid = getCoguidOfActiveMediaAsset(movieType); checkVODDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "delete episode") + @Test(groups = {"opc"}, description = "delete episode") public void deleteEpisode() { String coguid = getCoguidOfActiveMediaAsset(episodeType); checkVODDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "delete series") + @Test(groups = {"opc"}, description = "delete series") public void deleteSeries() { String coguid = getCoguidOfActiveMediaAsset(seriesType); checkVODDeletion(coguid); } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert without coguid") + @Test(groups = {"opc"}, description = "try insert without coguid") public void tryInsertWithEmptyCoguid() { String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -324,7 +326,7 @@ public void tryInsertWithEmptyCoguid() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete without coguid", priority =-1) + @Test(groups = {"opc"}, description = "try delete without coguid", priority =-1) public void tryDeleteWithEmptyCoguid() { String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -338,7 +340,7 @@ public void tryDeleteWithEmptyCoguid() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try delete with non-existed coguid") + @Test(groups = {"opc"}, description = "try delete with non-existed coguid") public void tryDeleteWithNonexistedCoguid() { int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); @@ -351,7 +353,7 @@ public void tryDeleteWithNonexistedCoguid() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty entry_id") + @Test(groups = {"opc"}, description = "try insert with empty entry_id") public void tryInsertWithEmptyEntryId() { String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -365,7 +367,7 @@ public void tryInsertWithEmptyEntryId() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert inactive item") + @Test(groups = {"opc"}, description = "try insert inactive item") public void tryInsertInactiveItem() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -381,7 +383,7 @@ public void tryInsertInactiveItem() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty isActive parameter") + @Test(groups = {"opc"}, description = "try insert with empty isActive parameter") public void tryInsertEmptyIsActive() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -390,7 +392,7 @@ public void tryInsertEmptyIsActive() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with empty name", priority =-1) + @Test(groups = {"opc"}, description = "try insert with empty name", priority =-1) public void tryInsertWithEmptyName() { String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -407,7 +409,7 @@ public void tryInsertWithEmptyName() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with invalid credentials") + @Test(groups = {"opc"}, description = "try insert with invalid credentials") public void tryInsertWithInvalidCredentials() { String statusMessage = "Invalid credentials"; String status = "ERROR"; @@ -428,7 +430,7 @@ public void tryInsertWithInvalidCredentials() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "try insert with invalid meta or tag field") + @Test(groups = {"opc"}, description = "try insert with invalid meta or tag field") public void tryInsertWithInvalidMetaOrTagField() { String suffix = "UPDATE654987321"; String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); @@ -455,7 +457,7 @@ public void tryInsertWithInvalidMetaOrTagField() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "insert multilingual fields") + @Test(groups = {"opc"}, description = "insert multilingual fields") public void ingestMultiLingualFields() { // ingested Movie for checking multilanguage final String JAP = "jap"; @@ -515,7 +517,7 @@ public void ingestMultiLingualFields() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with emtpy images and files fields") + @Test(groups = {"opc"}, description = "ingest VOD with emtpy images and files fields") public void insertVodMediaBaseEmptyImagesAndFields() { String suffix = "123"; String ingestXmlWithEmptyFiles = ingestInsertXml @@ -550,7 +552,7 @@ public void insertVodMediaBaseEmptyImagesAndFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "ingest VOD with different Ppv") + @Test(groups = {"opc"}, description = "ingest VOD with different Ppv") public void insertUpdateVodMediaPpv() { generateDefaultValues4Insert(MOVIE); List movieAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, @@ -582,83 +584,8 @@ public void insertUpdateVodMediaPpv() { // TODO: complete } - boolean isTagValueFound(String value2Found, Asset asset) { - Map tags = asset.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - if (value2Found.equals(tagValue.getValue())) { - return true; - } - } - return false; - } - - void validateInvalidMovieField(String ingestXml, String fieldName, String fieldType) { - Response resp = getResponseBodyFromIngestVod(ingestXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)) - .isEqualTo(fieldType + ": " + fieldName + " does not exist for group"); - } - - void checkVODDeletion(String coguid) { - SearchAssetFilter assetFilter = new SearchAssetFilter(); - assetFilter.setKSql("externalId='" + coguid + "'"); - com.kaltura.client.utils.response.base.Response> assetListResponse = - executor.executeSync(list(assetFilter) - .setKs(getAnonymousKs())); - assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); - - deleteVod(coguid); - AssetService.ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); - await() - .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) - .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) - .until(() -> (executor.executeSync(listAssetBuilder).results.getTotalCount() == 0)); - } - - // to check that ingested file data are corresponding to getAsset file data - private void checkFiles(List ingestAssetFiles, String assetId) { - boolean isFileWasFound = false; - - AssetService.GetAssetBuilder assetBuilder = AssetService.get(assetId, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); - com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); - List getMediaFiles = assetGetResponse.results.getMediaFiles(); - - for (VodFile ingestFile: ingestAssetFiles) { - for (MediaFile getFile: getMediaFiles) { - if (getFile.getType().equals(ingestFile.type())) { - isFileWasFound = true; - assertThat(getFile.getDuration().toString()).isEqualTo(ingestFile.assetDuration()); - assertThat(getFile.getUrl()).isEqualTo(ingestFile.cdn_code()); - assertThat(getFile.getAltStreamingCode()).isEqualTo(ingestFile.alt_cdn_code()); - assertThat(getFile.getExternalStoreId()).isEqualTo(ingestFile.product_code()); - assertThat(getFile.getExternalId()).isEqualTo(ingestFile.coguid()); - } - } - } - assertThat(isFileWasFound).isEqualTo(true); - } - - private String getIngestXmlWithoutFiles(String ingestXml) { - return getUpdatedIngestXml(ingestXml, "", "", ""); - } - - String getUpdatedIngestXml(String ingestXml, String openTag2Update, String closeTag2Update, String updateOnString) { - int positionBeginTag = ingestXml.indexOf(openTag2Update); - int positionEndTag; - if ("/>".equals(closeTag2Update)) { - positionEndTag = ingestXml.indexOf(closeTag2Update, positionBeginTag); - } else { - positionEndTag = ingestXml.indexOf(closeTag2Update); - } - - String string2Delete = ingestXml.substring(positionBeginTag, positionEndTag + closeTag2Update.length()); - return ingestXml.replace(string2Delete, updateOnString); - } - @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD images") + @Test(groups = {"opc"}, description = "update VOD images") public void updateImages() { // insert vod generateDefaultValues4Insert(MOVIE); @@ -683,11 +610,12 @@ public void updateImages() { // assertThat(images).extracting("ratio").containsExactlyInAnyOrderElementsOf(ratios); // cleanup - deleteVod(movie.getExternalId()); + deleteVod(mediaAsset.getExternalId()); } + @Issue("BEO-5536") @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"ingest VOD for OPC", "opc"}, description = "update VOD files") + @Test(groups = {"opc"}, description = "update VOD files") public void updateFiles() { List files = new ArrayList<>(); @@ -726,7 +654,52 @@ public void updateFiles() { // assertThat(images).extracting("ratio").containsExactlyInAnyOrderElementsOf(ratios); // cleanup - deleteVod(movie.getExternalId()); + deleteVod(mediaAsset.getExternalId()); + } + + void validateInvalidMovieField(String ingestXml, String fieldName, String fieldType) { + Response resp = getResponseBodyFromIngestVod(ingestXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)) + .isEqualTo(fieldType + ": " + fieldName + " does not exist for group"); + } + + void checkVODDeletion(String coguid) { + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setKSql("externalId='" + coguid + "'"); + com.kaltura.client.utils.response.base.Response> assetListResponse = + executor.executeSync(list(assetFilter) + .setKs(getAnonymousKs())); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); + + deleteVod(coguid); + AssetService.ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> (executor.executeSync(listAssetBuilder).results.getTotalCount() == 0)); } + // to check that ingested file data are corresponding to getAsset file data + private void checkFiles(List ingestAssetFiles, String assetId) { + boolean isFileWasFound = false; + + AssetService.GetAssetBuilder assetBuilder = AssetService.get(assetId, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); + com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); + List getMediaFiles = assetGetResponse.results.getMediaFiles(); + + for (VodFile ingestFile: ingestAssetFiles) { + for (MediaFile getFile: getMediaFiles) { + if (getFile.getType().equals(ingestFile.type())) { + isFileWasFound = true; + assertThat(getFile.getDuration().toString()).isEqualTo(ingestFile.assetDuration()); + assertThat(getFile.getUrl()).isEqualTo(ingestFile.cdn_code()); + assertThat(getFile.getAltStreamingCode()).isEqualTo(ingestFile.alt_cdn_code()); + assertThat(getFile.getExternalStoreId()).isEqualTo(ingestFile.product_code()); + assertThat(getFile.getExternalId()).isEqualTo(ingestFile.coguid()); + } + } + } + assertThat(isFileWasFound).isEqualTo(true); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java index 432629dd8..17a61e824 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.utils.BaseUtils.*; @@ -242,4 +243,33 @@ public static List getAssetFiles(String fileType1, String fileType2, St return result; } + + public static boolean isTagValueFound(String value2Found, Asset asset) { + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + if (value2Found.equals(tagValue.getValue())) { + return true; + } + } + return false; + } + + public static String getIngestXmlWithoutFiles(String ingestXml) { + return getUpdatedIngestXml(ingestXml, "", "", ""); + } + + public static String getUpdatedIngestXml(String ingestXml, String openTag2Update, String closeTag2Update, String updateOnString) { + int positionBeginTag = ingestXml.indexOf(openTag2Update); + int positionEndTag; + if ("/>".equals(closeTag2Update)) { + positionEndTag = ingestXml.indexOf(closeTag2Update, positionBeginTag); + } else { + positionEndTag = ingestXml.indexOf(closeTag2Update); + } + + String string2Delete = ingestXml.substring(positionBeginTag, positionEndTag + closeTag2Update.length()); + return ingestXml.replace(string2Delete, updateOnString); + } } From a45c90258dbaf4888b2cca31ac1ae3483814465a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 2 Sep 2018 10:12:17 +0300 Subject: [PATCH 506/605] returned back proper validation of images in MediaAsset --- src/test/resources/schemas/MediaAsset.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/schemas/MediaAsset.json b/src/test/resources/schemas/MediaAsset.json index a6b07ae4a..780562cb0 100644 --- a/src/test/resources/schemas/MediaAsset.json +++ b/src/test/resources/schemas/MediaAsset.json @@ -55,7 +55,7 @@ }, "url": { "type": "string", - "minLength": 0 + "minLength": 1 }, "version": { "type": "integer", @@ -63,7 +63,7 @@ }, "id": { "type": "string", - "minLength": 0 + "minLength": 1 }, "isDefault": { "type": "boolean" From e20bb43d6254c354eed76e7a2da6ee9919460dc4 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 2 Sep 2018 10:38:11 +0300 Subject: [PATCH 507/605] fixed failed test case --- .../featuresTests/versions/five_zero_two/IngestVodTests.java | 4 +++- .../client/test/utils/ingestUtils/BaseIngestUtils.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index 8bc18e413..76889bf68 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -214,7 +214,9 @@ public void updateVodMediaBaseFields() { // to remove boolean meta from XML .replaceAll("", "") .replaceAll("" + doubleValue + "", "") - .replaceAll("", ""); + .replaceAll("", "") + // to remove thumb + .replaceAll("", ""); Response resp = getResponseBodyFromIngestVod(updateRequest); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 9ee3b667e..f96fbf732 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -44,7 +44,7 @@ public class BaseIngestUtils { public static final String FIVE_MINUTES_PERIOD = "5 Minutes"; // data - static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; + public static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; /* // PG adapter data From 447bde09b4f85de31e790e34868080b424d6aa49 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Sun, 2 Sep 2018 11:02:33 +0300 Subject: [PATCH 508/605] Updated base test class - change paramter from "opc" to "regular" --- src/test/java/com/kaltura/client/test/tests/BaseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 1b9f6645f..30102a397 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -119,7 +119,7 @@ public class BaseTest { @Parameters({"accountType"}) @BeforeSuite(alwaysRun=true) - public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType) { + public void baseTest_beforeSuite(@org.testng.annotations.Optional("regular") String accountType) { Logger.getLogger(BaseTest.class).debug("Start baseTest_beforeSuite"); // set configuration config = new Configuration(); From b1a2ff171446a98a07f0f89f2fcb16c50bf587b9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 2 Sep 2018 11:05:44 +0300 Subject: [PATCH 509/605] no message --- .../five_zero_two/IngestVodTests.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java index 7a8ec3ee0..f4d8e10fe 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java @@ -2,6 +2,7 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.MediaFileService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; @@ -705,23 +706,27 @@ public void updateFiles() { VodData vodData = getVodData(MOVIE, files); MediaAsset mediaAsset = insertVod(vodData, true); - mediaAsset.getMediaFiles().forEach(file -> assertThat(file.getDuration()).isEqualTo(1000)); - // update vod images - e = getEpoch(); - String r = getRandomValue(); - - String coguid1 = "file_1" + e + "_" + r; - String coguid2 = "file_2" + e + "_" + r; - - file1.coguid(coguid1).assetDuration("5"); - file2.coguid(coguid2).assetDuration("5"); - - VodData updateVodData = new VodData() - .assetFiles(files); - List mediaFiles = updateVod(mediaAsset.getExternalId(), updateVodData).getMediaFiles(); - - assertThat(mediaFiles.size()).isEqualTo(4); + MediaFileFilter filter = new MediaFileFilter(); + filter.setAssetIdEqual(mediaAsset.getId()); + executor.executeSync(MediaFileService.list(filter).setKs(getOperatorKs())); +// mediaAsset.getMediaFiles().forEach(file -> assertThat(file.getDuration()).isEqualTo(1000)); +// +// // update vod images +// e = getEpoch(); +// String r = getRandomValue(); +// +// String coguid1 = "file_1" + e + "_" + r; +// String coguid2 = "file_2" + e + "_" + r; +// +// file1.coguid(coguid1).assetDuration("5"); +// file2.coguid(coguid2).assetDuration("5"); +// +// VodData updateVodData = new VodData() +// .assetFiles(files); +// List mediaFiles = updateVod(mediaAsset.getExternalId(), updateVodData).getMediaFiles(); +// +// assertThat(mediaFiles.size()).isEqualTo(4); // mediaFiles.forEach(file -> assertThat(file.getDuration()).isEqualTo(5)); // assertThat(images).extracting("ratio").containsExactlyInAnyOrderElementsOf(ratios); From b0150da307ca14b542c5857613f7a95559a2a22d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 2 Sep 2018 12:16:18 +0300 Subject: [PATCH 510/605] small refactoring done for permission management tests --- .../PermissionsManagementTests.java | 99 +++++++++++-------- 1 file changed, 56 insertions(+), 43 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 337150f31..920323e3f 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -23,9 +23,8 @@ /** * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 + * started in 4_8 and completed in 5_0_3 */ - - public class PermissionsManagementTests { String mainFile = "PermissionsDeployment.exe"; @@ -183,8 +182,10 @@ public void runningDeleteUsingEmptyFile() { @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") public void importFromFile() { String suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, roleName, "partner*", + permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB @@ -194,20 +195,20 @@ public void importFromFile() { executeCommandsInColsole(commands); // check data in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); assertThat(rowsInRolesHavingName).isEqualTo(1); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); - int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions(roleName, 0); assertThat(rowsInPermissionsHavingName).isEqualTo(1); - int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); assertThat(idRolePermission).isEqualTo(1); - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems(permissionItemName); assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); @@ -222,15 +223,19 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { // insert data in DB String suffix = String.valueOf(BaseUtils.getEpoch()) + "inserted"; - PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", + permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, false); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); // generate import file data suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + roleName = "MaxTest" + suffix; + permissionItemName = "Asset_List_Max" + suffix; + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, roleName, "partner*", + permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5, false); // try to import into DB @@ -248,8 +253,10 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") public void deleteFromDB() { String suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, roleName, "partner*", + permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB @@ -259,20 +266,20 @@ public void deleteFromDB() { executeCommandsInColsole(commands); // check data in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); assertThat(rowsInRolesHavingName).isEqualTo(1); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); - int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions(roleName, 0); assertThat(rowsInPermissionsHavingName).isEqualTo(1); - int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); assertThat(idRolePermission).isEqualTo(1); - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems(permissionItemName); assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); @@ -288,13 +295,13 @@ public void deleteFromDB() { executeCommandsInColsole(commands); // DB should be empty - rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); assertThat(rowsInRolesHavingName).isEqualTo(0); - rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions(roleName, 0); assertThat(rowsInPermissionsHavingName).isEqualTo(0); - rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); + rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems(permissionItemName + suffix); assertThat(rowsInPermissionItemsHavingName).isEqualTo(0); } @@ -302,8 +309,10 @@ public void deleteFromDB() { @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") public void importAlreadyExistedFromFile() { String suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; + PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, roleName, "partner*", + permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB @@ -316,20 +325,20 @@ public void importAlreadyExistedFromFile() { executeCommandsInColsole(commands); // check data in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); assertThat(rowsInRolesHavingName).isEqualTo(1); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); - int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions("MaxTest" + suffix, 0); + int rowsInPermissionsHavingName = getCountRowsHavingRoleNameInPermissions(roleName, 0); assertThat(rowsInPermissionsHavingName).isEqualTo(1); - int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions("MaxTest" + suffix, 0); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); int idRolePermission = getCountSpecificRowsFromRolesPermissions(idRoleHavingName, idPermissionHavingName, 0); assertThat(idRolePermission).isEqualTo(1); - int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems("Asset_List_Max" + suffix); + int rowsInPermissionItemsHavingName = getCountRowsHavingNameInPermissionItems(permissionItemName); assertThat(rowsInPermissionItemsHavingName).isEqualTo(1); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems("Asset_List_Max" + suffix); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); @@ -341,10 +350,11 @@ public void importAlreadyExistedFromFile() { public void runningDeleteUsingFileWithInvalidTags() { // insert role in DB String suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); + String roleName = "MaxTest" + suffix; + PermissionsManagementDBUtils.insertRole(roleName); int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); - PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); + PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, roleName, idRoleHavingName); // try delete List commands = new ArrayList<>(); @@ -353,7 +363,7 @@ public void runningDeleteUsingFileWithInvalidTags() { executeCommandsInColsole(commands); // check data still in DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); assertThat(rowsInRolesHavingName).isEqualTo(1); } @@ -362,10 +372,11 @@ public void runningDeleteUsingFileWithInvalidTags() { public void deleteOnlyFromOneTable() { // insert role in DB String suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionsManagementDBUtils.insertRole("MaxTest" + suffix); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles("MaxTest" + suffix, 0); + String roleName = "MaxTest" + suffix; + PermissionsManagementDBUtils.insertRole(roleName); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); - PermissionManagementUtils.generateFileForRole(generatedDataFilePath, "MaxTest" + suffix, idRoleHavingName); + PermissionManagementUtils.generateFileForRole(generatedDataFilePath, roleName, idRoleHavingName); // delete List commands = new ArrayList<>(); @@ -374,7 +385,7 @@ public void deleteOnlyFromOneTable() { executeCommandsInColsole(commands); // check data deleted from DB - int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles("MaxTest" + suffix, 0); + int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); assertThat(rowsInRolesHavingName).isEqualTo(0); } @@ -419,8 +430,10 @@ public void runningExportJson() throws IOException { // prepare data inserting them in DB using stored procedures String suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", + permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, true); // command From ad8e26544e70af7664c0e15133e4ba613e616668 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 2 Sep 2018 15:55:32 +0300 Subject: [PATCH 511/605] Refactoring done for permission management tests. Completed test case for export Json --- .../PermissionsManagementTests.java | 166 +++++++++--------- .../test/utils/PermissionManagementUtils.java | 12 +- 2 files changed, 97 insertions(+), 81 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 920323e3f..464cb0a8d 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -18,6 +18,7 @@ import static com.kaltura.client.test.utils.BaseUtils.deleteFile; import static com.kaltura.client.test.utils.BaseUtils.getFileContent; import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; +import static com.kaltura.client.test.utils.PermissionManagementUtils.getConsoleCommand; import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -36,6 +37,10 @@ public class PermissionsManagementTests { String dataFilePath = path2Util + "333\\" + "exp1.txt"; String path2JsonFolder = path2Util + "333\\JSON\\"; String generatedDataFilePath = path2Util + "333\\" + "import.txt"; + String path2JsonRoles = path2JsonFolder + "roles.json"; + String path2JsonPermissions = path2JsonFolder + "permissions.json"; + String path2JsonMethods = path2JsonFolder + "permission_items\\controllers\\"; + String fullPath2Util = path2Util + mainFile; // these files added into project String importOnly4TablesFilePath; @@ -59,8 +64,7 @@ public void setUp() { @Severity(SeverityLevel.MINOR) @Test(groups = {"Permission management"}, description = "execute console util without parameters") public void runningWithoutParameters() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); + List commands = getConsoleCommand(fullPath2Util, ""); String consoleOutput = executeCommandsInColsole(commands); assertThat(consoleOutput).contains("Permissions deployment tool"); @@ -75,9 +79,7 @@ public void runningWithoutParameters() { @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") public void runningExportWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(EXPORT_KEY); + List commands = getConsoleCommand(fullPath2Util, EXPORT_KEY); String consoleOutput = executeCommandsInColsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); @@ -87,9 +89,7 @@ public void runningExportWithoutFile() { @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") public void runningImportWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY); + List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY); String consoleOutput = executeCommandsInColsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); @@ -99,9 +99,7 @@ public void runningImportWithoutFile() { @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") public void runningDeleteWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY); + List commands = getConsoleCommand(fullPath2Util, DELETE_KEY); String consoleOutput = executeCommandsInColsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); @@ -112,22 +110,30 @@ public void runningDeleteWithoutFile() { public void export() { // prepare data inserting them in DB using stored procedures String suffix = String.valueOf(BaseUtils.getEpoch()); - PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, "MaxTest" + suffix, "partner*", - "Asset_List_Max" + suffix, "asset", "list", "permissionItemObject" + suffix, + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", + permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, false); // export from DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(EXPORT_KEY + dataFilePath); + List commands = getConsoleCommand(fullPath2Util, EXPORT_KEY + dataFilePath); executeCommandsInColsole(commands); // checks that created file contains inserted data String fileContent = getFileContent(dataFilePath); - assertThat(fileContent).contains("MaxTest" + suffix); - assertThat(fileContent).contains("Asset_List_Max" + suffix); + assertThat(fileContent).contains(roleName); + assertThat(fileContent).contains(permissionItemName); assertThat(fileContent).contains("permissionItemObject" + suffix); assertThat(fileContent).contains("parameter" + suffix); + + // cleaning + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); + PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); + PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); + PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); } @Severity(SeverityLevel.MINOR) @@ -137,9 +143,7 @@ public void runningImportFromFileNotHavingAllTables() { deleteFile(path2Log); // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + importOnly4TablesFilePath); + List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + importOnly4TablesFilePath); executeCommandsInColsole(commands); String fileContent = getFileContent(path2Log); @@ -153,9 +157,7 @@ public void runningImportFromEmptyFile() { deleteFile(path2Log); // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + path2EmptyFile); + List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + path2EmptyFile); executeCommandsInColsole(commands); String fileContent = getFileContent(path2Log); @@ -169,9 +171,7 @@ public void runningDeleteUsingEmptyFile() { deleteFile(path2Log); // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + path2EmptyFile); + List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + path2EmptyFile); executeCommandsInColsole(commands); String fileContent = getFileContent(path2Log); @@ -189,9 +189,7 @@ public void importFromFile() { "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + generatedDataFilePath); + List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + generatedDataFilePath); executeCommandsInColsole(commands); // check data in DB @@ -213,11 +211,17 @@ public void importFromFile() { int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); assertThat(rowsInPermissionsPermissions).isEqualTo(1); + + // cleaning + PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); + PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); + PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); } @Severity(SeverityLevel.NORMAL) @Test(groups = {"Permission management"}, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { + // TODO: update test // remove log file deleteFile(path2Log); @@ -239,14 +243,19 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { "parameter" + suffix, 1, 2, 3, 4, 5, false); // try to import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + path2EmptyFile); + List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + path2EmptyFile); String outputInConsole = executeCommandsInColsole(commands); String fileContent = getFileContent(path2Log); assertThat(fileContent).contains("ex = System.Xml.XmlException: Root element is missing"); assertThat(outputInConsole).contains("ex = System.Xml.XmlException: Root element is missing"); + + // cleaning +// PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); +// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); +// PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); +// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); +// PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); } @Severity(SeverityLevel.CRITICAL) @@ -260,9 +269,7 @@ public void deleteFromDB() { "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + generatedDataFilePath); + List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + generatedDataFilePath); executeCommandsInColsole(commands); // check data in DB @@ -289,9 +296,7 @@ public void deleteFromDB() { deleteFile(path2Log); // delete from DB - commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + generatedDataFilePath); + commands = getConsoleCommand(fullPath2Util, DELETE_KEY + generatedDataFilePath); executeCommandsInColsole(commands); // DB should be empty @@ -316,9 +321,7 @@ public void importAlreadyExistedFromFile() { "parameter" + suffix, 1, 2, 3, 4, 5, false); // import into DB - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_KEY + generatedDataFilePath); + List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + generatedDataFilePath); executeCommandsInColsole(commands); // retry import @@ -343,6 +346,11 @@ public void importAlreadyExistedFromFile() { int rowsInPermissionsPermissions = getCountSpecificRowsFromPermissionsPermissionsItems(idPermissionHavingName, idPermissionItemHavingName, 0); assertThat(rowsInPermissionsPermissions).isEqualTo(1); + + // cleaning + PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); + PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); + PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); } @Severity(SeverityLevel.NORMAL) @@ -357,9 +365,7 @@ public void runningDeleteUsingFileWithInvalidTags() { PermissionManagementUtils.generateFileWithInvalidTagForRole(generatedDataFilePath, roleName, idRoleHavingName); // try delete - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + generatedDataFilePath); + List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + generatedDataFilePath); executeCommandsInColsole(commands); // check data still in DB @@ -379,9 +385,7 @@ public void deleteOnlyFromOneTable() { PermissionManagementUtils.generateFileForRole(generatedDataFilePath, roleName, idRoleHavingName); // delete - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(DELETE_KEY + generatedDataFilePath); + List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + generatedDataFilePath); executeCommandsInColsole(commands); // check data deleted from DB @@ -393,9 +397,7 @@ public void deleteOnlyFromOneTable() { @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to export in JSON without mentioned file") public void runningExportJsonWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(EXPORT_JSON_KEY); + List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY); String consoleOutput = executeCommandsInColsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); @@ -405,26 +407,15 @@ public void runningExportJsonWithoutFile() { @Issue("BEO-5504") @Test(groups = {"Permission management"}, description = "execute console util to import in JSON without mentioned file") public void runningImportJsonWithoutFile() { - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(IMPORT_JSON_KEY); + List commands = getConsoleCommand(fullPath2Util, IMPORT_JSON_KEY); String consoleOutput = executeCommandsInColsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); } - /* - - // export from DB - // checks that created file contains inserted data - String fileContent = getFileContent(dataFilePath); - assertThat(fileContent).contains("MaxTest" + suffix); - assertThat(fileContent).contains("Asset_List_Max" + suffix); - assertThat(fileContent).contains("permissionItemObject" + suffix); - assertThat(fileContent).contains("parameter" + suffix);*/ @Severity(SeverityLevel.CRITICAL) @Test(groups = {"Permission management"}, description = "execute console util to export in JSON from DB") - public void runningExportJson() throws IOException { + public void exportJson() throws IOException { // clean folder with logs FileUtils.cleanDirectory(new File(path2JsonFolder)); @@ -432,27 +423,44 @@ public void runningExportJson() throws IOException { String suffix = String.valueOf(BaseUtils.getEpoch()); String roleName = "MaxTest" + suffix; String permissionItemName = "Asset_List_Max" + suffix; + String serviceName = "asset"; PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", - permissionItemName, "asset", "list", "permissionItemObject" + suffix, + permissionItemName, serviceName, "list", "permissionItemObject" + suffix, "parameter" + suffix, true); - // command - List commands = new ArrayList<>(); - commands.add(path2Util + mainFile); - commands.add(EXPORT_JSON_KEY + path2JsonFolder); + List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); String consoleOutput = executeCommandsInColsole(commands); - String fileContent = getFileContent(generatedDataFilePath); - System.out.println("FILE: " + fileContent); + String importFileContent = getFileContent(generatedDataFilePath); + assertThat(importFileContent).contains(roleName); + assertThat(importFileContent).contains(permissionItemName); + checkActionResult(serviceName, importFileContent); + // cleaning + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); + PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); + PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); + PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); + } - - //assertThat(consoleOutput).contains("The system cannot find the file specified"); - // TODO: add assertions - -// List commands = new ArrayList<>(); -// commands.add(path2Util + mainFile); -// commands.add(IMPORT_JSON_KEY + path2JsonFolder); -// String consoleOutput = executeCommandsInColsole(commands); + void checkActionResult(String serviceName, String importFileContent) { + // data prepared so that they splitted by symbol ";" + String[] results = importFileContent.split(";"); + String contentOfJsonFile = getFileContent(path2JsonRoles) + .replaceAll(" ", ""); + //.replaceAll("\\t", ""); + assertThat(contentOfJsonFile).contains(results[0] + .replaceAll(" ", "")); + contentOfJsonFile = getFileContent(path2JsonPermissions) + .replaceAll(" ", ""); + //.replaceAll("\\t", ""); + assertThat(contentOfJsonFile).contains(results[1] + .replaceAll(" ", "")); + contentOfJsonFile = getFileContent(path2JsonMethods + serviceName + ".json") + .replaceAll(" ", ""); + //.replaceAll("\\t", ""); + assertThat(contentOfJsonFile).contains(results[2].replaceAll(" ", "")); } } diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index 51adc63b5..baaefe363 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -3,6 +3,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import java.io.*; +import java.util.ArrayList; import java.util.List; public class PermissionManagementUtils extends BaseUtils { @@ -110,10 +111,10 @@ public static void generateFileWithInsertedIntoDBData(String path2ResultFile, St if (isJson) { printRolesFormat(writer, role); // to separate - printRolesFormat(writer, ";"); + writer.println(";"); printPermissionsFormat(writer, role, usersGroup); // to separate - printRolesFormat(writer, ";"); + writer.println(";"); printServiceFormat(writer, role, permissionItemName, service, action); } else { // XML @@ -198,5 +199,12 @@ public static void generateFileForRole(String path2ResultFile, String roleName, e.printStackTrace(); } } + + public static List getConsoleCommand(String path2Util, String parameters) { + List commands = new ArrayList<>(); + commands.add(path2Util); + commands.add(parameters); + return commands; + } } From 57ffc631173cc43227149a105a40ad0c2ad3814e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 3 Sep 2018 16:38:29 +0300 Subject: [PATCH 512/605] change testng xml's --- pom.xml | 1 + .../kaltura/client/test/tests/BaseTest.java | 11 +- ...stVodTests.java => IngestVodOpcTests.java} | 160 +++++++++--------- .../test/utils/dbUtils/DBConstants.java | 4 + .../client/test/utils/dbUtils/DBUtils.java | 38 ++++- .../utils/ingestUtils/IngestVodOPCUtils.java | 9 +- src/test/resources/AllSuitesTestng.xml | 8 - src/test/resources/testng.xml | 40 +---- .../{testngopc.xml => testng_opc.xml} | 0 src/test/resources/testng_regular.xml | 36 ++++ 10 files changed, 175 insertions(+), 132 deletions(-) rename src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/{IngestVodTests.java => IngestVodOpcTests.java} (86%) delete mode 100644 src/test/resources/AllSuitesTestng.xml rename src/test/resources/{testngopc.xml => testng_opc.xml} (100%) create mode 100644 src/test/resources/testng_regular.xml diff --git a/pom.xml b/pom.xml index 256f236a7..d4ba530dc 100644 --- a/pom.xml +++ b/pom.xml @@ -287,6 +287,7 @@ src\test\resources\testng.xml + ${project.basedir}/target false diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 1b9f6645f..269af7a5e 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -11,15 +11,15 @@ import com.kaltura.client.types.*; import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; +import org.apache.commons.io.FileUtils; import org.testng.annotations.*; -import java.lang.reflect.Method; -import java.util.*; -import java.util.Optional; -import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; import java.nio.file.Files; +import java.util.*; +import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.google.common.base.Verify.verify; @@ -121,6 +121,7 @@ public class BaseTest { @BeforeSuite(alwaysRun=true) public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType) { Logger.getLogger(BaseTest.class).debug("Start baseTest_beforeSuite"); + // set configuration config = new Configuration(); config.setEndpoint(getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION)); @@ -141,7 +142,7 @@ public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String isOpcGroup = false; partnerId = Integer.parseInt(getProperty(PARTNER_ID)); } - //opcPartnerId = Integer.parseInt(getProperty(OPC_PARTNER_ID)); + defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); // set performance report diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java similarity index 86% rename from src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java rename to src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 1820d2ff5..91679ffd1 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -2,10 +2,10 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.MediaFileService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import io.qameta.allure.Issue; @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.services.AssetService.list; @@ -37,9 +38,9 @@ * * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-5428 */ -@Test(groups = { "ingest VOD for OPC" }) +@Test(groups = { "opc", "ingest VOD for OPC" }) // tag @Test allow to exclude class from testng using it's group name in form -public class IngestVodTests extends BaseTest { +public class IngestVodOpcTests extends BaseTest { private MediaAsset movie; private MediaAsset episode; @@ -54,15 +55,20 @@ public class IngestVodTests extends BaseTest { private static final String suffix4Coguid = "123"; private static String coguid4NegativeTests = ""; - @BeforeClass(groups = {"opc"}) + private static List fileTypeNames; + private static List ppvNames; + + @BeforeClass() public void setUp() { + fileTypeNames = DBUtils.getMediaFileTypeNames(2); + ppvNames = DBUtils.getPpvNames(2); + String prefix = "Movie_"; localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); name = prefix + "Name_" + localCoguid; description = prefix + "Description_" + localCoguid; - movieAssetFiles = getAssetFiles("Test130301", "new file type1", "Test130301_1" + localCoguid, - "new file type1_1" + localCoguid, "Shai_Regression_PPV", "Subscription_only_PPV"); + movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData; generateDefaultValues4Insert(MOVIE); @@ -75,15 +81,13 @@ public void setUp() { ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); ingestDeleteXml = DELETE_VOD_XML.replaceAll("180822092522774", movie.getExternalId()); - episodeAssetFiles = getAssetFiles("Test130301", "new file type1", "Test130301_2" + localCoguid, - "new file type1_2" + localCoguid, "Shai_Regression_PPV", "Subscription_only_PPV"); + episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1));; generateDefaultValues4Insert(EPISODE); vodData = getVodData(EPISODE, episodeAssetFiles); episode = insertVod(vodData, true); episodeType = episode.getType(); - seriesAssetFiles = getAssetFiles("Test130301", "new file type1", "Test130301_3" + localCoguid, - "new file type1_3" + localCoguid, "Shai_Regression_PPV", "Subscription_only_PPV"); + seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1));; generateDefaultValues4Insert(SERIES); vodData = getVodData(SERIES, seriesAssetFiles); series = insertVod(vodData, true); @@ -91,11 +95,10 @@ public void setUp() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, priority =-2, description = "ingest VOD with filled base meta fields") + @Test(priority =-2, description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, - "new file type1_11" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); + List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(MOVIE, movieAssetFiles); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; @@ -124,11 +127,10 @@ public void insertVodMediaBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "ingest VOD with filled base meta fields") + @Test(description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { generateDefaultValues4Insert(EPISODE); - List episodeAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_21" + localCoguid, - "new file type1_21" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); + List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(EPISODE, episodeAssetFiles); MediaAsset episode = insertVod(vodData, true); @@ -153,11 +155,10 @@ public void insertVodEpisodeBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "ingest VOD with filled base meta fields") + @Test(description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { generateDefaultValues4Insert(SERIES); - List seriesAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_31" + localCoguid, - "new file type1_31" + localCoguid,"Shai_Regression_PPV", "Subscription_only_PPV"); + List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(SERIES, seriesAssetFiles); MediaAsset series = insertVod(vodData, true); @@ -181,7 +182,7 @@ public void insertVodSeriesBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "update VOD with filled base meta fields") + @Test(description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { String coguid = getCoguidOfActiveMediaAsset(movieType); generateDefaultValues4Update(true, MOVIE); @@ -242,7 +243,7 @@ public void updateVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "update VOD episode with filled base meta fields") + @Test(description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { generateDefaultValues4Update(false, EPISODE); IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); @@ -267,7 +268,7 @@ public void updateVodEpisodeBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "update VOD series with filled base meta fields") + @Test(description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { generateDefaultValues4Update(true, SERIES); IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); @@ -292,28 +293,28 @@ public void updateVodSeriesBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "delete") + @Test(description = "delete") public void deleteMovie() { String coguid = getCoguidOfActiveMediaAsset(movieType); checkVODDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "delete episode") + @Test(description = "delete episode") public void deleteEpisode() { String coguid = getCoguidOfActiveMediaAsset(episodeType); checkVODDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "delete series") + @Test(description = "delete series") public void deleteSeries() { String coguid = getCoguidOfActiveMediaAsset(seriesType); checkVODDeletion(coguid); } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"opc"}, description = "try insert without coguid") + @Test(description = "try insert without coguid") public void tryInsertWithEmptyCoguid() { String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -327,7 +328,7 @@ public void tryInsertWithEmptyCoguid() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"opc"}, description = "try delete without coguid", priority =-1) + @Test(description = "try delete without coguid", priority =-1) public void tryDeleteWithEmptyCoguid() { String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -341,7 +342,7 @@ public void tryDeleteWithEmptyCoguid() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"opc"}, description = "try delete with non-existed coguid") + @Test(description = "try delete with non-existed coguid") public void tryDeleteWithNonexistedCoguid() { int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); @@ -354,7 +355,7 @@ public void tryDeleteWithNonexistedCoguid() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"opc"}, description = "try insert with empty entry_id") + @Test(description = "try insert with empty entry_id") public void tryInsertWithEmptyEntryId() { String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -368,7 +369,7 @@ public void tryInsertWithEmptyEntryId() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"opc"}, description = "try insert inactive item") + @Test(description = "try insert inactive item") public void tryInsertInactiveItem() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -384,16 +385,16 @@ public void tryInsertInactiveItem() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"opc"}, description = "try insert with empty isActive parameter") + @Test(description = "try insert with empty isActive parameter") public void tryInsertEmptyIsActive() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); } @Severity(SeverityLevel.MINOR) - @Test(groups = {"opc"}, description = "try insert with empty name", priority =-1) + @Test(description = "try insert with empty name", priority =-1) public void tryInsertWithEmptyName() { String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -410,8 +411,8 @@ public void tryInsertWithEmptyName() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"opc"}, description = "try insert with invalid credentials") - public void tryInsertWithInvalidCredentials() { + @Test(description = "try insert with invalid credentials") + public void insertWithInvalidCredentials() { String statusMessage = "Invalid credentials"; String status = "ERROR"; @@ -431,8 +432,8 @@ public void tryInsertWithInvalidCredentials() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"opc"}, description = "try insert with invalid meta or tag field") - public void tryInsertWithInvalidMetaOrTagField() { + @Test(description = "try insert with invalid meta or tag field") + public void insertWithInvalidMetaOrTagField() { String suffix = "UPDATE654987321"; String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); @@ -458,7 +459,7 @@ public void tryInsertWithInvalidMetaOrTagField() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"opc"}, description = "insert multilingual fields") + @Test(description = "insert multilingual fields") public void ingestMultiLingualFields() { // ingested Movie for checking multilanguage final String JAP = "jap"; @@ -518,7 +519,7 @@ public void ingestMultiLingualFields() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"opc"}, description = "ingest VOD with emtpy images and files fields") + @Test(description = "ingest VOD with emtpy images and files fields") public void insertVodMediaBaseEmptyImagesAndFields() { String suffix = "123"; String ingestXmlWithEmptyFiles = ingestInsertXml @@ -553,11 +554,10 @@ public void insertVodMediaBaseEmptyImagesAndFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "ingest VOD with different Ppv") + @Test(description = "ingest VOD with different Ppv") public void insertUpdateVodMediaPpv() { generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = getAssetFiles("Test130301","new file type1", "Test130301_11" + localCoguid, - "new file type1_11" + localCoguid,"Shai_Regression_PPV;Subscription_only_PPV", "Subscription_only_PPV"); + List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(MOVIE, movieAssetFiles); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; @@ -586,29 +586,38 @@ public void insertUpdateVodMediaPpv() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "update VOD images") + @Test(description = "update VOD images") public void updateImages() { // insert vod generateDefaultValues4Insert(MOVIE); VodData vodData = getVodData(MOVIE, movieAssetFiles); MediaAsset mediaAsset = insertVod(vodData, true); - // update vod images - List ratios = Arrays.asList("1:1", "2:1", "2:3"); + // get list of original images + List originalImages = mediaAsset.getImages(); + assertThat(originalImages.size()).isEqualTo(3); + + // update vod images - enter 2 new images + List newRatios = Arrays.asList("2:1", "2:3"); String fakeImageUrl = "https://picsum.photos/200/300/?random"; VodData updateVodData = new VodData() .thumbUrl(fakeImageUrl) - .thumbRatios(ratios); + .thumbRatios(newRatios); mediaAsset = updateVod(mediaAsset.getExternalId(), updateVodData); // assert update List images = mediaAsset.getImages(); + assertThat(images.size()).isEqualTo(5); - assertThat(images.size()).isEqualTo(6); + List newImages = images.stream() + .filter(image -> originalImages.stream() + .map(MediaImage::getRatio) + .noneMatch(s1 -> s1.equals(image.getRatio()))) + .collect(Collectors.toList()); -// images.forEach(image -> assertThat(image.getUrl()).isEqualTo(fakeImageUrl)); -// assertThat(images).extracting("ratio").containsExactlyInAnyOrderElementsOf(ratios); + newImages.forEach(image -> assertThat(image.getUrl()).isNotEmpty()); + assertThat(newImages).extracting("ratio").containsExactlyInAnyOrderElementsOf(newRatios); // cleanup deleteVod(mediaAsset.getExternalId()); @@ -616,47 +625,34 @@ public void updateImages() { @Issue("BEO-5536") @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"opc"}, description = "update VOD files") + @Test(description = "update VOD files", enabled = false) public void updateFiles() { - List files = new ArrayList<>(); - // insert vod - // TODO: 8/30/2018 remove hardcoded values - long e = getEpoch(); - VodFile file1 = new VodFile("Test130301", "Shai_Regression_PPV").coguid("file_1" + e); - VodFile file2 = new VodFile("new file type1", "Subscription_only_PPV").coguid("file_2" + e); - - files.add(file1); - files.add(file2); + List files = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); generateDefaultValues4Insert(MOVIE); VodData vodData = getVodData(MOVIE, files); MediaAsset mediaAsset = insertVod(vodData, true); - MediaFileFilter filter = new MediaFileFilter(); - filter.setAssetIdEqual(mediaAsset.getId()); - executor.executeSync(MediaFileService.list(filter).setKs(getOperatorKs())); -// mediaAsset.getMediaFiles().forEach(file -> assertThat(file.getDuration()).isEqualTo(1000)); -// -// // update vod images -// e = getEpoch(); -// String r = getRandomValue(); -// -// String coguid1 = "file_1" + e + "_" + r; -// String coguid2 = "file_2" + e + "_" + r; -// -// file1.coguid(coguid1).assetDuration("5"); -// file2.coguid(coguid2).assetDuration("5"); -// -// VodData updateVodData = new VodData() -// .assetFiles(files); -// List mediaFiles = updateVod(mediaAsset.getExternalId(), updateVodData).getMediaFiles(); -// -// assertThat(mediaFiles.size()).isEqualTo(4); - -// mediaFiles.forEach(file -> assertThat(file.getDuration()).isEqualTo(5)); -// assertThat(images).extracting("ratio").containsExactlyInAnyOrderElementsOf(ratios); + // update vod images + long e = getEpoch(); + String r = getRandomValue(); + + String coguid1 = "file_1_" + e + "_" + r; + String coguid2 = "file_2_" + e + "_" + r; + + files.get(0).coguid(coguid1).assetDuration("5"); + files.get(1).coguid(coguid2).assetDuration("5"); + + VodData updateVodData = new VodData() + .assetFiles(files); + List mediaFiles = updateVod(mediaAsset.getExternalId(), updateVodData).getMediaFiles(); + + // assert update + assertThat(mediaFiles.size()).isEqualTo(2); + mediaFiles.forEach(file -> assertThat(file.getDuration()).isEqualTo(5)); + assertThat(mediaFiles).extracting("externalId").containsExactlyInAnyOrder(coguid1, coguid2); // cleanup deleteVod(mediaAsset.getExternalId()); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 595ed10d7..c7ea5bfe8 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -236,8 +236,12 @@ public class DBConstants { static final String MEDIA_FILE_TYPE_ID_SELECT = "SELECT [NAME] FROM [TVinci].[dbo].[groups_media_type] where GROUP_ID = ? and ID = ?"; + static final String MEDIA_FILE_TYPE_IDS_SELECT = "SELECT top (?) [NAME] FROM [TVinci].[dbo].[groups_media_type] where GROUP_ID = ? and status = 1 and IS_ACTIVE = 1 and DESCRIPTION <> ''"; + static final String RESULT_MESSAGE_ID_SELECT = "SELECT result_message_id FROM [MessageBox].[dbo].[message_announcements] WHERE group_id = ? AND ID = ?"; + static final String PPV_NAME_AND_ID_SELECT = "select top (?) ID, NAME FROM [Pricing].[dbo].[ppv_modules] where group_id= ? and STATUS = 1 and IS_ACTIVE = 1"; + // STORED PROCEDURES: static final String SP_INSERT_PERMISSION = "{call TVinci.dbo.__482V0__Insert_Permission(?, ?, ?, ?)}"; static final String SP_INSERT_PERMISSION_ITEM = "{call TVinci.dbo.__482V0__Insert_PermissionItem(?, ?, ?, ?, ?, ?)}"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 665059ce0..8ca1ae328 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -16,9 +16,13 @@ import org.json.JSONException; import org.json.JSONObject; +import javax.annotation.Nonnull; import java.sql.*; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; @@ -28,11 +32,16 @@ public class DBUtils extends BaseUtils { - static final String ERROR_MESSAGE = "*** no data found ***"; + private static final String ERROR_MESSAGE = "*** no data found ***"; private static boolean isActivationNeeded = false; private static boolean isActivationNeededWasLoaded = false; + @Nonnull + private static Stream arrayToStream(JSONArray array) { + return StreamSupport.stream(array.spliterator(), false); + } + private static JSONArray buildJsonArrayFromQueryResult(ResultSet rs) throws SQLException { JSONArray jsonArray = new JSONArray(); ResultSetMetaData rsmd = rs.getMetaData(); @@ -270,6 +279,24 @@ public static String getMediaFileTypeName(int mediaFileId) { .getString("name"); } + public static List getMediaFileTypeNames(int amount) { + if (isOpcGroup) { + JSONArray jsonArray = getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_IDS_SELECT, amount, partnerId); + + return arrayToStream(jsonArray) + .map(JSONObject.class::cast) + .map(jsonObject -> jsonObject.getString("name")) + .collect(Collectors.toList()); + } else { + JSONArray jsonArray = getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_IDS_SELECT, amount, partnerId + 1); + + return arrayToStream(jsonArray) + .map(JSONObject.class::cast) + .map(jsonObject -> jsonObject.getString("name")) + .collect(Collectors.toList()); + } + } + public static List getAnnouncementResultMessageId(int announcementId) { List ids = null; @@ -283,4 +310,13 @@ public static List getAnnouncementResultMessageId(int announcementId) { return ids; } + + public static List getPpvNames(int amount) { + JSONArray jsonArray = getJsonArrayFromQueryResult(PPV_NAME_AND_ID_SELECT, amount, partnerId); + + return arrayToStream(jsonArray) + .map(JSONObject.class::cast) + .map(jsonObject -> jsonObject.getString("name")) + .collect(Collectors.toList()); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java index 17a61e824..d76528715 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java @@ -231,10 +231,15 @@ public static String getCoguidOfActiveMediaAsset(int assetType) { return assetListResponse.results.getObjects().get(0).getExternalId(); } - public static List getAssetFiles(String fileType1, String fileType2, String coguid1, - String coguid2, String ppvs1, String ppvs2) { + public static List get2AssetFiles(String fileType1, String fileType2, String ppvs1, String ppvs2) { List result = new ArrayList<>(); + long e = getEpoch(); + String r = getRandomValue(); + + String coguid1 = "file_1_" + e + "_" + r; + String coguid2 = "file_2_" + e + "_" + r; + VodFile file1 = new VodFile(fileType1, ppvs1).coguid(coguid1); VodFile file2 = new VodFile(fileType2, ppvs2).coguid(coguid2); diff --git a/src/test/resources/AllSuitesTestng.xml b/src/test/resources/AllSuitesTestng.xml deleted file mode 100644 index 846a9c9f8..000000000 --- a/src/test/resources/AllSuitesTestng.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 2adb1885d..2afc1f802 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,36 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + \ No newline at end of file diff --git a/src/test/resources/testngopc.xml b/src/test/resources/testng_opc.xml similarity index 100% rename from src/test/resources/testngopc.xml rename to src/test/resources/testng_opc.xml diff --git a/src/test/resources/testng_regular.xml b/src/test/resources/testng_regular.xml new file mode 100644 index 000000000..2adb1885d --- /dev/null +++ b/src/test/resources/testng_regular.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5ad1a345981676fb357d4829bd3ecb519d764129 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 3 Sep 2018 17:29:52 +0300 Subject: [PATCH 513/605] no message --- .../five_zero_two/IngestVodOpcTests.java | 24 +++++++++---------- .../utils/ingestUtils/IngestVodUtils.java | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 3da4f2326..1dd924708 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -95,7 +95,7 @@ public void setUp() { } @Severity(SeverityLevel.CRITICAL) - @Test(priority =-2, description = "ingest VOD with filled base meta fields") + @Test(description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { generateDefaultValues4Insert(MOVIE); List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); @@ -317,7 +317,7 @@ public void deleteSeries() { @Severity(SeverityLevel.NORMAL) @Test(description = "try insert without coguid") - public void tryInsertWithEmptyCoguid() { + public void insertWithEmptyCoguid() { String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -331,7 +331,7 @@ public void tryInsertWithEmptyCoguid() { @Severity(SeverityLevel.NORMAL) @Test(description = "try delete without coguid", priority =-1) - public void tryDeleteWithEmptyCoguid() { + public void deleteWithEmptyCoguid() { String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -345,7 +345,7 @@ public void tryDeleteWithEmptyCoguid() { @Severity(SeverityLevel.NORMAL) @Test(description = "try delete with non-existed coguid") - public void tryDeleteWithNonexistedCoguid() { + public void deleteWithNonExistedCoguid() { int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); int positionEndOfCoguid = ingestDeleteXml.indexOf("\"", positionBeginOfCoguid + 1); @@ -358,7 +358,7 @@ public void tryDeleteWithNonexistedCoguid() { @Severity(SeverityLevel.MINOR) @Test(description = "try insert with empty entry_id") - public void tryInsertWithEmptyEntryId() { + public void insertWithEmptyEntryId() { String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -372,7 +372,7 @@ public void tryInsertWithEmptyEntryId() { @Severity(SeverityLevel.MINOR) @Test(description = "try insert inactive item") - public void tryInsertInactiveItem() { + public void insertInactiveItem() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -388,7 +388,7 @@ public void tryInsertInactiveItem() { @Severity(SeverityLevel.MINOR) @Test(description = "try insert with empty isActive parameter") - public void tryInsertEmptyIsActive() { + public void insertEmptyIsActive() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -397,7 +397,7 @@ public void tryInsertEmptyIsActive() { @Severity(SeverityLevel.MINOR) @Test(description = "try insert with empty name", priority =-1) - public void tryInsertWithEmptyName() { + public void insertWithEmptyName() { String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -462,7 +462,7 @@ public void insertWithInvalidMetaOrTagField() { @Severity(SeverityLevel.NORMAL) @Test(description = "insert multilingual fields") - public void ingestMultiLingualFields() { + public void insertMultiLingualFields() { // ingested Movie for checking multilanguage final String JAP = "jap"; final String ENG = "eng"; @@ -557,7 +557,7 @@ public void insertVodMediaBaseEmptyImagesAndFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with different Ppv") - public void insertUpdateVodMediaPpv() { + public void updateVodMediaPpv() { generateDefaultValues4Insert(MOVIE); List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(MOVIE, movieAssetFiles); @@ -568,7 +568,7 @@ public void insertUpdateVodMediaPpv() { assertThat(movie.getDescription()).isEqualTo(description); checkFiles(movieAssetFiles, movie.getId().toString()); - Household household = HouseholdUtils.createHousehold(1, 1, true); + Household household = HouseholdUtils.createHousehold(); String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); @@ -627,7 +627,7 @@ public void updateImages() { @Issue("BEO-5536") @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD files", enabled = false) + @Test(description = "update VOD files") public void updateFiles() { // insert vod List files = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 86f8537aa..0dfb26f9b 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -106,7 +106,6 @@ public VodFile(String type, String ppvModule) { } /** IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" **/ - public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { final String coguidDatePattern = "yyMMddHHmmssSS"; From b49f95b5976411de9decc7299197405ddd1ce947 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 4 Sep 2018 11:47:39 +0300 Subject: [PATCH 514/605] diable testng for Jenkins test --- .../five_zero_two/IngestVodOpcTests.java | 1071 ++++++++--------- src/test/resources/testng_regular.xml | 54 +- 2 files changed, 558 insertions(+), 567 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 1dd924708..05f9eb418 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -2,11 +2,8 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import io.qameta.allure.Issue; import io.qameta.allure.Severity; @@ -15,14 +12,9 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.*; @@ -30,7 +22,6 @@ import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.maxTimeExpectingValidResponseInSeconds; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static io.restassured.path.xml.XmlPath.from; -import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -94,536 +85,536 @@ public void setUp() { seriesType = series.getType(); } - @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with filled base meta fields") - public void insertVodMediaBaseFields() { - generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles); - MediaAsset movie = insertVod(vodData, true); - String ingestRequest = ingestXmlRequest; - - assertThat(movie.getName()).isEqualTo(name); - assertThat(movie.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = movie.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - - checkFiles(movieAssetFiles, movie.getId().toString()); - - assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); - assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); - - // without cleanup as we have below tests that can delete ingested item - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with filled base meta fields") - public void insertVodEpisodeBaseFields() { - generateDefaultValues4Insert(EPISODE); - List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(EPISODE, episodeAssetFiles); - MediaAsset episode = insertVod(vodData, true); - - assertThat(episode.getName()).isEqualTo(name); - assertThat(episode.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = episode.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - - checkFiles(episodeAssetFiles, episode.getId().toString()); - - // without cleanup as we have below tests that can delete ingested item - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with filled base meta fields") - public void insertVodSeriesBaseFields() { - generateDefaultValues4Insert(SERIES); - List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(SERIES, seriesAssetFiles); - MediaAsset series = insertVod(vodData, true); - - assertThat(series.getName()).isEqualTo(name); - assertThat(series.getDescription()).isEqualTo(description); - assertThat(((StringValue)series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = series.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - - checkFiles(seriesAssetFiles, series.getId().toString()); - // without cleanup as we have below tests that can delete ingested item - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD with filled base meta fields") - public void updateVodMediaBaseFields() { - String coguid = getCoguidOfActiveMediaAsset(movieType); - generateDefaultValues4Update(true, MOVIE); - IngestVodUtils.VodData vodData = getVodData(MOVIE, new ArrayList<>()); - - MediaAsset asset = updateVod(coguid, vodData); - String updateRequest = ingestXmlRequest; - - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = asset.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - - // check update with erase="true" - updateRequest = updateRequest - .replaceAll("erase=\"false\"", "erase=\"true\"") - // to remove description from XML - .replaceAll("", "") - .replaceAll("" + description + "", "") - .replaceAll("", "") - // to remove boolean meta from XML - .replaceAll("", "") - .replaceAll("" + doubleValue + "", "") - .replaceAll("", "") - // to remove thumb - .replaceAll("", ""); - Response resp = getResponseBodyFromIngestVod(updateRequest); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); - - AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(movie.getId()), AssetReferenceType.MEDIA) - .setKs(getAnonymousKs()); - com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); - MediaAsset asset2 = (MediaAsset)assetGetResponse.results; - assertThat(asset2.getId()).isEqualTo(movie.getId()); - assertThat(asset2.getName()).isEqualTo(name); - assertThat(asset2.getDescription()).isEqualTo(""); - assertThat(((MultilingualStringValue)asset2.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(asset2.getMetas().get(mediaNumberFieldName)).isEqualTo(null); - assertThat(getFormattedDate(((LongValue)asset2.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset2.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - tags = asset2.getTags(); - entry = tags.entrySet().iterator().next(); - tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - } - - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD episode with filled base meta fields") - public void updateVodEpisodeBaseFields() { - generateDefaultValues4Update(false, EPISODE); - IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); - - String coguid = getCoguidOfActiveMediaAsset(episodeType); - MediaAsset asset = updateVod(coguid, vodData); - - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = asset.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD series with filled base meta fields") - public void updateVodSeriesBaseFields() { - generateDefaultValues4Update(true, SERIES); - IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); - - String coguid = getCoguidOfActiveMediaAsset(seriesType); - MediaAsset asset = updateVod(coguid, vodData); - - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = asset.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "delete") - public void deleteMovie() { - String coguid = getCoguidOfActiveMediaAsset(movieType); - checkVODDeletion(coguid); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "delete episode") - public void deleteEpisode() { - String coguid = getCoguidOfActiveMediaAsset(episodeType); - checkVODDeletion(coguid); - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "delete series") - public void deleteSeries() { - String coguid = getCoguidOfActiveMediaAsset(seriesType); - checkVODDeletion(coguid); - } - - @Severity(SeverityLevel.NORMAL) - @Test(description = "try insert without coguid") - public void insertWithEmptyCoguid() { - String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - - invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", ""); - resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - } - - @Severity(SeverityLevel.NORMAL) - @Test(description = "try delete without coguid", priority =-1) - public void deleteWithEmptyCoguid() { - String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - - invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", ""); - resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - } - - @Severity(SeverityLevel.NORMAL) - @Test(description = "try delete with non-existed coguid") - public void deleteWithNonExistedCoguid() { - int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); - int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); - int positionEndOfCoguid = ingestDeleteXml.indexOf("\"", positionBeginOfCoguid + 1); - String coguid = ingestDeleteXml.substring(positionBeginOfCoguid + 1, positionEndOfCoguid); - String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + coguid + "\"", "co_guid=\"123456\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); - } - - @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with empty entry_id") - public void insertWithEmptyEntryId() { - String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); - - invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", ""); - resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); - } - - @Severity(SeverityLevel.MINOR) - @Test(description = "try insert inactive item") - public void insertInactiveItem() { - String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - String id = from(resp.asString()).get(ingestAssetIdPath).toString(); - - SearchAssetFilter assetFilter = new SearchAssetFilter(); - assetFilter.setKSql("media_id='" + id + "'"); - com.kaltura.client.utils.response.base.Response> assetListResponse = - executor.executeSync(list(assetFilter) - .setKs(getAnonymousKs())); - assertThat(assetListResponse.results.getTotalCount()).isEqualTo(0); - } - - @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with empty isActive parameter") - public void insertEmptyIsActive() { - String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); - } - - @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with empty name", priority =-1) - public void insertWithEmptyName() { - String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); - - invalidXml = ingestInsertXml - .replaceAll("", "") - .replaceAll("" + movie.getName() + "", "") - .replaceAll("", ""); - resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.Basic.Name cannot be empty"); - } - - @Severity(SeverityLevel.NORMAL) - @Test(description = "try insert with invalid credentials") - public void insertWithInvalidCredentials() { - String statusMessage = "Invalid credentials"; - String status = "ERROR"; - - // invalid user name - String invalidXml = ingestInsertXml.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); - Response resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); - assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); - - // invalid password - invalidXml = ingestInsertXml.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); - resp = getResponseBodyFromIngestVod(invalidXml); - - assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); - assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); - } - - @Severity(SeverityLevel.NORMAL) - @Test(description = "try insert with invalid meta or tag field") - public void insertWithInvalidMetaOrTagField() { - String suffix = "UPDATE654987321"; - String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); - - String updatedField = mediaNumberFieldName + suffix; - String invalidXml = ingestXml.replaceAll(mediaNumberFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); - - updatedField = mediaDateFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaDateFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); - - updatedField = mediaBooleanFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaBooleanFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); - - updatedField = mediaTagFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaTagFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "tag"); - - updatedField = mediaTextFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaTextFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); - } - - @Severity(SeverityLevel.NORMAL) - @Test(description = "insert multilingual fields") - public void insertMultiLingualFields() { - // ingested Movie for checking multilanguage - final String JAP = "jap"; - final String ENG = "eng"; - String suffix = "multilingual"; - name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically - description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically - generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE, movieAssetFiles); - movie = insertVod(vodData, true); - String nameData = "" + movie.getName() + ""; - String descriptionData = "" + movie.getDescription() + ""; - String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); - String stringMetaData = "" + stringMetaDataValue + ""; - String tagData = "" + tagValue1 + ""; - - // to get xml having all fields supporting multilingual - String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); - ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) - .replaceAll(movie.getName(), movie.getName() + JAP)); - ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) - .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); - ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) - .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); - ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) - .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); - - Response resp = getResponseBodyFromIngestVod(ingestXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); - String id = from(resp.asString()).get(ingestAssetIdPath).toString(); - assertThat(id).isEqualTo(movie.getId().toString()); - - AssetService.GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA) - .setKs(getAnonymousKs()) - .setLanguage(JAP); - Asset asset = executor.executeSync(getAssetBuilder).results; - assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); - assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); - assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) - .isEqualTo(stringMetaDataValue + JAP); - // check tag value - boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); - assertThat(isTagValueFound).isEqualTo(true); - - getAssetBuilder = get(id, AssetReferenceType.MEDIA) - .setKs(getAnonymousKs()) - .setLanguage(ENG); - asset = executor.executeSync(getAssetBuilder).results; - assertThat(asset.getName()).isEqualTo(movie.getName()); - assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); - assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); - // check tag value - isTagValueFound = isTagValueFound(tagValue1, asset); - assertThat(isTagValueFound).isEqualTo(true); - // TODO: update multilingual fields - } - - @Severity(SeverityLevel.MINOR) - @Test(description = "ingest VOD with emtpy images and files fields") - public void insertVodMediaBaseEmptyImagesAndFields() { - String suffix = "123"; - String ingestXmlWithEmptyFiles = ingestInsertXml - .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); - String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; - // check empty files - String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; - String ingestXml = getUpdatedIngestXml(ingestXmlWithEmptyFiles, "", "", emptyFiles); - - Response resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); - - /* TODO: Shir said that current logic should allow to ingest without any errors - that can be checked after Alon complete image update - // check empty images - ingestXml = ingestXmlBeforeTransformations - .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); - ingestXml = getIngestXmlWithoutFiles(ingestXml); - String emptyImages = "" + EMPTY_IMAGE_TAG + ""; - ingestXml = getUpdatedIngestXml(ingestXml, "", "", emptyImages); - - resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); - - // checkEmptyThumb - ingestXml = ingestXmlBeforeTransformations - .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); - ingestXml = getIngestXmlWithoutFiles(ingestXml); - ingestXml = getUpdatedIngestXml(ingestXml, "", EMPTY_THUMB_TAG); - - resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique");*/ - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with different Ppv") - public void updateVodMediaPpv() { - generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles); - MediaAsset movie = insertVod(vodData, true); - String ingestRequest = ingestXmlRequest; - - assertThat(movie.getName()).isEqualTo(name); - assertThat(movie.getDescription()).isEqualTo(description); - checkFiles(movieAssetFiles, movie.getId().toString()); - - Household household = HouseholdUtils.createHousehold(); - String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); - AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); - com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); - List getMediaFiles = assetGetResponse.results.getMediaFiles(); - int fileId1 = getMediaFiles.get(0).getId(); - int fileId2 = getMediaFiles.get(1).getId(); - - ProductPriceFilter ppFilter = new ProductPriceFilter(); - ppFilter.setFileIdIn(String.valueOf(fileId1)); - ppFilter.setIsLowest(false); - ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); - com.kaltura.client.utils.response.base.Response> productPriceResponse = - executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); - assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); - assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); - // TODO: complete - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD images") - public void updateImages() { - // insert vod - generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE, movieAssetFiles); - MediaAsset mediaAsset = insertVod(vodData, true); - - // get list of original images - List originalImages = mediaAsset.getImages(); - assertThat(originalImages.size()).isEqualTo(3); - - // update vod images - enter 2 new images - List newRatios = Arrays.asList("2:1", "2:3"); - String fakeImageUrl = "https://picsum.photos/200/300/?random"; - - VodData updateVodData = new VodData() - .thumbUrl(fakeImageUrl) - .thumbRatios(newRatios); - mediaAsset = updateVod(mediaAsset.getExternalId(), updateVodData); - - // assert update - List images = mediaAsset.getImages(); - assertThat(images.size()).isEqualTo(5); - - List newImages = images.stream() - .filter(image -> originalImages.stream() - .map(MediaImage::getRatio) - .noneMatch(s1 -> s1.equals(image.getRatio()))) - .collect(Collectors.toList()); - - newImages.forEach(image -> assertThat(image.getUrl()).isNotEmpty()); - assertThat(newImages).extracting("ratio").containsExactlyInAnyOrderElementsOf(newRatios); - - // cleanup - deleteVod(mediaAsset.getExternalId()); - } +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "ingest VOD with filled base meta fields") +// public void insertVodMediaBaseFields() { +// generateDefaultValues4Insert(MOVIE); +// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// VodData vodData = getVodData(MOVIE, movieAssetFiles); +// MediaAsset movie = insertVod(vodData, true); +// String ingestRequest = ingestXmlRequest; +// +// assertThat(movie.getName()).isEqualTo(name); +// assertThat(movie.getDescription()).isEqualTo(description); +// assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); +// assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); +// assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); +// assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); +// +// Map tags = movie.getTags(); +// Map.Entry entry = tags.entrySet().iterator().next(); +// List tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagValues).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// +// checkFiles(movieAssetFiles, movie.getId().toString()); +// +// assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); +// assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); +// +// // without cleanup as we have below tests that can delete ingested item +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "ingest VOD with filled base meta fields") +// public void insertVodEpisodeBaseFields() { +// generateDefaultValues4Insert(EPISODE); +// List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// VodData vodData = getVodData(EPISODE, episodeAssetFiles); +// MediaAsset episode = insertVod(vodData, true); +// +// assertThat(episode.getName()).isEqualTo(name); +// assertThat(episode.getDescription()).isEqualTo(description); +// assertThat(((MultilingualStringValue)episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); +// assertThat(((DoubleValue)episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); +// assertThat(getFormattedDate(((LongValue)episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); +// assertThat(((BooleanValue)episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); +// +// Map tags = episode.getTags(); +// Map.Entry entry = tags.entrySet().iterator().next(); +// List tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagValues).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// +// checkFiles(episodeAssetFiles, episode.getId().toString()); +// +// // without cleanup as we have below tests that can delete ingested item +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "ingest VOD with filled base meta fields") +// public void insertVodSeriesBaseFields() { +// generateDefaultValues4Insert(SERIES); +// List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// VodData vodData = getVodData(SERIES, seriesAssetFiles); +// MediaAsset series = insertVod(vodData, true); +// +// assertThat(series.getName()).isEqualTo(name); +// assertThat(series.getDescription()).isEqualTo(description); +// assertThat(((StringValue)series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); +// assertThat(((DoubleValue)series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); +// assertThat(getFormattedDate(((LongValue)series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); +// assertThat(((BooleanValue)series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); +// +// Map tags = series.getTags(); +// Map.Entry entry = tags.entrySet().iterator().next(); +// List tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagValues).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// +// checkFiles(seriesAssetFiles, series.getId().toString()); +// // without cleanup as we have below tests that can delete ingested item +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "update VOD with filled base meta fields") +// public void updateVodMediaBaseFields() { +// String coguid = getCoguidOfActiveMediaAsset(movieType); +// generateDefaultValues4Update(true, MOVIE); +// IngestVodUtils.VodData vodData = getVodData(MOVIE, new ArrayList<>()); +// +// MediaAsset asset = updateVod(coguid, vodData); +// String updateRequest = ingestXmlRequest; +// +// assertThat(asset.getName()).isEqualTo(name); +// assertThat(asset.getDescription()).isEqualTo(description); +// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); +// assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); +// assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); +// assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); +// +// Map tags = asset.getTags(); +// Map.Entry entry = tags.entrySet().iterator().next(); +// List tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagValues).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// +// // check update with erase="true" +// updateRequest = updateRequest +// .replaceAll("erase=\"false\"", "erase=\"true\"") +// // to remove description from XML +// .replaceAll("", "") +// .replaceAll("" + description + "", "") +// .replaceAll("", "") +// // to remove boolean meta from XML +// .replaceAll("", "") +// .replaceAll("" + doubleValue + "", "") +// .replaceAll("", "") +// // to remove thumb +// .replaceAll("", ""); +// Response resp = getResponseBodyFromIngestVod(updateRequest); +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); +// +// AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(movie.getId()), AssetReferenceType.MEDIA) +// .setKs(getAnonymousKs()); +// com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); +// MediaAsset asset2 = (MediaAsset)assetGetResponse.results; +// assertThat(asset2.getId()).isEqualTo(movie.getId()); +// assertThat(asset2.getName()).isEqualTo(name); +// assertThat(asset2.getDescription()).isEqualTo(""); +// assertThat(((MultilingualStringValue)asset2.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); +// assertThat(asset2.getMetas().get(mediaNumberFieldName)).isEqualTo(null); +// assertThat(getFormattedDate(((LongValue)asset2.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); +// assertThat(((BooleanValue)asset2.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); +// +// tags = asset2.getTags(); +// entry = tags.entrySet().iterator().next(); +// tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagValues).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// } +// +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "update VOD episode with filled base meta fields") +// public void updateVodEpisodeBaseFields() { +// generateDefaultValues4Update(false, EPISODE); +// IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); +// +// String coguid = getCoguidOfActiveMediaAsset(episodeType); +// MediaAsset asset = updateVod(coguid, vodData); +// +// assertThat(asset.getName()).isEqualTo(name); +// assertThat(asset.getDescription()).isEqualTo(description); +// assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); +// assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); +// assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); +// assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); +// +// Map tags = asset.getTags(); +// Map.Entry entry = tags.entrySet().iterator().next(); +// List tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagValues).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "update VOD series with filled base meta fields") +// public void updateVodSeriesBaseFields() { +// generateDefaultValues4Update(true, SERIES); +// IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); +// +// String coguid = getCoguidOfActiveMediaAsset(seriesType); +// MediaAsset asset = updateVod(coguid, vodData); +// +// assertThat(asset.getName()).isEqualTo(name); +// assertThat(asset.getDescription()).isEqualTo(description); +// assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); +// assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); +// assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); +// assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); +// +// Map tags = asset.getTags(); +// Map.Entry entry = tags.entrySet().iterator().next(); +// List tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagValues).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "delete") +// public void deleteMovie() { +// String coguid = getCoguidOfActiveMediaAsset(movieType); +// checkVodDeletion(coguid); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "delete episode") +// public void deleteEpisode() { +// String coguid = getCoguidOfActiveMediaAsset(episodeType); +// checkVodDeletion(coguid); +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "delete series") +// public void deleteSeries() { +// String coguid = getCoguidOfActiveMediaAsset(seriesType); +// checkVodDeletion(coguid); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "try insert without coguid") +// public void insertWithEmptyCoguid() { +// String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); +// +// invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", ""); +// resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "try delete without coguid", priority =-1) +// public void deleteWithEmptyCoguid() { +// String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); +// +// invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", ""); +// resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "try delete with non-existed coguid") +// public void deleteWithNonExistedCoguid() { +// int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); +// int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); +// int positionEndOfCoguid = ingestDeleteXml.indexOf("\"", positionBeginOfCoguid + 1); +// String coguid = ingestDeleteXml.substring(positionBeginOfCoguid + 1, positionEndOfCoguid); +// String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + coguid + "\"", "co_guid=\"123456\""); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(description = "try insert with empty entry_id") +// public void insertWithEmptyEntryId() { +// String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); +// +// invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", ""); +// resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(description = "try insert inactive item") +// public void insertInactiveItem() { +// String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// String id = from(resp.asString()).get(ingestAssetIdPath).toString(); +// +// SearchAssetFilter assetFilter = new SearchAssetFilter(); +// assetFilter.setKSql("media_id='" + id + "'"); +// com.kaltura.client.utils.response.base.Response> assetListResponse = +// executor.executeSync(list(assetFilter) +// .setKs(getAnonymousKs())); +// assertThat(assetListResponse.results.getTotalCount()).isEqualTo(0); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(description = "try insert with empty isActive parameter") +// public void insertEmptyIsActive() { +// String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(description = "try insert with empty name", priority =-1) +// public void insertWithEmptyName() { +// String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); +// +// invalidXml = ingestInsertXml +// .replaceAll("", "") +// .replaceAll("" + movie.getName() + "", "") +// .replaceAll("", ""); +// resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.Basic.Name cannot be empty"); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "try insert with invalid credentials") +// public void insertWithInvalidCredentials() { +// String statusMessage = "Invalid credentials"; +// String status = "ERROR"; +// +// // invalid user name +// String invalidXml = ingestInsertXml.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); +// Response resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); +// assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); +// +// // invalid password +// invalidXml = ingestInsertXml.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); +// resp = getResponseBodyFromIngestVod(invalidXml); +// +// assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); +// assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "try insert with invalid meta or tag field") +// public void insertWithInvalidMetaOrTagField() { +// String suffix = "UPDATE654987321"; +// String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); +// +// String updatedField = mediaNumberFieldName + suffix; +// String invalidXml = ingestXml.replaceAll(mediaNumberFieldName, updatedField); +// validateInvalidMovieField(invalidXml, updatedField, "meta"); +// +// updatedField = mediaDateFieldName + suffix; +// invalidXml = ingestXml.replaceAll(mediaDateFieldName, updatedField); +// validateInvalidMovieField(invalidXml, updatedField, "meta"); +// +// updatedField = mediaBooleanFieldName + suffix; +// invalidXml = ingestXml.replaceAll(mediaBooleanFieldName, updatedField); +// validateInvalidMovieField(invalidXml, updatedField, "meta"); +// +// updatedField = mediaTagFieldName + suffix; +// invalidXml = ingestXml.replaceAll(mediaTagFieldName, updatedField); +// validateInvalidMovieField(invalidXml, updatedField, "tag"); +// +// updatedField = mediaTextFieldName + suffix; +// invalidXml = ingestXml.replaceAll(mediaTextFieldName, updatedField); +// validateInvalidMovieField(invalidXml, updatedField, "meta"); +// } +// +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "insert multilingual fields") +// public void insertMultiLingualFields() { +// // ingested Movie for checking multilanguage +// final String JAP = "jap"; +// final String ENG = "eng"; +// String suffix = "multilingual"; +// name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically +// description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically +// generateDefaultValues4Insert(MOVIE); +// VodData vodData = getVodData(MOVIE, movieAssetFiles); +// movie = insertVod(vodData, true); +// String nameData = "" + movie.getName() + ""; +// String descriptionData = "" + movie.getDescription() + ""; +// String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); +// String stringMetaData = "" + stringMetaDataValue + ""; +// String tagData = "" + tagValue1 + ""; +// +// // to get xml having all fields supporting multilingual +// String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); +// ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) +// .replaceAll(movie.getName(), movie.getName() + JAP)); +// ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) +// .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); +// ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) +// .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); +// ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) +// .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); +// +// Response resp = getResponseBodyFromIngestVod(ingestXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); +// String id = from(resp.asString()).get(ingestAssetIdPath).toString(); +// assertThat(id).isEqualTo(movie.getId().toString()); +// +// AssetService.GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA) +// .setKs(getAnonymousKs()) +// .setLanguage(JAP); +// Asset asset = executor.executeSync(getAssetBuilder).results; +// assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); +// assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); +// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) +// .isEqualTo(stringMetaDataValue + JAP); +// // check tag value +// boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); +// assertThat(isTagValueFound).isEqualTo(true); +// +// getAssetBuilder = get(id, AssetReferenceType.MEDIA) +// .setKs(getAnonymousKs()) +// .setLanguage(ENG); +// asset = executor.executeSync(getAssetBuilder).results; +// assertThat(asset.getName()).isEqualTo(movie.getName()); +// assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); +// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); +// // check tag value +// isTagValueFound = isTagValueFound(tagValue1, asset); +// assertThat(isTagValueFound).isEqualTo(true); +// // TODO: update multilingual fields +// } +// +// @Severity(SeverityLevel.MINOR) +// @Test(description = "ingest VOD with emtpy images and files fields") +// public void insertVodMediaBaseEmptyImagesAndFields() { +// String suffix = "123"; +// String ingestXmlWithEmptyFiles = ingestInsertXml +// .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); +// String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; +// // check empty files +// String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; +// String ingestXml = getUpdatedIngestXml(ingestXmlWithEmptyFiles, "", "", emptyFiles); +// +// Response resp = getResponseBodyFromIngestVod(ingestXml); +// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); +// +// /* TODO: Shir said that current logic should allow to ingest without any errors - that can be checked after Alon complete image update +// // check empty images +// ingestXml = ingestXmlBeforeTransformations +// .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); +// ingestXml = getIngestXmlWithoutFiles(ingestXml); +// String emptyImages = "" + EMPTY_IMAGE_TAG + ""; +// ingestXml = getUpdatedIngestXml(ingestXml, "", "", emptyImages); +// +// resp = getResponseBodyFromIngestVod(ingestXml); +// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); +// +// // checkEmptyThumb +// ingestXml = ingestXmlBeforeTransformations +// .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); +// ingestXml = getIngestXmlWithoutFiles(ingestXml); +// ingestXml = getUpdatedIngestXml(ingestXml, "", EMPTY_THUMB_TAG); +// +// resp = getResponseBodyFromIngestVod(ingestXml); +// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique");*/ +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "ingest VOD with different Ppv") +// public void updateVodMediaPpv() { +// generateDefaultValues4Insert(MOVIE); +// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// VodData vodData = getVodData(MOVIE, movieAssetFiles); +// MediaAsset movie = insertVod(vodData, true); +// String ingestRequest = ingestXmlRequest; +// +// assertThat(movie.getName()).isEqualTo(name); +// assertThat(movie.getDescription()).isEqualTo(description); +// checkFiles(movieAssetFiles, movie.getId().toString()); +// +// Household household = HouseholdUtils.createHousehold(); +// String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); +// AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); +// com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); +// List getMediaFiles = assetGetResponse.results.getMediaFiles(); +// int fileId1 = getMediaFiles.get(0).getId(); +// int fileId2 = getMediaFiles.get(1).getId(); +// +// ProductPriceFilter ppFilter = new ProductPriceFilter(); +// ppFilter.setFileIdIn(String.valueOf(fileId1)); +// ppFilter.setIsLowest(false); +// ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); +// com.kaltura.client.utils.response.base.Response> productPriceResponse = +// executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); +// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); +// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); +// // TODO: complete +// } +// +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "update VOD images") +// public void updateImages() { +// // insert vod +// generateDefaultValues4Insert(MOVIE); +// VodData vodData = getVodData(MOVIE, movieAssetFiles); +// MediaAsset mediaAsset = insertVod(vodData, true); +// +// // get list of original images +// List originalImages = mediaAsset.getImages(); +// assertThat(originalImages.size()).isEqualTo(3); +// +// // update vod images - enter 2 new images +// List newRatios = Arrays.asList("2:1", "2:3"); +// String fakeImageUrl = "https://picsum.photos/200/300/?random"; +// +// VodData updateVodData = new VodData() +// .thumbUrl(fakeImageUrl) +// .thumbRatios(newRatios); +// mediaAsset = updateVod(mediaAsset.getExternalId(), updateVodData); +// +// // assert update +// List images = mediaAsset.getImages(); +// assertThat(images.size()).isEqualTo(5); +// +// List newImages = images.stream() +// .filter(image -> originalImages.stream() +// .map(MediaImage::getRatio) +// .noneMatch(s1 -> s1.equals(image.getRatio()))) +// .collect(Collectors.toList()); +// +// newImages.forEach(image -> assertThat(image.getUrl()).isNotEmpty()); +// assertThat(newImages).extracting("ratio").containsExactlyInAnyOrderElementsOf(newRatios); +// +// // cleanup +// deleteVod(mediaAsset.getExternalId()); +// } @Issue("BEO-5536") @Severity(SeverityLevel.CRITICAL) @@ -667,7 +658,7 @@ void validateInvalidMovieField(String ingestXml, String fieldName, String fieldT .isEqualTo(fieldType + ": " + fieldName + " does not exist for group"); } - void checkVODDeletion(String coguid) { + void checkVodDeletion(String coguid) { SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setKSql("externalId='" + coguid + "'"); com.kaltura.client.utils.response.base.Response> assetListResponse = diff --git a/src/test/resources/testng_regular.xml b/src/test/resources/testng_regular.xml index 2adb1885d..d95d10dd1 100644 --- a/src/test/resources/testng_regular.xml +++ b/src/test/resources/testng_regular.xml @@ -3,34 +3,34 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + From d64b9503963e20f9f89e9e344773f5894c34f39a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 4 Sep 2018 14:43:59 +0300 Subject: [PATCH 515/605] no message --- .../kaltura/client/test/tests/BaseTest.java | 33 ++++++++++++++----- .../five_zero_two/IngestVodOpcTests.java | 6 ++-- .../utils/ingestUtils/BaseIngestUtils.java | 2 +- ...odOPCUtils.java => IngestVodOpcUtils.java} | 2 +- src/test/resources/testng.xml | 6 ++-- src/test/resources/testng_opc.xml | 2 +- 6 files changed, 34 insertions(+), 17 deletions(-) rename src/test/java/com/kaltura/client/test/utils/ingestUtils/{IngestVodOPCUtils.java => IngestVodOpcUtils.java} (99%) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 269af7a5e..19feb73c8 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -12,7 +12,11 @@ import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; import org.apache.commons.io.FileUtils; +import org.testng.ITestContext; import org.testng.annotations.*; +import org.testng.xml.XmlSuite; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; import java.io.File; import java.io.IOException; @@ -55,7 +59,7 @@ public class BaseTest { public static Configuration config; public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); private static Response loginResponse; - + private static int numOfSuites = getNumOfSuites(); /*================================================================================ Shared Test Params - used as a helper common params across tests @@ -118,9 +122,10 @@ public class BaseTest { ================================================================================*/ @Parameters({"accountType"}) - @BeforeSuite(alwaysRun=true) - public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType) { - Logger.getLogger(BaseTest.class).debug("Start baseTest_beforeSuite"); + @BeforeSuite(alwaysRun = true) + public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType, ITestContext testContext) { + XmlSuite suite = testContext.getCurrentXmlTest().getSuite(); + Logger.getLogger(BaseTest.class).debug("Start suite >>> Suite: " + suite.getName()); // set configuration config = new Configuration(); @@ -146,7 +151,7 @@ public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); // set performance report - if ("true".equals(getProperty(WRITE_REGRESSION_LOGS))) { + if ("true".equals(getProperty(WRITE_REGRESSION_LOGS)) && numOfSuites == getNumOfSuites()) { File logsDir = new File(getProperty(LOGS_DIR)); if (Files.exists(logsDir.toPath())) { try { @@ -156,6 +161,9 @@ public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String } } } + + // decrement numOfSuites in order to generate the performance report after all suites finish + numOfSuites--; } @BeforeMethod @@ -589,14 +597,23 @@ public static HouseholdUser getSharedUser() { } } - @AfterSuite - public void tearDownSuite() { + @AfterSuite(alwaysRun = true) + public void baseTest_afterSuite(ITestContext testContext) { + XmlSuite suite = testContext.getCurrentXmlTest().getSuite(); + Logger.getLogger(BaseTest.class).debug("End suite >>> Suite: " + suite.getName()); + // generate performance report - if ("true".equals(getProperty(WRITE_REGRESSION_LOGS))) { + if ("true".equals(getProperty(WRITE_REGRESSION_LOGS)) && numOfSuites == 0) { PerformanceUtils.generatePerformanceReport(); } // TODO: 8/14/2018 cleanup: delete generated shared resources and data! } + private static int getNumOfSuites() { + Document doc = getDocument("src/test/resources/testng.xml"); + NodeList suites = doc.getElementsByTagName("suite-file"); + return suites.getLength(); + } + } diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 05f9eb418..610dd1d94 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -17,9 +17,9 @@ import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.utils.BaseUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.delayBetweenRetriesInSeconds; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOPCUtils.maxTimeExpectingValidResponseInSeconds; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.delayBetweenRetriesInSeconds; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.maxTimeExpectingValidResponseInSeconds; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static io.restassured.path.xml.XmlPath.from; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index f96fbf732..399a4be7f 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -58,7 +58,7 @@ public class BaseIngestUtils { public static final String PG_DEFAULT_PG_SETTINGS = "{}"; */ - static Document getDocument(String uri) { + public static Document getDocument(String uri) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; Document doc = null; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java similarity index 99% rename from src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java rename to src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index d76528715..592419d5d 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOPCUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -14,7 +14,7 @@ import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; -public class IngestVodOPCUtils extends BaseIngestUtils { +public class IngestVodOpcUtils extends BaseIngestUtils { public static String name; public static String description; diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 2afc1f802..0835589ed 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,8 +1,8 @@ - + - - + + \ No newline at end of file diff --git a/src/test/resources/testng_opc.xml b/src/test/resources/testng_opc.xml index d755103fd..e68dc7221 100644 --- a/src/test/resources/testng_opc.xml +++ b/src/test/resources/testng_opc.xml @@ -1,6 +1,6 @@ - + From 2e69b9e7780d5283faafef05e742e51e098b61f7 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 4 Sep 2018 14:52:38 +0300 Subject: [PATCH 516/605] no message --- .../five_zero_two/IngestVodOpcTests.java | 1069 +++++++++-------- src/test/resources/testng_regular.xml | 54 +- 2 files changed, 566 insertions(+), 557 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 610dd1d94..5178e4f65 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -2,8 +2,11 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import io.qameta.allure.Issue; import io.qameta.allure.Severity; @@ -12,16 +15,22 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.utils.BaseUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.DEFAULT_THUMB; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.delayBetweenRetriesInSeconds; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.maxTimeExpectingValidResponseInSeconds; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static io.restassured.path.xml.XmlPath.from; +import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -85,536 +94,536 @@ public void setUp() { seriesType = series.getType(); } -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "ingest VOD with filled base meta fields") -// public void insertVodMediaBaseFields() { -// generateDefaultValues4Insert(MOVIE); -// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// VodData vodData = getVodData(MOVIE, movieAssetFiles); -// MediaAsset movie = insertVod(vodData, true); -// String ingestRequest = ingestXmlRequest; -// -// assertThat(movie.getName()).isEqualTo(name); -// assertThat(movie.getDescription()).isEqualTo(description); -// assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); -// assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); -// assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); -// assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); -// -// Map tags = movie.getTags(); -// Map.Entry entry = tags.entrySet().iterator().next(); -// List tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagValues).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// -// checkFiles(movieAssetFiles, movie.getId().toString()); -// -// assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); -// assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); -// -// // without cleanup as we have below tests that can delete ingested item -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "ingest VOD with filled base meta fields") -// public void insertVodEpisodeBaseFields() { -// generateDefaultValues4Insert(EPISODE); -// List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// VodData vodData = getVodData(EPISODE, episodeAssetFiles); -// MediaAsset episode = insertVod(vodData, true); -// -// assertThat(episode.getName()).isEqualTo(name); -// assertThat(episode.getDescription()).isEqualTo(description); -// assertThat(((MultilingualStringValue)episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); -// assertThat(((DoubleValue)episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); -// assertThat(getFormattedDate(((LongValue)episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); -// assertThat(((BooleanValue)episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); -// -// Map tags = episode.getTags(); -// Map.Entry entry = tags.entrySet().iterator().next(); -// List tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagValues).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// -// checkFiles(episodeAssetFiles, episode.getId().toString()); -// -// // without cleanup as we have below tests that can delete ingested item -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "ingest VOD with filled base meta fields") -// public void insertVodSeriesBaseFields() { -// generateDefaultValues4Insert(SERIES); -// List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// VodData vodData = getVodData(SERIES, seriesAssetFiles); -// MediaAsset series = insertVod(vodData, true); -// -// assertThat(series.getName()).isEqualTo(name); -// assertThat(series.getDescription()).isEqualTo(description); -// assertThat(((StringValue)series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); -// assertThat(((DoubleValue)series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); -// assertThat(getFormattedDate(((LongValue)series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); -// assertThat(((BooleanValue)series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); -// -// Map tags = series.getTags(); -// Map.Entry entry = tags.entrySet().iterator().next(); -// List tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagValues).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// -// checkFiles(seriesAssetFiles, series.getId().toString()); -// // without cleanup as we have below tests that can delete ingested item -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "update VOD with filled base meta fields") -// public void updateVodMediaBaseFields() { -// String coguid = getCoguidOfActiveMediaAsset(movieType); -// generateDefaultValues4Update(true, MOVIE); -// IngestVodUtils.VodData vodData = getVodData(MOVIE, new ArrayList<>()); -// -// MediaAsset asset = updateVod(coguid, vodData); -// String updateRequest = ingestXmlRequest; -// -// assertThat(asset.getName()).isEqualTo(name); -// assertThat(asset.getDescription()).isEqualTo(description); -// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); -// assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); -// assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); -// assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); -// -// Map tags = asset.getTags(); -// Map.Entry entry = tags.entrySet().iterator().next(); -// List tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagValues).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// -// // check update with erase="true" -// updateRequest = updateRequest -// .replaceAll("erase=\"false\"", "erase=\"true\"") -// // to remove description from XML -// .replaceAll("", "") -// .replaceAll("" + description + "", "") -// .replaceAll("", "") -// // to remove boolean meta from XML -// .replaceAll("", "") -// .replaceAll("" + doubleValue + "", "") -// .replaceAll("", "") -// // to remove thumb -// .replaceAll("", ""); -// Response resp = getResponseBodyFromIngestVod(updateRequest); -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); -// -// AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(movie.getId()), AssetReferenceType.MEDIA) -// .setKs(getAnonymousKs()); -// com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); -// MediaAsset asset2 = (MediaAsset)assetGetResponse.results; -// assertThat(asset2.getId()).isEqualTo(movie.getId()); -// assertThat(asset2.getName()).isEqualTo(name); -// assertThat(asset2.getDescription()).isEqualTo(""); -// assertThat(((MultilingualStringValue)asset2.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); -// assertThat(asset2.getMetas().get(mediaNumberFieldName)).isEqualTo(null); -// assertThat(getFormattedDate(((LongValue)asset2.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); -// assertThat(((BooleanValue)asset2.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); -// -// tags = asset2.getTags(); -// entry = tags.entrySet().iterator().next(); -// tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagValues).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// } -// -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "update VOD episode with filled base meta fields") -// public void updateVodEpisodeBaseFields() { -// generateDefaultValues4Update(false, EPISODE); -// IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); -// -// String coguid = getCoguidOfActiveMediaAsset(episodeType); -// MediaAsset asset = updateVod(coguid, vodData); -// -// assertThat(asset.getName()).isEqualTo(name); -// assertThat(asset.getDescription()).isEqualTo(description); -// assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); -// assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); -// assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); -// assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); -// -// Map tags = asset.getTags(); -// Map.Entry entry = tags.entrySet().iterator().next(); -// List tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagValues).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "update VOD series with filled base meta fields") -// public void updateVodSeriesBaseFields() { -// generateDefaultValues4Update(true, SERIES); -// IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); -// -// String coguid = getCoguidOfActiveMediaAsset(seriesType); -// MediaAsset asset = updateVod(coguid, vodData); -// -// assertThat(asset.getName()).isEqualTo(name); -// assertThat(asset.getDescription()).isEqualTo(description); -// assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); -// assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); -// assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); -// assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); -// -// Map tags = asset.getTags(); -// Map.Entry entry = tags.entrySet().iterator().next(); -// List tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagValues).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "delete") -// public void deleteMovie() { -// String coguid = getCoguidOfActiveMediaAsset(movieType); -// checkVodDeletion(coguid); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "delete episode") -// public void deleteEpisode() { -// String coguid = getCoguidOfActiveMediaAsset(episodeType); -// checkVodDeletion(coguid); -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "delete series") -// public void deleteSeries() { -// String coguid = getCoguidOfActiveMediaAsset(seriesType); -// checkVodDeletion(coguid); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "try insert without coguid") -// public void insertWithEmptyCoguid() { -// String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); -// -// invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", ""); -// resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "try delete without coguid", priority =-1) -// public void deleteWithEmptyCoguid() { -// String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); -// -// invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", ""); -// resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "try delete with non-existed coguid") -// public void deleteWithNonExistedCoguid() { -// int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); -// int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); -// int positionEndOfCoguid = ingestDeleteXml.indexOf("\"", positionBeginOfCoguid + 1); -// String coguid = ingestDeleteXml.substring(positionBeginOfCoguid + 1, positionEndOfCoguid); -// String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + coguid + "\"", "co_guid=\"123456\""); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(description = "try insert with empty entry_id") -// public void insertWithEmptyEntryId() { -// String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); -// -// invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", ""); -// resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(description = "try insert inactive item") -// public void insertInactiveItem() { -// String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// String id = from(resp.asString()).get(ingestAssetIdPath).toString(); -// -// SearchAssetFilter assetFilter = new SearchAssetFilter(); -// assetFilter.setKSql("media_id='" + id + "'"); -// com.kaltura.client.utils.response.base.Response> assetListResponse = -// executor.executeSync(list(assetFilter) -// .setKs(getAnonymousKs())); -// assertThat(assetListResponse.results.getTotalCount()).isEqualTo(0); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(description = "try insert with empty isActive parameter") -// public void insertEmptyIsActive() { -// String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(description = "try insert with empty name", priority =-1) -// public void insertWithEmptyName() { -// String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); -// -// invalidXml = ingestInsertXml -// .replaceAll("", "") -// .replaceAll("" + movie.getName() + "", "") -// .replaceAll("", ""); -// resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.Basic.Name cannot be empty"); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "try insert with invalid credentials") -// public void insertWithInvalidCredentials() { -// String statusMessage = "Invalid credentials"; -// String status = "ERROR"; -// -// // invalid user name -// String invalidXml = ingestInsertXml.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); -// Response resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); -// assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); -// -// // invalid password -// invalidXml = ingestInsertXml.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); -// resp = getResponseBodyFromIngestVod(invalidXml); -// -// assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); -// assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "try insert with invalid meta or tag field") -// public void insertWithInvalidMetaOrTagField() { -// String suffix = "UPDATE654987321"; -// String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); -// -// String updatedField = mediaNumberFieldName + suffix; -// String invalidXml = ingestXml.replaceAll(mediaNumberFieldName, updatedField); -// validateInvalidMovieField(invalidXml, updatedField, "meta"); -// -// updatedField = mediaDateFieldName + suffix; -// invalidXml = ingestXml.replaceAll(mediaDateFieldName, updatedField); -// validateInvalidMovieField(invalidXml, updatedField, "meta"); -// -// updatedField = mediaBooleanFieldName + suffix; -// invalidXml = ingestXml.replaceAll(mediaBooleanFieldName, updatedField); -// validateInvalidMovieField(invalidXml, updatedField, "meta"); -// -// updatedField = mediaTagFieldName + suffix; -// invalidXml = ingestXml.replaceAll(mediaTagFieldName, updatedField); -// validateInvalidMovieField(invalidXml, updatedField, "tag"); -// -// updatedField = mediaTextFieldName + suffix; -// invalidXml = ingestXml.replaceAll(mediaTextFieldName, updatedField); -// validateInvalidMovieField(invalidXml, updatedField, "meta"); -// } -// -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "insert multilingual fields") -// public void insertMultiLingualFields() { -// // ingested Movie for checking multilanguage -// final String JAP = "jap"; -// final String ENG = "eng"; -// String suffix = "multilingual"; -// name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically -// description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically -// generateDefaultValues4Insert(MOVIE); -// VodData vodData = getVodData(MOVIE, movieAssetFiles); -// movie = insertVod(vodData, true); -// String nameData = "" + movie.getName() + ""; -// String descriptionData = "" + movie.getDescription() + ""; -// String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); -// String stringMetaData = "" + stringMetaDataValue + ""; -// String tagData = "" + tagValue1 + ""; -// -// // to get xml having all fields supporting multilingual -// String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); -// ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) -// .replaceAll(movie.getName(), movie.getName() + JAP)); -// ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) -// .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); -// ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) -// .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); -// ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) -// .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); -// -// Response resp = getResponseBodyFromIngestVod(ingestXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); -// String id = from(resp.asString()).get(ingestAssetIdPath).toString(); -// assertThat(id).isEqualTo(movie.getId().toString()); -// -// AssetService.GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA) -// .setKs(getAnonymousKs()) -// .setLanguage(JAP); -// Asset asset = executor.executeSync(getAssetBuilder).results; -// assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); -// assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); -// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) -// .isEqualTo(stringMetaDataValue + JAP); -// // check tag value -// boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); -// assertThat(isTagValueFound).isEqualTo(true); -// -// getAssetBuilder = get(id, AssetReferenceType.MEDIA) -// .setKs(getAnonymousKs()) -// .setLanguage(ENG); -// asset = executor.executeSync(getAssetBuilder).results; -// assertThat(asset.getName()).isEqualTo(movie.getName()); -// assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); -// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); -// // check tag value -// isTagValueFound = isTagValueFound(tagValue1, asset); -// assertThat(isTagValueFound).isEqualTo(true); -// // TODO: update multilingual fields -// } -// -// @Severity(SeverityLevel.MINOR) -// @Test(description = "ingest VOD with emtpy images and files fields") -// public void insertVodMediaBaseEmptyImagesAndFields() { -// String suffix = "123"; -// String ingestXmlWithEmptyFiles = ingestInsertXml -// .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); -// String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; -// // check empty files -// String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; -// String ingestXml = getUpdatedIngestXml(ingestXmlWithEmptyFiles, "", "", emptyFiles); -// -// Response resp = getResponseBodyFromIngestVod(ingestXml); -// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); -// -// /* TODO: Shir said that current logic should allow to ingest without any errors - that can be checked after Alon complete image update -// // check empty images -// ingestXml = ingestXmlBeforeTransformations -// .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); -// ingestXml = getIngestXmlWithoutFiles(ingestXml); -// String emptyImages = "" + EMPTY_IMAGE_TAG + ""; -// ingestXml = getUpdatedIngestXml(ingestXml, "", "", emptyImages); -// -// resp = getResponseBodyFromIngestVod(ingestXml); -// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); -// -// // checkEmptyThumb -// ingestXml = ingestXmlBeforeTransformations -// .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); -// ingestXml = getIngestXmlWithoutFiles(ingestXml); -// ingestXml = getUpdatedIngestXml(ingestXml, "", EMPTY_THUMB_TAG); -// -// resp = getResponseBodyFromIngestVod(ingestXml); -// assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique");*/ -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "ingest VOD with different Ppv") -// public void updateVodMediaPpv() { -// generateDefaultValues4Insert(MOVIE); -// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// VodData vodData = getVodData(MOVIE, movieAssetFiles); -// MediaAsset movie = insertVod(vodData, true); -// String ingestRequest = ingestXmlRequest; -// -// assertThat(movie.getName()).isEqualTo(name); -// assertThat(movie.getDescription()).isEqualTo(description); -// checkFiles(movieAssetFiles, movie.getId().toString()); -// -// Household household = HouseholdUtils.createHousehold(); -// String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); -// AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); -// com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); -// List getMediaFiles = assetGetResponse.results.getMediaFiles(); -// int fileId1 = getMediaFiles.get(0).getId(); -// int fileId2 = getMediaFiles.get(1).getId(); -// -// ProductPriceFilter ppFilter = new ProductPriceFilter(); -// ppFilter.setFileIdIn(String.valueOf(fileId1)); -// ppFilter.setIsLowest(false); -// ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); -// com.kaltura.client.utils.response.base.Response> productPriceResponse = -// executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); -// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); -// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); -// // TODO: complete -// } -// -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "update VOD images") -// public void updateImages() { -// // insert vod -// generateDefaultValues4Insert(MOVIE); -// VodData vodData = getVodData(MOVIE, movieAssetFiles); -// MediaAsset mediaAsset = insertVod(vodData, true); -// -// // get list of original images -// List originalImages = mediaAsset.getImages(); -// assertThat(originalImages.size()).isEqualTo(3); -// -// // update vod images - enter 2 new images -// List newRatios = Arrays.asList("2:1", "2:3"); -// String fakeImageUrl = "https://picsum.photos/200/300/?random"; -// -// VodData updateVodData = new VodData() -// .thumbUrl(fakeImageUrl) -// .thumbRatios(newRatios); -// mediaAsset = updateVod(mediaAsset.getExternalId(), updateVodData); -// -// // assert update -// List images = mediaAsset.getImages(); -// assertThat(images.size()).isEqualTo(5); -// -// List newImages = images.stream() -// .filter(image -> originalImages.stream() -// .map(MediaImage::getRatio) -// .noneMatch(s1 -> s1.equals(image.getRatio()))) -// .collect(Collectors.toList()); -// -// newImages.forEach(image -> assertThat(image.getUrl()).isNotEmpty()); -// assertThat(newImages).extracting("ratio").containsExactlyInAnyOrderElementsOf(newRatios); -// -// // cleanup -// deleteVod(mediaAsset.getExternalId()); -// } + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with filled base meta fields") + public void insertVodMediaBaseFields() { + generateDefaultValues4Insert(MOVIE); + List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(MOVIE, movieAssetFiles); + MediaAsset movie = insertVod(vodData, true); + String ingestRequest = ingestXmlRequest; + + assertThat(movie.getName()).isEqualTo(name); + assertThat(movie.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = movie.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + checkFiles(movieAssetFiles, movie.getId().toString()); + + assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); + assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); + + // without cleanup as we have below tests that can delete ingested item + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with filled base meta fields") + public void insertVodEpisodeBaseFields() { + generateDefaultValues4Insert(EPISODE); + List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(EPISODE, episodeAssetFiles); + MediaAsset episode = insertVod(vodData, true); + + assertThat(episode.getName()).isEqualTo(name); + assertThat(episode.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = episode.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + checkFiles(episodeAssetFiles, episode.getId().toString()); + + // without cleanup as we have below tests that can delete ingested item + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with filled base meta fields") + public void insertVodSeriesBaseFields() { + generateDefaultValues4Insert(SERIES); + List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(SERIES, seriesAssetFiles); + MediaAsset series = insertVod(vodData, true); + + assertThat(series.getName()).isEqualTo(name); + assertThat(series.getDescription()).isEqualTo(description); + assertThat(((StringValue)series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = series.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + checkFiles(seriesAssetFiles, series.getId().toString()); + // without cleanup as we have below tests that can delete ingested item + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD with filled base meta fields") + public void updateVodMediaBaseFields() { + String coguid = getCoguidOfActiveMediaAsset(movieType); + generateDefaultValues4Update(true, MOVIE); + IngestVodUtils.VodData vodData = getVodData(MOVIE, new ArrayList<>()); + + MediaAsset asset = updateVod(coguid, vodData); + String updateRequest = ingestXmlRequest; + + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + // check update with erase="true" + updateRequest = updateRequest + .replaceAll("erase=\"false\"", "erase=\"true\"") + // to remove description from XML + .replaceAll("", "") + .replaceAll("" + description + "", "") + .replaceAll("", "") + // to remove boolean meta from XML + .replaceAll("", "") + .replaceAll("" + doubleValue + "", "") + .replaceAll("", "") + // to remove thumb + .replaceAll("", ""); + Response resp = getResponseBodyFromIngestVod(updateRequest); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); + + AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(movie.getId()), AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()); + com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); + MediaAsset asset2 = (MediaAsset)assetGetResponse.results; + assertThat(asset2.getId()).isEqualTo(movie.getId()); + assertThat(asset2.getName()).isEqualTo(name); + assertThat(asset2.getDescription()).isEqualTo(""); + assertThat(((MultilingualStringValue)asset2.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(asset2.getMetas().get(mediaNumberFieldName)).isEqualTo(null); + assertThat(getFormattedDate(((LongValue)asset2.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset2.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + tags = asset2.getTags(); + entry = tags.entrySet().iterator().next(); + tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD episode with filled base meta fields") + public void updateVodEpisodeBaseFields() { + generateDefaultValues4Update(false, EPISODE); + IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); + + String coguid = getCoguidOfActiveMediaAsset(episodeType); + MediaAsset asset = updateVod(coguid, vodData); + + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD series with filled base meta fields") + public void updateVodSeriesBaseFields() { + generateDefaultValues4Update(true, SERIES); + IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); + + String coguid = getCoguidOfActiveMediaAsset(seriesType); + MediaAsset asset = updateVod(coguid, vodData); + + assertThat(asset.getName()).isEqualTo(name); + assertThat(asset.getDescription()).isEqualTo(description); + assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = asset.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "delete") + public void deleteMovie() { + String coguid = getCoguidOfActiveMediaAsset(movieType); + checkVodDeletion(coguid); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "delete episode") + public void deleteEpisode() { + String coguid = getCoguidOfActiveMediaAsset(episodeType); + checkVodDeletion(coguid); + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "delete series") + public void deleteSeries() { + String coguid = getCoguidOfActiveMediaAsset(seriesType); + checkVodDeletion(coguid); + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "try insert without coguid") + public void insertWithEmptyCoguid() { + String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + + invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "try delete without coguid", priority =-1) + public void deleteWithEmptyCoguid() { + String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + + invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "try delete with non-existed coguid") + public void deleteWithNonExistedCoguid() { + int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); + int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); + int positionEndOfCoguid = ingestDeleteXml.indexOf("\"", positionBeginOfCoguid + 1); + String coguid = ingestDeleteXml.substring(positionBeginOfCoguid + 1, positionEndOfCoguid); + String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + coguid + "\"", "co_guid=\"123456\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert with empty entry_id") + public void insertWithEmptyEntryId() { + String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); + + invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert inactive item") + public void insertInactiveItem() { + String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + String id = from(resp.asString()).get(ingestAssetIdPath).toString(); + + SearchAssetFilter assetFilter = new SearchAssetFilter(); + assetFilter.setKSql("media_id='" + id + "'"); + com.kaltura.client.utils.response.base.Response> assetListResponse = + executor.executeSync(list(assetFilter) + .setKs(getAnonymousKs())); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(0); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert with empty isActive parameter") + public void insertEmptyIsActive() { + String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "try insert with empty name", priority =-1) + public void insertWithEmptyName() { + String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); + + invalidXml = ingestInsertXml + .replaceAll("", "") + .replaceAll("" + movie.getName() + "", "") + .replaceAll("", ""); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.Basic.Name cannot be empty"); + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "try insert with invalid credentials") + public void insertWithInvalidCredentials() { + String statusMessage = "Invalid credentials"; + String status = "ERROR"; + + // invalid user name + String invalidXml = ingestInsertXml.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); + Response resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); + assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); + + // invalid password + invalidXml = ingestInsertXml.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); + resp = getResponseBodyFromIngestVod(invalidXml); + + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); + assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "try insert with invalid meta or tag field") + public void insertWithInvalidMetaOrTagField() { + String suffix = "UPDATE654987321"; + String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); + + String updatedField = mediaNumberFieldName + suffix; + String invalidXml = ingestXml.replaceAll(mediaNumberFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + + updatedField = mediaDateFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaDateFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + + updatedField = mediaBooleanFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaBooleanFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + + updatedField = mediaTagFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaTagFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "tag"); + + updatedField = mediaTextFieldName + suffix; + invalidXml = ingestXml.replaceAll(mediaTextFieldName, updatedField); + validateInvalidMovieField(invalidXml, updatedField, "meta"); + } + + @Severity(SeverityLevel.NORMAL) + @Test(description = "insert multilingual fields") + public void insertMultiLingualFields() { + // ingested Movie for checking multilanguage + final String JAP = "jap"; + final String ENG = "eng"; + String suffix = "multilingual"; + name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically + description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically + generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE, movieAssetFiles); + movie = insertVod(vodData, true); + String nameData = "" + movie.getName() + ""; + String descriptionData = "" + movie.getDescription() + ""; + String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); + String stringMetaData = "" + stringMetaDataValue + ""; + String tagData = "" + tagValue1 + ""; + + // to get xml having all fields supporting multilingual + String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); + ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) + .replaceAll(movie.getName(), movie.getName() + JAP)); + ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) + .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); + ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) + .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); + ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) + .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); + + Response resp = getResponseBodyFromIngestVod(ingestXml); + + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); + String id = from(resp.asString()).get(ingestAssetIdPath).toString(); + assertThat(id).isEqualTo(movie.getId().toString()); + + AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()) + .setLanguage(JAP); + Asset asset = executor.executeSync(getAssetBuilder).results; + assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); + assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); + assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) + .isEqualTo(stringMetaDataValue + JAP); + // check tag value + boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); + assertThat(isTagValueFound).isEqualTo(true); + + getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()) + .setLanguage(ENG); + asset = executor.executeSync(getAssetBuilder).results; + assertThat(asset.getName()).isEqualTo(movie.getName()); + assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); + assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); + // check tag value + isTagValueFound = isTagValueFound(tagValue1, asset); + assertThat(isTagValueFound).isEqualTo(true); + // TODO: update multilingual fields + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "ingest VOD with emtpy images and files fields") + public void insertVodMediaBaseEmptyImagesAndFields() { + String suffix = "123"; + String ingestXmlWithEmptyFiles = ingestInsertXml + .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); + String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; + // check empty files + String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; + String ingestXml = getUpdatedIngestXml(ingestXmlWithEmptyFiles, "", "", emptyFiles); + + Response resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); + + /* TODO: Shir said that current logic should allow to ingest without any errors - that can be checked after Alon complete image update + // check empty images + ingestXml = ingestXmlBeforeTransformations + .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); + ingestXml = getIngestXmlWithoutFiles(ingestXml); + String emptyImages = "" + EMPTY_IMAGE_TAG + ""; + ingestXml = getUpdatedIngestXml(ingestXml, "", "", emptyImages); + + resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + + // checkEmptyThumb + ingestXml = ingestXmlBeforeTransformations + .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); + ingestXml = getIngestXmlWithoutFiles(ingestXml); + ingestXml = getUpdatedIngestXml(ingestXml, "", EMPTY_THUMB_TAG); + + resp = getResponseBodyFromIngestVod(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique");*/ + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with different Ppv") + public void updateVodMediaPpv() { + generateDefaultValues4Insert(MOVIE); + List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(MOVIE, movieAssetFiles); + MediaAsset movie = insertVod(vodData, true); + String ingestRequest = ingestXmlRequest; + + assertThat(movie.getName()).isEqualTo(name); + assertThat(movie.getDescription()).isEqualTo(description); + checkFiles(movieAssetFiles, movie.getId().toString()); + + Household household = HouseholdUtils.createHousehold(); + String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); + AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); + com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); + List getMediaFiles = assetGetResponse.results.getMediaFiles(); + int fileId1 = getMediaFiles.get(0).getId(); + int fileId2 = getMediaFiles.get(1).getId(); + + ProductPriceFilter ppFilter = new ProductPriceFilter(); + ppFilter.setFileIdIn(String.valueOf(fileId1)); + ppFilter.setIsLowest(false); + ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); + com.kaltura.client.utils.response.base.Response> productPriceResponse = + executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); + assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); + assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); + // TODO: complete + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD images") + public void updateImages() { + // insert vod + generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE, movieAssetFiles); + MediaAsset mediaAsset = insertVod(vodData, true); + + // get list of original images + List originalImages = mediaAsset.getImages(); + assertThat(originalImages.size()).isEqualTo(3); + + // update vod images - enter 2 new images + List newRatios = Arrays.asList("2:1", "2:3"); + String fakeImageUrl = "https://picsum.photos/200/300/?random"; + + VodData updateVodData = new VodData() + .thumbUrl(fakeImageUrl) + .thumbRatios(newRatios); + mediaAsset = updateVod(mediaAsset.getExternalId(), updateVodData); + + // assert update + List images = mediaAsset.getImages(); + assertThat(images.size()).isEqualTo(5); + + List newImages = images.stream() + .filter(image -> originalImages.stream() + .map(MediaImage::getRatio) + .noneMatch(s1 -> s1.equals(image.getRatio()))) + .collect(Collectors.toList()); + + newImages.forEach(image -> assertThat(image.getUrl()).isNotEmpty()); + assertThat(newImages).extracting("ratio").containsExactlyInAnyOrderElementsOf(newRatios); + + // cleanup + deleteVod(mediaAsset.getExternalId()); + } @Issue("BEO-5536") @Severity(SeverityLevel.CRITICAL) diff --git a/src/test/resources/testng_regular.xml b/src/test/resources/testng_regular.xml index d95d10dd1..2adb1885d 100644 --- a/src/test/resources/testng_regular.xml +++ b/src/test/resources/testng_regular.xml @@ -3,34 +3,34 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + From e491d667f2bbb74e5cff77add78e107e956ce6d7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 5 Sep 2018 02:38:32 +0300 Subject: [PATCH 517/605] Fixed failed test case updateVodMediaBaseFields() --- .../versions/five_zero_two/IngestVodOpcTests.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 5178e4f65..a26317f50 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -222,11 +222,11 @@ public void updateVodMediaBaseFields() { Response resp = getResponseBodyFromIngestVod(updateRequest); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); - AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(movie.getId()), AssetReferenceType.MEDIA) + AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(asset.getId()), AssetReferenceType.MEDIA) .setKs(getAnonymousKs()); com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); MediaAsset asset2 = (MediaAsset)assetGetResponse.results; - assertThat(asset2.getId()).isEqualTo(movie.getId()); + assertThat(asset2.getId()).isEqualTo(asset.getId()); assertThat(asset2.getName()).isEqualTo(name); assertThat(asset2.getDescription()).isEqualTo(""); assertThat(((MultilingualStringValue)asset2.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); @@ -243,7 +243,6 @@ public void updateVodMediaBaseFields() { assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); } - @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { From 8d6b49c0cc80f93a599c1ea49551b83a4f5d2fe7 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 5 Sep 2018 08:35:04 +0300 Subject: [PATCH 518/605] groups "Permission management" set into class level instead of method level --- .../PermissionsManagementTests.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 464cb0a8d..f943725a5 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -9,12 +9,9 @@ import org.apache.commons.io.FileUtils; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.List; - import static com.kaltura.client.test.utils.BaseUtils.deleteFile; import static com.kaltura.client.test.utils.BaseUtils.getFileContent; import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; @@ -26,6 +23,7 @@ * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-4885 * started in 4_8 and completed in 5_0_3 */ +@Test(groups = {"Permission management"}) public class PermissionsManagementTests { String mainFile = "PermissionsDeployment.exe"; @@ -62,7 +60,7 @@ public void setUp() { public static final String IMPORT_JSON_KEY = "l="; @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util without parameters") + @Test(description = "execute console util without parameters") public void runningWithoutParameters() { List commands = getConsoleCommand(fullPath2Util, ""); String consoleOutput = executeCommandsInColsole(commands); @@ -77,7 +75,7 @@ public void runningWithoutParameters() { @Severity(SeverityLevel.MINOR) @Issue("BEO-5504") - @Test(groups = {"Permission management"}, description = "execute console util to export without mentioned file") + @Test(description = "execute console util to export without mentioned file") public void runningExportWithoutFile() { List commands = getConsoleCommand(fullPath2Util, EXPORT_KEY); String consoleOutput = executeCommandsInColsole(commands); @@ -87,7 +85,7 @@ public void runningExportWithoutFile() { @Severity(SeverityLevel.MINOR) @Issue("BEO-5504") - @Test(groups = {"Permission management"}, description = "execute console util to import without mentioned file") + @Test(description = "execute console util to import without mentioned file") public void runningImportWithoutFile() { List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY); String consoleOutput = executeCommandsInColsole(commands); @@ -97,7 +95,7 @@ public void runningImportWithoutFile() { @Severity(SeverityLevel.MINOR) @Issue("BEO-5504") - @Test(groups = {"Permission management"}, description = "execute console util to delete without mentioned file") + @Test(description = "execute console util to delete without mentioned file") public void runningDeleteWithoutFile() { List commands = getConsoleCommand(fullPath2Util, DELETE_KEY); String consoleOutput = executeCommandsInColsole(commands); @@ -106,7 +104,7 @@ public void runningDeleteWithoutFile() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to export data from DB into file") + @Test(description = "execute console util to export data from DB into file") public void export() { // prepare data inserting them in DB using stored procedures String suffix = String.valueOf(BaseUtils.getEpoch()); @@ -137,7 +135,7 @@ public void export() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from file having only 4 tables instead of 5") + @Test(description = "execute console util to import data into DB from file having only 4 tables instead of 5") public void runningImportFromFileNotHavingAllTables() { // remove log file deleteFile(path2Log); @@ -151,7 +149,7 @@ public void runningImportFromFileNotHavingAllTables() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to try import data into DB from empty file") + @Test(description = "execute console util to try import data into DB from empty file") public void runningImportFromEmptyFile() { // remove log file deleteFile(path2Log); @@ -165,7 +163,7 @@ public void runningImportFromEmptyFile() { } @Severity(SeverityLevel.MINOR) - @Test(groups = {"Permission management"}, description = "execute console util to try delete data from DB using empty file") + @Test(description = "execute console util to try delete data from DB using empty file") public void runningDeleteUsingEmptyFile() { // remove log file deleteFile(path2Log); @@ -179,7 +177,7 @@ public void runningDeleteUsingEmptyFile() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to import data into DB from valid file") + @Test(description = "execute console util to import data into DB from valid file") public void importFromFile() { String suffix = String.valueOf(BaseUtils.getEpoch()); String roleName = "MaxTest" + suffix; @@ -219,7 +217,7 @@ public void importFromFile() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"Permission management"}, description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") + @Test(description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { // TODO: update test // remove log file @@ -259,7 +257,7 @@ public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to delete data from DB") + @Test(description = "execute console util to delete data from DB") public void deleteFromDB() { String suffix = String.valueOf(BaseUtils.getEpoch()); String roleName = "MaxTest" + suffix; @@ -311,7 +309,7 @@ public void deleteFromDB() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to import already existed data into DB from valid file") + @Test(description = "execute console util to import already existed data into DB from valid file") public void importAlreadyExistedFromFile() { String suffix = String.valueOf(BaseUtils.getEpoch()); String roleName = "MaxTest" + suffix; @@ -354,7 +352,7 @@ public void importAlreadyExistedFromFile() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"Permission management"}, description = "execute console util to try delete data in DB using file with invalid tags") + @Test(description = "execute console util to try delete data in DB using file with invalid tags") public void runningDeleteUsingFileWithInvalidTags() { // insert role in DB String suffix = String.valueOf(BaseUtils.getEpoch()); @@ -374,7 +372,7 @@ public void runningDeleteUsingFileWithInvalidTags() { } @Severity(SeverityLevel.NORMAL) - @Test(groups = {"Permission management"}, description = "execute console util to delete data in 1 related table of DB") + @Test(description = "execute console util to delete data in 1 related table of DB") public void deleteOnlyFromOneTable() { // insert role in DB String suffix = String.valueOf(BaseUtils.getEpoch()); @@ -395,7 +393,7 @@ public void deleteOnlyFromOneTable() { @Severity(SeverityLevel.MINOR) @Issue("BEO-5504") - @Test(groups = {"Permission management"}, description = "execute console util to export in JSON without mentioned file") + @Test(description = "execute console util to export in JSON without mentioned file") public void runningExportJsonWithoutFile() { List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY); String consoleOutput = executeCommandsInColsole(commands); @@ -405,7 +403,7 @@ public void runningExportJsonWithoutFile() { @Severity(SeverityLevel.MINOR) @Issue("BEO-5504") - @Test(groups = {"Permission management"}, description = "execute console util to import in JSON without mentioned file") + @Test(description = "execute console util to import in JSON without mentioned file") public void runningImportJsonWithoutFile() { List commands = getConsoleCommand(fullPath2Util, IMPORT_JSON_KEY); String consoleOutput = executeCommandsInColsole(commands); @@ -414,7 +412,7 @@ public void runningImportJsonWithoutFile() { } @Severity(SeverityLevel.CRITICAL) - @Test(groups = {"Permission management"}, description = "execute console util to export in JSON from DB") + @Test(description = "execute console util to export in JSON from DB") public void exportJson() throws IOException { // clean folder with logs FileUtils.cleanDirectory(new File(path2JsonFolder)); From a7d75e9e55f6756173716d3bd44e7257e514213e Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 5 Sep 2018 09:02:46 +0300 Subject: [PATCH 519/605] draft for json import --- .../PermissionsManagementTests.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index f943725a5..40522ee03 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -427,7 +427,7 @@ public void exportJson() throws IOException { "parameter" + suffix, true); // command List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); - String consoleOutput = executeCommandsInColsole(commands); + executeCommandsInColsole(commands); String importFileContent = getFileContent(generatedDataFilePath); assertThat(importFileContent).contains(roleName); @@ -443,6 +443,48 @@ public void exportJson() throws IOException { PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); } +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "execute console util to import from JSON into DB") +// public void importJson() throws IOException { +// // clean folder with logs +// FileUtils.cleanDirectory(new File(path2JsonFolder)); +// +// // export command to get results +// List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); +// executeCommandsInColsole(commands); +// +// // prepare data +// String suffix = String.valueOf(BaseUtils.getEpoch()); +// String roleName = "MaxTest" + suffix; +// String permissionItemName = "Asset_List_Max" + suffix; +// String serviceName = "asset"; +// fillFilesWithImportData(roleName, permissionItemName, serviceName); +// +// PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", +// permissionItemName, serviceName, "list", "permissionItemObject" + suffix, +// "parameter" + suffix, true); +// +// String importFileContent = getFileContent(generatedDataFilePath); +// assertThat(importFileContent).contains(roleName); +// assertThat(importFileContent).contains(permissionItemName); +// checkActionResult(serviceName, importFileContent); +// +// // cleaning +// int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); +// PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); +// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); +// PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); +// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); +// PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); +// } + + // method checks that all related files contain information related to service + /** + * + * @param serviceName - name of service (e.g.: "asset") + * @param importFileContent - file created during adding data into DB by util PermissionManagementUtils.insertDataInAllTables + * data in that file related to data from files with roles info, permissions info and methods info and separated by symbol ";" + */ void checkActionResult(String serviceName, String importFileContent) { // data prepared so that they splitted by symbol ";" String[] results = importFileContent.split(";"); From 9683b0870f260d289f8187425b2c5841ddbfbb75 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 5 Sep 2018 13:54:04 +0300 Subject: [PATCH 520/605] clean shared params after each suite in order to switch groups --- .../kaltura/client/test/tests/BaseTest.java | 59 +++++++++++++------ .../client/test/utils/annotations/Shared.java | 8 +++ .../client/test/utils/dbUtils/DBUtils.java | 15 +++-- .../utils/ingestUtils/IngestVodOpcUtils.java | 2 - .../utils/ingestUtils/IngestVodUtils.java | 9 ++- 5 files changed, 64 insertions(+), 29 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/annotations/Shared.java diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 19feb73c8..56f065012 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -6,6 +6,7 @@ import com.kaltura.client.services.ChannelService.AddChannelBuilder; import com.kaltura.client.test.TestAPIOkRequestsExecutor; import com.kaltura.client.test.utils.PerformanceUtils; +import com.kaltura.client.test.utils.annotations.Shared; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.*; @@ -20,6 +21,8 @@ import java.io.File; import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.nio.file.Files; import java.util.*; @@ -67,51 +70,49 @@ public class BaseTest { // shared common params public static int partnerId; -// public static int opcPartnerId; public static boolean isOpcGroup; public static String defaultUserPassword; // shared ks's - private static String administratorKs, operatorKs, managerKs, anonymousKs; + @Shared private static String administratorKs, operatorKs, managerKs, anonymousKs; // shared ingest users data - private static String ingestAssetUserUsername, ingestAssetUserPassword, ingestBusinessModuleUserUsername, + @Shared private static String ingestAssetUserUsername, ingestAssetUserPassword, ingestBusinessModuleUserUsername, ingestBusinessModuleUserPassword, ingestVirtualAssetUserUsername, ingestVirtualAssetUserPassword; // shared VOD - private static MediaAsset mediaAsset; + @Shared private static MediaAsset mediaAsset; // shared channel name - private static String epgChannelName; + @Shared private static String epgChannelName; // shared EPG program - private static Asset epgProgram; + @Shared private static Asset epgProgram; // shared files - private static MediaFile webMediaFile; - private static MediaFile mobileMediaFile; + @Shared private static MediaFile webMediaFile; + @Shared private static MediaFile mobileMediaFile; // shared MPP - private static Subscription fiveMinRenewableSubscription; + @Shared private static Subscription fiveMinRenewableSubscription; // shared ingested PP - private static PricePlan sharedCommonPricePlan; + @Shared private static PricePlan sharedCommonPricePlan; // shared discount module for shared PP - private static DiscountModule sharedCommonDiscountModule; + @Shared private static DiscountModule sharedCommonDiscountModule; // shared ingested subscription - private static Subscription sharedCommonSubscription; + @Shared private static Subscription sharedCommonSubscription; // shared collection - private static Collection sharedCommonCollection; + @Shared private static Collection sharedCommonCollection; // shared ingested PPV - private static Ppv sharedCommonPpv; + @Shared private static Ppv sharedCommonPpv; // cycles map with values related view/full life cycles of price plans - public static Map cycles = new HashMap<>(); - + private static Map cycles = new HashMap<>(); { // TODO: complete other values cycles.put(1440, "1 Day"); @@ -139,6 +140,9 @@ public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String // set default awaitility timeout setDefaultTimeout(Long.parseLong(getProperty(DEFAULT_TIMEOUT_IN_SEC)), TimeUnit.SECONDS); + // set default users password + defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); + // set shared common params if ("opc".equals(accountType)) { isOpcGroup = true; @@ -148,8 +152,6 @@ public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String partnerId = Integer.parseInt(getProperty(PARTNER_ID)); } - defaultUserPassword = getProperty(DEFAULT_USER_PASSWORD); - // set performance report if ("true".equals(getProperty(WRITE_REGRESSION_LOGS)) && numOfSuites == getNumOfSuites()) { File logsDir = new File(getProperty(LOGS_DIR)); @@ -602,6 +604,9 @@ public void baseTest_afterSuite(ITestContext testContext) { XmlSuite suite = testContext.getCurrentXmlTest().getSuite(); Logger.getLogger(BaseTest.class).debug("End suite >>> Suite: " + suite.getName()); + // reset shared params + getSharedParams().forEach(o -> o = null); + // generate performance report if ("true".equals(getProperty(WRITE_REGRESSION_LOGS)) && numOfSuites == 0) { PerformanceUtils.generatePerformanceReport(); @@ -616,4 +621,22 @@ private static int getNumOfSuites() { return suites.getLength(); } + private List getSharedParams() { + List sharedParams = new ArrayList<>(); + + for (Field field : this.getClass().getDeclaredFields()) { + for (Annotation annotation : field.getDeclaredAnnotations()) { + if (annotation instanceof Shared) { + try { + field.setAccessible(true); + sharedParams.add(field.get(this)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + } + return sharedParams; + } + } diff --git a/src/test/java/com/kaltura/client/test/utils/annotations/Shared.java b/src/test/java/com/kaltura/client/test/utils/annotations/Shared.java new file mode 100644 index 000000000..33f6cccd0 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/annotations/Shared.java @@ -0,0 +1,8 @@ +package com.kaltura.client.test.utils.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface Shared { +} diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 8ca1ae328..813b95a0d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -265,12 +265,15 @@ public static JSONObject getUserById(int userId) { } public static int getMediaTypeId(MediaType mediaType) { - return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, - partnerId + 1, - partnerId + 2, - mediaType.getValue()) - .getJSONObject(0) - .getInt("id"); + if (isOpcGroup) { + return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId, partnerId, mediaType.getValue()) + .getJSONObject(0) + .getInt("id"); + } else { + return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 1, partnerId + 2, mediaType.getValue()) + .getJSONObject(0) + .getInt("id"); + } } public static String getMediaFileTypeName(int mediaFileId) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 592419d5d..16135f0cf 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -28,8 +28,6 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static final String FILE_TYPE_2 = "new file type1"; public static final String EMPTY_FILE_1_TAG = "\n"; public static final String EMPTY_FILE_2_TAG = "\n"; - public static final String EMPTY_IMAGE_TAG = "\n"; - public static final String EMPTY_THUMB_TAG = "\n"; // TODO: remove it using util public static final String DELETE_VOD_XML = "\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 0dfb26f9b..e9e38269b 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -172,7 +172,7 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); - Response resp = getResponseBodyFromIngestVod(reqBody); + Response resp = executeIngestVodRequest(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); @@ -190,7 +190,7 @@ public static MediaAsset updateVod(String coguid, VodData vodData) { vodData.coguid = coguid; String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_UPDATE); - Response resp = getResponseBodyFromIngestVod(reqBody); + Response resp = executeIngestVodRequest(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); @@ -210,6 +210,7 @@ public static void deleteVod(String coguid) { String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_DELETE); Response resp = executeIngestVodRequest(reqBody); + // on delete it returns media id // assertThat(from(resp.asString()).getInt(ingestAssetIdPath)).isEqualTo(0); } @@ -222,6 +223,8 @@ public static Response getResponseBodyFromIngestVod(String reqBody) { .when() .post(ingestUrl); + assertThat(resp).isNotNull(); + Logger.getLogger(IngestVodUtils.class).debug(reqBody + "\n"); Logger.getLogger(IngestVodUtils.class).debug(resp.asString()); @@ -232,7 +235,7 @@ public static Response getResponseBodyFromIngestVod(String reqBody) { private static Response executeIngestVodRequest(String reqBody) { Response resp = getResponseBodyFromIngestVod(reqBody); - assertThat(resp).isNotNull(); + assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); return resp; From 77aeb4bb1eb604289a8006b5c366b810883242e1 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 5 Sep 2018 15:42:34 +0300 Subject: [PATCH 521/605] fix resetSharedParmas() --- .../com/kaltura/client/test/tests/BaseTest.java | 10 +++------- .../client/test/utils/PerformanceUtils.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 56f065012..416032c63 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -605,7 +605,7 @@ public void baseTest_afterSuite(ITestContext testContext) { Logger.getLogger(BaseTest.class).debug("End suite >>> Suite: " + suite.getName()); // reset shared params - getSharedParams().forEach(o -> o = null); + resetSharedParams(); // generate performance report if ("true".equals(getProperty(WRITE_REGRESSION_LOGS)) && numOfSuites == 0) { @@ -621,22 +621,18 @@ private static int getNumOfSuites() { return suites.getLength(); } - private List getSharedParams() { - List sharedParams = new ArrayList<>(); - + void resetSharedParams() { for (Field field : this.getClass().getDeclaredFields()) { for (Annotation annotation : field.getDeclaredAnnotations()) { if (annotation instanceof Shared) { try { field.setAccessible(true); - sharedParams.add(field.get(this)); + field.set(this, null); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } - return sharedParams; } - } diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index be9de4412..01a3a32c0 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -41,7 +41,7 @@ public class PerformanceUtils extends BaseUtils { public static void generatePerformanceReport() { - logger.debug("start generate performance report..."); + logger.debug("start generatePerformanceReport()"); // get aggregate regression data sessions List regressionSessions = getRegressionData().values() @@ -55,10 +55,12 @@ public static void generatePerformanceReport() { // write performance report writeReport(sessions); - logger.debug("finish generate performance report!"); + logger.debug("finish generatePerformanceReport()"); } private static Map> getRegressionData() { + logger.debug("start getRegressionData()"); + File data = new File(getProperty(LOGS_DIR) + getProperty(REGRESSION_LOGS_FILE)); List lines = null; try { @@ -67,6 +69,8 @@ private static Map> getRegressionData() { e.printStackTrace(); } + logger.debug("end getRegressionData()"); + return lines .stream() .collect(Collectors.groupingBy( @@ -129,6 +133,8 @@ private static List getLinesFromUrls(List urls) { } private static List getSessions(List sessionStrings) { + logger.debug("start getSessions()"); + List lines = getLinesFromUrls(getLogFilesUrls()); List sessionList = new ArrayList<>(); @@ -146,6 +152,8 @@ private static Session getSession(List lines, String session) { } }); + logger.debug("end getSessions()"); + return new Session(sessionData); } @@ -171,6 +179,8 @@ private static File getReportFile() { } private static void writeReport(List sessions) { + logger.debug("start writeReport()"); + List slowSessions = getSlowSessions(sessions); Map slowActionsCount = slowSessions.stream().collect(Collectors.groupingBy( @@ -190,7 +200,6 @@ private static void writeReport(List sessions) { + "Max percentage: " + getProperty(MAX_CODE_PERCENTAGE) + "%\n" + "Max execution time: " + getProperty(MAX_EXECUTION_TIME_IN_SEC) + " sec\n\n" + "Slow Actions Summary:\n\n"; - try { FileUtils.writeStringToFile(file, reportSummary, Charset.defaultCharset(), true); @@ -220,6 +229,8 @@ private static void writeReport(List sessions) { e.printStackTrace(); } }); + + logger.debug("end writeReport()"); } @Getter From 9779743c7ab472d3499cb44a6ee09219d9ea999e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 5 Sep 2018 16:46:14 +0300 Subject: [PATCH 522/605] change testng xmls for testing --- .../kaltura/client/test/tests/BaseTest.java | 7 ++- .../five_zero_two/IngestVodOpcTests.java | 46 ++++++++++------ .../client/test/utils/PerformanceUtils.java | 5 +- src/test/resources/testng_opc.xml | 18 +++++-- src/test/resources/testng_regular.xml | 54 +++++++++---------- 5 files changed, 79 insertions(+), 51 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 416032c63..b3eeba833 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -622,17 +622,22 @@ private static int getNumOfSuites() { } void resetSharedParams() { - for (Field field : this.getClass().getDeclaredFields()) { + Logger.getLogger(BaseTest.class).debug("start resetSharedParams()"); + + for (Field field : BaseTest.class.getDeclaredFields()) { for (Annotation annotation : field.getDeclaredAnnotations()) { if (annotation instanceof Shared) { try { field.setAccessible(true); field.set(this, null); + Logger.getLogger(BaseTest.class).debug("set " + field.getName() + " to null"); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } + + Logger.getLogger(BaseTest.class).debug("finish resetSharedParams()"); } } diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 5178e4f65..36a2e8674 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.services.AssetService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; @@ -41,17 +42,18 @@ @Test(groups = { "opc", "ingest VOD for OPC" }) // tag @Test allow to exclude class from testng using it's group name in form public class IngestVodOpcTests extends BaseTest { - private MediaAsset movie; - private MediaAsset episode; - private MediaAsset series; +// private MediaAsset episode; +// private MediaAsset series; + private int movieType; private int episodeType; private int seriesType; - private String localCoguid = ""; + private String localCoguid; private String ingestInsertXml; private String ingestDeleteXml; + private static final String suffix4Coguid = "123"; private static String coguid4NegativeTests = ""; @@ -60,6 +62,7 @@ public class IngestVodOpcTests extends BaseTest { @BeforeClass() public void setUp() { + // get data for ingest 2 files fileTypeNames = DBUtils.getMediaFileTypeNames(2); ppvNames = DBUtils.getPpvNames(2); @@ -81,17 +84,26 @@ public void setUp() { ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); ingestDeleteXml = DELETE_VOD_XML.replaceAll("180822092522774", movie.getExternalId()); - episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1));; - generateDefaultValues4Insert(EPISODE); - vodData = getVodData(EPISODE, episodeAssetFiles); - episode = insertVod(vodData, true); - episodeType = episode.getType(); +// episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// generateDefaultValues4Insert(EPISODE); +// vodData = getVodData(EPISODE, episodeAssetFiles); +// episode = insertVod(vodData, true); +// episodeType = episode.getType(); + + episodeType = DBUtils.getMediaTypeId(MediaType.EPISODE); + +// seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// generateDefaultValues4Insert(SERIES); +// vodData = getVodData(SERIES, seriesAssetFiles); +// series = insertVod(vodData, true); +// seriesType = series.getType(); + + seriesType = DBUtils.getMediaTypeId(MediaType.SERIES); + } + + @Test + public void sandbox() { - seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1));; - generateDefaultValues4Insert(SERIES); - vodData = getVodData(SERIES, seriesAssetFiles); - series = insertVod(vodData, true); - seriesType = series.getType(); } @Severity(SeverityLevel.CRITICAL) @@ -295,7 +307,7 @@ public void updateVodSeriesBaseFields() { } @Severity(SeverityLevel.CRITICAL) - @Test(description = "delete") + @Test(description = "delete movie") public void deleteMovie() { String coguid = getCoguidOfActiveMediaAsset(movieType); checkVodDeletion(coguid); @@ -330,7 +342,7 @@ public void insertWithEmptyCoguid() { } @Severity(SeverityLevel.NORMAL) - @Test(description = "try delete without coguid", priority =-1) + @Test(description = "try delete without coguid") public void deleteWithEmptyCoguid() { String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); Response resp = getResponseBodyFromIngestVod(invalidXml); @@ -396,7 +408,7 @@ public void insertEmptyIsActive() { } @Severity(SeverityLevel.MINOR) - @Test(description = "try insert with empty name", priority =-1) + @Test(description = "try insert with empty name") public void insertWithEmptyName() { String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); Response resp = getResponseBodyFromIngestVod(invalidXml); diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index 01a3a32c0..bd6564f2a 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -139,6 +139,9 @@ private static List getSessions(List sessionStrings) { List sessionList = new ArrayList<>(); sessionStrings.forEach(s -> sessionList.add(getSession(lines, s))); + + + logger.debug("end getSessions()"); return sessionList; } @@ -152,8 +155,6 @@ private static Session getSession(List lines, String session) { } }); - logger.debug("end getSessions()"); - return new Session(sessionData); } diff --git a/src/test/resources/testng_opc.xml b/src/test/resources/testng_opc.xml index e68dc7221..fa993fb9d 100644 --- a/src/test/resources/testng_opc.xml +++ b/src/test/resources/testng_opc.xml @@ -8,9 +8,19 @@ - - - - + + + + + + + + + + + + + + diff --git a/src/test/resources/testng_regular.xml b/src/test/resources/testng_regular.xml index 2adb1885d..d95d10dd1 100644 --- a/src/test/resources/testng_regular.xml +++ b/src/test/resources/testng_regular.xml @@ -3,34 +3,34 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + From a4b45e3c96f613c31d0c7e4b6cfedfbac5def706 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 5 Sep 2018 17:12:03 +0300 Subject: [PATCH 523/605] revert change in testng xmls --- .../kaltura/client/test/tests/BaseTest.java | 15 ++++-- src/test/resources/testng_opc.xml | 22 ++++---- src/test/resources/testng_regular.xml | 54 +++++++++---------- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index b3eeba833..6c3009e99 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -13,6 +13,7 @@ import com.kaltura.client.types.Collection; import com.kaltura.client.utils.response.base.Response; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.ArrayUtils; import org.testng.ITestContext; import org.testng.annotations.*; import org.testng.xml.XmlSuite; @@ -544,9 +545,9 @@ private static DynamicChannel loadDefaultChannel() { // shared household public static class SharedHousehold { - private static Household sharedHousehold; - private static HouseholdUser sharedMasterUser, sharedUser; - private static String sharedMasterUserKs, sharedUserKs; + @Shared private static Household sharedHousehold; + @Shared private static HouseholdUser sharedMasterUser, sharedUser; + @Shared private static String sharedMasterUserKs, sharedUserKs; public static Household getSharedHousehold() { @@ -624,13 +625,17 @@ private static int getNumOfSuites() { void resetSharedParams() { Logger.getLogger(BaseTest.class).debug("start resetSharedParams()"); - for (Field field : BaseTest.class.getDeclaredFields()) { + // TODO: 9/5/2018 make dynamic in case more inner classes will be added + Field[] baseTestFields = BaseTest.class.getDeclaredFields(); + Field[] sharedHouseholdFields = SharedHousehold.class.getDeclaredFields(); + Field[] fields = ArrayUtils.addAll(baseTestFields, sharedHouseholdFields); + + for (Field field : fields) { for (Annotation annotation : field.getDeclaredAnnotations()) { if (annotation instanceof Shared) { try { field.setAccessible(true); field.set(this, null); - Logger.getLogger(BaseTest.class).debug("set " + field.getName() + " to null"); } catch (IllegalAccessException e) { e.printStackTrace(); } diff --git a/src/test/resources/testng_opc.xml b/src/test/resources/testng_opc.xml index fa993fb9d..0f03cfa07 100644 --- a/src/test/resources/testng_opc.xml +++ b/src/test/resources/testng_opc.xml @@ -9,18 +9,18 @@ - - - - + + + + - - - - - - - + + + + + + + diff --git a/src/test/resources/testng_regular.xml b/src/test/resources/testng_regular.xml index d95d10dd1..2adb1885d 100644 --- a/src/test/resources/testng_regular.xml +++ b/src/test/resources/testng_regular.xml @@ -3,34 +3,34 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + From eed58cfcd9acfe743f52264e7038f7d6e508a84f Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 5 Sep 2018 17:46:06 +0300 Subject: [PATCH 524/605] added logs to performane utils due to failure generating the report when running from Jeniks complete regression --- .../kaltura/client/test/utils/PerformanceUtils.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index bd6564f2a..99df8e388 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -80,6 +80,8 @@ private static Map> getRegressionData() { } private static List getLogFilesUrls() { + logger.debug("start getLogFilesUrls()"); + Document doc = null; try { doc = Jsoup.connect(logsUrl).get(); @@ -104,10 +106,14 @@ private static List getLogFilesUrls() { } }); + logger.debug("end getLogFilesUrls()"); + return urls; } private static List getLinesFromUrls(List urls) { + logger.debug("start getLinesFromUrls()"); + List> data = new ArrayList<>(); urls.forEach(url -> { @@ -126,6 +132,9 @@ private static List getLinesFromUrls(List urls) { } }); + + logger.debug("end getLinesFromUrls()"); + return data .stream() .flatMap(Collection::stream) @@ -140,7 +149,6 @@ private static List getSessions(List sessionStrings) { List sessionList = new ArrayList<>(); sessionStrings.forEach(s -> sessionList.add(getSession(lines, s))); - logger.debug("end getSessions()"); return sessionList; } From 0aafd35b071e2ea2a7361815e36386e7f94a522b Mon Sep 17 00:00:00 2001 From: Jenkins Date: Wed, 5 Sep 2018 15:49:04 +0000 Subject: [PATCH 525/605] Auto-generated by Jenkins --- pom.xml | 2 +- src/main/java/com/kaltura/client/Client.java | 2 +- .../kaltura/client/types/AssetStructMeta.java | 19 ------------------- .../client/types/BaseSearchAssetFilter.java | 2 +- .../kaltura/client/types/ChannelFilter.java | 2 +- .../kaltura/client/types/DynamicChannel.java | 2 +- .../kaltura/client/types/PersonalList.java | 2 +- 7 files changed, 6 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 73bba4aa6..c24c3aa36 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 4.0.0 com.kaltura KalturaOttApiClient - 5.0.2.27144-SNAPSHOT + 5.0.2.28437-SNAPSHOT jar diff --git a/src/main/java/com/kaltura/client/Client.java b/src/main/java/com/kaltura/client/Client.java index 5e3199e41..25b8dbf9d 100644 --- a/src/main/java/com/kaltura/client/Client.java +++ b/src/main/java/com/kaltura/client/Client.java @@ -44,7 +44,7 @@ public Client(ConnectionConfiguration config) { super(config); this.setClientTag("java:18-09-05"); - this.setApiVersion("5.0.2.27144"); + this.setApiVersion("5.0.2.28437"); this.clientConfiguration.put("format", 1); // JSON } diff --git a/src/main/java/com/kaltura/client/types/AssetStructMeta.java b/src/main/java/com/kaltura/client/types/AssetStructMeta.java index a31c95be2..8d9028d53 100644 --- a/src/main/java/com/kaltura/client/types/AssetStructMeta.java +++ b/src/main/java/com/kaltura/client/types/AssetStructMeta.java @@ -55,7 +55,6 @@ public interface Tokenizer extends ObjectBase.Tokenizer { String defaultIngestValue(); String createDate(); String updateDate(); - String isInherited(); } /** @@ -88,10 +87,6 @@ public interface Tokenizer extends ObjectBase.Tokenizer { as epoch. */ private Long updateDate; - /** - * Is inherited - */ - private Boolean isInherited; // assetStructId: public Long getAssetStructId(){ @@ -145,18 +140,6 @@ public Long getCreateDate(){ public Long getUpdateDate(){ return this.updateDate; } - // isInherited: - public Boolean getIsInherited(){ - return this.isInherited; - } - public void setIsInherited(Boolean isInherited){ - this.isInherited = isInherited; - } - - public void isInherited(String multirequestToken){ - setToken("isInherited", multirequestToken); - } - public AssetStructMeta() { super(); @@ -175,7 +158,6 @@ public AssetStructMeta(JsonObject jsonObject) throws APIException { defaultIngestValue = GsonParser.parseString(jsonObject.get("defaultIngestValue")); createDate = GsonParser.parseLong(jsonObject.get("createDate")); updateDate = GsonParser.parseLong(jsonObject.get("updateDate")); - isInherited = GsonParser.parseBoolean(jsonObject.get("isInherited")); } @@ -185,7 +167,6 @@ public Params toParams() { kparams.add("ingestReferencePath", this.ingestReferencePath); kparams.add("protectFromIngest", this.protectFromIngest); kparams.add("defaultIngestValue", this.defaultIngestValue); - kparams.add("isInherited", this.isInherited); return kparams; } diff --git a/src/main/java/com/kaltura/client/types/BaseSearchAssetFilter.java b/src/main/java/com/kaltura/client/types/BaseSearchAssetFilter.java index ded0ce441..50af14695 100644 --- a/src/main/java/com/kaltura/client/types/BaseSearchAssetFilter.java +++ b/src/main/java/com/kaltura/client/types/BaseSearchAssetFilter.java @@ -74,7 +74,7 @@ only assets that the user defined as his interests (by tags and metas) will (not), ~ (like), !~, ^ (any word starts with), ^= (phrase starts with), + (exists), !+ (not exists). Logical conjunction: and, or. Search values are limited to 20 characters each for the next operators: ~, - !~, ^, ^= (maximum length of entire filter is 4096 characters) + !~, ^, ^= (maximum length of entire filter is 2048 characters) */ private String kSql; /** diff --git a/src/main/java/com/kaltura/client/types/ChannelFilter.java b/src/main/java/com/kaltura/client/types/ChannelFilter.java index e70d5a88f..b6726b58d 100644 --- a/src/main/java/com/kaltura/client/types/ChannelFilter.java +++ b/src/main/java/com/kaltura/client/types/ChannelFilter.java @@ -79,7 +79,7 @@ only assets that the user defined as his interests (by tags and metas) will (not), ~ (like), !~, ^ (any word starts with), ^= (phrase starts with), + (exists), !+ (not exists). Logical conjunction: and, or. Search values are limited to 20 characters each for the next operators: ~, - !~, ^, ^= (maximum length of entire filter is 4096 characters) + !~, ^, ^= (maximum length of entire filter is 2048 characters) */ private String kSql; /** diff --git a/src/main/java/com/kaltura/client/types/DynamicChannel.java b/src/main/java/com/kaltura/client/types/DynamicChannel.java index b1acd9906..27d5044bb 100644 --- a/src/main/java/com/kaltura/client/types/DynamicChannel.java +++ b/src/main/java/com/kaltura/client/types/DynamicChannel.java @@ -75,7 +75,7 @@ only assets that the user defined as his interests (by tags and metas) will =, != (not), ~ (like), !~, ^ (any word starts with), ^= (phrase starts with), + (exists), !+ (not exists). Logical conjunction: and, or. Search values are limited to 20 characters each. (maximum length - of entire filter is 4096 characters) + of entire filter is 2048 characters) */ private String kSql; /** diff --git a/src/main/java/com/kaltura/client/types/PersonalList.java b/src/main/java/com/kaltura/client/types/PersonalList.java index 1baf1b2ef..a2718fcb5 100644 --- a/src/main/java/com/kaltura/client/types/PersonalList.java +++ b/src/main/java/com/kaltura/client/types/PersonalList.java @@ -88,7 +88,7 @@ only assets that the user defined as his interests (by tags and metas) will (not), ~ (like), !~, ^ (any word starts with), ^= (phrase starts with), + (exists), !+ (not exists). Logical conjunction: and, or. Search values are limited to 20 characters each for the next operators: ~, - !~, ^, ^= (maximum length of entire filter is 4096 characters) + !~, ^, ^= (maximum length of entire filter is 2048 characters) */ private String ksql; /** From a246a2824476dd40f3dd8b255b02d09720dfb477 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 6 Sep 2018 01:08:26 +0300 Subject: [PATCH 526/605] Added more logic for importJson --- .../PermissionsManagementTests.java | 86 +++++++++++-------- .../test/utils/PermissionManagementUtils.java | 29 +++++++ 2 files changed, 81 insertions(+), 34 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 40522ee03..0978ff24e 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -443,40 +443,58 @@ public void exportJson() throws IOException { PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); } -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "execute console util to import from JSON into DB") -// public void importJson() throws IOException { -// // clean folder with logs -// FileUtils.cleanDirectory(new File(path2JsonFolder)); -// -// // export command to get results -// List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); -// executeCommandsInColsole(commands); -// -// // prepare data -// String suffix = String.valueOf(BaseUtils.getEpoch()); -// String roleName = "MaxTest" + suffix; -// String permissionItemName = "Asset_List_Max" + suffix; -// String serviceName = "asset"; -// fillFilesWithImportData(roleName, permissionItemName, serviceName); -// -// PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", -// permissionItemName, serviceName, "list", "permissionItemObject" + suffix, -// "parameter" + suffix, true); -// -// String importFileContent = getFileContent(generatedDataFilePath); -// assertThat(importFileContent).contains(roleName); -// assertThat(importFileContent).contains(permissionItemName); -// checkActionResult(serviceName, importFileContent); -// -// // cleaning -// int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); -// PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); -// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); -// PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); -// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); -// PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); -// } + @Severity(SeverityLevel.CRITICAL) + @Test(description = "execute console util to import from JSON into DB") + public void importJson() throws IOException { + // clean folder with logs + FileUtils.cleanDirectory(new File(path2JsonFolder)); + + // export command to get results and not break + List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); + executeCommandsInColsole(commands); + + // prepare data + String suffix = String.valueOf(BaseUtils.getEpoch()); + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; + String serviceName = "asset"; + fillFilesWithImportData(roleName, permissionItemName, "partner*", serviceName, "list"); + + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", + permissionItemName, serviceName, "list", "permissionItemObject" + suffix, + "parameter" + suffix, true); + + String importFileContent = getFileContent(generatedDataFilePath); + assertThat(importFileContent).contains(roleName); + assertThat(importFileContent).contains(permissionItemName); + checkActionResult(serviceName, importFileContent); + + // cleaning + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); + PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); + PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); + PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); + } + + private void fillFilesWithImportData(String roleName, String permissionItemName, String usersGroup, String serviceName, String actionName) { + fillRolesFile(roleName); + fillPermissionsFile(roleName, usersGroup); + fillServiceFile(roleName, permissionItemName, serviceName, actionName); + } + + private void fillServiceFile(String roleName, String permissionItemName, String serviceName, String actionName) { + // TODO: + } + + private void fillPermissionsFile(String roleName, String usersGroup) { + // TODO: + } + + private void fillRolesFile(String roleName) { + // TODO: + } // method checks that all related files contain information related to service /** diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index baaefe363..2b122b264 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -2,12 +2,41 @@ import com.kaltura.client.Logger; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; +import lombok.Data; +import lombok.experimental.Accessors; import java.io.*; import java.util.ArrayList; import java.util.List; public class PermissionManagementUtils extends BaseUtils { + @Accessors(fluent = true) + @Data + public static class PermissionItem { + private List permissions; + private List excludedPermissions; + private String name; + private String service; + private String action; + private String type; + } + + @Accessors(fluent = true) + @Data + public static class Permission { + private String name; + private String usersGroup; + } + + @Accessors(fluent = true) + @Data + public static class Role { + private List permissions; + private List excludedPermissions; + private String name; + } + + public static void printPermissionPermissionItem(PrintWriter writer, long id, long permissionId, long permissionItemId, int isExcluded, String permissionItemName, String permissionName) { writer.println(""); From d1006ae76fba36db75a9b9a296d9dd9fd7460a4e Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 6 Sep 2018 10:36:05 +0300 Subject: [PATCH 527/605] fix performane report --- .../client/test/utils/PerformanceUtils.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index 99df8e388..0e0a90ea5 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -43,7 +43,7 @@ public class PerformanceUtils extends BaseUtils { public static void generatePerformanceReport() { logger.debug("start generatePerformanceReport()"); - // get aggregate regression data sessions + // get aggregate regression sessions strings List regressionSessions = getRegressionData().values() .stream() .flatMap(List::stream) @@ -145,9 +145,14 @@ private static List getSessions(List sessionStrings) { logger.debug("start getSessions()"); List lines = getLinesFromUrls(getLogFilesUrls()); - + List sessionList = new ArrayList<>(); - sessionStrings.forEach(s -> sessionList.add(getSession(lines, s))); + sessionStrings.forEach(s -> { + Session session = getSession(lines, s); + if (session != null) { + sessionList.add(session); + } + }); logger.debug("end getSessions()"); return sessionList; @@ -163,6 +168,11 @@ private static Session getSession(List lines, String session) { } }); + if (sessionData.size() == 0) { + logger.debug("missing session from logs: " + session); + return null; + } + return new Session(sessionData); } From 6a80c7ac1f8a7922075a2420308aded02c4d0db9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 6 Sep 2018 14:26:45 +0300 Subject: [PATCH 528/605] added action average time to performance report --- .../java/com/kaltura/client/test/utils/PerformanceUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index 0e0a90ea5..788fa4f35 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -169,7 +169,7 @@ private static Session getSession(List lines, String session) { }); if (sessionData.size() == 0) { - logger.debug("missing session from logs: " + session); +// logger.debug("missing session from logs: " + session); return null; } @@ -226,10 +226,11 @@ private static void writeReport(List sessions) { long actionSlowCount = aLong; long actionTotalCount = actionsCount.get(s); double slowPercentage = (double) actionSlowCount / actionTotalCount * 100; + double averageTime = sessions.stream().filter(session -> session.getAction().equals(s)).mapToDouble(Session::getTotalTime).sum() / actionTotalCount; try { FileUtils.writeStringToFile(file, s + " - was slow " + String.format("%.0f", slowPercentage) + - "% of executions (" + actionSlowCount + "/" + actionTotalCount + ")\n", + "% of executions (" + actionSlowCount + "/" + actionTotalCount + ") " + "[average time: " + String.format("%.2f", averageTime) + " sec]\n", Charset.defaultCharset(), true); } catch (IOException e) { e.printStackTrace(); From c5c41fe93a03a4beb3c13a4fa3122d6621fbbb1d Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Fri, 7 Sep 2018 15:17:48 +0300 Subject: [PATCH 529/605] Added draft of ParentChildMetadataInheritanceTest class. Added AssetStruct.json --- .../ParentChildMetadataInheritanceTests.java | 90 +++++++++++++++ src/test/resources/schemas/AssetStruct.json | 109 ++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java create mode 100644 src/test/resources/schemas/AssetStruct.json diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java new file mode 100644 index 000000000..4f4bc1eaf --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -0,0 +1,90 @@ +package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; + +import com.kaltura.client.services.AssetStructService; +import com.kaltura.client.services.AssetStructService.*; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.AssetStruct; +import com.kaltura.client.types.AssetStructFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.TranslationToken; +import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * + * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-5423 + */ +@Test(groups = { "opc", "Parent children metadata inheritance" }) +public class ParentChildMetadataInheritanceTests extends BaseTest { + + @BeforeClass() + public void setUp() { + } + + @Test + public void sandbox() { + String prefix = "MaxTest_assetStruct_"; + // added to play with methods that are going to be checked + + // assetStructList + AssetStructFilter filter = new AssetStructFilter(); + ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); + Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + assertThat(assetStructListResponse.results.getTotalCount()).isGreaterThan(0); + String metaIds = assetStructListResponse.results.getObjects().get(0).getMetaIds(); + + // assetStructAdd + AssetStruct assetStruct = getAssetStruct(prefix, "eng"); + assetStruct.setMetaIds(metaIds); + AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(assetStruct); + Response assetStructResponse = executor.executeSync(addAssetStructBuilder + .setKs(getOperatorKs()).setLanguage("*")); + AssetStruct assetStructFromResponse = assetStructResponse.results; + assertThat(assetStructResponse.results.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); + + assetStruct.setSystemName(prefix + "_System_name_upd"); + + // assetStructUpdate + UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update(assetStructFromResponse.getId(), assetStruct); + assetStructResponse = executor.executeSync(updateAssetStructBuilder.setKs(getOperatorKs()).setLanguage("*")); + assertThat(assetStructResponse.results.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name_upd"); + + // assetStructDelete + DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(assetStructFromResponse.getId()); + Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder.setKs(getOperatorKs())); + assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); + } + + @Test + public void sandboxDelete() { + DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(2381); + Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder.setKs(getOperatorKs())); + assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); + } + + AssetStruct getAssetStruct(String prefix, String language) { + AssetStruct assetStruct = new AssetStruct(); + assetStruct.setSystemName(prefix + "_System_name"); + List translationTokens = new ArrayList<>(); + TranslationToken translationToken = new TranslationToken(); + translationToken.setValue(prefix + "_multiLingualName"); + translationToken.setLanguage(language); + translationTokens.add(translationToken); + assetStruct.setMultilingualName(translationTokens); + assetStruct.setIsProtected(false); + assetStruct.setMetaIds(""); + return assetStruct; + } + + @AfterClass() + public void tearDown() { + } +} diff --git a/src/test/resources/schemas/AssetStruct.json b/src/test/resources/schemas/AssetStruct.json new file mode 100644 index 000000000..e62ed6b0b --- /dev/null +++ b/src/test/resources/schemas/AssetStruct.json @@ -0,0 +1,109 @@ +{ + "$id": "AssetStruct", + "definitions": { + "AssetStruct": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "enum": ["KalturaAssetStruct"] + }, + "connectedParentMetaId": { + "type": "integer", + "minimum": 0 + }, + "connectingMetaId": { + "type": "integer", + "minimum": 0 + }, + "createDate": { + "type": "integer", + "minimum": 1 + }, + "features": { + "type": "string", + "minLength": 0 + }, + "id": { + "type": "integer", + "minimum": 1 + }, + "isProtected": { + "type": "boolean" + }, + "metaIds": { + "type": "string", + "minLength": 1 + }, + "name": { + "type": "string", + "minLength": 0 + }, + "multilingualName": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "enum": ["KalturaTranslationToken"] + }, + "language": { + "type": "string", + "minLength": 3 + }, + "value": { + "type": "string" + } + }, + "required": [ + "objectType", + "language", + "value" + ] + } + }, + "parentId": { + "type": "integer", + "minimum": 0 + }, + "pluralName": { + "type": "string", + "minLength": 0 + }, + "systemName": { + "type": "string", + "minLength": 1 + }, + "updateDate": { + "type": "integer", + "minimum": 1 + } + }, + "required": [ + "id", + "connectedParentMetaId", + "connectingMetaId", + "createDate", + "features", + "isProtected", + "objectType", + "name", + "multilingualName", + "parentId", + "pluralName", + "systemName", + "updateDate" + ] + } + }, + "type": "object", + "properties": { + "executionTime": { + "type": "number" + }, + "result": { + "ref": "#/definitions/AssetStruct" + } + } +} \ No newline at end of file From cf93da2236b8fb731cd6a8a048da7d63e44db7ee Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sat, 8 Sep 2018 03:34:07 +0300 Subject: [PATCH 530/605] Added logic to process AssetStructMeta --- .../ParentChildMetadataInheritanceTests.java | 24 +++++--- .../resources/schemas/AssetStructMeta.json | 55 +++++++++++++++++++ src/test/resources/schemas/ListResponse.json | 6 +- 3 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/schemas/AssetStructMeta.json diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 4f4bc1eaf..066abc125 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -1,12 +1,11 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; +import com.kaltura.client.services.AssetStructMetaService; +import com.kaltura.client.services.AssetStructMetaService.*; import com.kaltura.client.services.AssetStructService; import com.kaltura.client.services.AssetStructService.*; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.AssetStruct; -import com.kaltura.client.types.AssetStructFilter; -import com.kaltura.client.types.ListResponse; -import com.kaltura.client.types.TranslationToken; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -41,6 +40,13 @@ public void sandbox() { assertThat(assetStructListResponse.results.getTotalCount()).isGreaterThan(0); String metaIds = assetStructListResponse.results.getObjects().get(0).getMetaIds(); + AssetStructMetaFilter assetStructMetaFilter = new AssetStructMetaFilter(); + assetStructMetaFilter.setAssetStructIdEqual(assetStructListResponse.results.getObjects().get(0).getId()); + ListAssetStructMetaBuilder listAssetStructMetaBuilder = AssetStructMetaService.list(assetStructMetaFilter); + Response> listAssetMetaStructResponse = executor.executeSync(listAssetStructMetaBuilder + .setKs(getOperatorKs())); + assertThat(listAssetMetaStructResponse.results.getTotalCount()).isGreaterThan(0); + // assetStructAdd AssetStruct assetStruct = getAssetStruct(prefix, "eng"); assetStruct.setMetaIds(metaIds); @@ -54,19 +60,23 @@ public void sandbox() { // assetStructUpdate UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update(assetStructFromResponse.getId(), assetStruct); - assetStructResponse = executor.executeSync(updateAssetStructBuilder.setKs(getOperatorKs()).setLanguage("*")); + assetStructResponse = executor.executeSync(updateAssetStructBuilder + .setKs(getOperatorKs()) + .setLanguage("*")); assertThat(assetStructResponse.results.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name_upd"); // assetStructDelete DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(assetStructFromResponse.getId()); - Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder.setKs(getOperatorKs())); + Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder + .setKs(getOperatorKs())); assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); } @Test public void sandboxDelete() { DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(2381); - Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder.setKs(getOperatorKs())); + Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder + .setKs(getOperatorKs())); assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); } diff --git a/src/test/resources/schemas/AssetStructMeta.json b/src/test/resources/schemas/AssetStructMeta.json new file mode 100644 index 000000000..678c10299 --- /dev/null +++ b/src/test/resources/schemas/AssetStructMeta.json @@ -0,0 +1,55 @@ +{ + "$id": "AssetStructMeta", + "definitions": { + "AssetStructMeta": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "enum": ["KalturaAssetStructMeta"] + }, + "assetStructId": { + "type": "integer", + "minimum": 1 + }, + "metaId": { + "type": "integer", + "minimum": 1 + }, + "ingestReferencePath": { + "type": "string", + "minLength": 0 + }, + "protectFromIngest": { + "type": "boolean" + }, + "defaultIngestValue": { + "type": "string", + "minLength": 0 + }, + "createDate": { + "type": "integer", + "minimum": 1 + }, + "updateDate": { + "type": "integer", + "minimum": 1 + }, + "isInherited": { + "type": "boolean" + } + }, + "required": [ + "assetStructId", + "metaId", + "ingestReferencePath", + "protectFromIngest", + "defaultIngestValue", + "createDate", + "updateDate", + "isInherited" + ] + } + }, + "$ref": "#/definitions/AssetStructMeta" +} \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 54fa378ca..e86b4f983 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -59,6 +59,9 @@ }, { "$ref": "DiscountDetails.json#/definitions/DiscountDetails" + }, + { + "$ref": "AssetStructMeta.json#/definitions/AssetStructMeta" } ] } @@ -86,7 +89,8 @@ "KalturaPriceDetailsListResponse", "KalturaPricePlanListResponse", "KalturaDynamicChannelListResponse", - "KalturaDiscountDetailsListResponse" + "KalturaDiscountDetailsListResponse", + "KalturaAssetStructMetaListResponse" ] } }, From 5080624fc2ec038189119390578da872bb982f69 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 9 Sep 2018 11:53:56 +0300 Subject: [PATCH 531/605] Added more logic to process assetStruct and assetStructMeta objects --- .../ParentChildMetadataInheritanceTests.java | 33 ++++++++++++++++++- src/test/resources/schemas/AssetStruct.json | 3 +- .../resources/schemas/AssetStructMeta.json | 11 ++++++- src/test/resources/schemas/ListResponse.json | 6 +++- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 066abc125..709ea82a6 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -39,13 +39,33 @@ public void sandbox() { .setKs(getOperatorKs())); assertThat(assetStructListResponse.results.getTotalCount()).isGreaterThan(0); String metaIds = assetStructListResponse.results.getObjects().get(0).getMetaIds(); + Long assetStructId = assetStructListResponse.results.getObjects().get(0).getId(); AssetStructMetaFilter assetStructMetaFilter = new AssetStructMetaFilter(); - assetStructMetaFilter.setAssetStructIdEqual(assetStructListResponse.results.getObjects().get(0).getId()); + assetStructMetaFilter.setAssetStructIdEqual(assetStructId); ListAssetStructMetaBuilder listAssetStructMetaBuilder = AssetStructMetaService.list(assetStructMetaFilter); Response> listAssetMetaStructResponse = executor.executeSync(listAssetStructMetaBuilder .setKs(getOperatorKs())); assertThat(listAssetMetaStructResponse.results.getTotalCount()).isGreaterThan(0); + Long metaId = listAssetMetaStructResponse.results.getObjects().get(0).getMetaId(); + + String defaultIngestValue = prefix + "_defaultIngestValue"; + String ingestReferencePath = prefix + "ingestReferencePath"; + boolean isProtectFromIngest = false; + boolean isInherited = true; + AssetStructMeta assetStructMeta = getAssetStructMeta(defaultIngestValue, + ingestReferencePath, isProtectFromIngest, isInherited); + UpdateAssetStructMetaBuilder updateAssetStructMetaBuilder = + new UpdateAssetStructMetaBuilder(assetStructId, metaId, assetStructMeta); + Response assetStructMetaResponse = executor.executeSync(updateAssetStructMetaBuilder + .setKs(getOperatorKs())); + assertThat(assetStructMetaResponse.results.getAssetStructId()).isEqualTo(assetStructId); + assertThat(assetStructMetaResponse.results.getMetaId()).isEqualTo(metaId); + assertThat(assetStructMetaResponse.results.getDefaultIngestValue()).isEqualToIgnoringCase(defaultIngestValue); + assertThat(assetStructMetaResponse.results.getIngestReferencePath()).isEqualToIgnoringCase(ingestReferencePath); + assertThat(assetStructMetaResponse.results.getProtectFromIngest()).isEqualTo(isProtectFromIngest); + //TODO: update library to have options compare it + //assertThat(assetStructMetaResponse.results.getInherited()).isEqualTo(isInherited); // assetStructAdd AssetStruct assetStruct = getAssetStruct(prefix, "eng"); @@ -72,6 +92,17 @@ public void sandbox() { assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); } + private AssetStructMeta getAssetStructMeta(String defaultIngestValue, String ingestReferencePath, + boolean isProtectFromIngest, boolean isInherited) { + AssetStructMeta assetStructMeta = new AssetStructMeta(); + assetStructMeta.setDefaultIngestValue(defaultIngestValue); + assetStructMeta.setIngestReferencePath(ingestReferencePath); + assetStructMeta.setProtectFromIngest(isProtectFromIngest); + // TODO: update library to have options update it + //assetStructMeta.setIsInherited(isInherited); + return assetStructMeta; + } + @Test public void sandboxDelete() { DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(2381); diff --git a/src/test/resources/schemas/AssetStruct.json b/src/test/resources/schemas/AssetStruct.json index e62ed6b0b..75df257d5 100644 --- a/src/test/resources/schemas/AssetStruct.json +++ b/src/test/resources/schemas/AssetStruct.json @@ -100,7 +100,8 @@ "type": "object", "properties": { "executionTime": { - "type": "number" + "type": "number", + "minimum": 0 }, "result": { "ref": "#/definitions/AssetStruct" diff --git a/src/test/resources/schemas/AssetStructMeta.json b/src/test/resources/schemas/AssetStructMeta.json index 678c10299..b8416684c 100644 --- a/src/test/resources/schemas/AssetStructMeta.json +++ b/src/test/resources/schemas/AssetStructMeta.json @@ -51,5 +51,14 @@ ] } }, - "$ref": "#/definitions/AssetStructMeta" + "type": "object", + "properties": { + "executionTime": { + "type": "number", + "minimum": 0 + }, + "result": { + "$ref": "#/definitions/AssetStructMeta" + } + } } \ No newline at end of file diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index e86b4f983..1a29854b4 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -62,6 +62,9 @@ }, { "$ref": "AssetStructMeta.json#/definitions/AssetStructMeta" + }, + { + "$ref": "AssetStruct.json#/definitions/AssetStruct" } ] } @@ -90,7 +93,8 @@ "KalturaPricePlanListResponse", "KalturaDynamicChannelListResponse", "KalturaDiscountDetailsListResponse", - "KalturaAssetStructMetaListResponse" + "KalturaAssetStructMetaListResponse", + "KalturaAssetStructListResponse" ] } }, From 24adb5d6200f8f44115d2f530e6d3950ba359e85 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 9 Sep 2018 12:45:17 +0300 Subject: [PATCH 532/605] added more sandboxes --- .../ParentChildMetadataInheritanceTests.java | 93 ++++++++++++++++--- 1 file changed, 79 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 709ea82a6..0e04757f3 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -1,10 +1,14 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.AssetService.*; import com.kaltura.client.services.AssetStructMetaService; import com.kaltura.client.services.AssetStructMetaService.*; import com.kaltura.client.services.AssetStructService; import com.kaltura.client.services.AssetStructService.*; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import org.testng.annotations.AfterClass; @@ -13,7 +17,15 @@ import java.util.ArrayList; import java.util.List; - +import java.util.Map; + +import static com.kaltura.client.test.utils.BaseUtils.getFormattedDate; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.tagsMetaMap; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestXmlRequest; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; /** @@ -27,10 +39,10 @@ public class ParentChildMetadataInheritanceTests extends BaseTest { public void setUp() { } + // added to play with methods that are going to be checked @Test public void sandbox() { String prefix = "MaxTest_assetStruct_"; - // added to play with methods that are going to be checked // assetStructList AssetStructFilter filter = new AssetStructFilter(); @@ -92,6 +104,71 @@ public void sandbox() { assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); } + @Test + public void sandboxRemoveMetasAndTags() { + generateDefaultValues4Insert(MOVIE); + IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles); + MediaAsset movie = insertVod(vodData, true); + + assertThat(movie.getName()).isEqualTo(movie.getExternalId()); + assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + Map tags = movie.getTags(); + Map.Entry entry = tags.entrySet().iterator().next(); + List tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + + // TODO: update idIn with real values from DB to check metas and tags are really deleted + /*RemoveMetasAndTagsAssetBuilder removeMetasAndTagsAssetBuilder = + AssetService.removeMetasAndTags(movie.getId(), AssetReferenceType.MEDIA, ""); + Response booleanResponse = executor.executeSync(removeMetasAndTagsAssetBuilder + .setKs(getOperatorKs())); + assertThat(booleanResponse.results).isEqualTo(true); + + // check results + GetAssetBuilder getAssetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA); + Response assetResponse = executor.executeSync(getAssetBuilder + .setKs(getOperatorKs())); + movie = (MediaAsset) assetResponse.results; + + assertThat(movie.getName()).isEqualTo(movie.getExternalId()); + assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + + tags = movie.getTags(); + entry = tags.entrySet().iterator().next(); + tagsValues = entry.getValue().getObjects(); + for (MultilingualStringValue tagValue: tagsValues) { + assertThat(tagValues).contains(tagValue.getValue()); + } + assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size());*/ + + // cleanup + deleteVod(movie.getExternalId()); + } + + @Test + public void sandboxDelete() { + DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(2381); + Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder + .setKs(getOperatorKs())); + assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); + } + + @AfterClass() + public void tearDown() { + } + private AssetStructMeta getAssetStructMeta(String defaultIngestValue, String ingestReferencePath, boolean isProtectFromIngest, boolean isInherited) { AssetStructMeta assetStructMeta = new AssetStructMeta(); @@ -103,14 +180,6 @@ private AssetStructMeta getAssetStructMeta(String defaultIngestValue, String ing return assetStructMeta; } - @Test - public void sandboxDelete() { - DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(2381); - Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder - .setKs(getOperatorKs())); - assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); - } - AssetStruct getAssetStruct(String prefix, String language) { AssetStruct assetStruct = new AssetStruct(); assetStruct.setSystemName(prefix + "_System_name"); @@ -124,8 +193,4 @@ AssetStruct getAssetStruct(String prefix, String language) { assetStruct.setMetaIds(""); return assetStruct; } - - @AfterClass() - public void tearDown() { - } } From bc3f912486d73c625dc1924855e9a314d69b1396 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 12 Sep 2018 11:36:26 +0300 Subject: [PATCH 533/605] order summary results in performne report --- .../five_zero_two/IngestVodOpcTests.java | 41 ++++++++++--------- .../client/test/utils/PerformanceUtils.java | 41 +++++++++++++------ .../utils/ingestUtils/IngestVodUtils.java | 15 ++++--- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index fb4c81c01..bd8b89512 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -6,6 +6,7 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; @@ -129,8 +130,7 @@ public void insertVodMediaBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - - checkFiles(movieAssetFiles, movie.getId().toString()); + assertFiles(movieAssetFiles, movie.getId().toString()); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); @@ -161,7 +161,7 @@ public void insertVodEpisodeBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - checkFiles(episodeAssetFiles, episode.getId().toString()); + assertFiles(episodeAssetFiles, episode.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -189,7 +189,7 @@ public void insertVodSeriesBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - checkFiles(seriesAssetFiles, series.getId().toString()); + assertFiles(seriesAssetFiles, series.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -309,21 +309,21 @@ public void updateVodSeriesBaseFields() { @Test(description = "delete movie") public void deleteMovie() { String coguid = getCoguidOfActiveMediaAsset(movieType); - checkVodDeletion(coguid); + assertVodDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) @Test(description = "delete episode") public void deleteEpisode() { String coguid = getCoguidOfActiveMediaAsset(episodeType); - checkVodDeletion(coguid); + assertVodDeletion(coguid); } @Severity(SeverityLevel.CRITICAL) @Test(description = "delete series") public void deleteSeries() { String coguid = getCoguidOfActiveMediaAsset(seriesType); - checkVodDeletion(coguid); + assertVodDeletion(coguid); } @Severity(SeverityLevel.NORMAL) @@ -452,23 +452,23 @@ public void insertWithInvalidMetaOrTagField() { String updatedField = mediaNumberFieldName + suffix; String invalidXml = ingestXml.replaceAll(mediaNumberFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); + assertInvalidMovieField(invalidXml, updatedField, "meta"); updatedField = mediaDateFieldName + suffix; invalidXml = ingestXml.replaceAll(mediaDateFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); + assertInvalidMovieField(invalidXml, updatedField, "meta"); updatedField = mediaBooleanFieldName + suffix; invalidXml = ingestXml.replaceAll(mediaBooleanFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); + assertInvalidMovieField(invalidXml, updatedField, "meta"); updatedField = mediaTagFieldName + suffix; invalidXml = ingestXml.replaceAll(mediaTagFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "tag"); + assertInvalidMovieField(invalidXml, updatedField, "tag"); updatedField = mediaTextFieldName + suffix; invalidXml = ingestXml.replaceAll(mediaTextFieldName, updatedField); - validateInvalidMovieField(invalidXml, updatedField, "meta"); + assertInvalidMovieField(invalidXml, updatedField, "meta"); } @Severity(SeverityLevel.NORMAL) @@ -577,7 +577,7 @@ public void updateVodMediaPpv() { assertThat(movie.getName()).isEqualTo(name); assertThat(movie.getDescription()).isEqualTo(description); - checkFiles(movieAssetFiles, movie.getId().toString()); + assertFiles(movieAssetFiles, movie.getId().toString()); Household household = HouseholdUtils.createHousehold(); String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); @@ -671,22 +671,25 @@ public void updateFiles() { deleteVod(mediaAsset.getExternalId()); } - void validateInvalidMovieField(String ingestXml, String fieldName, String fieldType) { + void assertInvalidMovieField(String ingestXml, String fieldName, String fieldType) { Response resp = getResponseBodyFromIngestVod(ingestXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)) .isEqualTo(fieldType + ": " + fieldName + " does not exist for group"); } - void checkVodDeletion(String coguid) { + void assertVodDeletion(String coguid) { SearchAssetFilter assetFilter = new SearchAssetFilter(); - assetFilter.setKSql("externalId='" + coguid + "'"); - com.kaltura.client.utils.response.base.Response> assetListResponse = - executor.executeSync(list(assetFilter) +// "externalId='" + coguid + "'" + assetFilter.setKSql(new KsqlBuilder().equal("externalId", coguid).toString()); + + com.kaltura.client.utils.response.base.Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getAnonymousKs())); + assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); deleteVod(coguid); + AssetService.ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) @@ -695,7 +698,7 @@ void checkVodDeletion(String coguid) { } // to check that ingested file data are corresponding to getAsset file data - private void checkFiles(List ingestAssetFiles, String assetId) { + private void assertFiles(List ingestAssetFiles, String assetId) { boolean isFileWasFound = false; AssetService.GetAssetBuilder assetBuilder = AssetService.get(assetId, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); diff --git a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java index 788fa4f35..9b886dc90 100644 --- a/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PerformanceUtils.java @@ -20,10 +20,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import static com.kaltura.client.test.Properties.*; @@ -76,7 +73,7 @@ private static Map> getRegressionData() { .collect(Collectors.groupingBy( s -> s.split(":")[0], Collectors.mapping(s -> s.split(":")[1], - Collectors.toList()))); + Collectors.toList()))); } private static List getLogFilesUrls() { @@ -200,18 +197,38 @@ private static File getReportFile() { private static void writeReport(List sessions) { logger.debug("start writeReport()"); + // get slow sessions List slowSessions = getSlowSessions(sessions); - Map slowActionsCount = slowSessions.stream().collect(Collectors.groupingBy( + // slow actions by count + Map slowActionsByCount = slowSessions.stream().collect(Collectors.groupingBy( Session::getAction, Collectors.counting() )); - Map actionsCount = sessions.stream().collect(Collectors.groupingBy( + // actions by count + Map actionsByCount = sessions.stream().collect(Collectors.groupingBy( Session::getAction, Collectors.counting() )); + // actions by average time + Map slowActionsByAverageTime = new HashMap<>(); + slowActionsByCount.keySet().forEach(s -> { + long actionTotalCount = actionsByCount.get(s); + + double averageTime = sessions.stream() + .filter(session -> session.getAction().equals(s)) + .mapToDouble(Session::getTotalTime).sum() / actionTotalCount; + + slowActionsByAverageTime.put(s, averageTime); + }); + + // sort actions by average time + List> slowActionsAverageTimeSortedList = slowActionsByAverageTime.entrySet().stream() + .sorted(Map.Entry.comparingByValue().reversed()) + .collect(Collectors.toList()); + // write data to file File file = getReportFile(); @@ -222,14 +239,14 @@ private static void writeReport(List sessions) { try { FileUtils.writeStringToFile(file, reportSummary, Charset.defaultCharset(), true); - slowActionsCount.forEach((s, aLong) -> { - long actionSlowCount = aLong; - long actionTotalCount = actionsCount.get(s); + slowActionsAverageTimeSortedList.forEach(entry -> { + long actionSlowCount = slowActionsByCount.get(entry.getKey()); + long actionTotalCount = actionsByCount.get(entry.getKey()); double slowPercentage = (double) actionSlowCount / actionTotalCount * 100; - double averageTime = sessions.stream().filter(session -> session.getAction().equals(s)).mapToDouble(Session::getTotalTime).sum() / actionTotalCount; + double averageTime = entry.getValue(); try { - FileUtils.writeStringToFile(file, s + " - was slow " + String.format("%.0f", slowPercentage) + + FileUtils.writeStringToFile(file, entry.getKey() + " - was slow " + String.format("%.0f", slowPercentage) + "% of executions (" + actionSlowCount + "/" + actionTotalCount + ") " + "[average time: " + String.format("%.2f", averageTime) + " sec]\n", Charset.defaultCharset(), true); } catch (IOException e) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index e9e38269b..2c7a86d34 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -6,7 +6,6 @@ import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; -import lombok.AccessLevel; import lombok.Data; import lombok.Getter; import lombok.Setter; @@ -21,9 +20,7 @@ import static com.kaltura.client.services.AssetService.GetAssetBuilder; import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.test.tests.BaseTest.*; -import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; -import static com.kaltura.client.test.utils.BaseUtils.getEpoch; -import static com.kaltura.client.test.utils.BaseUtils.getOffsetDateInFormat; +import static com.kaltura.client.test.utils.BaseUtils.*; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; import static org.assertj.core.api.Assertions.assertThat; @@ -45,11 +42,10 @@ public class IngestVodUtils extends BaseIngestUtils { @Accessors(fluent = true) @Data public static class VodData { - @Setter(AccessLevel.NONE) private String coguid; - @Setter(AccessLevel.NONE) private boolean isActive = true; - private boolean isVirtual = false; + private boolean isActive = true; + private String coguid; private String name; private String description; private String lang; @@ -61,6 +57,7 @@ public static class VodData { private String ppvWebName; private String ppvMobileName; private String geoBlockRule; + private MediaType mediaType; private Map> tags; @@ -114,7 +111,9 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { final String endDateValue = "14/10/2099 17:00:00"; final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value - vodData.coguid = getCurrentDateInFormat(coguidDatePattern); + if (vodData.coguid == null) { + vodData.coguid = getCurrentDateInFormat(coguidDatePattern); + } if (useDefaultValues) { if (vodData.name == null) { From 95f60cf9b4b8694782d1c00ab58e7f8ac08e3929 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 12 Sep 2018 23:01:41 +0300 Subject: [PATCH 534/605] bookmark regression fix --- .../bookmarkTests/BookmarkAddTests.java | 128 +++++++++++++++--- 1 file changed, 109 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index ec9a6f84d..06585a118 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -17,11 +17,13 @@ import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class BookmarkAddTests extends BaseTest { @@ -31,6 +33,8 @@ public class BookmarkAddTests extends BaseTest { private List assetList; private Bookmark bookmark; private BookmarkFilter bookmarkFilter; + private int position; +// private String masterUserKs; @BeforeClass private void bookmark_addTests_before_class() { @@ -42,12 +46,17 @@ private void bookmark_addTests_before_class() { // Initialize bookmarkFilter object parameters bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC, AssetType.MEDIA, assetList); + +// Household household = HouseholdUtils.createHousehold(1,1,false); +// masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); } @Description("bookmark/action/add - first play") - @Test - private void firstPlayback() { - int position = 0; + @Test(groups = "slow_before") + private void firstPlayback_before_wait() { + bookmark_addTests_before_class(); + position = 0; + bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); // Invoke bookmark/action/add request @@ -56,10 +65,25 @@ private void firstPlayback() { assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); + } + @Description("bookmark/action/add - first play") + @Test(groups = "slow_after", dependsOnMethods = {"firstPlayback_before_wait"}) + private void firstPlayback_after_wait() { + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 75; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() ->{ + return (executor.executeSync(listBookmarkBuilder).results.getTotalCount() != 0); + }); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + assertThat(bookmarkListResponse.error).isNull(); Bookmark bookmark1 = bookmarkListResponse.results.getObjects().get(0); @@ -83,9 +107,9 @@ private void firstPlayback() { } @Description("bookmark/action/add - pause") - @Test - private void pausePlayback() { - int position = 30; + @Test(groups = "slow_after", dependsOnMethods = {"firstPlayback_after_wait"}, alwaysRun=true) + private void pausePlayback_before_wait() { + position = 30; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PAUSE); // Invoke bookmark/action/add request @@ -94,10 +118,26 @@ private void pausePlayback() { assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); + } + + @Description("bookmark/action/add - pause") + @Test(groups = "slow_after", dependsOnMethods = {"pausePlayback_before_wait"}) + private void pausePlayback_after_wait() { + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 75; // Invoke bookmark/action/list to verify insertion of bookmark position - Response> bookmarkListResponse = executor.executeSync(list(bookmarkFilter) - .setKs(getSharedMasterUserKs())); + ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() ->{ + return (executor.executeSync(listBookmarkBuilder).results.getObjects().get(0).getPosition() == position); + }); + + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + assertThat(bookmarkListResponse.error).isNull(); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Match content of asset position @@ -105,9 +145,9 @@ private void pausePlayback() { } @Description("bookmark/action/add - 95% watching == finish watching") - @Test - private void watchingNinetyFive() { - int position = 999; + @Test(groups = "slow_after", dependsOnMethods = {"pausePlayback_after_wait"}, alwaysRun=true) + private void watchingNinetyFive_before_wait() { + position = 999; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PLAY); // Invoke bookmark/action/add request @@ -116,10 +156,26 @@ private void watchingNinetyFive() { assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); + } + + @Description("bookmark/action/add - 95% watching == finish watching") + @Test(groups = "slow_after", dependsOnMethods = {"watchingNinetyFive_before_wait"}) + private void watchingNinetyFive_after_wait() { + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 75; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() ->{ + return (executor.executeSync(listBookmarkBuilder).results.getObjects().get(0).getPosition() == position); + }); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + assertThat(bookmarkListResponse.error).isNull(); Bookmark bookmark3 = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = true @@ -127,17 +183,35 @@ private void watchingNinetyFive() { } @Description("bookmark/action/add - back to start - position:0") - @Test - private void backToStart() { - int position = 0; + @Test(groups = "slow_after", dependsOnMethods = {"watchingNinetyFive_after_wait"}, alwaysRun=true) + private void backToStart_before_wait() { + position = 0; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.STOP); AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(getSharedMasterUserKs()); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results.booleanValue()).isTrue(); + assertThat(booleanResponse.error).isNull(); + } + + @Description("bookmark/action/add - back to start - position:0") + @Test(groups = "slow_after", dependsOnMethods = {"backToStart_before_wait"}) + private void backToStart_after_wait() { + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 75; + // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() ->{ + return (executor.executeSync(listBookmarkBuilder).results.getObjects().get(0).getPosition() == position); + }); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + assertThat(bookmarkListResponse.error).isNull(); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); // Verify finishedWatching = false @@ -145,9 +219,9 @@ private void backToStart() { } @Description("bookmark/action/add - finish watching") - @Test - private void finishWatching() { - int position = 60; + @Test(groups = "slow_after", dependsOnMethods = {"backToStart_after_wait"}, alwaysRun=true) + private void finishWatching_before_wait() { + position = 60; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FINISH); // Invoke bookmark/action/add request @@ -156,14 +230,30 @@ private void finishWatching() { assertThat(booleanResponse.results.booleanValue()).isTrue(); assertThat(booleanResponse.error).isNull(); + } + + @Description("bookmark/action/add - finish watching") + @Test(groups = "slow_after", dependsOnMethods = {"finishWatching_before_wait"}) + private void finishWatching_after_wait() { + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 75; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() ->{ + return (executor.executeSync(listBookmarkBuilder).results.getObjects().get(0).getFinishedWatching().equals(true)); + }); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + assertThat(bookmarkListResponse.error).isNull(); Bookmark bookmark = bookmarkListResponse.results.getObjects().get(0); - // Verify finishedWatching = true - assertThat(bookmark.getFinishedWatching()).isTrue(); + // Verify postion = 0 + assertThat(bookmark.getPosition()).isEqualTo(0); } @Description("bookmark/action/add - empty asset id") From c405b89e2becf394be08f8796be81952b010bf46 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 13 Sep 2018 11:14:27 +0300 Subject: [PATCH 535/605] added IngestAction Enum --- .../client/test/tests/enums/IngestAction.java | 39 ++++ .../ParentChildMetadataInheritanceTests.java | 22 +- .../kaltura/client/test/utils/BaseUtils.java | 13 +- .../utils/ingestUtils/BaseIngestUtils.java | 5 - .../utils/ingestUtils/IngestMppUtils.java | 13 +- .../test/utils/ingestUtils/IngestPpUtils.java | 16 +- .../utils/ingestUtils/IngestPpvUtils.java | 16 +- .../utils/ingestUtils/IngestVodOpcUtils.java | 197 +++++++----------- .../utils/ingestUtils/IngestVodUtils.java | 26 +-- 9 files changed, 172 insertions(+), 175 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/IngestAction.java diff --git a/src/test/java/com/kaltura/client/test/tests/enums/IngestAction.java b/src/test/java/com/kaltura/client/test/tests/enums/IngestAction.java new file mode 100644 index 000000000..d55dc819c --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/IngestAction.java @@ -0,0 +1,39 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum IngestAction implements EnumAsString { + INSERT("insert"), + UPDATE("update"), + DELETE("delete"); + + private String value; + + IngestAction(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static IngestAction get(String value) { + if(value == null) { + return null; + } + + // goes over IngestAction defined values and compare the inner value with the given one: + for(IngestAction item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return IngestAction.values().length > 0 ? IngestAction.values()[0]: null; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 0e04757f3..6b07ae3d8 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -1,16 +1,18 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; -import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.AssetService.*; import com.kaltura.client.services.AssetStructMetaService; -import com.kaltura.client.services.AssetStructMetaService.*; +import com.kaltura.client.services.AssetStructMetaService.ListAssetStructMetaBuilder; +import com.kaltura.client.services.AssetStructMetaService.UpdateAssetStructMetaBuilder; import com.kaltura.client.services.AssetStructService; -import com.kaltura.client.services.AssetStructService.*; +import com.kaltura.client.services.AssetStructService.AddAssetStructBuilder; +import com.kaltura.client.services.AssetStructService.DeleteAssetStructBuilder; +import com.kaltura.client.services.AssetStructService.ListAssetStructBuilder; +import com.kaltura.client.services.AssetStructService.UpdateAssetStructBuilder; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Link; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -19,11 +21,11 @@ import java.util.List; import java.util.Map; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; +import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getFormattedDate; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.tagsMetaMap; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.ingestXmlRequest; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; @@ -32,7 +34,8 @@ * * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-5423 */ -@Test(groups = { "opc", "Parent children metadata inheritance" }) +@Link(name = "Parent Child Metadata Inheritance", url = "BEO-5423") +@Test(groups = { "opc", "Parent Child Metadata Inheritance" }) public class ParentChildMetadataInheritanceTests extends BaseTest { @BeforeClass() @@ -106,8 +109,7 @@ public void sandbox() { @Test public void sandboxRemoveMetasAndTags() { - generateDefaultValues4Insert(MOVIE); - IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles); + IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); assertThat(movie.getName()).isEqualTo(movie.getExternalId()); diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index e3f9bd9d7..5b262835b 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -123,23 +123,20 @@ public static String getRandomValue(String prefix, long maxValue) { } public static String getRandomValue(String prefix) { - long max = 9999999999L; - long randomLongValue = ThreadLocalRandom.current().nextLong(max); - return prefix + randomLongValue; + return prefix + getRandomLong(); } - public static String getRandomValue() { + public static long getRandomLong() { long max = 9999999999L; - long randomLongValue = ThreadLocalRandom.current().nextLong(max); - return String.valueOf(randomLongValue); + return ThreadLocalRandom.current().nextLong(max); } - public static double getRandomDoubleValue() { + public static double getRandomDouble() { double max = 9999999.1; return ThreadLocalRandom.current().nextDouble(max); } - public static boolean getRandomBooleanValue() { + public static boolean getRandomBoolean() { return ThreadLocalRandom.current().nextBoolean(); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index 399a4be7f..ad614d811 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -31,11 +31,6 @@ public class BaseIngestUtils { static final Header soapActionIngestBusinessModules = new Header("SOAPAction", "http://tempuri.org/IService/IngestBusinessModules"); static final Header soapActionIngestKalturaEpg = new Header("SOAPAction", "http://tempuri.org/IService/IngestKalturaEpg"); - // actions - public static final String INGEST_ACTION_INSERT = "insert"; - static final String INGEST_ACTION_UPDATE = "update"; - static final String INGEST_ACTION_DELETE = "delete"; - // wait configuration public static final int delayBetweenRetriesInSeconds = 5; public static final int maxTimeExpectingValidResponseInSeconds = 120; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java index 8576a6813..5ae716f4d 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestMppUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.SubscriptionService; +import com.kaltura.client.test.tests.enums.IngestAction; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.CouponsGroup; import com.kaltura.client.types.ProductCode; @@ -19,6 +20,8 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.enums.IngestAction.DELETE; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; import static com.kaltura.client.test.utils.BaseUtils.getFormattedTime; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; @@ -109,7 +112,7 @@ public static Subscription insertMpp(MppData mppData) { // if (mppData.couponGroup == null) { mppData.couponGroup = DEFAULT_COUPON_GROUP; } // if (mppData.productCodes == null) { mppData.productCodes = DEFAULT_PRODUCT_CODES; } - String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_INSERT); + String reqBody = buildIngestMppXml(mppData, INSERT); Response resp = executeIngestMppRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -150,7 +153,7 @@ public static Subscription insertMpp(MppData mppData) { public static void deleteMpp(String mppCode) { MppData mppData = new MppData(); mppData.mppCode = mppCode; - String reqBody = buildIngestMppXml(mppData, INGEST_ACTION_DELETE); + String reqBody = buildIngestMppXml(mppData, DELETE); Response resp = executeIngestMppRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -180,7 +183,7 @@ private static Response executeIngestMppRequest(String reqBody) { return resp; } - private static String buildIngestMppXml(MppData mppData, String action) { + private static String buildIngestMppXml(MppData mppData, IngestAction action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestMPP.xml"); // user and password @@ -194,10 +197,10 @@ private static String buildIngestMppXml(MppData mppData, String action) { // multi price plan Element mpp = (Element) ingest.getElementsByTagName("multi_price_plan").item(0); mpp.setAttribute("code", mppData.mppCode); - mpp.setAttribute("action", action); + mpp.setAttribute("action", action.getValue()); mpp.setAttribute("is_active", Boolean.toString(mppData.isActive)); - if (action.equals(INGEST_ACTION_DELETE)) { + if (action.equals(DELETE)) { return uncommentCdataSection(docToString(doc)); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java index 3ce7528fd..08835d34c 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.PricePlanService; +import com.kaltura.client.test.tests.enums.IngestAction; import com.kaltura.client.test.utils.dbUtils.IngestFixtureData; import com.kaltura.client.types.DiscountModule; import com.kaltura.client.types.PricePlan; @@ -17,6 +18,9 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; +import static com.kaltura.client.test.tests.enums.IngestAction.DELETE; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; +import static com.kaltura.client.test.tests.enums.IngestAction.UPDATE; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; @@ -80,7 +84,7 @@ public static PricePlan insertPp(PpData ppData) { ppData.recurringPeriods = DEFAULT_RECURRING_PERIODS; } - String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_INSERT); + String reqBody = buildIngestPpXml(ppData, INSERT); Response resp = executeIngestPpRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -99,7 +103,7 @@ public static PricePlan insertPp(PpData ppData) { public static PricePlan updatePp(String ppCode, PpData ppData) { ppData.ppCode = ppCode; - String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_UPDATE); + String reqBody = buildIngestPpXml(ppData, UPDATE); Response resp = executeIngestPpRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -120,7 +124,7 @@ public static PricePlan updatePp(String ppCode, PpData ppData) { public static void deletePp(String ppCode) { PpData ppData = new PpData(); ppData.ppCode = ppCode; - String reqBody = buildIngestPpXml(ppData, INGEST_ACTION_DELETE); + String reqBody = buildIngestPpXml(ppData, DELETE); Response resp = executeIngestPpRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -151,7 +155,7 @@ private static Response executeIngestPpRequest(String reqBody) { return resp; } - private static String buildIngestPpXml(PpData ppData, String action) { + private static String buildIngestPpXml(PpData ppData, IngestAction action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestPP.xml"); // user and password @@ -165,10 +169,10 @@ private static String buildIngestPpXml(PpData ppData, String action) { // price plan Element pp = (Element) ingest.getElementsByTagName("price_plan").item(0); pp.setAttribute("code", ppData.ppCode); - pp.setAttribute("action", action); + pp.setAttribute("action", action.getValue()); pp.setAttribute("is_active", Boolean.toString(ppData.isActive)); - if (action.equals(INGEST_ACTION_DELETE)) { + if (action.equals(DELETE)) { return uncommentCdataSection(docToString(doc)); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java index 997ef6cc4..20b75682e 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestPpvUtils.java @@ -1,6 +1,7 @@ package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.Logger; +import com.kaltura.client.test.tests.enums.IngestAction; import com.kaltura.client.types.CouponsGroup; import com.kaltura.client.types.Ppv; import io.restassured.response.Response; @@ -15,6 +16,9 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; import static com.kaltura.client.test.tests.enums.Currency.EUR; +import static com.kaltura.client.test.tests.enums.IngestAction.DELETE; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; +import static com.kaltura.client.test.tests.enums.IngestAction.UPDATE; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; @@ -61,7 +65,7 @@ public static Ppv insertPpv(PpvData ppvData) { if (ppvData.firstFileType == null) { ppvData.firstFileType = getProperty(WEB_FILE_TYPE); } if (ppvData.secondFileType == null) { ppvData.secondFileType = getProperty(MOBILE_FILE_TYPE); } - String reqBody = buildIngestPpvXml(ppvData, INGEST_ACTION_INSERT); + String reqBody = buildIngestPpvXml(ppvData, INSERT); Response resp = executeIngestPpvRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -78,7 +82,7 @@ public static Ppv insertPpv(PpvData ppvData) { public static Ppv updatePpv(String ppvCode, PpvData ppvData) { ppvData.ppvCode = ppvCode; - String reqBody = buildIngestPpvXml(ppvData, INGEST_ACTION_UPDATE); + String reqBody = buildIngestPpvXml(ppvData, UPDATE); Response resp = executeIngestPpvRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -95,7 +99,7 @@ public static Ppv updatePpv(String ppvCode, PpvData ppvData) { public static void deletePpv(String ppvCode) { PpvData ppvData = new PpvData(); ppvData.ppvCode = ppvCode; - String reqBody = buildIngestPpvXml(ppvData, INGEST_ACTION_DELETE); + String reqBody = buildIngestPpvXml(ppvData, DELETE); Response resp = executeIngestPpvRequest(reqBody); String reportId = from(resp.asString()).getString(ingestReportIdPath); @@ -124,7 +128,7 @@ private static Response executeIngestPpvRequest(String reqBody) { return resp; } - private static String buildIngestPpvXml(PpvData ppvData, String action) { + private static String buildIngestPpvXml(PpvData ppvData, IngestAction action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestPPV.xml"); // user and password @@ -138,10 +142,10 @@ private static String buildIngestPpvXml(PpvData ppvData, String action) { // ppv Element ppv = (Element) ingest.getElementsByTagName("ppv").item(0); ppv.setAttribute("code", ppvData.ppvCode); - ppv.setAttribute("action", action); + ppv.setAttribute("action", action.getValue()); ppv.setAttribute("is_active", Boolean.toString(ppvData.isActive)); - if (action.equals(INGEST_ACTION_DELETE)) { + if (action.equals(DELETE)) { return uncommentCdataSection(docToString(doc)); } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 16135f0cf..41d7a508c 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -1,7 +1,9 @@ package com.kaltura.client.test.utils.ingestUtils; import com.kaltura.client.enums.AssetOrderBy; +import com.kaltura.client.test.tests.enums.IngestAction; import com.kaltura.client.test.tests.enums.MediaType; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; @@ -9,10 +11,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import static com.kaltura.client.services.AssetService.list; -import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.BaseTest.executor; +import static com.kaltura.client.test.tests.BaseTest.getAnonymousKs; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; +import static com.kaltura.client.test.tests.enums.IngestAction.UPDATE; import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodFile; public class IngestVodOpcUtils extends BaseIngestUtils { @@ -26,53 +33,26 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static final String FILE_TYPE_1 = "Test130301"; public static final String FILE_TYPE_2 = "new file type1"; + public static final String EMPTY_FILE_1_TAG = "\n"; public static final String EMPTY_FILE_2_TAG = "\n"; - // TODO: remove it using util - public static final String DELETE_VOD_XML = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "Test_API_27_03\n" + - "Test_API_27_03\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "]]>\n" + - "\n" + - "\n" + - "\n" + - "\n" + - ""; - - // media types - public static final String EPISODE = "Episode"; - public static final String MOVIE = "Movie"; - public static final String SERIES = "Series"; - // TODO: how to get these data from DB or request? - //Movie fields + // Movie fields public static final String mediaTextFieldName = "BoxOffice"; public static final String mediaDateFieldName = "ReleaseDate"; public static final String mediaNumberFieldName = "Runtime2"; public static final String mediaBooleanFieldName = "IsAgeLimited"; public static final String mediaTagFieldName = "Actors"; - //Episode fields + // Episode fields public static final String episodeTextFieldName = "TwitterHashtag"; public static final String episodeDateFieldName = "Date"; public static final String episodeNumberFieldName = "CommonIpAddress"; public static final String episodeBooleanFieldName = "CyyNCAh"; public static final String episodeTagFieldName = "Studio"; - //Series fields + // Series fields public static final String seriesTextFieldName = "SeriesID"; public static final String seriesDateFieldName = "DateField"; public static final String seriesNumberFieldName = "ReleaseYear"; @@ -85,87 +65,51 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static HashMap booleanHashMap = new HashMap<>(); public static HashMap datesMetaMap = new HashMap<>(); public static HashMap> tagsMetaMap = new HashMap<>(); + public static List movieAssetFiles = new ArrayList<>(); public static List episodeAssetFiles = new ArrayList<>(); public static List seriesAssetFiles = new ArrayList<>(); + public static String tagValue1 = "Jack Nicholson"; public static String tagValue2 = "Natalie Portman"; - public static IngestVodUtils.VodData getVodData(String mediaType, List mediaAssetFiles) { + public static VodData getVodData(MediaType mediaType, List mediaAssetFiles, IngestAction action) { + if (action == INSERT) { + generateDefaultValues4Insert(mediaType); + } else if (action == UPDATE) { + generateDefaultValues4Update(booleanValue, mediaType); + } + + VodData data = new VodData() + .name(name) + .description(description) + .thumbUrl(DEFAULT_THUMB) + .strings(stringMetaMap) + .booleans(booleanHashMap) + .numbers(numberMetaMap) + .dates(datesMetaMap) + .tags(tagsMetaMap) + .assetFiles(mediaAssetFiles); + switch (mediaType) { - case "Movie": - return new IngestVodUtils.VodData() - .name(name) - .description(description) - .mediaType(MediaType.MOVIE) - .thumbUrl(DEFAULT_THUMB) - .strings(stringMetaMap) - .booleans(booleanHashMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) - .tags(tagsMetaMap) - .isVirtual(false) - .assetFiles(mediaAssetFiles); - case "Episode": - return new IngestVodUtils.VodData() - .name(name) - .description(description) - .mediaType(MediaType.EPISODE) - .thumbUrl(DEFAULT_THUMB) - .strings(stringMetaMap) - .booleans(booleanHashMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) - .tags(tagsMetaMap) - .isVirtual(false) - .assetFiles(mediaAssetFiles); - case "Series": - return new IngestVodUtils.VodData() - .name(name) - .description(description) - .mediaType(MediaType.SERIES) - .thumbUrl(DEFAULT_THUMB) - .strings(stringMetaMap) - .booleans(booleanHashMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) - .tags(tagsMetaMap) - .isVirtual(true) - .assetFiles(mediaAssetFiles); + case MOVIE: + data.mediaType(MediaType.MOVIE).isVirtual(false); + return data; + case EPISODE: + data.mediaType(MediaType.EPISODE).isVirtual(false); + return data; + case SERIES: + data.mediaType(MediaType.SERIES).isVirtual(true); + return data; default: return null; } } - static void fillMediaMapsWithData() { - stringMetaMap.put(mediaTextFieldName, textValue); - numberMetaMap.put(mediaNumberFieldName, doubleValue); - datesMetaMap.put(mediaDateFieldName, dateValue); - booleanHashMap.put(mediaBooleanFieldName, booleanValue); - tagsMetaMap.put(mediaTagFieldName, tagValues); - } - - static void fillEpisodeMapsWithData() { - stringMetaMap.put(episodeTextFieldName, textValue); - numberMetaMap.put(episodeNumberFieldName, doubleValue); - datesMetaMap.put(episodeDateFieldName, dateValue); - booleanHashMap.put(episodeBooleanFieldName, booleanValue); - tagsMetaMap.put(episodeTagFieldName, tagValues); - } - - static void fillSeriesMapsWithData() { - stringMetaMap.put(seriesTextFieldName, textValue); - numberMetaMap.put(seriesNumberFieldName, doubleValue); - datesMetaMap.put(seriesDateFieldName, dateValue); - booleanHashMap.put(seriesBooleanFieldName, booleanValue); - tagsMetaMap.put(seriesTagFieldName, tagValues); - } - - public static void generateDefaultValues4Update(boolean previousValue, String mediaType) { + private static void generateDefaultValues4Update(boolean previousValue, MediaType mediaType) { textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy") + "_updated"; - dateValue = getOffsetDateInFormat(1,"MM/dd/yyyy"); - // to round up 2 decimal places - doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; + dateValue = getOffsetDateInFormat(1, "MM/dd/yyyy"); + doubleValue = Math.round(getRandomDouble() * 100.0) / 100.0; booleanValue = !previousValue; tagValues = new ArrayList<>(); tagValues.add(tagValue1 + "Upd"); @@ -175,12 +119,12 @@ public static void generateDefaultValues4Update(boolean previousValue, String me fillMapsWithData(mediaType); } - public static void generateDefaultValues4Insert(String mediaType) { + private static void generateDefaultValues4Insert(MediaType mediaType) { textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy"); dateValue = getCurrentDateInFormat("MM/dd/yyyy"); - // to round up 2 decimal places - doubleValue = Math.round(getRandomDoubleValue() * 100.0) / 100.0; - booleanValue = getRandomBooleanValue(); + + doubleValue = Math.round(getRandomDouble() * 100.0) / 100.0; + booleanValue = getRandomBoolean(); tagValues = new ArrayList<>(); tagValues.add(tagValue1); tagValues.add(tagValue2); @@ -189,31 +133,43 @@ public static void generateDefaultValues4Insert(String mediaType) { fillMapsWithData(mediaType); } - private static void fillMapsWithData(String mediaType) { - clearMapsBeforeFilling(); + private static void fillMapsWithData(MediaType mediaType) { + stringMetaMap = new HashMap<>(); + numberMetaMap = new HashMap<>(); + booleanHashMap = new HashMap<>(); + datesMetaMap = new HashMap<>(); + tagsMetaMap = new HashMap<>(); + switch (mediaType) { case MOVIE: - fillMediaMapsWithData(); + stringMetaMap.put(mediaTextFieldName, textValue); + numberMetaMap.put(mediaNumberFieldName, doubleValue); + datesMetaMap.put(mediaDateFieldName, dateValue); + booleanHashMap.put(mediaBooleanFieldName, booleanValue); + tagsMetaMap.put(mediaTagFieldName, tagValues); break; + case EPISODE: - fillEpisodeMapsWithData(); + stringMetaMap.put(episodeTextFieldName, textValue); + numberMetaMap.put(episodeNumberFieldName, doubleValue); + datesMetaMap.put(episodeDateFieldName, dateValue); + booleanHashMap.put(episodeBooleanFieldName, booleanValue); + tagsMetaMap.put(episodeTagFieldName, tagValues); break; + case SERIES: - fillSeriesMapsWithData(); + stringMetaMap.put(seriesTextFieldName, textValue); + numberMetaMap.put(seriesNumberFieldName, doubleValue); + datesMetaMap.put(seriesDateFieldName, dateValue); + booleanHashMap.put(seriesBooleanFieldName, booleanValue); + tagsMetaMap.put(seriesTagFieldName, tagValues); break; + default: break; } } - private static void clearMapsBeforeFilling() { - stringMetaMap = new HashMap<>(); - numberMetaMap = new HashMap<>(); - booleanHashMap = new HashMap<>(); - datesMetaMap = new HashMap<>(); - tagsMetaMap = new HashMap<>(); - } - public static String getCoguidOfActiveMediaAsset(int assetType) { SearchAssetFilter assetFilter = new SearchAssetFilter(); assetFilter.setOrderBy(AssetOrderBy.CREATE_DATE_DESC.getValue()); @@ -224,7 +180,6 @@ public static String getCoguidOfActiveMediaAsset(int assetType) { Response> assetListResponse = executor.executeSync(list(assetFilter, pager) .setKs(getAnonymousKs())); - //assertThat(assetListResponse.results.getObjects().size()).isEqualTo(1); return assetListResponse.results.getObjects().get(0).getExternalId(); } @@ -233,7 +188,7 @@ public static List get2AssetFiles(String fileType1, String fileType2, S List result = new ArrayList<>(); long e = getEpoch(); - String r = getRandomValue(); + String r = String.valueOf(BaseUtils.getRandomLong()); String coguid1 = "file_1_" + e + "_" + r; String coguid2 = "file_2_" + e + "_" + r; @@ -259,10 +214,6 @@ public static boolean isTagValueFound(String value2Found, Asset asset) { return false; } - public static String getIngestXmlWithoutFiles(String ingestXml) { - return getUpdatedIngestXml(ingestXml, "", "", ""); - } - public static String getUpdatedIngestXml(String ingestXml, String openTag2Update, String closeTag2Update, String updateOnString) { int positionBeginTag = ingestXml.indexOf(openTag2Update); int positionEndTag; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 2c7a86d34..ba60b6fac 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -3,6 +3,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.test.tests.enums.MediaType; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.Asset; import com.kaltura.client.types.MediaAsset; import io.restassured.response.Response; @@ -20,6 +21,7 @@ import static com.kaltura.client.services.AssetService.GetAssetBuilder; import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.enums.IngestAction.*; import static com.kaltura.client.test.utils.BaseUtils.*; import static io.restassured.RestAssured.given; import static io.restassured.path.xml.XmlPath.from; @@ -109,7 +111,7 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { final String datePattern = "dd/MM/yyyy hh:mm:ss"; final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); final String endDateValue = "14/10/2099 17:00:00"; - final String ppvModuleName = "Shai_Regression_PPV"; // TODO: update on any generated value + final String ppvModuleName = DBUtils.getPpvNames(1).get(0); // "Shai_Regression_PPV"; if (vodData.coguid == null) { vodData.coguid = getCurrentDateInFormat(coguidDatePattern); @@ -169,9 +171,9 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { } } - String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_INSERT); + String reqBody = buildIngestVodXml(vodData, INSERT.getValue()); - Response resp = executeIngestVodRequest(reqBody); + Response resp = executeIngestVodRequestWithAssertion(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); @@ -187,9 +189,9 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { public static MediaAsset updateVod(String coguid, VodData vodData) { vodData.coguid = coguid; - String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_UPDATE); + String reqBody = buildIngestVodXml(vodData, UPDATE.getValue()); - Response resp = executeIngestVodRequest(reqBody); + Response resp = executeIngestVodRequestWithAssertion(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); GetAssetBuilder getAssetBuilder = get(id, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); @@ -206,15 +208,15 @@ public static MediaAsset updateVod(String coguid, VodData vodData) { public static void deleteVod(String coguid) { VodData vodData = new VodData(); vodData.coguid = coguid; - String reqBody = buildIngestVodXml(vodData, INGEST_ACTION_DELETE); + String reqBody = buildIngestVodXml(vodData, DELETE.getValue()); - Response resp = executeIngestVodRequest(reqBody); + Response resp = executeIngestVodRequestWithAssertion(reqBody); // on delete it returns media id // assertThat(from(resp.asString()).getInt(ingestAssetIdPath)).isEqualTo(0); } - public static Response getResponseBodyFromIngestVod(String reqBody) { + public static Response executeIngestVodRequest(String reqBody) { Response resp = given() .header(contentTypeXml) .header(soapActionIngestTvinciData) @@ -231,8 +233,8 @@ public static Response getResponseBodyFromIngestVod(String reqBody) { } // private methods - private static Response executeIngestVodRequest(String reqBody) { - Response resp = getResponseBodyFromIngestVod(reqBody); + private static Response executeIngestVodRequestWithAssertion(String reqBody) { + Response resp = executeIngestVodRequest(reqBody); assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo("OK"); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); @@ -240,7 +242,7 @@ private static Response executeIngestVodRequest(String reqBody) { return resp; } - private static String buildIngestVodXml(VodData vodData, String action) { + public static String buildIngestVodXml(VodData vodData, String action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password @@ -263,7 +265,7 @@ private static String buildIngestVodXml(VodData vodData, String action) { media.setAttribute("action", action); media.setAttribute("is_active", Boolean.toString(vodData.isActive())); - if (action.equals(INGEST_ACTION_DELETE)) { + if (action.equals(DELETE.getValue())) { return uncommentCdataSection(docToString(doc)); } From 60aa90477e453b78bd75a22eaaa9deed13ec22dd Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 13 Sep 2018 14:54:24 +0300 Subject: [PATCH 536/605] remove hardcoded delete ingest xml --- .../five_zero_two/IngestVodOpcTests.java | 128 +++++++----------- 1 file changed, 51 insertions(+), 77 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index bd8b89512..ffd012ed7 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -4,16 +4,16 @@ import com.kaltura.client.services.AssetService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.HouseholdUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.DBUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import io.qameta.allure.Issue; +import io.qameta.allure.Link; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import io.restassured.response.Response; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -25,6 +25,8 @@ import java.util.stream.Collectors; import static com.kaltura.client.services.AssetService.list; +import static com.kaltura.client.test.tests.enums.IngestAction.*; +import static com.kaltura.client.test.tests.enums.MediaType.*; import static com.kaltura.client.test.utils.BaseUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.DEFAULT_THUMB; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; @@ -40,12 +42,10 @@ * * Class to test functionality described in https://kaltura.atlassian.net/browse/BEO-5428 */ -@Test(groups = { "opc", "ingest VOD for OPC" }) -// tag @Test allow to exclude class from testng using it's group name in form +@Link(name = "OPC VOD Ingest", url = "BEO-5428") +@Test(groups = { "opc", "OPC VOD Ingest" }) public class IngestVodOpcTests extends BaseTest { private MediaAsset movie; -// private MediaAsset episode; -// private MediaAsset series; private int movieType; private int episodeType; @@ -53,7 +53,6 @@ public class IngestVodOpcTests extends BaseTest { private String localCoguid; private String ingestInsertXml; - private String ingestDeleteXml; private static final String suffix4Coguid = "123"; private static String coguid4NegativeTests = ""; @@ -62,7 +61,7 @@ public class IngestVodOpcTests extends BaseTest { private static List ppvNames; @BeforeClass() - public void setUp() { + public void ingestVodOpcTests_beforeClass() { // get data for ingest 2 files fileTypeNames = DBUtils.getMediaFileTypeNames(2); ppvNames = DBUtils.getPpvNames(2); @@ -74,45 +73,29 @@ public void setUp() { movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData; - generateDefaultValues4Insert(MOVIE); - vodData = getVodData(MOVIE, movieAssetFiles); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); movie = insertVod(vodData, true); movieType = movie.getType(); // generate ingest XMLs for negative cases coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); - ingestDeleteXml = DELETE_VOD_XML.replaceAll("180822092522774", movie.getExternalId()); -// episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// generateDefaultValues4Insert(EPISODE); -// vodData = getVodData(EPISODE, episodeAssetFiles); -// episode = insertVod(vodData, true); -// episodeType = episode.getType(); - - episodeType = DBUtils.getMediaTypeId(MediaType.EPISODE); - -// seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// generateDefaultValues4Insert(SERIES); -// vodData = getVodData(SERIES, seriesAssetFiles); -// series = insertVod(vodData, true); -// seriesType = series.getType(); - - seriesType = DBUtils.getMediaTypeId(MediaType.SERIES); + episodeType = DBUtils.getMediaTypeId(EPISODE); + seriesType = DBUtils.getMediaTypeId(SERIES); } - @Test - public void sandbox() { - + @AfterClass + public void ingestVodOpcTests_afterClass() { + // cleanup + deleteVod(movie.getExternalId()); } @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { - generateDefaultValues4Insert(MOVIE); List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; @@ -141,9 +124,8 @@ public void insertVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { - generateDefaultValues4Insert(EPISODE); List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(EPISODE, episodeAssetFiles); + VodData vodData = getVodData(EPISODE, episodeAssetFiles, INSERT); MediaAsset episode = insertVod(vodData, true); assertThat(episode.getName()).isEqualTo(name); @@ -169,9 +151,8 @@ public void insertVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { - generateDefaultValues4Insert(SERIES); List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(SERIES, seriesAssetFiles); + VodData vodData = getVodData(SERIES, seriesAssetFiles, INSERT); MediaAsset series = insertVod(vodData, true); assertThat(series.getName()).isEqualTo(name); @@ -197,8 +178,7 @@ public void insertVodSeriesBaseFields() { @Test(description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { String coguid = getCoguidOfActiveMediaAsset(movieType); - generateDefaultValues4Update(true, MOVIE); - IngestVodUtils.VodData vodData = getVodData(MOVIE, new ArrayList<>()); + VodData vodData = getVodData(MOVIE, new ArrayList<>(), UPDATE); MediaAsset asset = updateVod(coguid, vodData); String updateRequest = ingestXmlRequest; @@ -231,7 +211,7 @@ public void updateVodMediaBaseFields() { .replaceAll("", "") // to remove thumb .replaceAll("", ""); - Response resp = getResponseBodyFromIngestVod(updateRequest); + Response resp = executeIngestVodRequest(updateRequest); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(asset.getId()), AssetReferenceType.MEDIA) @@ -258,8 +238,7 @@ public void updateVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { - generateDefaultValues4Update(false, EPISODE); - IngestVodUtils.VodData vodData = getVodData(EPISODE, episodeAssetFiles); + VodData vodData = getVodData(EPISODE, episodeAssetFiles, UPDATE); String coguid = getCoguidOfActiveMediaAsset(episodeType); MediaAsset asset = updateVod(coguid, vodData); @@ -283,8 +262,7 @@ public void updateVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { - generateDefaultValues4Update(true, SERIES); - IngestVodUtils.VodData vodData = getVodData(SERIES, seriesAssetFiles); + VodData vodData = getVodData(SERIES, seriesAssetFiles, UPDATE); String coguid = getCoguidOfActiveMediaAsset(seriesType); MediaAsset asset = updateVod(coguid, vodData); @@ -330,12 +308,12 @@ public void deleteSeries() { @Test(description = "try insert without coguid") public void insertWithEmptyCoguid() { String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", ""); - resp = getResponseBodyFromIngestVod(invalidXml); + resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); } @@ -343,13 +321,15 @@ public void insertWithEmptyCoguid() { @Severity(SeverityLevel.NORMAL) @Test(description = "try delete without coguid") public void deleteWithEmptyCoguid() { - String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", "co_guid=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); + // delete with empty coguid + String invalidXml = buildIngestVodXml(new VodData(), DELETE.getValue()); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + movie.getExternalId() + "\"", ""); - resp = getResponseBodyFromIngestVod(invalidXml); + // delete with missing coguid attribute + invalidXml = invalidXml.replaceAll("co_guid=\"\"", ""); + resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); } @@ -357,12 +337,10 @@ public void deleteWithEmptyCoguid() { @Severity(SeverityLevel.NORMAL) @Test(description = "try delete with non-existed coguid") public void deleteWithNonExistedCoguid() { - int positionCoguidTag = ingestDeleteXml.indexOf("co_guid=\""); - int positionBeginOfCoguid = ingestDeleteXml.indexOf("\"", positionCoguidTag + 1); - int positionEndOfCoguid = ingestDeleteXml.indexOf("\"", positionBeginOfCoguid + 1); - String coguid = ingestDeleteXml.substring(positionBeginOfCoguid + 1, positionEndOfCoguid); - String invalidXml = ingestDeleteXml.replaceAll("co_guid=\"" + coguid + "\"", "co_guid=\"123456\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); + String invalidCoguid = "123456"; + VodData vodData = new VodData().coguid(invalidCoguid); + String invalidXml = buildIngestVodXml(vodData, DELETE.getValue()); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); } @@ -371,12 +349,12 @@ public void deleteWithNonExistedCoguid() { @Test(description = "try insert with empty entry_id") public void insertWithEmptyEntryId() { String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", ""); - resp = getResponseBodyFromIngestVod(invalidXml); + resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); } @@ -385,7 +363,7 @@ public void insertWithEmptyEntryId() { @Test(description = "try insert inactive item") public void insertInactiveItem() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); + Response resp = executeIngestVodRequest(invalidXml); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); @@ -401,7 +379,7 @@ public void insertInactiveItem() { @Test(description = "try insert with empty isActive parameter") public void insertEmptyIsActive() { String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); - Response resp = getResponseBodyFromIngestVod(invalidXml); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); } @@ -410,7 +388,7 @@ public void insertEmptyIsActive() { @Test(description = "try insert with empty name") public void insertWithEmptyName() { String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); - Response resp = getResponseBodyFromIngestVod(invalidXml); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); @@ -418,7 +396,7 @@ public void insertWithEmptyName() { .replaceAll("", "") .replaceAll("" + movie.getName() + "", "") .replaceAll("", ""); - resp = getResponseBodyFromIngestVod(invalidXml); + resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.Basic.Name cannot be empty"); } @@ -431,14 +409,14 @@ public void insertWithInvalidCredentials() { // invalid user name String invalidXml = ingestInsertXml.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); - Response resp = getResponseBodyFromIngestVod(invalidXml); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); // invalid password invalidXml = ingestInsertXml.replaceAll("passWord>Test_API_27_03<", "passWord>aTest_API_27_03<"); - resp = getResponseBodyFromIngestVod(invalidXml); + resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestStatusMessagePath)).isEqualTo(statusMessage); assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); @@ -480,8 +458,7 @@ public void insertMultiLingualFields() { String suffix = "multilingual"; name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically - generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE, movieAssetFiles); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); movie = insertVod(vodData, true); String nameData = "" + movie.getName() + ""; String descriptionData = "" + movie.getDescription() + ""; @@ -500,7 +477,7 @@ public void insertMultiLingualFields() { ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); - Response resp = getResponseBodyFromIngestVod(ingestXml); + Response resp = executeIngestVodRequest(ingestXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); @@ -542,7 +519,7 @@ public void insertVodMediaBaseEmptyImagesAndFields() { String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; String ingestXml = getUpdatedIngestXml(ingestXmlWithEmptyFiles, "", "", emptyFiles); - Response resp = getResponseBodyFromIngestVod(ingestXml); + Response resp = executeIngestVodRequest(ingestXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); /* TODO: Shir said that current logic should allow to ingest without any errors - that can be checked after Alon complete image update @@ -569,9 +546,9 @@ public void insertVodMediaBaseEmptyImagesAndFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with different Ppv") public void updateVodMediaPpv() { - generateDefaultValues4Insert(MOVIE); +// generateDefaultValues4Insert(MOVIE); List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; @@ -602,8 +579,8 @@ public void updateVodMediaPpv() { @Test(description = "update VOD images") public void updateImages() { // insert vod - generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE, movieAssetFiles); +// generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); // get list of original images @@ -642,15 +619,12 @@ public void updateImages() { public void updateFiles() { // insert vod List files = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - - generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE, files); - + VodData vodData = getVodData(MOVIE, files, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); // update vod images long e = getEpoch(); - String r = getRandomValue(); + String r = String.valueOf(getRandomLong()); String coguid1 = "file_1_" + e + "_" + r; String coguid2 = "file_2_" + e + "_" + r; @@ -672,7 +646,7 @@ public void updateFiles() { } void assertInvalidMovieField(String ingestXml, String fieldName, String fieldType) { - Response resp = getResponseBodyFromIngestVod(ingestXml); + Response resp = executeIngestVodRequest(ingestXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)) .isEqualTo(fieldType + ": " + fieldName + " does not exist for group"); From 2ded02cc7d9e180f1b5e8aa735d479cea7171ff9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 09:40:25 +0300 Subject: [PATCH 537/605] no message --- .../versions/five_zero_two/IngestVodOpcTests.java | 3 +-- .../servicesTests/AssetTests/AssetCountTests.java | 13 +++++-------- .../test/utils/ingestUtils/IngestVodOpcUtils.java | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index ffd012ed7..2471e5aca 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -632,8 +632,7 @@ public void updateFiles() { files.get(0).coguid(coguid1).assetDuration("5"); files.get(1).coguid(coguid2).assetDuration("5"); - VodData updateVodData = new VodData() - .assetFiles(files); + VodData updateVodData = new VodData().files(files); List mediaFiles = updateVod(mediaAsset.getExternalId(), updateVodData).getMediaFiles(); // assert update diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index 26862aeac..23ab38023 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -3,10 +3,8 @@ import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.KsqlBuilder; - import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -19,13 +17,13 @@ import java.util.HashMap; import java.util.List; - -import static com.kaltura.client.services.AssetService.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; +import static com.kaltura.client.services.AssetService.CountAssetBuilder; import static com.kaltura.client.test.tests.enums.KsqlKey.EPG_ID; import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.EpgData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.VodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; @@ -58,7 +56,7 @@ private void asset_count_before_class() { stringMetaMap.put(tagName,tagValue); // ingest asset 1 - IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() + VodData vodData1 = new VodData() .mediaType(MOVIE) .strings(stringMetaMap); asset = insertVod(vodData1, true); @@ -69,10 +67,9 @@ private void asset_count_before_class() { stringMetaMap2.put(tagName,tagValue); // ingest asset 2 - IngestVodUtils.VodData vodData2 = new IngestVodUtils.VodData() + VodData vodData2 = new VodData() .mediaType(MOVIE) .strings(stringMetaMap2); - asset2 = insertVod(vodData2, true); HashMap epgMetas = new HashMap<>(); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 41d7a508c..8b4c67f54 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -89,7 +89,7 @@ public static VodData getVodData(MediaType mediaType, List mediaAssetFi .numbers(numberMetaMap) .dates(datesMetaMap) .tags(tagsMetaMap) - .assetFiles(mediaAssetFiles); + .files(mediaAssetFiles); switch (mediaType) { case MOVIE: From 87e484a165ebcff6faad530375aacdc8e9b3bc08 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 09:45:16 +0300 Subject: [PATCH 538/605] no message --- .../utils/ingestUtils/IngestVodUtils.java | 75 ++++++++++++------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index ba60b6fac..d1c62d074 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -30,6 +30,7 @@ public class IngestVodUtils extends BaseIngestUtils { + // response paths private static final String ingestDataResultPath = "Envelope.Body.IngestTvinciDataResponse.IngestTvinciDataResult."; private static final String ingestAssetStatusPath = ingestDataResultPath + "AssetsStatus.IngestAssetStatus[0]."; @@ -39,7 +40,14 @@ public class IngestVodUtils extends BaseIngestUtils { public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; public static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; - public static String ingestXmlRequest = ""; + // + static final String coguidDatePattern = "yyMMddHHmmssSS"; + static final String datePattern = "dd/MM/yyyy hh:mm:ss"; + static final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); + static final String endDateValue = "14/10/2099 17:00:00"; + static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); + +// public static String ingestXmlRequest = ""; @Accessors(fluent = true) @Data @@ -69,7 +77,28 @@ public static class VodData { private Map booleans; private List thumbRatios; - private List assetFiles; + private List files; + + private void setDefaultValues() { + coguid = getCurrentDateInFormat(coguidDatePattern) + "_" + getRandomLong(); + name = coguid; + description = "description of " + coguid; + lang = "eng"; + thumbUrl = DEFAULT_THUMB; + catalogStartDate = offsetDateValue; + catalogEndDate = endDateValue; + startDate = offsetDateValue; + endDate = endDateValue; + mediaType = MediaType.MOVIE; + tags = getDefaultTags(); + strings = getDefaultStrings(); + dates = getDefaultDates(); + numbers = getDefaultNumbers(); + ppvWebName = ppvModuleName; + ppvMobileName = ppvModuleName; + files = getDefaultAssetFiles(ppvWebName, ppvMobileName); + thumbRatios = Arrays.asList("4:3", "16:9"); + } } @Accessors(fluent = true) @@ -83,10 +112,14 @@ public static class VodFile { private String billing_type; private String product_code; - @Setter private String coguid; - @Setter private String assetDuration; - @Setter private String type; - @Setter private String ppvModule; + @Setter + private String coguid; + @Setter + private String assetDuration; + @Setter + private String type; + @Setter + private String ppvModule; public VodFile(String type, String ppvModule) { quality = "HIGH"; @@ -104,15 +137,10 @@ public VodFile(String type, String ppvModule) { } } - /** IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" **/ + /** + * IMPORTANT: In order to update or delete existing asset use asset.getName() as "coguid" + **/ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { - - final String coguidDatePattern = "yyMMddHHmmssSS"; - final String datePattern = "dd/MM/yyyy hh:mm:ss"; - final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); - final String endDateValue = "14/10/2099 17:00:00"; - final String ppvModuleName = DBUtils.getPpvNames(1).get(0); // "Shai_Regression_PPV"; - if (vodData.coguid == null) { vodData.coguid = getCurrentDateInFormat(coguidDatePattern); } @@ -163,8 +191,8 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { if (vodData.ppvMobileName == null) { vodData.ppvMobileName = ppvModuleName; } - if (vodData.assetFiles == null) { - vodData.assetFiles = getDefaultAssetFiles(vodData.ppvWebName, vodData.ppvMobileName); + if (vodData.files == null) { + vodData.files = getDefaultAssetFiles(vodData.ppvWebName, vodData.ppvMobileName); } if (vodData.thumbRatios == null) { vodData.thumbRatios = Arrays.asList("4:3", "16:9"); @@ -254,9 +282,9 @@ public static String buildIngestVodXml(VodData vodData, String action) { doc.getElementsByTagName("passWord").item(0).setTextContent(getIngestAssetUserPassword()); } -// // add CDATA section -// CDATASection cdata = doc.createCDATASection(""); -// doc.getElementsByTagName("tem:request").item(0).appendChild(cdata); + // add CDATA section +// CDATASection cdata = doc.createCDATASection(""); +// doc.getElementsByTagName("tem:request").item(0).appendChild(cdata); // media Element media = (Element) doc.getElementsByTagName("media").item(0); @@ -397,20 +425,17 @@ public static String buildIngestVodXml(VodData vodData, String action) { } // files - if (vodData.assetFiles != null && vodData.assetFiles.size() > 0) { + if (vodData.files != null && vodData.files.size() > 0) { Element files = (Element) media.getElementsByTagName("files").item(0); - for (VodFile vodFile : vodData.assetFiles) { + for (VodFile vodFile : vodData.files) { files.appendChild(addFile(doc, vodFile)); } } // uncomment cdata String docAsString = docToString(doc); - - ingestXmlRequest = uncommentCdataSection(docAsString); - //Logger.getLogger(IngestVodUtils.class).debug("ingestXmlRequest: " + ingestXmlRequest); - return ingestXmlRequest; + return uncommentCdataSection(docAsString); } private static Element addFile(Document doc, VodFile vodFile) { From d2bbe6bd72c5bd817721622a09b2666d1ed5a3bd Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 11:32:40 +0300 Subject: [PATCH 539/605] add getEpochInMillis() --- src/test/java/com/kaltura/client/test/utils/BaseUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 5b262835b..5496816aa 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -108,6 +108,10 @@ public static long getEpoch(int calendarType, int amount) { return c.toInstant().getEpochSecond(); } + public static long getEpochInMillis() { + return System.currentTimeMillis(); + } + public static Date getDateFromEpoch(long epoch) { return new Date(epoch * 1000); } From f60c50b84c1dd8f210c6d1402c301a3f5f54596f Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 11:35:13 +0300 Subject: [PATCH 540/605] no message --- .../test/utils/ingestUtils/IngestVodUtils.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index d1c62d074..4d56176cf 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -40,14 +40,12 @@ public class IngestVodUtils extends BaseIngestUtils { public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; public static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; - // - static final String coguidDatePattern = "yyMMddHHmmssSS"; - static final String datePattern = "dd/MM/yyyy hh:mm:ss"; - static final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); - static final String endDateValue = "14/10/2099 17:00:00"; - static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); + private static final String datePattern = "dd/MM/yyyy hh:mm:ss"; + private static final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); + private static final String endDateValue = "14/10/2099 17:00:00"; + private static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); -// public static String ingestXmlRequest = ""; + public static String ingestXmlRequest = ""; @Accessors(fluent = true) @Data @@ -80,7 +78,7 @@ public static class VodData { private List files; private void setDefaultValues() { - coguid = getCurrentDateInFormat(coguidDatePattern) + "_" + getRandomLong(); + coguid = String.valueOf(getEpochInMillis()); name = coguid; description = "description of " + coguid; lang = "eng"; @@ -142,7 +140,7 @@ public VodFile(String type, String ppvModule) { **/ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { if (vodData.coguid == null) { - vodData.coguid = getCurrentDateInFormat(coguidDatePattern); + vodData.coguid = String.valueOf(getEpochInMillis()); } if (useDefaultValues) { From 9cea571e097128b45553453ac5de243fee45fa7c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 11:45:23 +0300 Subject: [PATCH 541/605] no message --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../ParentChildMetadataInheritanceTests.java | 13 ++++-- .../five_zero_two/IngestVodOpcTests.java | 46 +++++++++---------- .../utils/ingestUtils/IngestVodOpcUtils.java | 4 -- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 6c3009e99..b58505aca 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -125,7 +125,7 @@ public class BaseTest { @Parameters({"accountType"}) @BeforeSuite(alwaysRun = true) - public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType, ITestContext testContext) { + public void baseTest_beforeSuite(@org.testng.annotations.Optional("regular") String accountType, ITestContext testContext) { XmlSuite suite = testContext.getCurrentXmlTest().getSuite(); Logger.getLogger(BaseTest.class).debug("Start suite >>> Suite: " + suite.getName()); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 6b07ae3d8..279c098e3 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -9,7 +9,7 @@ import com.kaltura.client.services.AssetStructService.ListAssetStructBuilder; import com.kaltura.client.services.AssetStructService.UpdateAssetStructBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Link; @@ -25,8 +25,7 @@ import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getFormattedDate; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; @@ -38,8 +37,14 @@ @Test(groups = { "opc", "Parent Child Metadata Inheritance" }) public class ParentChildMetadataInheritanceTests extends BaseTest { + private static List assetFiles; + @BeforeClass() public void setUp() { + // get data for ingest 2 files + List fileTypeNames = DBUtils.getMediaFileTypeNames(2); + List ppvNames = DBUtils.getPpvNames(2); + assetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); } // added to play with methods that are going to be checked @@ -109,7 +114,7 @@ public void sandbox() { @Test public void sandboxRemoveMetasAndTags() { - IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, assetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); assertThat(movie.getName()).isEqualTo(movie.getExternalId()); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 2471e5aca..30f7b26e9 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -57,30 +57,30 @@ public class IngestVodOpcTests extends BaseTest { private static final String suffix4Coguid = "123"; private static String coguid4NegativeTests = ""; - private static List fileTypeNames; - private static List ppvNames; + private static List assetFiles; @BeforeClass() public void ingestVodOpcTests_beforeClass() { // get data for ingest 2 files - fileTypeNames = DBUtils.getMediaFileTypeNames(2); - ppvNames = DBUtils.getPpvNames(2); + List fileTypeNames = DBUtils.getMediaFileTypeNames(2); + List ppvNames = DBUtils.getPpvNames(2); + assetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); String prefix = "Movie_"; localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); name = prefix + "Name_" + localCoguid; description = prefix + "Description_" + localCoguid; - movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, assetFiles, INSERT); movie = insertVod(vodData, true); - movieType = movie.getType(); // generate ingest XMLs for negative cases coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); + // get media types + movieType = DBUtils.getMediaTypeId(MOVIE); episodeType = DBUtils.getMediaTypeId(EPISODE); seriesType = DBUtils.getMediaTypeId(SERIES); } @@ -94,8 +94,7 @@ public void ingestVodOpcTests_afterClass() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { - List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, assetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; @@ -113,7 +112,7 @@ public void insertVodMediaBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(movieAssetFiles, movie.getId().toString()); + assertFiles(assetFiles, movie.getId().toString()); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); @@ -124,8 +123,7 @@ public void insertVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { - List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(EPISODE, episodeAssetFiles, INSERT); + VodData vodData = getVodData(EPISODE, assetFiles, INSERT); MediaAsset episode = insertVod(vodData, true); assertThat(episode.getName()).isEqualTo(name); @@ -143,7 +141,7 @@ public void insertVodEpisodeBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(episodeAssetFiles, episode.getId().toString()); + assertFiles(assetFiles, episode.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -151,8 +149,7 @@ public void insertVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { - List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(SERIES, seriesAssetFiles, INSERT); + VodData vodData = getVodData(SERIES, assetFiles, INSERT); MediaAsset series = insertVod(vodData, true); assertThat(series.getName()).isEqualTo(name); @@ -170,7 +167,7 @@ public void insertVodSeriesBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(seriesAssetFiles, series.getId().toString()); + assertFiles(assetFiles, series.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -238,7 +235,7 @@ public void updateVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { - VodData vodData = getVodData(EPISODE, episodeAssetFiles, UPDATE); + VodData vodData = getVodData(EPISODE, assetFiles, UPDATE); String coguid = getCoguidOfActiveMediaAsset(episodeType); MediaAsset asset = updateVod(coguid, vodData); @@ -262,7 +259,7 @@ public void updateVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { - VodData vodData = getVodData(SERIES, seriesAssetFiles, UPDATE); + VodData vodData = getVodData(SERIES, assetFiles, UPDATE); String coguid = getCoguidOfActiveMediaAsset(seriesType); MediaAsset asset = updateVod(coguid, vodData); @@ -458,7 +455,7 @@ public void insertMultiLingualFields() { String suffix = "multilingual"; name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, assetFiles, INSERT); movie = insertVod(vodData, true); String nameData = "" + movie.getName() + ""; String descriptionData = "" + movie.getDescription() + ""; @@ -546,15 +543,13 @@ public void insertVodMediaBaseEmptyImagesAndFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with different Ppv") public void updateVodMediaPpv() { -// generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, assetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; assertThat(movie.getName()).isEqualTo(name); assertThat(movie.getDescription()).isEqualTo(description); - assertFiles(movieAssetFiles, movie.getId().toString()); + assertFiles(assetFiles, movie.getId().toString()); Household household = HouseholdUtils.createHousehold(); String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); @@ -579,8 +574,7 @@ public void updateVodMediaPpv() { @Test(description = "update VOD images") public void updateImages() { // insert vod -// generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, assetFiles, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); // get list of original images @@ -618,6 +612,8 @@ public void updateImages() { @Test(description = "update VOD files") public void updateFiles() { // insert vod + List fileTypeNames = DBUtils.getMediaFileTypeNames(2); + List ppvNames = DBUtils.getPpvNames(2); List files = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(MOVIE, files, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 8b4c67f54..04499fb47 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -66,10 +66,6 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static HashMap datesMetaMap = new HashMap<>(); public static HashMap> tagsMetaMap = new HashMap<>(); - public static List movieAssetFiles = new ArrayList<>(); - public static List episodeAssetFiles = new ArrayList<>(); - public static List seriesAssetFiles = new ArrayList<>(); - public static String tagValue1 = "Jack Nicholson"; public static String tagValue2 = "Natalie Portman"; From dd8c6cf80e473d36ea29222f20b520923f16c53d Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 11:59:40 +0300 Subject: [PATCH 542/605] Revert "no message" This reverts commit 9cea571e097128b45553453ac5de243fee45fa7c. --- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../ParentChildMetadataInheritanceTests.java | 13 ++---- .../five_zero_two/IngestVodOpcTests.java | 46 ++++++++++--------- .../utils/ingestUtils/IngestVodOpcUtils.java | 4 ++ 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index b58505aca..6c3009e99 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -125,7 +125,7 @@ public class BaseTest { @Parameters({"accountType"}) @BeforeSuite(alwaysRun = true) - public void baseTest_beforeSuite(@org.testng.annotations.Optional("regular") String accountType, ITestContext testContext) { + public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType, ITestContext testContext) { XmlSuite suite = testContext.getCurrentXmlTest().getSuite(); Logger.getLogger(BaseTest.class).debug("Start suite >>> Suite: " + suite.getName()); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 279c098e3..6b07ae3d8 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -9,7 +9,7 @@ import com.kaltura.client.services.AssetStructService.ListAssetStructBuilder; import com.kaltura.client.services.AssetStructService.UpdateAssetStructBuilder; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Link; @@ -25,7 +25,8 @@ import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getFormattedDate; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; @@ -37,14 +38,8 @@ @Test(groups = { "opc", "Parent Child Metadata Inheritance" }) public class ParentChildMetadataInheritanceTests extends BaseTest { - private static List assetFiles; - @BeforeClass() public void setUp() { - // get data for ingest 2 files - List fileTypeNames = DBUtils.getMediaFileTypeNames(2); - List ppvNames = DBUtils.getPpvNames(2); - assetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); } // added to play with methods that are going to be checked @@ -114,7 +109,7 @@ public void sandbox() { @Test public void sandboxRemoveMetasAndTags() { - VodData vodData = getVodData(MOVIE, assetFiles, INSERT); + IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); assertThat(movie.getName()).isEqualTo(movie.getExternalId()); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 30f7b26e9..2471e5aca 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -57,30 +57,30 @@ public class IngestVodOpcTests extends BaseTest { private static final String suffix4Coguid = "123"; private static String coguid4NegativeTests = ""; - private static List assetFiles; + private static List fileTypeNames; + private static List ppvNames; @BeforeClass() public void ingestVodOpcTests_beforeClass() { // get data for ingest 2 files - List fileTypeNames = DBUtils.getMediaFileTypeNames(2); - List ppvNames = DBUtils.getPpvNames(2); - assetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + fileTypeNames = DBUtils.getMediaFileTypeNames(2); + ppvNames = DBUtils.getPpvNames(2); String prefix = "Movie_"; localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); name = prefix + "Name_" + localCoguid; description = prefix + "Description_" + localCoguid; + movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, assetFiles, INSERT); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); movie = insertVod(vodData, true); + movieType = movie.getType(); // generate ingest XMLs for negative cases coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); - // get media types - movieType = DBUtils.getMediaTypeId(MOVIE); episodeType = DBUtils.getMediaTypeId(EPISODE); seriesType = DBUtils.getMediaTypeId(SERIES); } @@ -94,7 +94,8 @@ public void ingestVodOpcTests_afterClass() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { - VodData vodData = getVodData(MOVIE, assetFiles, INSERT); + List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; @@ -112,7 +113,7 @@ public void insertVodMediaBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(assetFiles, movie.getId().toString()); + assertFiles(movieAssetFiles, movie.getId().toString()); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); @@ -123,7 +124,8 @@ public void insertVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { - VodData vodData = getVodData(EPISODE, assetFiles, INSERT); + List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(EPISODE, episodeAssetFiles, INSERT); MediaAsset episode = insertVod(vodData, true); assertThat(episode.getName()).isEqualTo(name); @@ -141,7 +143,7 @@ public void insertVodEpisodeBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(assetFiles, episode.getId().toString()); + assertFiles(episodeAssetFiles, episode.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -149,7 +151,8 @@ public void insertVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { - VodData vodData = getVodData(SERIES, assetFiles, INSERT); + List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(SERIES, seriesAssetFiles, INSERT); MediaAsset series = insertVod(vodData, true); assertThat(series.getName()).isEqualTo(name); @@ -167,7 +170,7 @@ public void insertVodSeriesBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(assetFiles, series.getId().toString()); + assertFiles(seriesAssetFiles, series.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -235,7 +238,7 @@ public void updateVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { - VodData vodData = getVodData(EPISODE, assetFiles, UPDATE); + VodData vodData = getVodData(EPISODE, episodeAssetFiles, UPDATE); String coguid = getCoguidOfActiveMediaAsset(episodeType); MediaAsset asset = updateVod(coguid, vodData); @@ -259,7 +262,7 @@ public void updateVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { - VodData vodData = getVodData(SERIES, assetFiles, UPDATE); + VodData vodData = getVodData(SERIES, seriesAssetFiles, UPDATE); String coguid = getCoguidOfActiveMediaAsset(seriesType); MediaAsset asset = updateVod(coguid, vodData); @@ -455,7 +458,7 @@ public void insertMultiLingualFields() { String suffix = "multilingual"; name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically - VodData vodData = getVodData(MOVIE, assetFiles, INSERT); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); movie = insertVod(vodData, true); String nameData = "" + movie.getName() + ""; String descriptionData = "" + movie.getDescription() + ""; @@ -543,13 +546,15 @@ public void insertVodMediaBaseEmptyImagesAndFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with different Ppv") public void updateVodMediaPpv() { - VodData vodData = getVodData(MOVIE, assetFiles, INSERT); +// generateDefaultValues4Insert(MOVIE); + List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; assertThat(movie.getName()).isEqualTo(name); assertThat(movie.getDescription()).isEqualTo(description); - assertFiles(assetFiles, movie.getId().toString()); + assertFiles(movieAssetFiles, movie.getId().toString()); Household household = HouseholdUtils.createHousehold(); String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); @@ -574,7 +579,8 @@ public void updateVodMediaPpv() { @Test(description = "update VOD images") public void updateImages() { // insert vod - VodData vodData = getVodData(MOVIE, assetFiles, INSERT); +// generateDefaultValues4Insert(MOVIE); + VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); // get list of original images @@ -612,8 +618,6 @@ public void updateImages() { @Test(description = "update VOD files") public void updateFiles() { // insert vod - List fileTypeNames = DBUtils.getMediaFileTypeNames(2); - List ppvNames = DBUtils.getPpvNames(2); List files = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(MOVIE, files, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 04499fb47..8b4c67f54 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -66,6 +66,10 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static HashMap datesMetaMap = new HashMap<>(); public static HashMap> tagsMetaMap = new HashMap<>(); + public static List movieAssetFiles = new ArrayList<>(); + public static List episodeAssetFiles = new ArrayList<>(); + public static List seriesAssetFiles = new ArrayList<>(); + public static String tagValue1 = "Jack Nicholson"; public static String tagValue2 = "Natalie Portman"; From 3035f2e4bbb6854d2fbf4fec0864abcca981be69 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 11:59:55 +0300 Subject: [PATCH 543/605] Revert "no message" This reverts commit f60c50b84c1dd8f210c6d1402c301a3f5f54596f. --- .../test/utils/ingestUtils/IngestVodUtils.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 4d56176cf..d1c62d074 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -40,12 +40,14 @@ public class IngestVodUtils extends BaseIngestUtils { public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; public static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; - private static final String datePattern = "dd/MM/yyyy hh:mm:ss"; - private static final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); - private static final String endDateValue = "14/10/2099 17:00:00"; - private static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); + // + static final String coguidDatePattern = "yyMMddHHmmssSS"; + static final String datePattern = "dd/MM/yyyy hh:mm:ss"; + static final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); + static final String endDateValue = "14/10/2099 17:00:00"; + static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); - public static String ingestXmlRequest = ""; +// public static String ingestXmlRequest = ""; @Accessors(fluent = true) @Data @@ -78,7 +80,7 @@ public static class VodData { private List files; private void setDefaultValues() { - coguid = String.valueOf(getEpochInMillis()); + coguid = getCurrentDateInFormat(coguidDatePattern) + "_" + getRandomLong(); name = coguid; description = "description of " + coguid; lang = "eng"; @@ -140,7 +142,7 @@ public VodFile(String type, String ppvModule) { **/ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { if (vodData.coguid == null) { - vodData.coguid = String.valueOf(getEpochInMillis()); + vodData.coguid = getCurrentDateInFormat(coguidDatePattern); } if (useDefaultValues) { From 1ea8030ca5c5abf9cfabdda3036d852447224228 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 12:04:11 +0300 Subject: [PATCH 544/605] no message --- .../kaltura/client/test/utils/ingestUtils/IngestVodUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index d1c62d074..9796c234e 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -47,7 +47,7 @@ public class IngestVodUtils extends BaseIngestUtils { static final String endDateValue = "14/10/2099 17:00:00"; static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); -// public static String ingestXmlRequest = ""; + public static String ingestXmlRequest = ""; @Accessors(fluent = true) @Data From 6a4802a7c1f3b7278a562d94daa566c3cef6e4ca Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Sun, 16 Sep 2018 14:31:06 +0300 Subject: [PATCH 545/605] no message --- .../ParentChildMetadataInheritanceTests.java | 2 +- .../five_zero_two/IngestVodOpcTests.java | 58 +++++++++---------- .../utils/ingestUtils/IngestVodOpcUtils.java | 12 ++-- .../utils/ingestUtils/IngestVodUtils.java | 35 ++++++----- 4 files changed, 55 insertions(+), 52 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 6b07ae3d8..27a1226a8 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -109,7 +109,7 @@ public void sandbox() { @Test public void sandboxRemoveMetasAndTags() { - IngestVodUtils.VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + IngestVodUtils.VodData vodData = getVodData(MOVIE, INSERT); MediaAsset movie = insertVod(vodData, true); assertThat(movie.getName()).isEqualTo(movie.getExternalId()); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 2471e5aca..d0501e95c 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -17,7 +17,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -65,22 +64,21 @@ public void ingestVodOpcTests_beforeClass() { // get data for ingest 2 files fileTypeNames = DBUtils.getMediaFileTypeNames(2); ppvNames = DBUtils.getPpvNames(2); +// movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); String prefix = "Movie_"; localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); name = prefix + "Name_" + localCoguid; description = prefix + "Description_" + localCoguid; - movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, INSERT); movie = insertVod(vodData, true); - movieType = movie.getType(); // generate ingest XMLs for negative cases coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); + movieType = DBUtils.getMediaTypeId(MOVIE); episodeType = DBUtils.getMediaTypeId(EPISODE); seriesType = DBUtils.getMediaTypeId(SERIES); } @@ -94,8 +92,8 @@ public void ingestVodOpcTests_afterClass() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodMediaBaseFields() { - List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); +// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(MOVIE, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; @@ -113,7 +111,7 @@ public void insertVodMediaBaseFields() { assertThat(tagValues).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(movieAssetFiles, movie.getId().toString()); +// assertFiles(movieAssetFiles, movie.getId().toString()); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); @@ -124,8 +122,8 @@ public void insertVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { - List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(EPISODE, episodeAssetFiles, INSERT); +// List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(EPISODE, INSERT); MediaAsset episode = insertVod(vodData, true); assertThat(episode.getName()).isEqualTo(name); @@ -143,7 +141,7 @@ public void insertVodEpisodeBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(episodeAssetFiles, episode.getId().toString()); +// assertFiles(episodeAssetFiles, episode.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -151,8 +149,8 @@ public void insertVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { - List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(SERIES, seriesAssetFiles, INSERT); +// List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(SERIES, INSERT); MediaAsset series = insertVod(vodData, true); assertThat(series.getName()).isEqualTo(name); @@ -170,7 +168,7 @@ public void insertVodSeriesBaseFields() { } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - assertFiles(seriesAssetFiles, series.getId().toString()); +// assertFiles(seriesAssetFiles, series.getId().toString()); // without cleanup as we have below tests that can delete ingested item } @@ -178,7 +176,7 @@ public void insertVodSeriesBaseFields() { @Test(description = "update VOD with filled base meta fields") public void updateVodMediaBaseFields() { String coguid = getCoguidOfActiveMediaAsset(movieType); - VodData vodData = getVodData(MOVIE, new ArrayList<>(), UPDATE); + VodData vodData = getVodData(MOVIE, UPDATE); MediaAsset asset = updateVod(coguid, vodData); String updateRequest = ingestXmlRequest; @@ -238,7 +236,7 @@ public void updateVodMediaBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { - VodData vodData = getVodData(EPISODE, episodeAssetFiles, UPDATE); + VodData vodData = getVodData(EPISODE, UPDATE); String coguid = getCoguidOfActiveMediaAsset(episodeType); MediaAsset asset = updateVod(coguid, vodData); @@ -262,7 +260,7 @@ public void updateVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD series with filled base meta fields") public void updateVodSeriesBaseFields() { - VodData vodData = getVodData(SERIES, seriesAssetFiles, UPDATE); + VodData vodData = getVodData(SERIES, UPDATE); String coguid = getCoguidOfActiveMediaAsset(seriesType); MediaAsset asset = updateVod(coguid, vodData); @@ -458,7 +456,7 @@ public void insertMultiLingualFields() { String suffix = "multilingual"; name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, INSERT); movie = insertVod(vodData, true); String nameData = "" + movie.getName() + ""; String descriptionData = "" + movie.getDescription() + ""; @@ -469,11 +467,11 @@ public void insertMultiLingualFields() { // to get xml having all fields supporting multilingual String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) - .replaceAll(movie.getName(), movie.getName() + JAP)); + .replaceAll(movie.getName(), movie.getName() + JAP)); ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) - .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); + .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) - .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); + .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); @@ -547,14 +545,14 @@ public void insertVodMediaBaseEmptyImagesAndFields() { @Test(description = "ingest VOD with different Ppv") public void updateVodMediaPpv() { // generateDefaultValues4Insert(MOVIE); - List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); +// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(MOVIE, INSERT); MediaAsset movie = insertVod(vodData, true); String ingestRequest = ingestXmlRequest; assertThat(movie.getName()).isEqualTo(name); assertThat(movie.getDescription()).isEqualTo(description); - assertFiles(movieAssetFiles, movie.getId().toString()); +// assertFiles(movieAssetFiles, movie.getId().toString()); Household household = HouseholdUtils.createHousehold(); String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); @@ -580,7 +578,7 @@ public void updateVodMediaPpv() { public void updateImages() { // insert vod // generateDefaultValues4Insert(MOVIE); - VodData vodData = getVodData(MOVIE, movieAssetFiles, INSERT); + VodData vodData = getVodData(MOVIE, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); // get list of original images @@ -618,8 +616,9 @@ public void updateImages() { @Test(description = "update VOD files") public void updateFiles() { // insert vod + VodData vodData = getVodData(MOVIE, INSERT); List files = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, files, INSERT); + vodData.files(files); MediaAsset mediaAsset = insertVod(vodData, true); // update vod images @@ -632,7 +631,8 @@ public void updateFiles() { files.get(0).coguid(coguid1).assetDuration("5"); files.get(1).coguid(coguid2).assetDuration("5"); - VodData updateVodData = new VodData().files(files); + VodData updateVodData = new VodData() + .files(files); List mediaFiles = updateVod(mediaAsset.getExternalId(), updateVodData).getMediaFiles(); // assert update @@ -657,7 +657,7 @@ void assertVodDeletion(String coguid) { assetFilter.setKSql(new KsqlBuilder().equal("externalId", coguid).toString()); com.kaltura.client.utils.response.base.Response> assetListResponse = executor.executeSync(list(assetFilter) - .setKs(getAnonymousKs())); + .setKs(getAnonymousKs())); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(1); @@ -692,4 +692,4 @@ private void assertFiles(List ingestAssetFiles, String assetId) { } assertThat(isFileWasFound).isEqualTo(true); } -} +} \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 8b4c67f54..5b3b65895 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -66,14 +66,14 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static HashMap datesMetaMap = new HashMap<>(); public static HashMap> tagsMetaMap = new HashMap<>(); - public static List movieAssetFiles = new ArrayList<>(); - public static List episodeAssetFiles = new ArrayList<>(); - public static List seriesAssetFiles = new ArrayList<>(); +// public static List movieAssetFiles = new ArrayList<>(); +// public static List episodeAssetFiles = new ArrayList<>(); +// public static List seriesAssetFiles = new ArrayList<>(); public static String tagValue1 = "Jack Nicholson"; public static String tagValue2 = "Natalie Portman"; - public static VodData getVodData(MediaType mediaType, List mediaAssetFiles, IngestAction action) { + public static VodData getVodData(MediaType mediaType, IngestAction action) { if (action == INSERT) { generateDefaultValues4Insert(mediaType); } else if (action == UPDATE) { @@ -81,6 +81,7 @@ public static VodData getVodData(MediaType mediaType, List mediaAssetFi } VodData data = new VodData() + .setDefaultValues() .name(name) .description(description) .thumbUrl(DEFAULT_THUMB) @@ -88,8 +89,7 @@ public static VodData getVodData(MediaType mediaType, List mediaAssetFi .booleans(booleanHashMap) .numbers(numberMetaMap) .dates(datesMetaMap) - .tags(tagsMetaMap) - .files(mediaAssetFiles); + .tags(tagsMetaMap); switch (mediaType) { case MOVIE: diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 9796c234e..d8484624a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -40,12 +40,11 @@ public class IngestVodUtils extends BaseIngestUtils { public static final String ingestAssetStatusWarningMessagePath = ingestAssetStatusPath + "Warnings.Status.Message"; public static final String ingestAssetIdPath = ingestAssetStatusPath + "InternalAssetId"; - // - static final String coguidDatePattern = "yyMMddHHmmssSS"; - static final String datePattern = "dd/MM/yyyy hh:mm:ss"; - static final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); - static final String endDateValue = "14/10/2099 17:00:00"; - static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); + private static final String datePattern = "dd/MM/yyyy hh:mm:ss"; + private static final String endDateValue = "14/10/2099 17:00:00"; + private static final String offsetDateValue = getOffsetDateInFormat(-1, datePattern); + + private static final List ppvNames = DBUtils.getPpvNames(2); public static String ingestXmlRequest = ""; @@ -79,8 +78,8 @@ public static class VodData { private List thumbRatios; private List files; - private void setDefaultValues() { - coguid = getCurrentDateInFormat(coguidDatePattern) + "_" + getRandomLong(); + public VodData setDefaultValues() { + coguid = String.valueOf(getEpochInMillis()); name = coguid; description = "description of " + coguid; lang = "eng"; @@ -94,10 +93,12 @@ private void setDefaultValues() { strings = getDefaultStrings(); dates = getDefaultDates(); numbers = getDefaultNumbers(); - ppvWebName = ppvModuleName; - ppvMobileName = ppvModuleName; + ppvWebName = ppvNames.get(0); + ppvMobileName = ppvNames.get(1); files = getDefaultAssetFiles(ppvWebName, ppvMobileName); thumbRatios = Arrays.asList("4:3", "16:9"); + + return this; } } @@ -142,7 +143,7 @@ public VodFile(String type, String ppvModule) { **/ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { if (vodData.coguid == null) { - vodData.coguid = getCurrentDateInFormat(coguidDatePattern); + vodData.coguid = String.valueOf(getEpochInMillis()); } if (useDefaultValues) { @@ -186,10 +187,10 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { vodData.numbers = getDefaultNumbers(); } if (vodData.ppvWebName == null) { - vodData.ppvWebName = ppvModuleName; + vodData.ppvWebName = ppvNames.get(0); } if (vodData.ppvMobileName == null) { - vodData.ppvMobileName = ppvModuleName; + vodData.ppvMobileName = ppvNames.get(1); } if (vodData.files == null) { vodData.files = getDefaultAssetFiles(vodData.ppvWebName, vodData.ppvMobileName); @@ -435,7 +436,8 @@ public static String buildIngestVodXml(VodData vodData, String action) { // uncomment cdata String docAsString = docToString(doc); - return uncommentCdataSection(docAsString); + ingestXmlRequest = uncommentCdataSection(docAsString); + return ingestXmlRequest = uncommentCdataSection(docAsString); } private static Element addFile(Document doc, VodFile vodFile) { @@ -545,9 +547,10 @@ private static Map getDefaultDates() { // TODO: these values should be get in another way than now private static List getDefaultAssetFiles(String ppvModuleName1, String ppvModuleName2) { List assetFiles = new ArrayList<>(); + List fileTypeNames = DBUtils.getMediaFileTypeNames(2); - VodFile file1 = new VodFile("Web HD", ppvModuleName1); - VodFile file2 = new VodFile("Mobile_Devices_Main_HD", ppvModuleName2); + VodFile file1 = new VodFile(fileTypeNames.get(0), ppvModuleName1); + VodFile file2 = new VodFile(fileTypeNames.get(1), ppvModuleName2); assetFiles.add(file1); assetFiles.add(file2); From 41b1869ccce91f64ab5219aecdf5004a2834eac5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 17 Sep 2018 10:24:49 +0300 Subject: [PATCH 546/605] assetHistory regression fixes --- .../com/kaltura/client/test/Properties.java | 4 + .../appTokenTests/AppTokenAddTests.java | 8 +- .../AssetHistoryCleanTests.java | 239 ++++++++++++---- .../AssetHistoryListTests.java | 255 +++++++++++++----- .../bookmarkTests/BookmarkAddTests.java | 56 ++-- .../householdTests/HouseholdSuspendTests.java | 4 +- .../OttUserLoginWithPinTests.java | 8 +- .../kaltura/client/test/utils/AssetUtils.java | 41 ++- .../resources/schemas/AssetFileContext.json | 38 +++ 9 files changed, 506 insertions(+), 147 deletions(-) create mode 100644 src/test/resources/schemas/AssetFileContext.json diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index ae0ef1957..740255197 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -96,6 +96,10 @@ public static String getProperty(String propertyKey) { } return resourceBundle.getString(propertyKey); } + + // playback context options + public static final String MEDIA_PROTOCOL = "http"; + public static final String STREAMER_TYPE = "applehttp"; } // todo global list diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index 207ad40b8..f9c1bb39b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -90,8 +90,8 @@ private void addAppTokenWithPrivileges() { @Description("appToken/action/add - with expiry date") // priority needed, because at parralel execution both test threads launch setup method of this class and this cause to Error 1 at login with operator user. - @Test(groups = "slow_before", priority = 1) - private void addAppTokenWithExpiryDate_before() { + @Test(groups = {"slowBefore"}, priority = 1) + private void addAppTokenWithExpiryDate_before_wait() { // setup for test add_tests_before_class(); // prepare token with expiration after 1 minute @@ -109,8 +109,8 @@ private void addAppTokenWithExpiryDate_before() { } - @Test(groups = "slow_after", dependsOnGroups = {"slow_before"}, priority = 1) - private void addAppTokenWithExpiryDate_after() { + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void addAppTokenWithExpiryDate_after_wait() { // prepare builder and variables for await() functionality GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponseSlowTest.results.getId()) .setKs(getOperatorKs()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 26b42ce00..09112b83d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -1,8 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.assetHistoryTests; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.enums.*; import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; @@ -13,6 +11,8 @@ import org.testng.annotations.Test; import java.util.List; +import java.util.Optional; +import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.AssetHistoryService.*; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; @@ -22,10 +22,14 @@ import static com.kaltura.client.test.utils.AssetUtils.getAssets; import static com.kaltura.client.test.utils.BookmarkUtils.addBookmark; import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.PurchaseUtils.purchasePpv; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class AssetHistoryCleanTests extends BaseTest { + + private final int position1 = 10; private final int position2 = 20; private final int numOfUsers = 1; @@ -40,6 +44,11 @@ public class AssetHistoryCleanTests extends BaseTest { private MediaAsset episode; private int episodeFileId; + String masterUserKsCleanHistory; + String masterUserKsCleanSpecifcAssetHistory; + String masterUserKsCleanSpecifcAssetTypeHistory; + String masterUserKsCleanAssetsAccordingToWatchStatusDone; + String masterUserKsCleanAssetsAccordingToWatchStatusProgress; @BeforeClass private void assetHistory_clean_tests_before_class() { @@ -58,215 +67,347 @@ private void assetHistory_clean_tests_before_class() { episodeFileId = AssetUtils.getAssetFileIds(String.valueOf(episode.getId())).get(0); } + @Description("assetHistory/action/clean - no filtering") - @Test - private void cleanHistory() { + @Test(groups = {"slowBefore"}, priority = -1) + private void cleanHistory_before_wait() { + assetHistory_clean_tests_before_class(); // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsCleanHistory = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsCleanHistory, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanHistory, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark1 = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark1).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark1).setKs(masterUserKsCleanHistory); executor.executeSync(addBookmarkBuilder); + // purchase media2 and prepare media file for playback + masterUserKsCleanHistory = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsCleanHistory, Optional.of(movie2.getId().intValue()), Optional.of(movie2FileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanHistory, String.valueOf(movie2.getId()), + String.valueOf(movie2FileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark second asset Bookmark bookmark2 = addBookmark(position1, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark2).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark2).setKs(masterUserKsCleanHistory); executor.executeSync(addBookmarkBuilder); + } + @Description("assetHistory/action/clean - no filtering") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void cleanHistory_after_wait() { // assetHistory/action/list - both assets should returned AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 2 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsCleanHistory)).results.getTotalCount() == 2); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanHistory)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); // assetHistory/action/clean CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(masterUserKsCleanHistory); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - no object returned assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanHistory)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(0); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsCleanHistory)); } @Description("assetHistory/action/clean - filtered by asset id") - @Test - private void cleanSpecifcAssetHistory() { + @Test(groups = {"slowBefore"}) + private void cleanSpecifcAssetHistory_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsCleanSpecifcAssetHistory = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsCleanSpecifcAssetHistory, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanSpecifcAssetHistory, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark1 = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); executor.executeSync(add(bookmark1) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanSpecifcAssetHistory)); + + // purchase media2 and prepare media file for playback + masterUserKsCleanSpecifcAssetHistory = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsCleanSpecifcAssetHistory, Optional.of(movie2.getId().intValue()), Optional.of(movie2FileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanSpecifcAssetHistory, String.valueOf(movie2.getId()), + String.valueOf(movie2FileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark second asset Bookmark bookmark2 = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid2); executor.executeSync(add(bookmark2) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanSpecifcAssetHistory)); + } + @Description("assetHistory/action/clean - filtered by asset id") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void cleanSpecifcAssetHistory_after_wait() { // assetHistory/action/clean AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setAssetIdIn(String.valueOf(movie.getId())); assetHistoryFilter.setStatusEqual(WatchStatus.ALL); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(masterUserKsCleanSpecifcAssetHistory); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = "") assetHistoryFilter.setAssetIdIn(""); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsCleanSpecifcAssetHistory)).results.getTotalCount() == 1); + }); + // assetHistory/action/list - after clean - only asset id 2 returned (was not cleaned) Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanSpecifcAssetHistory)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsCleanSpecifcAssetHistory)); } @Description("assetHistory/action/clean - filtered by asset type") - @Test - private void cleanSpecifcAssetTypeHistory() { + @Test(groups = {"slowBefore"}) + private void cleanSpecifcAssetTypeHistory_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsCleanSpecifcAssetTypeHistory = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsCleanSpecifcAssetTypeHistory, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanSpecifcAssetTypeHistory, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); executor.executeSync(add(bookmark) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanSpecifcAssetTypeHistory)); + + // purchase media episode and prepare media file for playback + masterUserKsCleanSpecifcAssetTypeHistory = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsCleanSpecifcAssetTypeHistory, Optional.of(episode.getId().intValue()), Optional.of(episodeFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanSpecifcAssetTypeHistory, String.valueOf(episode.getId()), + String.valueOf(episodeFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid2); executor.executeSync(add(bookmark) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanSpecifcAssetTypeHistory)); + } + @Description("assetHistory/action/clean - filtered by asset type") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void cleanSpecifcAssetTypeHistory_after_wait() { //assetHistory/action/clean - only episode type (episode) AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setTypeIn(String.valueOf(getMediaTypeId(EPISODE))); assetHistoryFilter.setStatusEqual(WatchStatus.ALL); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(masterUserKsCleanSpecifcAssetTypeHistory); executor.executeSync(cleanAssetHistoryBuilder); // Update assetHistoryFilter object (assetIdIn = "") assetHistoryFilter.setTypeIn(""); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsCleanSpecifcAssetTypeHistory)).results.getTotalCount() == 1); + }); + // assetHistory/action/list - after clean - only movie returned (was not cleaned) Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanSpecifcAssetTypeHistory)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsCleanSpecifcAssetTypeHistory)); } @Description("assetHistory/action/clean - filtered by asset finished") - @Test - private void cleanAssetsAccordingToWatchStatusDone() { + @Test(groups = {"slowBefore"}) + private void cleanAssetsAccordingToWatchStatusDone_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsCleanAssetsAccordingToWatchStatusDone = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsCleanAssetsAccordingToWatchStatusDone, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanAssetsAccordingToWatchStatusDone, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKsCleanAssetsAccordingToWatchStatusDone); executor.executeSync(addBookmarkBuilder); + // purchase media episode and prepare media file for playback + masterUserKsCleanAssetsAccordingToWatchStatusDone = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsCleanAssetsAccordingToWatchStatusDone, Optional.of(episode.getId().intValue()), Optional.of(episodeFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanAssetsAccordingToWatchStatusDone, String.valueOf(episode.getId()), + String.valueOf(episodeFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(masterUserKsCleanAssetsAccordingToWatchStatusDone); executor.executeSync(addBookmarkBuilder); + } + @Description("assetHistory/action/clean - filtered by asset finished") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void cleanAssetsAccordingToWatchStatusDone_after_wait() { //assetHistory/action/clean - only asset that were finished (episode) AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setStatusEqual(WatchStatus.DONE); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(masterUserKsCleanAssetsAccordingToWatchStatusDone); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - only movie returned (was not cleaned) assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsCleanAssetsAccordingToWatchStatusDone)).results.getTotalCount() == 1); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanAssetsAccordingToWatchStatusDone)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsCleanAssetsAccordingToWatchStatusDone)); } @Description("assetHistory/action/clean - filtered by asset in progress") - @Test - private void cleanAssetsAccordingToWatchStatusProgress() { + @Test(groups = {"slowBefore"}) + private void cleanAssetsAccordingToWatchStatusProgress_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsCleanAssetsAccordingToWatchStatusProgress = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsCleanAssetsAccordingToWatchStatusProgress, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanAssetsAccordingToWatchStatusProgress, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKsCleanAssetsAccordingToWatchStatusProgress); executor.executeSync(addBookmarkBuilder); + // purchase media2 and prepare media file for playback + masterUserKsCleanAssetsAccordingToWatchStatusProgress = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsCleanAssetsAccordingToWatchStatusProgress, Optional.of(episode.getId().intValue()), Optional.of(episodeFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsCleanAssetsAccordingToWatchStatusProgress, String.valueOf(episode.getId()), + String.valueOf(episodeFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(masterUserKsCleanAssetsAccordingToWatchStatusProgress); executor.executeSync(addBookmarkBuilder); + } + @Description("assetHistory/action/clean - filtered by asset in progress") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void cleanAssetsAccordingToWatchStatusProgress_after_wait() { // assetHistory/action/clean - only asset that in progress (movie) AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setStatusEqual(WatchStatus.PROGRESS); CleanAssetHistoryBuilder cleanAssetHistoryBuilder = clean(assetHistoryFilter); - cleanAssetHistoryBuilder.setKs(masterUserKs); + cleanAssetHistoryBuilder.setKs(masterUserKsCleanAssetsAccordingToWatchStatusProgress); executor.executeSync(cleanAssetHistoryBuilder); // assetHistory/action/list - after clean - only episode returned (was not cleaned) assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsCleanAssetsAccordingToWatchStatusProgress)).results.getTotalCount() == 1); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsCleanAssetsAccordingToWatchStatusProgress)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsCleanAssetsAccordingToWatchStatusProgress)); } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index db8d39e76..5de4df63c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -1,8 +1,6 @@ package com.kaltura.client.test.tests.servicesTests.assetHistoryTests; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.WatchStatus; +import com.kaltura.client.enums.*; import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.tests.enums.MediaType; @@ -15,6 +13,8 @@ import org.testng.annotations.Test; import java.util.List; +import java.util.Optional; +import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.AssetHistoryService.list; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; @@ -25,8 +25,10 @@ import static com.kaltura.client.test.utils.BaseUtils.getConcatenatedString; import static com.kaltura.client.test.utils.BookmarkUtils.addBookmark; import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.PurchaseUtils.purchasePpv; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class AssetHistoryListTests extends BaseTest { private final int position1 = 10; @@ -43,6 +45,12 @@ public class AssetHistoryListTests extends BaseTest { private MediaAsset episode; private int episodeFileId; + private String masterUserKsAssetHistoryTwoMedias; + private String masterUserKsAssetHistoryOneMedia; + private String masterUserKsVodAssetHistoryFilteredByAssetId; + private String masterUserKsVodAssetHistoryFilteredByAssetType; + private String masterUserKsVodAssetHistoryFilteredByAssetProgress; + @BeforeClass private void list_tests_before_class() { @@ -62,52 +70,59 @@ private void list_tests_before_class() { } @Description("assetHistory/action/list - with no filter and one device and two media") - @Test - private void assetHistory_vod_with_one_device_and_two_media() { + @Test(groups = {"slowBefore"}, priority = -1) + private void assetHistory_vod_with_one_device_and_two_media_before_wait() { + list_tests_before_class(); // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsAssetHistoryTwoMedias = getHouseholdMasterUserKs(household, udid1); - // Bookmark first asset -// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(movie.getId())), Optional.of(movieFileId), Optional.empty()); -// -// // getPlaybackContext -// PlaybackContextOptions options = new PlaybackContextOptions(); -// options.setStreamerType("applehttp"); -// options.setMediaProtocol("http"); -// options.setContext(PlaybackContextType.PLAYBACK); -// -// GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = -// getPlaybackContext(String.valueOf(movie.getId()), AssetType.MEDIA, options) -// .setKs(masterUserKs); -// executor.executeSync(getPlaybackContextAssetBuilder); + // purchase media and prepare media file for playback + purchasePpv(masterUserKsAssetHistoryTwoMedias, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsAssetHistoryTwoMedias, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset - first play Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - executor.executeSync(add(bookmark).setKs(masterUserKs)); + executor.executeSync(add(bookmark).setKs(masterUserKsAssetHistoryTwoMedias)); // Bookmark first asset - stop bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.STOP); - executor.executeSync(add(bookmark).setKs(masterUserKs)); + executor.executeSync(add(bookmark).setKs(masterUserKsAssetHistoryTwoMedias)); - // Bookmark second asset - first play -// PurchaseUtils.purchasePpv(masterUserKs, Optional.of(Math.toIntExact(movie2.getId())), Optional.of(movie2FileId), Optional.empty()); -// -// getPlaybackContextAssetBuilder = getPlaybackContext(String.valueOf(movie2.getId()), AssetType.MEDIA, options) -// .setKs(masterUserKs); -// executor.executeSync(getPlaybackContextAssetBuilder); + // purchase media2 and prepare media file for playback + purchasePpv(masterUserKsAssetHistoryTwoMedias, Optional.of(movie2.getId().intValue()), Optional.of(movie2FileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsAssetHistoryTwoMedias, String.valueOf(movie2.getId()), + String.valueOf(movie2FileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark second asset - first play bookmark = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - executor.executeSync(add(bookmark).setKs(masterUserKs)); + executor.executeSync(add(bookmark).setKs(masterUserKsAssetHistoryTwoMedias)); + } + @Description("assetHistory/action/list - with no filter and one device and two media") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void assetHistory_vod_with_one_device_and_two_media_after_wait() { // assetHistory/action/list - both assets should returned AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsAssetHistoryTwoMedias)).results.getTotalCount() == 2); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsAssetHistoryTwoMedias)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); // objects can be returned in any order @@ -139,34 +154,59 @@ private void assetHistory_vod_with_one_device_and_two_media() { assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(2); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsAssetHistoryTwoMedias)); } @Description("assetHistory/action/list - with no filter and two devices and one media") - @Test - private void assetHistory_vod_with_two_devices_and_one_media() { + @Test(groups = {"slowBefore"}) + private void assetHistory_vod_with_two_devices_and_one_media_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsAssetHistoryOneMedia = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback on first device + purchasePpv(masterUserKsAssetHistoryOneMedia, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsAssetHistoryOneMedia, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first device - first play Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - executor.executeSync(add(bookmark).setKs(masterUserKs)); + executor.executeSync(add(bookmark).setKs(masterUserKsAssetHistoryOneMedia)); + + // prepare media file for playback on second device + masterUserKsAssetHistoryOneMedia = getHouseholdMasterUserKs(household, udid2); + AssetUtils.playbackAssetFilePreparation(masterUserKsAssetHistoryOneMedia, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark second device - first play bookmark = addBookmark(position2, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - executor.executeSync(add(bookmark).setKs(masterUserKs)); + executor.executeSync(add(bookmark).setKs(masterUserKsAssetHistoryOneMedia)); + } + @Description("assetHistory/action/list - with no filter and two devices and one media") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void assetHistory_vod_with_two_devices_and_one_media_after_wait() { // assetHistory/action/list - both assets should returned AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsAssetHistoryOneMedia)).results.getTotalCount() == 1); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsAssetHistoryOneMedia)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); AssetHistory assetHistoryObject1 = assetHistoryListResponse.results.getObjects().get(0); @@ -178,45 +218,76 @@ private void assetHistory_vod_with_two_devices_and_one_media() { assertThat(assetHistoryObject1.getWatchedDate()).isLessThanOrEqualTo(BaseUtils.getEpoch()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsAssetHistoryOneMedia)); } @Description("assetHistory/action/list - filtered by movie asset id") - @Test - private void vodAssetHistoryFilteredByAssetId() { + @Test(groups = {"slowBefore"}) + private void vodAssetHistoryFilteredByAssetId_before_wait() { // create household int numOfDevices = 3; Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); String udid3 = getDevicesList(household).get(2).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsVodAssetHistoryFilteredByAssetId = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsVodAssetHistoryFilteredByAssetId, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsVodAssetHistoryFilteredByAssetId, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKsVodAssetHistoryFilteredByAssetId); executor.executeSync(addBookmarkBuilder); + // purchase media2 and prepare media file for playback + masterUserKsVodAssetHistoryFilteredByAssetId = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsVodAssetHistoryFilteredByAssetId, Optional.of(movie2.getId().intValue()), Optional.of(movie2FileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsVodAssetHistoryFilteredByAssetId, String.valueOf(movie2.getId()), + String.valueOf(movie2FileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark Second asset bookmark = addBookmark(position2, String.valueOf(movie2.getId()), movie2FileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(masterUserKsVodAssetHistoryFilteredByAssetId); executor.executeSync(addBookmarkBuilder); + // purchase media2 and prepare media file for playback + masterUserKsVodAssetHistoryFilteredByAssetId = getHouseholdMasterUserKs(household, udid3); + purchasePpv(masterUserKsVodAssetHistoryFilteredByAssetId, Optional.of(episode.getId().intValue()), Optional.of(episodeFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsVodAssetHistoryFilteredByAssetId, String.valueOf(episode.getId()), + String.valueOf(episodeFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark third asset bookmark = addBookmark(position1, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid3); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(masterUserKsVodAssetHistoryFilteredByAssetId); executor.executeSync(addBookmarkBuilder); + } + @Description("assetHistory/action/list - filtered by movie asset id") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void vodAssetHistoryFilteredByAssetId_after_wait() { //assetHistory/action/list - filter by asset 2 id AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setAssetIdIn(String.valueOf(movie2.getId())); assetHistoryFilter.setStatusEqual(WatchStatus.ALL); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsVodAssetHistoryFilteredByAssetId)).results.getTotalCount() == 1); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsVodAssetHistoryFilteredByAssetId)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie2.getId()); @@ -225,77 +296,129 @@ private void vodAssetHistoryFilteredByAssetId() { assetHistoryFilter.setAssetIdIn(concatenatedString); List assetHistoryList = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)).results.getObjects(); + .setKs(masterUserKsVodAssetHistoryFilteredByAssetId)).results.getObjects(); assertThat(assetHistoryList).extracting("assetId") .containsExactlyInAnyOrder(movie2.getId(), episode.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsVodAssetHistoryFilteredByAssetId)); } @Description("assetHistory/action/list - filtered by movie type id") - @Test - private void vodAssetHistoryFilteredByAssetType() { + @Test(groups = {"slowBefore"}) + private void vodAssetHistoryFilteredByAssetType_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsVodAssetHistoryFilteredByAssetType = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsVodAssetHistoryFilteredByAssetType, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsVodAssetHistoryFilteredByAssetType, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKsVodAssetHistoryFilteredByAssetType); executor.executeSync(addBookmarkBuilder); + // purchase media episode and prepare media file for playback + masterUserKsVodAssetHistoryFilteredByAssetType = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsVodAssetHistoryFilteredByAssetType, Optional.of(episode.getId().intValue()), Optional.of(episodeFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsVodAssetHistoryFilteredByAssetType, String.valueOf(episode.getId()), + String.valueOf(episodeFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark Second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(masterUserKsVodAssetHistoryFilteredByAssetType); executor.executeSync(addBookmarkBuilder); + } + @Description("assetHistory/action/list - filtered by movie type id") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void vodAssetHistoryFilteredByAssetType_after_wait() { //assetHistory/action/list - filter by in progress assets only AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setStatusEqual(WatchStatus.ALL); assetHistoryFilter.setTypeIn(String.valueOf(getMediaTypeId(MediaType.MOVIE))); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsVodAssetHistoryFilteredByAssetType)).results.getTotalCount() == 1); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsVodAssetHistoryFilteredByAssetType)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsVodAssetHistoryFilteredByAssetType)); } @Description("assetHistory/action/list - filtered by assets progress") - @Test - private void vodAssetHistoryFilteredByAssetProgress() { + @Test(groups = {"slowBefore"}) + private void vodAssetHistoryFilteredByAssetProgress_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); String udid2 = getDevicesList(household).get(1).getUdid(); - String masterUserKs = getHouseholdMasterUserKs(household, udid1); + masterUserKsVodAssetHistoryFilteredByAssetProgress = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKsVodAssetHistoryFilteredByAssetProgress, Optional.of(movie.getId().intValue()), Optional.of(movieFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsVodAssetHistoryFilteredByAssetProgress, String.valueOf(movie.getId()), + String.valueOf(movieFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); // Bookmark first asset Bookmark bookmark = addBookmark(position1, String.valueOf(movie.getId()), movieFileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKsVodAssetHistoryFilteredByAssetProgress); executor.executeSync(addBookmarkBuilder); + // purchase media episode and prepare media file for playback + masterUserKsVodAssetHistoryFilteredByAssetProgress = getHouseholdMasterUserKs(household, udid2); + purchasePpv(masterUserKsVodAssetHistoryFilteredByAssetProgress, Optional.of(episode.getId().intValue()), Optional.of(episodeFileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKsVodAssetHistoryFilteredByAssetProgress, String.valueOf(episode.getId()), + String.valueOf(episodeFileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark Second asset bookmark = addBookmark(position2, String.valueOf(episode.getId()), episodeFileId, AssetType.MEDIA, BookmarkActionType.FINISH); - masterUserKs = getHouseholdMasterUserKs(household, udid2); - addBookmarkBuilder = add(bookmark).setKs(masterUserKs); + addBookmarkBuilder = add(bookmark).setKs(masterUserKsVodAssetHistoryFilteredByAssetProgress); executor.executeSync(addBookmarkBuilder); + } + @Description("assetHistory/action/list - filtered by assets progress") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void vodAssetHistoryFilteredByAssetProgress_after_wait() { //assetHistory/action/list - filter by in progress assets only AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); assetHistoryFilter.setStatusEqual(WatchStatus.PROGRESS); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + // wait for 1 assets at history response + return (executor.executeSync(list(assetHistoryFilter).setKs(masterUserKsVodAssetHistoryFilteredByAssetProgress)).results.getTotalCount() == 1); + }); + Response> assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsVodAssetHistoryFilteredByAssetProgress)); + assertThat(assetHistoryListResponse.error).isNull(); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(movie.getId()); @@ -303,13 +426,13 @@ private void vodAssetHistoryFilteredByAssetProgress() { assetHistoryFilter.setStatusEqual(WatchStatus.DONE); assetHistoryListResponse = executor.executeSync(list(assetHistoryFilter) - .setKs(masterUserKs)); + .setKs(masterUserKsVodAssetHistoryFilteredByAssetProgress)); assertThat(assetHistoryListResponse.results.getTotalCount()).isEqualTo(1); assertThat(assetHistoryListResponse.results.getObjects().get(0).getAssetId()).isEqualTo(episode.getId()); // cleanup - delete household - executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); + executor.executeSync(HouseholdService.delete().setKs(masterUserKsVodAssetHistoryFilteredByAssetProgress)); } //todo - Currently EPG program not returned in response (Ticket was opened to Omer - BEO-4594] } \ No newline at end of file diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 06585a118..661cdb7ad 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -1,14 +1,13 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.BookmarkOrderBy; -import com.kaltura.client.enums.PositionOwner; +import com.kaltura.client.enums.*; +import com.kaltura.client.services.HouseholdService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.Bookmark; import com.kaltura.client.types.BookmarkFilter; +import com.kaltura.client.types.Household; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -17,11 +16,14 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.PurchaseUtils.purchasePpv; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -52,7 +54,7 @@ private void bookmark_addTests_before_class() { } @Description("bookmark/action/add - first play") - @Test(groups = "slow_before") + @Test(groups = {"slowBefore"}) private void firstPlayback_before_wait() { bookmark_addTests_before_class(); position = 0; @@ -67,11 +69,11 @@ private void firstPlayback_before_wait() { assertThat(booleanResponse.error).isNull(); } @Description("bookmark/action/add - first play") - @Test(groups = "slow_after", dependsOnMethods = {"firstPlayback_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) private void firstPlayback_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; - int maxTimeExpectingValidResponseInSeconds = 75; + int maxTimeExpectingValidResponseInSeconds = 80; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); @@ -107,7 +109,7 @@ private void firstPlayback_after_wait() { } @Description("bookmark/action/add - pause") - @Test(groups = "slow_after", dependsOnMethods = {"firstPlayback_after_wait"}, alwaysRun=true) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"firstPlayback_after_wait"}, alwaysRun=true) private void pausePlayback_before_wait() { position = 30; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PAUSE); @@ -121,11 +123,11 @@ private void pausePlayback_before_wait() { } @Description("bookmark/action/add - pause") - @Test(groups = "slow_after", dependsOnMethods = {"pausePlayback_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"pausePlayback_before_wait"}) private void pausePlayback_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; - int maxTimeExpectingValidResponseInSeconds = 75; + int maxTimeExpectingValidResponseInSeconds = 80; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); @@ -145,7 +147,7 @@ private void pausePlayback_after_wait() { } @Description("bookmark/action/add - 95% watching == finish watching") - @Test(groups = "slow_after", dependsOnMethods = {"pausePlayback_after_wait"}, alwaysRun=true) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"pausePlayback_after_wait"}, alwaysRun=true) private void watchingNinetyFive_before_wait() { position = 999; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.PLAY); @@ -159,11 +161,11 @@ private void watchingNinetyFive_before_wait() { } @Description("bookmark/action/add - 95% watching == finish watching") - @Test(groups = "slow_after", dependsOnMethods = {"watchingNinetyFive_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"watchingNinetyFive_before_wait"}) private void watchingNinetyFive_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; - int maxTimeExpectingValidResponseInSeconds = 75; + int maxTimeExpectingValidResponseInSeconds = 80; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); @@ -183,7 +185,7 @@ private void watchingNinetyFive_after_wait() { } @Description("bookmark/action/add - back to start - position:0") - @Test(groups = "slow_after", dependsOnMethods = {"watchingNinetyFive_after_wait"}, alwaysRun=true) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"watchingNinetyFive_after_wait"}, alwaysRun=true) private void backToStart_before_wait() { position = 0; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.STOP); @@ -195,11 +197,11 @@ private void backToStart_before_wait() { } @Description("bookmark/action/add - back to start - position:0") - @Test(groups = "slow_after", dependsOnMethods = {"backToStart_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"backToStart_before_wait"}) private void backToStart_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; - int maxTimeExpectingValidResponseInSeconds = 75; + int maxTimeExpectingValidResponseInSeconds = 80; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); @@ -219,7 +221,7 @@ private void backToStart_after_wait() { } @Description("bookmark/action/add - finish watching") - @Test(groups = "slow_after", dependsOnMethods = {"backToStart_after_wait"}, alwaysRun=true) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"backToStart_after_wait"}, alwaysRun=true) private void finishWatching_before_wait() { position = 60; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FINISH); @@ -233,11 +235,11 @@ private void finishWatching_before_wait() { } @Description("bookmark/action/add - finish watching") - @Test(groups = "slow_after", dependsOnMethods = {"finishWatching_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"finishWatching_before_wait"}) private void finishWatching_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; - int maxTimeExpectingValidResponseInSeconds = 75; + int maxTimeExpectingValidResponseInSeconds = 80; // Invoke bookmark/action/list to verify insertion of bookmark position ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); @@ -259,13 +261,27 @@ private void finishWatching_after_wait() { @Description("bookmark/action/add - empty asset id") @Test private void emptyAssetId() { + // create household + Household household = createHousehold(1, 1, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + String udid2 = getDevicesList(household).get(1).getUdid(); + String masterUserKs = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKs, Optional.of((int)assetId), Optional.of(fileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKs, String.valueOf(assetId), + String.valueOf(fileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + bookmark = BookmarkUtils.addBookmark(0, null, fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(masterUserKs); Response booleanResponse = executor.executeSync(addBookmarkBuilder); assertThat(booleanResponse.results).isNull(); // Verify exception returned - code: 500003 ("Invalid Asset id") assertThat(booleanResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500003).getCode()); + + // cleanup - delete household + executor.executeSync(HouseholdService.delete().setKs(masterUserKs)); } // TODO - Add test for EPG bookmark diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index a5a445c27..b21ad5d25 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -421,7 +421,7 @@ private void suspend_with_playback_ppv_role() { @Severity(SeverityLevel.NORMAL) @Description("household/action/suspend - with renew_subscription role") - @Test(groups = "slow_before") + @Test(groups = {"slowBefore"}) private void suspend_with_renew_subscription_role_before_wait() { // setup for test household_suspendTests_beforeClass(); @@ -466,7 +466,7 @@ private void suspend_with_renew_subscription_role_before_wait() { assertThat(booleanResponse.results).isTrue(); } - @Test(groups = "slow_after", dependsOnGroups = {"slow_before"}, priority = 3) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) private void suspend_with_renew_subscription_role_after_wait() { // get productprice list for asset in subscription - after renew Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(fiveMinRenewSubscriptionSlowTest.getId()), Optional.empty(), false).get(0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index eb4d0bbb2..834399807 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -82,8 +82,8 @@ private void loginWithPin_with_invalid_secret() { @Severity(SeverityLevel.NORMAL) @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") - @Test(groups = "slow_before") - private void loginWithPin_with_expired_pinCode_before() { + @Test(groups = {"slowBefore"}) + private void loginWithPin_with_expired_pinCode_before_wait() { // setup for test ottUser_login_tests_setup(); // add pin @@ -93,8 +93,8 @@ private void loginWithPin_with_expired_pinCode_before() { userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); } - @Test(groups = "slow_after", dependsOnGroups = {"slow_before"}, priority = 2) - private void loginWithPin_with_expired_pinCode_after() { + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void loginWithPin_with_expired_pinCode_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 10; int maxTimeExpectingValidResponseInSeconds = 200; diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 70635e666..e618e97f9 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -3,7 +3,6 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.*; import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.BookmarkService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.services.SocialActionService; import com.kaltura.client.test.tests.enums.MediaType; @@ -15,17 +14,21 @@ import java.util.Optional; import java.util.stream.Collectors; +import static com.kaltura.client.services.AssetFileService.GetContextAssetFileBuilder; +import static com.kaltura.client.services.AssetFileService.getContext; import static com.kaltura.client.services.AssetService.*; import static com.kaltura.client.services.BookmarkService.AddBookmarkBuilder; import static com.kaltura.client.services.BookmarkService.add; import static com.kaltura.client.services.HouseholdService.delete; import static com.kaltura.client.services.SocialActionService.AddSocialActionBuilder; +import static com.kaltura.client.test.Properties.MEDIA_PROTOCOL; +import static com.kaltura.client.test.Properties.STREAMER_TYPE; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; import static com.kaltura.client.test.tests.BaseTest.executor; import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; -import static com.kaltura.client.test.tests.BaseTest.getSharedCommonSubscription; import static com.kaltura.client.test.tests.enums.KsqlKey.ASSET_TYPE; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; +import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -114,6 +117,40 @@ public static void addViewToAsset(Asset asset, AssetType assetType) { executor.executeSync(addBookmarkBuilder); } + public static void playbackAssetFilePreparation(String userKs, String assetId, String assetFileId, AssetType assetType, PlaybackContextType context, UrlType urlType) { + + PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); + playbackContextOptions.setMediaProtocol(MEDIA_PROTOCOL); + playbackContextOptions.setStreamerType(STREAMER_TYPE); + playbackContextOptions.setAssetFileIds(assetFileId); + playbackContextOptions.setContext(context); + playbackContextOptions.setUrlType(urlType); + + GetPlaybackContextAssetBuilder getPlaybackContextAssetBuilder = getPlaybackContext(assetId, assetType, playbackContextOptions).setKs(userKs); + Response playbackContextResponse = executor.executeSync(getPlaybackContextAssetBuilder); + + assertThat(playbackContextResponse.error).isNull(); + assertThat(playbackContextResponse.results.getMessages().get(0).getCode()).isEqualTo("OK"); + assertThat(playbackContextResponse.results.getSources().size()).isGreaterThan(0); + assertThat(playbackContextResponse.results.getSources().get(0).getAssetId()).isEqualTo(Integer.valueOf(assetId)); + assertThat(playbackContextResponse.results.getSources().get(0).getId()).isEqualTo(Integer.valueOf(assetFileId)); + String playbackUrl = playbackContextResponse.results.getSources().get(0).getUrl(); + + if (urlType.equals(UrlType.PLAYMANIFEST)){ + io.restassured.response.Response resp = given() + .when().redirects().follow(false) + .get(playbackUrl); + assertThat(resp.getStatusCode()).isEqualTo(302); + assertThat(resp.getHeader("Location")).contains("switch3.castup.net"); + } + + GetContextAssetFileBuilder getContextAssetFileBuilder = getContext(assetFileId, ContextType.NONE).setKs(userKs); + Response assetFileContextResponse = executor.executeSync(getContextAssetFileBuilder); + + assertThat(assetFileContextResponse.error).isNull(); + assertThat(assetFileContextResponse.results.getFullLifeCycle()).isNotEqualTo("00:00:00"); + assertThat(assetFileContextResponse.results.getViewLifeCycle()).isNotEqualTo("00:00:00"); + } public static void addLikesToAsset(Long assetId, int numOfActions, AssetType assetType) { if (numOfActions <= 0) { diff --git a/src/test/resources/schemas/AssetFileContext.json b/src/test/resources/schemas/AssetFileContext.json new file mode 100644 index 000000000..c9b4e5c99 --- /dev/null +++ b/src/test/resources/schemas/AssetFileContext.json @@ -0,0 +1,38 @@ +{ + "$id": "AssetFileContext", + "type": "object", + "properties": { + "result": { + "type": "object", + "properties": { + "fullLifeCycle": { + "type": "string" + }, + "isOfflinePlayBack": { + "type": "boolean" + }, + "viewLifeCycle": { + "type": "string" + }, + "objectType": { + "type": "string", + "enum": [ + "KalturaAssetFileContext" + ] + } + }, + "required": [ + "fullLifeCycle", + "isOfflinePlayBack", + "viewLifeCycle" + ] + }, + "executionTime": { + "type": "number" + } + }, + "required": [ + "result", + "executionTime" + ] +} \ No newline at end of file From 21e2fcf0c4f45287a5fdf52df7f62f7da3136892 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 17 Sep 2018 10:28:13 +0300 Subject: [PATCH 547/605] build failure fix --- .../kaltura/client/test/utils/ingestUtils/IngestVodUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index d1c62d074..9796c234e 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -47,7 +47,7 @@ public class IngestVodUtils extends BaseIngestUtils { static final String endDateValue = "14/10/2099 17:00:00"; static final String ppvModuleName = DBUtils.getPpvNames(1).get(0); -// public static String ingestXmlRequest = ""; + public static String ingestXmlRequest = ""; @Accessors(fluent = true) @Data From e12b8bfa1469fc10b968d5f0166d6c031cfcf1e4 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 17 Sep 2018 12:42:34 +0300 Subject: [PATCH 548/605] fix ingestVodOpcTests --- .../ParentChildMetadataInheritanceTests.java | 43 +- .../five_zero_two/IngestVodOpcTests.java | 620 ++++++++---------- .../utils/ingestUtils/IngestVodOpcUtils.java | 98 ++- .../utils/ingestUtils/IngestVodUtils.java | 18 +- .../ingest_xml_templates/ingestVOD.xml | 2 +- 5 files changed, 360 insertions(+), 421 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 27a1226a8..2830b14da 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -19,15 +19,12 @@ import java.util.ArrayList; import java.util.List; -import java.util.Map; import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; -import static com.kaltura.client.test.utils.BaseUtils.getFormattedDate; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; -import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; /** @@ -112,20 +109,20 @@ public void sandboxRemoveMetasAndTags() { IngestVodUtils.VodData vodData = getVodData(MOVIE, INSERT); MediaAsset movie = insertVod(vodData, true); - assertThat(movie.getName()).isEqualTo(movie.getExternalId()); - assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); - assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = movie.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); +// assertThat(movie.getName()).isEqualTo(movie.getExternalId()); +// assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); +// assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaValue); +// assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(numberMetaValue); +// assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateMetaValue); +// assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanMetaValue); +// +// Map tags = movie.getTags(); +// Map.Entry entry = tags.entrySet().iterator().next(); +// List tagsValues = entry.getValue().getObjects(); +// for (MultilingualStringValue tagValue: tagsValues) { +// assertThat(tagMetaValue).contains(tagValue.getValue()); +// } +// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); // TODO: update idIn with real values from DB to check metas and tags are really deleted /*RemoveMetasAndTagsAssetBuilder removeMetasAndTagsAssetBuilder = @@ -142,16 +139,16 @@ public void sandboxRemoveMetasAndTags() { assertThat(movie.getName()).isEqualTo(movie.getExternalId()); assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); - assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaValue); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(numberMetaValue); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateMetaValue); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanMetaValue); tags = movie.getTags(); entry = tags.entrySet().iterator().next(); tagsValues = entry.getValue().getObjects(); for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); + assertThat(tagMetaValue).contains(tagValue.getValue()); } assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size());*/ diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index d0501e95c..fc5d7f221 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -2,9 +2,8 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; -import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.HouseholdUtils; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; @@ -24,17 +23,20 @@ import java.util.stream.Collectors; import static com.kaltura.client.services.AssetService.list; -import static com.kaltura.client.test.tests.enums.IngestAction.*; +import static com.kaltura.client.test.tests.enums.IngestAction.DELETE; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; +import static com.kaltura.client.test.tests.enums.IngestAction.UPDATE; +import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.*; import static com.kaltura.client.test.utils.BaseUtils.*; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.DEFAULT_THUMB; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.delayBetweenRetriesInSeconds; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.maxTimeExpectingValidResponseInSeconds; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static io.restassured.path.xml.XmlPath.from; import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import static org.awaitility.Awaitility.await; /** @@ -44,40 +46,40 @@ @Link(name = "OPC VOD Ingest", url = "BEO-5428") @Test(groups = { "opc", "OPC VOD Ingest" }) public class IngestVodOpcTests extends BaseTest { - private MediaAsset movie; +// private MediaAsset movie; private int movieType; private int episodeType; private int seriesType; - private String localCoguid; - private String ingestInsertXml; - - private static final String suffix4Coguid = "123"; - private static String coguid4NegativeTests = ""; - - private static List fileTypeNames; - private static List ppvNames; +// private String localCoguid; +// private String ingestInsertXml; +// +// private static final String suffix4Coguid = "123"; +// private static String coguid4NegativeTests = ""; +// +// private static List fileTypeNames; +// private static List ppvNames; @BeforeClass() public void ingestVodOpcTests_beforeClass() { - // get data for ingest 2 files - fileTypeNames = DBUtils.getMediaFileTypeNames(2); - ppvNames = DBUtils.getPpvNames(2); -// movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - - String prefix = "Movie_"; - localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); - name = prefix + "Name_" + localCoguid; - description = prefix + "Description_" + localCoguid; - - VodData vodData = getVodData(MOVIE, INSERT); - movie = insertVod(vodData, true); - - // generate ingest XMLs for negative cases - coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; - ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); - +// // get data for ingest 2 files +// fileTypeNames = DBUtils.getMediaFileTypeNames(2); +// ppvNames = DBUtils.getPpvNames(2); +//// movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// +// String prefix = "Movie_"; +// localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); +// name = prefix + "Name_" + localCoguid; +// description = prefix + "Description_" + localCoguid; +// +// VodData vodData = getVodData(MOVIE, INSERT); +// movie = insertVod(vodData, true); +// +// // generate ingest XMLs for negative cases +// coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; +// ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); +// movieType = DBUtils.getMediaTypeId(MOVIE); episodeType = DBUtils.getMediaTypeId(EPISODE); seriesType = DBUtils.getMediaTypeId(SERIES); @@ -86,62 +88,87 @@ public void ingestVodOpcTests_beforeClass() { @AfterClass public void ingestVodOpcTests_afterClass() { // cleanup - deleteVod(movie.getExternalId()); +// deleteVod(movie.getExternalId()); } @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") - public void insertVodMediaBaseFields() { -// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); + public void insertVodMediaTagFieldName() { VodData vodData = getVodData(MOVIE, INSERT); MediaAsset movie = insertVod(vodData, true); - String ingestRequest = ingestXmlRequest; - - assertThat(movie.getName()).isEqualTo(name); - assertThat(movie.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = movie.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); -// assertFiles(movieAssetFiles, movie.getId().toString()); - assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(0).getRatio() + "\""); - assertThat(ingestRequest).contains("ratio=\"" + movie.getImages().get(1).getRatio() + "\""); + assertThat(movie.getName()).isEqualTo(vodData.name()); + assertThat(movie.getDescription()).isEqualTo(vodData.description()); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(vodData.strings().get(mediaTextFieldName)); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(mediaNumberFieldName)); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(mediaDateFieldName)); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(mediaBooleanFieldName)); + assertThat(movie.getTags().get(mediaTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(mediaTagFieldName)); + assertFiles(vodData.files(), movie.getId().toString()); + assertThat(movie.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); // without cleanup as we have below tests that can delete ingested item } + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD with filled base meta fields and erase = true") + public void updateVodMediaBaseFieldsWithErase() { + String coguid = getCoguidOfActiveMediaAsset(movieType); + VodData vodData = new VodData() + .name(String.valueOf(getEpochInMillis())) + .isErase(true); + + MediaAsset movie = updateVod(coguid, vodData); + + assertThat(movie.getName()).isEqualTo(vodData.name()); + assertThat(movie.getDescription()).isEqualTo(""); + + fail("ask Shir why some of the old data return while some being delete as expected"); + +// assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(vodData.strings().get(mediaTextFieldName)); +// assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(mediaNumberFieldName)); +// assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(mediaDateFieldName)); +// assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(mediaBooleanFieldName)); +// assertThat(movie.getTags().get(mediaTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(mediaTagFieldName)); +// assertFiles(vodData.files(), movie.getId().toString()); +// assertThat(movie.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); + + } + + @Severity(SeverityLevel.CRITICAL) + @Test(description = "update VOD with filled base meta fields and erase = false") + public void updateVodMediaBaseFieldsWithoutErase() { + String coguid = getCoguidOfActiveMediaAsset(movieType); + VodData vodData = getVodData(MOVIE, UPDATE); + + MediaAsset movie = updateVod(coguid, vodData); + + assertThat(movie.getName()).isEqualTo(vodData.name()); + assertThat(movie.getDescription()).isEqualTo(vodData.description()); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(vodData.strings().get(mediaTextFieldName)); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(mediaNumberFieldName)); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(mediaDateFieldName)); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(mediaBooleanFieldName)); + assertThat(movie.getTags().get(mediaTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(mediaTagFieldName)); + assertFiles(vodData.files(), movie.getId().toString()); + assertThat(movie.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); + } + @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodEpisodeBaseFields() { -// List episodeAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(EPISODE, INSERT); MediaAsset episode = insertVod(vodData, true); - assertThat(episode.getName()).isEqualTo(name); - assertThat(episode.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = episode.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - -// assertFiles(episodeAssetFiles, episode.getId().toString()); + assertThat(episode.getName()).isEqualTo(vodData.name()); + assertThat(episode.getDescription()).isEqualTo(vodData.description()); + assertThat(((MultilingualStringValue) episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(vodData.strings().get(episodeTextFieldName)); + assertThat(((DoubleValue) episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(episodeNumberFieldName)); + assertThat(getFormattedDate(((LongValue) episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(episodeDateFieldName)); + assertThat(((BooleanValue) episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(episodeBooleanFieldName)); + assertThat(episode.getTags().get(episodeTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(episodeTagFieldName)); + assertFiles(vodData.files(), episode.getId().toString()); + assertThat(episode.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); // without cleanup as we have below tests that can delete ingested item } @@ -149,112 +176,39 @@ public void insertVodEpisodeBaseFields() { @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodSeriesBaseFields() { -// List seriesAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); VodData vodData = getVodData(SERIES, INSERT); MediaAsset series = insertVod(vodData, true); - assertThat(series.getName()).isEqualTo(name); - assertThat(series.getDescription()).isEqualTo(description); - assertThat(((StringValue)series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = series.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + assertThat(series.getName()).isEqualTo(vodData.name()); + assertThat(series.getDescription()).isEqualTo(vodData.description()); + assertThat(((StringValue) series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(vodData.strings().get(seriesTextFieldName)); + assertThat(((DoubleValue) series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(seriesNumberFieldName)); + assertThat(getFormattedDate(((LongValue) series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(seriesDateFieldName)); + assertThat(((BooleanValue) series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(seriesBooleanFieldName)); + assertThat(series.getTags().get(seriesTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(seriesTagFieldName)); + assertFiles(vodData.files(), series.getId().toString()); + assertThat(series.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); -// assertFiles(seriesAssetFiles, series.getId().toString()); // without cleanup as we have below tests that can delete ingested item } - @Severity(SeverityLevel.CRITICAL) - @Test(description = "update VOD with filled base meta fields") - public void updateVodMediaBaseFields() { - String coguid = getCoguidOfActiveMediaAsset(movieType); - VodData vodData = getVodData(MOVIE, UPDATE); - - MediaAsset asset = updateVod(coguid, vodData); - String updateRequest = ingestXmlRequest; - - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = asset.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - - // check update with erase="true" - updateRequest = updateRequest - .replaceAll("erase=\"false\"", "erase=\"true\"") - // to remove description from XML - .replaceAll("", "") - .replaceAll("" + description + "", "") - .replaceAll("", "") - // to remove boolean meta from XML - .replaceAll("", "") - .replaceAll("" + doubleValue + "", "") - .replaceAll("", "") - // to remove thumb - .replaceAll("", ""); - Response resp = executeIngestVodRequest(updateRequest); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); - - AssetService.GetAssetBuilder assetBuilder = AssetService.get(String.valueOf(asset.getId()), AssetReferenceType.MEDIA) - .setKs(getAnonymousKs()); - com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); - MediaAsset asset2 = (MediaAsset)assetGetResponse.results; - assertThat(asset2.getId()).isEqualTo(asset.getId()); - assertThat(asset2.getName()).isEqualTo(name); - assertThat(asset2.getDescription()).isEqualTo(""); - assertThat(((MultilingualStringValue)asset2.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(asset2.getMetas().get(mediaNumberFieldName)).isEqualTo(null); - assertThat(getFormattedDate(((LongValue)asset2.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset2.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - tags = asset2.getTags(); - entry = tags.entrySet().iterator().next(); - tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - } - @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD episode with filled base meta fields") public void updateVodEpisodeBaseFields() { VodData vodData = getVodData(EPISODE, UPDATE); String coguid = getCoguidOfActiveMediaAsset(episodeType); - MediaAsset asset = updateVod(coguid, vodData); - - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((MultilingualStringValue)asset.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = asset.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + MediaAsset episode = updateVod(coguid, vodData); + + assertThat(episode.getName()).isEqualTo(vodData.name()); + assertThat(episode.getDescription()).isEqualTo(vodData.description()); + assertThat(((MultilingualStringValue) episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(vodData.strings().get(episodeTextFieldName)); + assertThat(((DoubleValue) episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(episodeNumberFieldName)); + assertThat(getFormattedDate(((LongValue) episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(episodeDateFieldName)); + assertThat(((BooleanValue) episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(episodeBooleanFieldName)); + assertThat(episode.getTags().get(episodeTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(episodeTagFieldName)); +// assertFiles(vodData.files(), episode.getId().toString()); + assertThat(episode.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); } @Severity(SeverityLevel.CRITICAL) @@ -263,22 +217,17 @@ public void updateVodSeriesBaseFields() { VodData vodData = getVodData(SERIES, UPDATE); String coguid = getCoguidOfActiveMediaAsset(seriesType); - MediaAsset asset = updateVod(coguid, vodData); - - assertThat(asset.getName()).isEqualTo(name); - assertThat(asset.getDescription()).isEqualTo(description); - assertThat(((StringValue)asset.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(textValue); - assertThat(((DoubleValue)asset.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(doubleValue); - assertThat(getFormattedDate(((LongValue)asset.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateValue); - assertThat(((BooleanValue)asset.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(booleanValue); - - Map tags = asset.getTags(); - Map.Entry entry = tags.entrySet().iterator().next(); - List tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagValues).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); + MediaAsset series = updateVod(coguid, vodData); + + assertThat(series.getName()).isEqualTo(vodData.name()); + assertThat(series.getDescription()).isEqualTo(vodData.description()); + assertThat(((StringValue) series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(vodData.strings().get(seriesTextFieldName)); + assertThat(((DoubleValue) series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(seriesNumberFieldName)); + assertThat(getFormattedDate(((LongValue) series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(seriesDateFieldName)); + assertThat(((BooleanValue) series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(seriesBooleanFieldName)); + assertThat(series.getTags().get(seriesTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(seriesTagFieldName)); +// assertFiles(vodData.files(), series.getId().toString()); + assertThat(series.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); } @Severity(SeverityLevel.CRITICAL) @@ -305,12 +254,15 @@ public void deleteSeries() { @Severity(SeverityLevel.NORMAL) @Test(description = "try insert without coguid") public void insertWithEmptyCoguid() { - String invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"\""); + // insert with empty coguid + VodData vodData = getVodData(MOVIE, INSERT).coguid(""); + String invalidXml = buildIngestVodXml(vodData, INSERT); Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); - invalidXml = ingestInsertXml.replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", ""); + // insert without coguid attribute + invalidXml = invalidXml.replaceAll("co_guid=\"\"", ""); resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); @@ -320,7 +272,7 @@ public void insertWithEmptyCoguid() { @Test(description = "try delete without coguid") public void deleteWithEmptyCoguid() { // delete with empty coguid - String invalidXml = buildIngestVodXml(new VodData(), DELETE.getValue()); + String invalidXml = buildIngestVodXml(new VodData(), DELETE); Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).contains("External identifier is missing"); @@ -337,7 +289,7 @@ public void deleteWithEmptyCoguid() { public void deleteWithNonExistedCoguid() { String invalidCoguid = "123456"; VodData vodData = new VodData().coguid(invalidCoguid); - String invalidXml = buildIngestVodXml(vodData, DELETE.getValue()); + String invalidXml = buildIngestVodXml(vodData, DELETE); Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("Media Id not exist"); @@ -346,12 +298,17 @@ public void deleteWithNonExistedCoguid() { @Severity(SeverityLevel.MINOR) @Test(description = "try insert with empty entry_id") public void insertWithEmptyEntryId() { - String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", "entry_id=\"\""); + VodData vodData = getVodData(MOVIE, INSERT); + String ingestInsertXml = buildIngestVodXml(vodData, INSERT); + + // entry_id tag empty + String invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + vodData.coguid() + "\"", "entry_id=\"\""); Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); - invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + coguid4NegativeTests + "\"", ""); + // without entry_id tag + invalidXml = ingestInsertXml.replaceAll("entry_id=\"entry_" + vodData.coguid() + "\"", ""); resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("entry_id is missing"); @@ -360,43 +317,48 @@ public void insertWithEmptyEntryId() { @Severity(SeverityLevel.MINOR) @Test(description = "try insert inactive item") public void insertInactiveItem() { - String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"false\""); - Response resp = executeIngestVodRequest(invalidXml); + VodData vodData = getVodData(MOVIE, INSERT).isActive(false); + String invalidXml = buildIngestVodXml(vodData, INSERT); + Response resp = executeIngestVodRequest(invalidXml); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); SearchAssetFilter assetFilter = new SearchAssetFilter(); - assetFilter.setKSql("media_id='" + id + "'"); - com.kaltura.client.utils.response.base.Response> assetListResponse = - executor.executeSync(list(assetFilter) - .setKs(getAnonymousKs())); - assertThat(assetListResponse.results.getTotalCount()).isEqualTo(0); + String query = new KsqlBuilder().equal(MEDIA_ID.getValue(), id).toString(); + assetFilter.setKSql(query); + + ListResponse assetListResponse = executor.executeSync(list(assetFilter) + .setKs(getAnonymousKs())) + .results; + assertThat(assetListResponse.getTotalCount()).isEqualTo(0); } @Severity(SeverityLevel.MINOR) @Test(description = "try insert with empty isActive parameter") public void insertEmptyIsActive() { + String ingestInsertXml = buildIngestVodXml(getVodData(MOVIE, INSERT), INSERT); String invalidXml = ingestInsertXml.replaceAll("is_active=\"true\"", "is_active=\"\""); - Response resp = executeIngestVodRequest(invalidXml); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.IsActive cannot be empty"); } @Severity(SeverityLevel.MINOR) @Test(description = "try insert with empty name") public void insertWithEmptyName() { - String invalidXml = ingestInsertXml.replaceAll(">" + movie.getName() + "<", "><"); - Response resp = executeIngestVodRequest(invalidXml); + // empty name value tag + VodData vodData = new VodData().mediaType(MOVIE).coguid(String.valueOf(getEpochInMillis())).name(""); + String invalidXml = buildIngestVodXml(vodData, INSERT); + Response resp = executeIngestVodRequest(invalidXml); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name.value.text cannot be empty"); - invalidXml = ingestInsertXml - .replaceAll("", "") - .replaceAll("" + movie.getName() + "", "") - .replaceAll("", ""); - resp = executeIngestVodRequest(invalidXml); + // empty name tag + VodData vodData1 = new VodData().mediaType(MOVIE).coguid(String.valueOf(getEpochInMillis())); + invalidXml = buildIngestVodXml(vodData1, INSERT); - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.Basic.Name cannot be empty"); + resp = executeIngestVodRequest(invalidXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("media.basic.name cannot be empty"); } @Severity(SeverityLevel.NORMAL) @@ -404,6 +366,9 @@ public void insertWithEmptyName() { public void insertWithInvalidCredentials() { String statusMessage = "Invalid credentials"; String status = "ERROR"; + String ingestInsertXml = buildIngestVodXml(new VodData(), INSERT); + + // TODO: 9/17/2018 fix the test to support dynamic accounts // invalid user name String invalidXml = ingestInsertXml.replaceAll("Name>Test_API_27_03<", "Name>aTest_API_27_03<"); @@ -423,161 +388,149 @@ public void insertWithInvalidCredentials() { @Severity(SeverityLevel.NORMAL) @Test(description = "try insert with invalid meta or tag field") public void insertWithInvalidMetaOrTagField() { - String suffix = "UPDATE654987321"; - String ingestXml = ingestInsertXml.replaceAll(localCoguid, localCoguid + suffix); + String suffix = "_" + getEpoch(); String updatedField = mediaNumberFieldName + suffix; - String invalidXml = ingestXml.replaceAll(mediaNumberFieldName, updatedField); - assertInvalidMovieField(invalidXml, updatedField, "meta"); - - updatedField = mediaDateFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaDateFieldName, updatedField); - assertInvalidMovieField(invalidXml, updatedField, "meta"); + VodData vodData = getVodData(MOVIE, INSERT).numbers(Map.of(updatedField, getRandomDouble())); + assertInvalidMovieField(vodData, updatedField, "meta"); updatedField = mediaBooleanFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaBooleanFieldName, updatedField); - assertInvalidMovieField(invalidXml, updatedField, "meta"); + vodData = getVodData(MOVIE, INSERT).booleans(Map.of(updatedField, getRandomBoolean())); + assertInvalidMovieField(vodData, updatedField, "meta"); updatedField = mediaTagFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaTagFieldName, updatedField); - assertInvalidMovieField(invalidXml, updatedField, "tag"); + vodData = getVodData(MOVIE, INSERT).tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); + assertInvalidMovieField(vodData, updatedField, "tag"); updatedField = mediaTextFieldName + suffix; - invalidXml = ingestXml.replaceAll(mediaTextFieldName, updatedField); - assertInvalidMovieField(invalidXml, updatedField, "meta"); + vodData = getVodData(MOVIE, INSERT).strings(Map.of(updatedField, getRandomString())); + assertInvalidMovieField(vodData, updatedField, "meta"); + + updatedField = mediaDateFieldName + suffix; + vodData = getVodData(MOVIE, INSERT).dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); + assertInvalidMovieField(vodData, updatedField, "meta"); } @Severity(SeverityLevel.NORMAL) @Test(description = "insert multilingual fields") public void insertMultiLingualFields() { - // ingested Movie for checking multilanguage - final String JAP = "jap"; - final String ENG = "eng"; - String suffix = "multilingual"; - name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically - description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically - VodData vodData = getVodData(MOVIE, INSERT); - movie = insertVod(vodData, true); - String nameData = "" + movie.getName() + ""; - String descriptionData = "" + movie.getDescription() + ""; - String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); - String stringMetaData = "" + stringMetaDataValue + ""; - String tagData = "" + tagValue1 + ""; - - // to get xml having all fields supporting multilingual - String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); - ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) - .replaceAll(movie.getName(), movie.getName() + JAP)); - ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) - .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); - ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) - .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); - ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) - .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); - - Response resp = executeIngestVodRequest(ingestXml); - - assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); - String id = from(resp.asString()).get(ingestAssetIdPath).toString(); - assertThat(id).isEqualTo(movie.getId().toString()); - - AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) - .setKs(getAnonymousKs()) - .setLanguage(JAP); - Asset asset = executor.executeSync(getAssetBuilder).results; - assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); - assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); - assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) - .isEqualTo(stringMetaDataValue + JAP); - // check tag value - boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); - assertThat(isTagValueFound).isEqualTo(true); - - getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) - .setKs(getAnonymousKs()) - .setLanguage(ENG); - asset = executor.executeSync(getAssetBuilder).results; - assertThat(asset.getName()).isEqualTo(movie.getName()); - assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); - assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); - // check tag value - isTagValueFound = isTagValueFound(tagValue1, asset); - assertThat(isTagValueFound).isEqualTo(true); - // TODO: update multilingual fields +// // ingested Movie for checking multilanguage +// final String JAP = "jap"; +// final String ENG = "eng"; +// String suffix = "multilingual"; +// +//// name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically +//// description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically +//// +// VodData vodData = getVodData(MOVIE, INSERT); +// MediaAsset movie = insertVod(vodData, true); +// String nameData = "" + movie.getName() + ""; +// String descriptionData = "" + movie.getDescription() + ""; +// String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); +// String stringMetaData = "" + stringMetaDataValue + ""; +// String tagData = "" + tagValue1 + ""; +// +// // to get xml having all fields supporting multilingual +// String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); +// ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) +// .replaceAll(movie.getName(), movie.getName() + JAP)); +// ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) +// .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); +// ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) +// .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); +// ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) +// .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); +// +// Response resp = executeIngestVodRequest(ingestXml); +// +// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); +// String id = from(resp.asString()).get(ingestAssetIdPath).toString(); +// assertThat(id).isEqualTo(movie.getId().toString()); +// +// AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) +// .setKs(getAnonymousKs()) +// .setLanguage(JAP); +// Asset asset = executor.executeSync(getAssetBuilder).results; +// assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); +// assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); +// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) +// .isEqualTo(stringMetaDataValue + JAP); +// // check tag value +// boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); +// assertThat(isTagValueFound).isEqualTo(true); +// +// getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) +// .setKs(getAnonymousKs()) +// .setLanguage(ENG); +// asset = executor.executeSync(getAssetBuilder).results; +// assertThat(asset.getName()).isEqualTo(movie.getName()); +// assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); +// assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); +// // check tag value +// isTagValueFound = isTagValueFound(tagValue1, asset); +// assertThat(isTagValueFound).isEqualTo(true); +// // TODO: update multilingual fields } @Severity(SeverityLevel.MINOR) - @Test(description = "ingest VOD with emtpy images and files fields") + @Test(description = "ingest VOD with empty images and thumb fields") public void insertVodMediaBaseEmptyImagesAndFields() { - String suffix = "123"; - String ingestXmlWithEmptyFiles = ingestInsertXml - .replaceAll("co_guid=\"" + coguid4NegativeTests + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "\""); - String ingestXmlBeforeTransformations = ingestXmlWithEmptyFiles; - // check empty files - String emptyFiles = "" + EMPTY_FILE_1_TAG + EMPTY_FILE_2_TAG + ""; - String ingestXml = getUpdatedIngestXml(ingestXmlWithEmptyFiles, "", "", emptyFiles); + // empty images tag + VodData vodData = getVodData(MOVIE, INSERT).thumbRatios(List.of()); + String ingestXml = buildIngestVodXml(vodData, INSERT); Response resp = executeIngestVodRequest(ingestXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); - /* TODO: Shir said that current logic should allow to ingest without any errors - that can be checked after Alon complete image update - // check empty images - ingestXml = ingestXmlBeforeTransformations - .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "1\""); - ingestXml = getIngestXmlWithoutFiles(ingestXml); - String emptyImages = "" + EMPTY_IMAGE_TAG + ""; - ingestXml = getUpdatedIngestXml(ingestXml, "", "", emptyImages); - - resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); - - // checkEmptyThumb - ingestXml = ingestXmlBeforeTransformations - .replaceAll("co_guid=\"" + coguid4NegativeTests + suffix + "\"", "co_guid=\"" + coguid4NegativeTests + suffix + "2\""); - ingestXml = getIngestXmlWithoutFiles(ingestXml); - ingestXml = getUpdatedIngestXml(ingestXml, "", EMPTY_THUMB_TAG); - - resp = getResponseBodyFromIngestVod(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique");*/ - } - - @Severity(SeverityLevel.CRITICAL) - @Test(description = "ingest VOD with different Ppv") - public void updateVodMediaPpv() { -// generateDefaultValues4Insert(MOVIE); -// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); - VodData vodData = getVodData(MOVIE, INSERT); - MediaAsset movie = insertVod(vodData, true); - String ingestRequest = ingestXmlRequest; + // empty thumb tag + VodData vodData1 = getVodData(MOVIE, INSERT).thumbUrl(""); + ingestXml = buildIngestVodXml(vodData1, INSERT); - assertThat(movie.getName()).isEqualTo(name); - assertThat(movie.getDescription()).isEqualTo(description); -// assertFiles(movieAssetFiles, movie.getId().toString()); + resp = executeIngestVodRequest(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); - Household household = HouseholdUtils.createHousehold(); - String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); - AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); - com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); - List getMediaFiles = assetGetResponse.results.getMediaFiles(); - int fileId1 = getMediaFiles.get(0).getId(); - int fileId2 = getMediaFiles.get(1).getId(); - - ProductPriceFilter ppFilter = new ProductPriceFilter(); - ppFilter.setFileIdIn(String.valueOf(fileId1)); - ppFilter.setIsLowest(false); - ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); - com.kaltura.client.utils.response.base.Response> productPriceResponse = - executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); - assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); - assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); - // TODO: complete +// // empty file coguid +// getDefaultAssetFiles(DBUtils.getPpvNames(2)) +// VodData vodData = getVodData(MOVIE, INSERT).files(); +// contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); } +// @Severity(SeverityLevel.CRITICAL) +// @Test(description = "ingest VOD with different Ppv") +// public void updateVodMediaPpv() { +//// generateDefaultValues4Insert(MOVIE); +//// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); +// VodData vodData = getVodData(MOVIE, INSERT); +// MediaAsset movie = insertVod(vodData, true); +// String ingestRequest = ingestXmlRequest; +// +// assertThat(movie.getName()).isEqualTo(name); +// assertThat(movie.getDescription()).isEqualTo(description); +//// assertFiles(movieAssetFiles, movie.getId().toString()); +// +// Household household = HouseholdUtils.createHousehold(); +// String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); +// AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); +// com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); +// List getMediaFiles = assetGetResponse.results.getMediaFiles(); +// int fileId1 = getMediaFiles.get(0).getId(); +// int fileId2 = getMediaFiles.get(1).getId(); +// +// ProductPriceFilter ppFilter = new ProductPriceFilter(); +// ppFilter.setFileIdIn(String.valueOf(fileId1)); +// ppFilter.setIsLowest(false); +// ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); +// com.kaltura.client.utils.response.base.Response> productPriceResponse = +// executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); +// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); +// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); +// // TODO: complete +// } +// @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD images") public void updateImages() { // insert vod -// generateDefaultValues4Insert(MOVIE); VodData vodData = getVodData(MOVIE, INSERT); MediaAsset mediaAsset = insertVod(vodData, true); @@ -606,9 +559,6 @@ public void updateImages() { newImages.forEach(image -> assertThat(image.getUrl()).isNotEmpty()); assertThat(newImages).extracting("ratio").containsExactlyInAnyOrderElementsOf(newRatios); - - // cleanup - deleteVod(mediaAsset.getExternalId()); } @Issue("BEO-5536") @@ -616,6 +566,9 @@ public void updateImages() { @Test(description = "update VOD files") public void updateFiles() { // insert vod + List fileTypeNames = DBUtils.getMediaFileTypeNames(2); + List ppvNames = DBUtils.getPpvNames(2); + VodData vodData = getVodData(MOVIE, INSERT); List files = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); vodData.files(files); @@ -644,8 +597,10 @@ public void updateFiles() { deleteVod(mediaAsset.getExternalId()); } - void assertInvalidMovieField(String ingestXml, String fieldName, String fieldType) { - Response resp = executeIngestVodRequest(ingestXml); + + // help methods + void assertInvalidMovieField(VodData vodData, String fieldName, String fieldType) { + Response resp = executeIngestVodRequest(buildIngestVodXml(vodData, INSERT)); assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)) .isEqualTo(fieldType + ": " + fieldName + " does not exist for group"); @@ -653,7 +608,6 @@ void assertInvalidMovieField(String ingestXml, String fieldName, String fieldTyp void assertVodDeletion(String coguid) { SearchAssetFilter assetFilter = new SearchAssetFilter(); -// "externalId='" + coguid + "'" assetFilter.setKSql(new KsqlBuilder().equal("externalId", coguid).toString()); com.kaltura.client.utils.response.base.Response> assetListResponse = executor.executeSync(list(assetFilter) diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 5b3b65895..cda4756ea 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -7,10 +7,7 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static com.kaltura.client.services.AssetService.list; import static com.kaltura.client.test.tests.BaseTest.executor; @@ -23,16 +20,16 @@ public class IngestVodOpcUtils extends BaseIngestUtils { - public static String name; - public static String description; - public static String textValue; - public static String dateValue; - public static double doubleValue; - public static boolean booleanValue; - public static List tagValues; + private static String name; + private static String description; + private static String stringMetaValue; + private static String dateMetaValue; + private static double numberMetaValue; + private static boolean booleanMetaValue; + private static List tagMetaValue; - public static final String FILE_TYPE_1 = "Test130301"; - public static final String FILE_TYPE_2 = "new file type1"; + private static final String FILE_TYPE_1 = "Test130301"; + private static final String FILE_TYPE_2 = "new file type1"; public static final String EMPTY_FILE_1_TAG = "\n"; public static final String EMPTY_FILE_2_TAG = "\n"; @@ -66,25 +63,21 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static HashMap datesMetaMap = new HashMap<>(); public static HashMap> tagsMetaMap = new HashMap<>(); -// public static List movieAssetFiles = new ArrayList<>(); -// public static List episodeAssetFiles = new ArrayList<>(); -// public static List seriesAssetFiles = new ArrayList<>(); - public static String tagValue1 = "Jack Nicholson"; public static String tagValue2 = "Natalie Portman"; public static VodData getVodData(MediaType mediaType, IngestAction action) { if (action == INSERT) { - generateDefaultValues4Insert(mediaType); + initDefaultValues4Insert(mediaType); } else if (action == UPDATE) { - generateDefaultValues4Update(booleanValue, mediaType); + initDefaultValues4Update(booleanMetaValue, mediaType); } VodData data = new VodData() .setDefaultValues() - .name(name) - .description(description) - .thumbUrl(DEFAULT_THUMB) +// .name(name) +// .description(description) +// .thumbUrl(DEFAULT_THUMB) .strings(stringMetaMap) .booleans(booleanHashMap) .numbers(numberMetaMap) @@ -106,29 +99,22 @@ public static VodData getVodData(MediaType mediaType, IngestAction action) { } } - private static void generateDefaultValues4Update(boolean previousValue, MediaType mediaType) { - textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy") + "_updated"; - dateValue = getOffsetDateInFormat(1, "MM/dd/yyyy"); - doubleValue = Math.round(getRandomDouble() * 100.0) / 100.0; - booleanValue = !previousValue; - tagValues = new ArrayList<>(); - tagValues.add(tagValue1 + "Upd"); - tagValues.add(tagValue2 + "Upd"); - tagValues.add(textValue); + private static void initDefaultValues4Update(boolean previousValue, MediaType mediaType) { + stringMetaValue = "stringMetaValue_" + getCurrentDateInFormat("MM/dd/yyyy") + "_updated"; + dateMetaValue = getOffsetDateInFormat(1, "MM/dd/yyyy"); + numberMetaValue = Math.round(getRandomDouble() * 100.0) / 100.0; + booleanMetaValue = !previousValue; + tagMetaValue = Arrays.asList(tagValue1 + "_updated", tagValue2 + "_updated", stringMetaValue + "_updated"); fillMapsWithData(mediaType); } - private static void generateDefaultValues4Insert(MediaType mediaType) { - textValue = "textValue" + getCurrentDateInFormat("MM/dd/yyyy"); - dateValue = getCurrentDateInFormat("MM/dd/yyyy"); - - doubleValue = Math.round(getRandomDouble() * 100.0) / 100.0; - booleanValue = getRandomBoolean(); - tagValues = new ArrayList<>(); - tagValues.add(tagValue1); - tagValues.add(tagValue2); - tagValues.add(textValue); + private static void initDefaultValues4Insert(MediaType mediaType) { + stringMetaValue = "stringMetaValue_" + getCurrentDateInFormat("MM/dd/yyyy"); + dateMetaValue = getCurrentDateInFormat("MM/dd/yyyy"); + numberMetaValue = Math.round(getRandomDouble() * 100.0) / 100.0; + booleanMetaValue = getRandomBoolean(); + tagMetaValue = Arrays.asList(tagValue1, tagValue2, stringMetaValue); fillMapsWithData(mediaType); } @@ -142,27 +128,27 @@ private static void fillMapsWithData(MediaType mediaType) { switch (mediaType) { case MOVIE: - stringMetaMap.put(mediaTextFieldName, textValue); - numberMetaMap.put(mediaNumberFieldName, doubleValue); - datesMetaMap.put(mediaDateFieldName, dateValue); - booleanHashMap.put(mediaBooleanFieldName, booleanValue); - tagsMetaMap.put(mediaTagFieldName, tagValues); + stringMetaMap.put(mediaTextFieldName, stringMetaValue); + numberMetaMap.put(mediaNumberFieldName, numberMetaValue); + datesMetaMap.put(mediaDateFieldName, dateMetaValue); + booleanHashMap.put(mediaBooleanFieldName, booleanMetaValue); + tagsMetaMap.put(mediaTagFieldName, tagMetaValue); break; case EPISODE: - stringMetaMap.put(episodeTextFieldName, textValue); - numberMetaMap.put(episodeNumberFieldName, doubleValue); - datesMetaMap.put(episodeDateFieldName, dateValue); - booleanHashMap.put(episodeBooleanFieldName, booleanValue); - tagsMetaMap.put(episodeTagFieldName, tagValues); + stringMetaMap.put(episodeTextFieldName, stringMetaValue); + numberMetaMap.put(episodeNumberFieldName, numberMetaValue); + datesMetaMap.put(episodeDateFieldName, dateMetaValue); + booleanHashMap.put(episodeBooleanFieldName, booleanMetaValue); + tagsMetaMap.put(episodeTagFieldName, tagMetaValue); break; case SERIES: - stringMetaMap.put(seriesTextFieldName, textValue); - numberMetaMap.put(seriesNumberFieldName, doubleValue); - datesMetaMap.put(seriesDateFieldName, dateValue); - booleanHashMap.put(seriesBooleanFieldName, booleanValue); - tagsMetaMap.put(seriesTagFieldName, tagValues); + stringMetaMap.put(seriesTextFieldName, stringMetaValue); + numberMetaMap.put(seriesNumberFieldName, numberMetaValue); + datesMetaMap.put(seriesDateFieldName, dateMetaValue); + booleanHashMap.put(seriesBooleanFieldName, booleanMetaValue); + tagsMetaMap.put(seriesTagFieldName, tagMetaValue); break; default: diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index d8484624a..1f199cee7 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.test.tests.enums.IngestAction; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.Asset; @@ -51,8 +52,9 @@ public class IngestVodUtils extends BaseIngestUtils { @Accessors(fluent = true) @Data public static class VodData { - private boolean isVirtual = false; private boolean isActive = true; + private boolean isVirtual = false; + private boolean isErase = false; private String coguid; private String name; @@ -200,7 +202,7 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { } } - String reqBody = buildIngestVodXml(vodData, INSERT.getValue()); + String reqBody = buildIngestVodXml(vodData, INSERT); Response resp = executeIngestVodRequestWithAssertion(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); @@ -218,7 +220,7 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { public static MediaAsset updateVod(String coguid, VodData vodData) { vodData.coguid = coguid; - String reqBody = buildIngestVodXml(vodData, UPDATE.getValue()); + String reqBody = buildIngestVodXml(vodData, UPDATE); Response resp = executeIngestVodRequestWithAssertion(reqBody); String id = from(resp.asString()).get(ingestAssetIdPath).toString(); @@ -237,7 +239,7 @@ public static MediaAsset updateVod(String coguid, VodData vodData) { public static void deleteVod(String coguid) { VodData vodData = new VodData(); vodData.coguid = coguid; - String reqBody = buildIngestVodXml(vodData, DELETE.getValue()); + String reqBody = buildIngestVodXml(vodData, DELETE); Response resp = executeIngestVodRequestWithAssertion(reqBody); @@ -271,7 +273,7 @@ private static Response executeIngestVodRequestWithAssertion(String reqBody) { return resp; } - public static String buildIngestVodXml(VodData vodData, String action) { + public static String buildIngestVodXml(VodData vodData, IngestAction action) { Document doc = getDocument("src/test/resources/ingest_xml_templates/ingestVOD.xml"); // user and password @@ -291,10 +293,11 @@ public static String buildIngestVodXml(VodData vodData, String action) { Element media = (Element) doc.getElementsByTagName("media").item(0); media.setAttribute("co_guid", vodData.coguid()); media.setAttribute("entry_id", "entry_" + vodData.coguid()); - media.setAttribute("action", action); + media.setAttribute("action", action.getValue()); media.setAttribute("is_active", Boolean.toString(vodData.isActive())); + media.setAttribute("erase", Boolean.toString(vodData.isErase())); - if (action.equals(DELETE.getValue())) { + if (action.equals(DELETE)) { return uncommentCdataSection(docToString(doc)); } @@ -544,7 +547,6 @@ private static Map getDefaultDates() { return dates; } - // TODO: these values should be get in another way than now private static List getDefaultAssetFiles(String ppvModuleName1, String ppvModuleName2) { List assetFiles = new ArrayList<>(); List fileTypeNames = DBUtils.getMediaFileTypeNames(2); diff --git a/src/test/resources/ingest_xml_templates/ingestVOD.xml b/src/test/resources/ingest_xml_templates/ingestVOD.xml index 1c048950c..983b5a9bc 100644 --- a/src/test/resources/ingest_xml_templates/ingestVOD.xml +++ b/src/test/resources/ingest_xml_templates/ingestVOD.xml @@ -10,7 +10,7 @@ - + From 530f145cabc47778ea41b3c45ede59b76dac7ff5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 17 Sep 2018 13:55:42 +0300 Subject: [PATCH 549/605] regression fixes --- .../kaltura/client/test/tests/BaseTest.java | 4 +- .../appTokenTests/AppTokenAddTests.java | 4 +- .../AssetHistoryCleanTests.java | 3 +- .../AssetHistoryListTests.java | 3 +- .../bookmarkTests/BookmarkAddTests.java | 14 ++-- .../bookmarkTests/BookmarkListTests.java | 81 ++++++++++++++++--- .../householdTests/HouseholdSuspendTests.java | 5 +- .../OttUserLoginWithPinTests.java | 4 +- src/test/resources/testng_regular.xml | 8 +- 9 files changed, 87 insertions(+), 39 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 6c3009e99..923872969 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -169,12 +169,12 @@ public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String numOfSuites--; } - @BeforeMethod + @BeforeMethod(alwaysRun = true) public void baseTest_beforeMethod(Method method) { Logger.getLogger(BaseTest.class).debug("Start test >>> Class: " + getClass().getSimpleName() + ", Test: " + method.getName()); } - @AfterMethod + @AfterMethod(alwaysRun = true) public void baseTest_afterMethod(Method method) { Logger.getLogger(BaseTest.class).debug("End test >>> Class: " + getClass().getSimpleName() + ", Test: " + method.getName()); } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index f9c1bb39b..b886e3b15 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -33,7 +33,7 @@ public class AppTokenAddTests extends BaseTest { private APIException apiException;; // TODO: 5/3/2018 Add comments! - @BeforeClass + @BeforeClass(alwaysRun = true) private void add_tests_before_class() { sessionUserId = getSharedUser().getUserId(); appToken = AppTokenUtils.addAppToken(sessionUserId, AppTokenHashType.SHA1, null, null); @@ -92,8 +92,6 @@ private void addAppTokenWithPrivileges() { // priority needed, because at parralel execution both test threads launch setup method of this class and this cause to Error 1 at login with operator user. @Test(groups = {"slowBefore"}, priority = 1) private void addAppTokenWithExpiryDate_before_wait() { - // setup for test - add_tests_before_class(); // prepare token with expiration after 1 minute Long expiryDate = getEpoch(Calendar.MINUTE, 1); appToken = AppTokenUtils.addAppToken(sessionUserId, null, sessionPrivileges, Math.toIntExact(expiryDate)); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 09112b83d..9d2eb6779 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -50,7 +50,7 @@ public class AssetHistoryCleanTests extends BaseTest { String masterUserKsCleanAssetsAccordingToWatchStatusDone; String masterUserKsCleanAssetsAccordingToWatchStatusProgress; - @BeforeClass + @BeforeClass(alwaysRun = true) private void assetHistory_clean_tests_before_class() { List movies = getAssets(2, MOVIE); @@ -71,7 +71,6 @@ private void assetHistory_clean_tests_before_class() { @Description("assetHistory/action/clean - no filtering") @Test(groups = {"slowBefore"}, priority = -1) private void cleanHistory_before_wait() { - assetHistory_clean_tests_before_class(); // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 5de4df63c..96a7d7072 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -52,7 +52,7 @@ public class AssetHistoryListTests extends BaseTest { private String masterUserKsVodAssetHistoryFilteredByAssetProgress; - @BeforeClass + @BeforeClass(alwaysRun = true) private void list_tests_before_class() { List movies = getAssets(2, MOVIE); @@ -72,7 +72,6 @@ private void list_tests_before_class() { @Description("assetHistory/action/list - with no filter and one device and two media") @Test(groups = {"slowBefore"}, priority = -1) private void assetHistory_vod_with_one_device_and_two_media_before_wait() { - list_tests_before_class(); // create household Household household = createHousehold(numOfUsers, numOfDevices, true); String udid1 = getDevicesList(household).get(0).getUdid(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 661cdb7ad..0f1a87a10 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -36,9 +36,8 @@ public class BookmarkAddTests extends BaseTest { private Bookmark bookmark; private BookmarkFilter bookmarkFilter; private int position; -// private String masterUserKs; - @BeforeClass + @BeforeClass(alwaysRun = true) private void bookmark_addTests_before_class() { assetList = new ArrayList<>(); assetId = BaseTest.getSharedMediaAsset().getId(); @@ -48,15 +47,11 @@ private void bookmark_addTests_before_class() { // Initialize bookmarkFilter object parameters bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC, AssetType.MEDIA, assetList); - -// Household household = HouseholdUtils.createHousehold(1,1,false); -// masterUserKs = HouseholdUtils.getHouseholdMasterUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); } @Description("bookmark/action/add - first play") @Test(groups = {"slowBefore"}) private void firstPlayback_before_wait() { - bookmark_addTests_before_class(); position = 0; bookmark = BookmarkUtils.addBookmark(position, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); @@ -259,12 +254,13 @@ private void finishWatching_after_wait() { } @Description("bookmark/action/add - empty asset id") - @Test + @Test(enabled = false) private void emptyAssetId() { // create household - Household household = createHousehold(1, 1, true); + int numberOfUsersInHousehold = 1; + int numberOfDevicesInHousehold = 1; + Household household = createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); String udid1 = getDevicesList(household).get(0).getUdid(); - String udid2 = getDevicesList(household).get(1).getUdid(); String masterUserKs = getHouseholdMasterUserKs(household, udid1); // purchase media and prepare media file for playback diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index 4e0f4851e..a91135077 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -1,14 +1,13 @@ package com.kaltura.client.test.tests.servicesTests.bookmarkTests; -import com.kaltura.client.enums.AssetType; -import com.kaltura.client.enums.BookmarkActionType; -import com.kaltura.client.enums.BookmarkOrderBy; +import com.kaltura.client.enums.*; import com.kaltura.client.services.BookmarkService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.AssetUtils; import com.kaltura.client.test.utils.BookmarkUtils; import com.kaltura.client.types.Bookmark; import com.kaltura.client.types.BookmarkFilter; +import com.kaltura.client.types.Household; import com.kaltura.client.types.ListResponse; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -17,18 +16,25 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.BookmarkService.*; import static com.kaltura.client.test.tests.BaseTest.SharedHousehold.getSharedMasterUserKs; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.HouseholdUtils.*; +import static com.kaltura.client.test.utils.PurchaseUtils.purchasePpv; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class BookmarkListTests extends BaseTest { private long assetId, assetId2; private int fileId, fileId2; private List assetList; + private String masterUserKs; - @BeforeClass + @BeforeClass(alwaysRun = true) private void bookmark_listTests_before_class() { assetList = new ArrayList<>(); @@ -44,27 +50,66 @@ private void bookmark_listTests_before_class() { } @Description("bookmark/action/list - order by") - @Test - private void BookmarkOrderBy() { + @Test(groups = {"slowBefore"}) + private void BookmarkOrderBy_before_wait() { + // create household + int numberOfUsersInHousehold = 1; + int numberOfDevicesInHousehold = 1; + Household household = createHousehold(numberOfUsersInHousehold, numberOfDevicesInHousehold, true); + String udid1 = getDevicesList(household).get(0).getUdid(); + masterUserKs = getHouseholdMasterUserKs(household, udid1); + + // purchase media and prepare media file for playback + purchasePpv(masterUserKs, Optional.of((int)assetId), Optional.of(fileId), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKs, String.valueOf(assetId), + String.valueOf(fileId), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark asset1 Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(assetId), fileId, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(getSharedMasterUserKs()); + BookmarkService.AddBookmarkBuilder addBookmarkBuilder = BookmarkService.add(bookmark).setKs(masterUserKs); Response booleanResponse = executor.executeSync(addBookmarkBuilder); + assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse.results.booleanValue()).isTrue(); + // purchase media2 and prepare media file for playback + purchasePpv(masterUserKs, Optional.of((int)assetId2), Optional.of(fileId2), Optional.empty()); + AssetUtils.playbackAssetFilePreparation(masterUserKs, String.valueOf(assetId2), + String.valueOf(fileId2), AssetType.MEDIA, PlaybackContextType.PLAYBACK, UrlType.PLAYMANIFEST); + // Bookmark asset2 Bookmark bookmark2 = BookmarkUtils.addBookmark(10, String.valueOf(assetId2), fileId2, AssetType.MEDIA, BookmarkActionType.FIRST_PLAY); - AddBookmarkBuilder addBookmarkBuilder2 = BookmarkService.add(bookmark2).setKs(getSharedMasterUserKs()); + AddBookmarkBuilder addBookmarkBuilder2 = BookmarkService.add(bookmark2).setKs(masterUserKs); Response booleanResponse2 = executor.executeSync(addBookmarkBuilder2); + + assertThat(booleanResponse.error).isNull(); assertThat(booleanResponse2.results.booleanValue()).isTrue(); + } + @Description("bookmark/action/list - order by") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + private void BookmarkOrderBy_after_wait() { // set filter BookmarkFilter bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_DESC,AssetType.MEDIA, assetList); - ListBookmarkBuilder listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); + + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + + // Invoke bookmark/action/list to verify insertion of assets bookmarks + ListBookmarkBuilder listBookmarkBuilderAwait = list(bookmarkFilter).setKs(masterUserKs); + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() ->{ + return (executor.executeSync(listBookmarkBuilderAwait).results.getTotalCount() == 2); + }); + + ListBookmarkBuilder listBookmarkBuilder = listBookmarkBuilderAwait; Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + assertThat(bookmarkListResponse.error).isNull(); Bookmark bookmarkObject = bookmarkListResponse.results.getObjects().get(0); Bookmark bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); @@ -73,9 +118,10 @@ private void BookmarkOrderBy() { assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId)); bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_ASC,AssetType.MEDIA, assetList); - listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(getSharedMasterUserKs()); + listBookmarkBuilder = BookmarkService.list(bookmarkFilter).setKs(masterUserKs); bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + assertThat(bookmarkListResponse.error).isNull(); bookmarkObject = bookmarkListResponse.results.getObjects().get(0); bookmarkObject2 = bookmarkListResponse.results.getObjects().get(1); @@ -83,4 +129,19 @@ private void BookmarkOrderBy() { assertThat( bookmarkObject.getId()).isEqualTo(String.valueOf(assetId)); assertThat( bookmarkObject2.getId()).isEqualTo(String.valueOf(assetId2)); } + + @Description("bookmark/action/list - empty asset id") + @Test + private void emptyAssetId() { + // creating bookmark filter with empty asset id + BookmarkFilter bookmarkFilter = new BookmarkFilter(); + bookmarkFilter.setAssetIdIn(""); + bookmarkFilter.setAssetTypeEqual(AssetType.MEDIA); + + ListBookmarkBuilder listBookmarkBuilder = list(bookmarkFilter).setKs(getSharedMasterUserKs()); + Response> bookmarkListResponse = executor.executeSync(listBookmarkBuilder); + + assertThat(bookmarkListResponse.results).isNull(); + assertThat(bookmarkListResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(50027).getCode()); + } } diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index b21ad5d25..08d281e0b 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -53,7 +53,7 @@ private enum Permissions { DELETE_ALL_APP_TOKENS } - @BeforeClass + @BeforeClass(alwaysRun = true) private void household_suspendTests_beforeClass() { // set subscription subscription = BaseTest.getSharedCommonSubscription(); @@ -423,9 +423,6 @@ private void suspend_with_playback_ppv_role() { @Description("household/action/suspend - with renew_subscription role") @Test(groups = {"slowBefore"}) private void suspend_with_renew_subscription_role_before_wait() { - // setup for test - household_suspendTests_beforeClass(); - // set household householdSlowTest = HouseholdUtils.createHousehold(numOfUsers, numOfDevices, true); HouseholdUser masterUser = HouseholdUtils.getMasterUser(householdSlowTest); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index 834399807..a3915ad61 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -32,7 +32,7 @@ public class OttUserLoginWithPinTests extends BaseTest { private final String SECRET = "secret"; - @BeforeClass + @BeforeClass(alwaysRun = true) private void ottUser_login_tests_setup() { // register user user = executor.executeSync(register(partnerId, generateOttUser(), defaultUserPassword)).results; @@ -84,8 +84,6 @@ private void loginWithPin_with_invalid_secret() { @Description("ottUser/action/loginWithPin - loginWithPin with expired pinCode - error 2004") @Test(groups = {"slowBefore"}) private void loginWithPin_with_expired_pinCode_before_wait() { - // setup for test - ottUser_login_tests_setup(); // add pin AddUserLoginPinBuilder addUserLoginPinBuilder = add(SECRET) .setKs(getAdministratorKs()) diff --git a/src/test/resources/testng_regular.xml b/src/test/resources/testng_regular.xml index 2adb1885d..53c698962 100644 --- a/src/test/resources/testng_regular.xml +++ b/src/test/resources/testng_regular.xml @@ -5,8 +5,8 @@ - - + + @@ -24,8 +24,8 @@ - - + + From 8128834f86bf7bac11bf17b22529b5ac1ea45098 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Mon, 17 Sep 2018 15:47:02 +0300 Subject: [PATCH 550/605] Updated class - "AssetCountTests" --- .../AssetTests/AssetCountTests.java | 69 ++++++++++++++++--- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index 26862aeac..2c10b5137 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -6,7 +6,6 @@ import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; @@ -16,16 +15,19 @@ import org.testng.annotations.Test; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import static com.kaltura.client.services.AssetService.*; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMediaTypeId; import static com.kaltura.client.test.utils.ingestUtils.IngestEpgUtils.*; import static com.kaltura.client.test.tests.enums.KsqlKey.EPG_ID; import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.BaseUtils.getRandomValue; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; @@ -46,40 +48,46 @@ public class AssetCountTests extends BaseTest { private final String epgMetaName = "Country"; private final String epgMetaValue = epgMetaName + getRandomValue("_"); - private final String epgTagName = "Director"; - private final String epgTagValue = epgTagName + getRandomValue("_"); + + private final String sharedTagName = "Director"; + private final String sharedTagValue = sharedTagName + getRandomValue("_"); @BeforeClass private void asset_count_before_class() { + // Metas HashMap stringMetaMap = new HashMap<>(); stringMetaMap.put(metaName1, metaValue1); stringMetaMap.put(metaName2,metaValue2); - stringMetaMap.put(tagName,tagValue); + + // Tags + HashMap> stringTagMap = new HashMap<>(); + stringTagMap.put(sharedTagName, Arrays.asList(sharedTagValue)); + stringTagMap.put(tagName,Arrays.asList(tagValue)); // ingest asset 1 - IngestVodUtils.VodData vodData1 = new IngestVodUtils.VodData() + VodData vodData1 = new VodData() .mediaType(MOVIE) - .strings(stringMetaMap); + .strings(stringMetaMap) + .tags(stringTagMap); asset = insertVod(vodData1, true); HashMap stringMetaMap2 = new HashMap<>(); stringMetaMap2.put(metaName1, metaValue1); stringMetaMap2.put(metaName2,metaValue3); - stringMetaMap2.put(tagName,tagValue); + stringTagMap.put(tagName,Arrays.asList(tagValue)); // ingest asset 2 - IngestVodUtils.VodData vodData2 = new IngestVodUtils.VodData() + VodData vodData2 = new VodData() .mediaType(MOVIE) .strings(stringMetaMap2); - asset2 = insertVod(vodData2, true); HashMap epgMetas = new HashMap<>(); epgMetas.put(epgMetaName, epgMetaValue); HashMap epgTags = new HashMap<>(); - epgTags.put(epgTagName,epgTagValue); + epgTags.put(sharedTagName, sharedTagValue); // ingest epg programs EpgData epgData = new EpgData(getSharedEpgChannelName()); @@ -230,7 +238,7 @@ private void groupByEPGTag() { ArrayList arrayList = new ArrayList<>(); AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); - assetMetaOrTagGroupBy.setValue(epgTagName); + assetMetaOrTagGroupBy.setValue(sharedTagName); arrayList.add(assetMetaOrTagGroupBy); searchAssetFilter.setGroupBy(arrayList); @@ -241,4 +249,43 @@ private void groupByEPGTag() { Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); } + + + @Description("VOD and EPG program with the same tag value") + @Test + private void groupByEPGAndVODTag() { + String query = new KsqlBuilder() + .equal(sharedTagName, sharedTagValue) + .toString(); + + SearchAssetFilter searchAssetFilter = new SearchAssetFilter(); + searchAssetFilter.setKSql(query); + + ArrayList arrayList = new ArrayList<>(); + AssetMetaOrTagGroupBy assetMetaOrTagGroupBy = new AssetMetaOrTagGroupBy(); + assetMetaOrTagGroupBy.setValue(sharedTagName); + arrayList.add(assetMetaOrTagGroupBy); + + searchAssetFilter.setGroupBy(arrayList); + CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + + // asset/action/count - no filtering (1 VOD asset and 2 EPG programs in count) + Response assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(3); + + // asset/action/count - filter by movie type id (1 VOD asset in count) + searchAssetFilter.setTypeIn(String.valueOf(getMediaTypeId(MediaType.MOVIE))); + countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(1); + + // asset/action/count - filter by EPG type id (2 EPG programs in count) + searchAssetFilter.setTypeIn("0"); + countAssetBuilder = AssetService.count(searchAssetFilter) + .setKs(BaseTest.getAnonymousKs()); + assetCountResponse = executor.executeSync(countAssetBuilder); + assertThat(assetCountResponse.results.getCount()).isEqualTo(2); + } } From 92fa0184c37c3f3cc5614514adf3cbf001e0ea6c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Mon, 17 Sep 2018 15:59:23 +0300 Subject: [PATCH 551/605] fix ingest opc vod tests --- .../five_zero_two/IngestVodOpcTests.java | 150 ++++++++---------- .../utils/ingestUtils/IngestVodUtils.java | 9 +- 2 files changed, 68 insertions(+), 91 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index fc5d7f221..c20c78080 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -2,6 +2,8 @@ import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.PpvService; +import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; @@ -12,7 +14,6 @@ import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import io.restassured.response.Response; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,9 +24,7 @@ import java.util.stream.Collectors; import static com.kaltura.client.services.AssetService.list; -import static com.kaltura.client.test.tests.enums.IngestAction.DELETE; -import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; -import static com.kaltura.client.test.tests.enums.IngestAction.UPDATE; +import static com.kaltura.client.test.tests.enums.IngestAction.*; import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.*; import static com.kaltura.client.test.utils.BaseUtils.*; @@ -46,51 +45,17 @@ @Link(name = "OPC VOD Ingest", url = "BEO-5428") @Test(groups = { "opc", "OPC VOD Ingest" }) public class IngestVodOpcTests extends BaseTest { -// private MediaAsset movie; - private int movieType; private int episodeType; private int seriesType; -// private String localCoguid; -// private String ingestInsertXml; -// -// private static final String suffix4Coguid = "123"; -// private static String coguid4NegativeTests = ""; -// -// private static List fileTypeNames; -// private static List ppvNames; - @BeforeClass() public void ingestVodOpcTests_beforeClass() { -// // get data for ingest 2 files -// fileTypeNames = DBUtils.getMediaFileTypeNames(2); -// ppvNames = DBUtils.getPpvNames(2); -//// movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// -// String prefix = "Movie_"; -// localCoguid = getCurrentDateInFormat("yyMMddHHmmssSS"); -// name = prefix + "Name_" + localCoguid; -// description = prefix + "Description_" + localCoguid; -// -// VodData vodData = getVodData(MOVIE, INSERT); -// movie = insertVod(vodData, true); -// -// // generate ingest XMLs for negative cases -// coguid4NegativeTests = movie.getExternalId() + suffix4Coguid; -// ingestInsertXml = ingestXmlRequest.replaceAll(movie.getExternalId(), coguid4NegativeTests); -// movieType = DBUtils.getMediaTypeId(MOVIE); episodeType = DBUtils.getMediaTypeId(EPISODE); seriesType = DBUtils.getMediaTypeId(SERIES); } - @AfterClass - public void ingestVodOpcTests_afterClass() { - // cleanup -// deleteVod(movie.getExternalId()); - } - @Severity(SeverityLevel.CRITICAL) @Test(description = "ingest VOD with filled base meta fields") public void insertVodMediaTagFieldName() { @@ -107,7 +72,8 @@ public void insertVodMediaTagFieldName() { assertFiles(vodData.files(), movie.getId().toString()); assertThat(movie.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); - // without cleanup as we have below tests that can delete ingested item + // cleanup + deleteVod(movie.getExternalId()); } @Severity(SeverityLevel.CRITICAL) @@ -170,7 +136,8 @@ public void insertVodEpisodeBaseFields() { assertFiles(vodData.files(), episode.getId().toString()); assertThat(episode.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); - // without cleanup as we have below tests that can delete ingested item + // cleanup + deleteVod(episode.getExternalId()); } @Severity(SeverityLevel.CRITICAL) @@ -189,7 +156,8 @@ public void insertVodSeriesBaseFields() { assertFiles(vodData.files(), series.getId().toString()); assertThat(series.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); - // without cleanup as we have below tests that can delete ingested item + // cleanup + deleteVod(series.getExternalId()); } @Severity(SeverityLevel.CRITICAL) @@ -389,31 +357,38 @@ public void insertWithInvalidCredentials() { @Test(description = "try insert with invalid meta or tag field") public void insertWithInvalidMetaOrTagField() { String suffix = "_" + getEpoch(); + VodData vodData = getVodData(MOVIE, INSERT); String updatedField = mediaNumberFieldName + suffix; - VodData vodData = getVodData(MOVIE, INSERT).numbers(Map.of(updatedField, getRandomDouble())); + vodData.numbers(Map.of(updatedField, getRandomDouble())); assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.numbers(Map.of()); updatedField = mediaBooleanFieldName + suffix; - vodData = getVodData(MOVIE, INSERT).booleans(Map.of(updatedField, getRandomBoolean())); + vodData.booleans(Map.of(updatedField, getRandomBoolean())); assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.booleans(Map.of()); updatedField = mediaTagFieldName + suffix; - vodData = getVodData(MOVIE, INSERT).tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); + vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); assertInvalidMovieField(vodData, updatedField, "tag"); + vodData.tags(Map.of()); updatedField = mediaTextFieldName + suffix; - vodData = getVodData(MOVIE, INSERT).strings(Map.of(updatedField, getRandomString())); + vodData.strings(Map.of(updatedField, getRandomString())); assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.strings(Map.of()); updatedField = mediaDateFieldName + suffix; - vodData = getVodData(MOVIE, INSERT).dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); + vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.dates(Map.of()); } @Severity(SeverityLevel.NORMAL) - @Test(description = "insert multilingual fields") + @Test(description = "insert multilingual fields", enabled = false) public void insertMultiLingualFields() { + // TODO: 9/17/2018 complete test // // ingested Movie for checking multilanguage // final String JAP = "jap"; // final String ENG = "eng"; @@ -476,7 +451,10 @@ public void insertMultiLingualFields() { @Test(description = "ingest VOD with empty images and thumb fields") public void insertVodMediaBaseEmptyImagesAndFields() { // empty images tag - VodData vodData = getVodData(MOVIE, INSERT).thumbRatios(List.of()); + VodData vodData = getVodData(MOVIE, INSERT); + long epoch = getEpoch(); + vodData.files().get(0).coguid(String.valueOf(epoch)); + vodData.files().get(1).coguid(String.valueOf(epoch)); String ingestXml = buildIngestVodXml(vodData, INSERT); Response resp = executeIngestVodRequest(ingestXml); @@ -487,46 +465,48 @@ public void insertVodMediaBaseEmptyImagesAndFields() { ingestXml = buildIngestVodXml(vodData1, INSERT); resp = executeIngestVodRequest(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageInvalidUrlForImage"); + } -// // empty file coguid -// getDefaultAssetFiles(DBUtils.getPpvNames(2)) -// VodData vodData = getVodData(MOVIE, INSERT).files(); -// contains("InvalidUrlForImageMediaFileExternalIdMustBeUniqueMediaFileExternalIdMustBeUnique"); + @Issue("BEO-5584") + @Severity(SeverityLevel.CRITICAL) + @Test(description = "ingest VOD with different Ppv", enabled = false) + public void updateVodMediaPpv() { + List ppvNames = DBUtils.getPpvNames(4); + + // insert vod + List files = getDefaultAssetFiles(ppvNames.get(0), ppvNames.get(1)); + VodData vodData = getVodData(MOVIE, INSERT).files(files); + MediaAsset movie = insertVod(vodData, true); + + // update ppvs + files.get(0).ppvModule(ppvNames.get(2)); + files.get(1).ppvModule(ppvNames.get(3)); + vodData = new VodData().files(files); + movie = updateVod(movie.getExternalId(), vodData); + + List mediaFiles = movie.getMediaFiles(); + assertThat(mediaFiles.size()).isEqualTo(2); + + // assert ppvs update + ProductPriceFilter filter = new ProductPriceFilter(); + List fileIds = Arrays.asList(String.valueOf(mediaFiles.get(0).getId()), String.valueOf(mediaFiles.get(1).getId())); + filter.setFileIdIn(getConcatenatedString(fileIds)); + + com.kaltura.client.utils.response.base.Response> productPriceListResponse = executor.executeSync(ProductPriceService.list(filter).setKs(getAnonymousKs())); + PpvPrice ppvPrice1 = (PpvPrice) productPriceListResponse.results.getObjects().get(0); + + String ppvName1 = executor.executeSync(PpvService.get(Long.parseLong(ppvPrice1 + .getPpvModuleId())) + .setKs(getAnonymousKs())) + .results + .getName(); + + System.out.println(ppvName1); + + // TODO: 9/17/2018 complete the test after the bug will be fixed } -// @Severity(SeverityLevel.CRITICAL) -// @Test(description = "ingest VOD with different Ppv") -// public void updateVodMediaPpv() { -//// generateDefaultValues4Insert(MOVIE); -//// List movieAssetFiles = get2AssetFiles(fileTypeNames.get(0), fileTypeNames.get(1), ppvNames.get(0), ppvNames.get(1)); -// VodData vodData = getVodData(MOVIE, INSERT); -// MediaAsset movie = insertVod(vodData, true); -// String ingestRequest = ingestXmlRequest; -// -// assertThat(movie.getName()).isEqualTo(name); -// assertThat(movie.getDescription()).isEqualTo(description); -//// assertFiles(movieAssetFiles, movie.getId().toString()); -// -// Household household = HouseholdUtils.createHousehold(); -// String classMasterUserKs = HouseholdUtils.getHouseholdUserKs(household, HouseholdUtils.getDevicesList(household).get(0).getUdid()); -// AssetService.GetAssetBuilder assetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA).setKs(classMasterUserKs); -// com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); -// List getMediaFiles = assetGetResponse.results.getMediaFiles(); -// int fileId1 = getMediaFiles.get(0).getId(); -// int fileId2 = getMediaFiles.get(1).getId(); -// -// ProductPriceFilter ppFilter = new ProductPriceFilter(); -// ppFilter.setFileIdIn(String.valueOf(fileId1)); -// ppFilter.setIsLowest(false); -// ProductPriceService.ListProductPriceBuilder productPriceListBeforePurchase = ProductPriceService.list(ppFilter); -// com.kaltura.client.utils.response.base.Response> productPriceResponse = -// executor.executeSync(productPriceListBeforePurchase.setKs(classMasterUserKs)); -// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(fileId1); -// assertThat(((PpvPrice)productPriceResponse.results.getObjects().get(0)).getPpvDescriptions().get(0).getValue()).isEqualTo(fileId1); -// // TODO: complete -// } -// @Severity(SeverityLevel.CRITICAL) @Test(description = "update VOD images") public void updateImages() { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 1f199cee7..3e81c38a9 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -47,8 +47,6 @@ public class IngestVodUtils extends BaseIngestUtils { private static final List ppvNames = DBUtils.getPpvNames(2); - public static String ingestXmlRequest = ""; - @Accessors(fluent = true) @Data public static class VodData { @@ -134,7 +132,7 @@ public VodFile(String type, String ppvModule) { product_code = "productExampleCode"; assetDuration = "1000"; - coguid = "file_" + getEpoch(); + coguid = "file_" + getEpoch() + "_" + getRandomLong(); this.type = type; this.ppvModule = ppvModule; } @@ -439,8 +437,7 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { // uncomment cdata String docAsString = docToString(doc); - ingestXmlRequest = uncommentCdataSection(docAsString); - return ingestXmlRequest = uncommentCdataSection(docAsString); + return uncommentCdataSection(docAsString); } private static Element addFile(Document doc, VodFile vodFile) { @@ -547,7 +544,7 @@ private static Map getDefaultDates() { return dates; } - private static List getDefaultAssetFiles(String ppvModuleName1, String ppvModuleName2) { + public static List getDefaultAssetFiles(String ppvModuleName1, String ppvModuleName2) { List assetFiles = new ArrayList<>(); List fileTypeNames = DBUtils.getMediaFileTypeNames(2); From 438842aecb791a44e45bd7226b812434e1357ff9 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Mon, 17 Sep 2018 16:25:21 +0300 Subject: [PATCH 552/605] Updated class - "AssetCountTests" - added comment --- .../test/tests/servicesTests/AssetTests/AssetCountTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index 2c10b5137..aaa8ab06a 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -36,6 +36,8 @@ public class AssetCountTests extends BaseTest { private ProgramAsset program, program2; private MediaAsset asset, asset2; + //TODO - Change all hardcoded values after Alon will add DB meta anf tags utils. + private final String metaName1 = "synopsis"; private final String metaValue1 = metaName1 + getRandomValue("_"); From b56ad04b959d436da66d8c83c9b59ca823706007 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Mon, 17 Sep 2018 16:38:40 +0300 Subject: [PATCH 553/605] regression fixes --- .../servicesTests/entitlementTests/EntitlementGrantTests.java | 3 ++- .../servicesTests/ottUserTests/OttUserRegisterTests.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java index af8e24f9e..82d37f16f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/entitlementTests/EntitlementGrantTests.java @@ -79,7 +79,8 @@ private void grant_subscription_with_history() { ProductPrice productPrice = productPriceListResponse.results.getObjects().get(0); assertThat(productPriceListResponse.results.getTotalCount()).isEqualTo(1); - assertThat(productPrice.getPrice().getAmount()).isEqualTo(0); + // due to double purchase price is not 0 + assertThat(productPrice.getPrice().getAmount()).isNotEqualTo(0); assertThat(productPrice.getPurchaseStatus().getValue()).isEqualTo(PurchaseStatus.SUBSCRIPTION_PURCHASED.getValue()); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java index 2c002bcf2..6a5632bec 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserRegisterTests.java @@ -51,7 +51,7 @@ private void register_exists_user() { // register - first time ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); - user = ottUserResponse.results; + String userId = ottUserResponse.results.getId(); // register - second time ottUserResponse = executor.executeSync(OttUserService.register(partnerId, user, defaultUserPassword)); @@ -60,7 +60,7 @@ private void register_exists_user() { assertThat(ottUserResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(2014).getCode()); // cleanup - executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(user.getId()))); + executor.executeSync(delete().setKs(getAdministratorKs()).setUserId(Integer.valueOf(userId))); } // From 1e6a2c2408c10938cc4e64c0a272772342fd6183 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 20 Sep 2018 00:44:55 +0300 Subject: [PATCH 554/605] small update --- .../five_zero_three/ParentChildMetadataInheritanceTests.java | 2 +- .../versions/four_eight/PermissionsManagementTests.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 2830b14da..f04b4c8c9 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -40,7 +40,7 @@ public void setUp() { } // added to play with methods that are going to be checked - @Test + @Test(groups = {"opc"}) public void sandbox() { String prefix = "MaxTest_assetStruct_"; diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 0978ff24e..090d5b3d4 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -449,7 +449,7 @@ public void importJson() throws IOException { // clean folder with logs FileUtils.cleanDirectory(new File(path2JsonFolder)); - // export command to get results and not break + // export command to get results and not break the system List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); executeCommandsInColsole(commands); @@ -486,6 +486,7 @@ private void fillFilesWithImportData(String roleName, String permissionItemName, private void fillServiceFile(String roleName, String permissionItemName, String serviceName, String actionName) { // TODO: + } private void fillPermissionsFile(String roleName, String usersGroup) { From cd9bb443c0b0f6a034945f1d55d530362378b15a Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 10:09:20 +0300 Subject: [PATCH 555/605] Updated class - "AssetCountTests" --- .../servicesTests/AssetTests/AssetCountTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index aaa8ab06a..d1b1d06fa 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -127,7 +127,7 @@ private void groupByVodMeta() { AssetService.CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) .setKs(BaseTest.getAnonymousKs()); - // asset/action/count + // asset/action/count - 2 VOD assets in count Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); } @@ -156,7 +156,7 @@ private void groupByVodTag() { AssetService.CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) .setKs(BaseTest.getAnonymousKs()); - // asset/action/count + // asset/action/count - 2 VOD assets in count Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); } @@ -185,7 +185,7 @@ private void groupByVodMetaWithDifferentValues() { AssetService.CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) .setKs(BaseTest.getAnonymousKs()); - // asset/action/count + // asset/action/count - 2 VOD assets in count Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); assertThat(assetCountResponse.results.getSubs().get(0).getObjects().get(0).getCount()).isEqualTo(1); @@ -218,7 +218,7 @@ private void groupByEPGMeta() { CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) .setKs(BaseTest.getAnonymousKs()); - // asset/action/count + // asset/action/count - 2 EPG in count Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); } @@ -247,7 +247,7 @@ private void groupByEPGTag() { CountAssetBuilder countAssetBuilder = AssetService.count(searchAssetFilter) .setKs(BaseTest.getAnonymousKs()); - // asset/action/count + // asset/action/count - 2 EPG in count Response assetCountResponse = executor.executeSync(countAssetBuilder); assertThat(assetCountResponse.results.getCount()).isEqualTo(2); } From 2609187f79e337a2ba7779cca3708e3daa5adb34 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 10:18:35 +0300 Subject: [PATCH 556/605] Added new class - "CountryListTests" --- .../tests/servicesTests/countryList/CountryListTests.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java new file mode 100644 index 000000000..0d56911e1 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java @@ -0,0 +1,4 @@ +package com.kaltura.client.test.tests.servicesTests.countryList; + +public class CountryListTests { +} From 5ea52e3dade2161240dc5efd1adba337d8ca1820 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 10:20:11 +0300 Subject: [PATCH 557/605] Updated work plan file --- src/test/resources/WORK_PLAN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index 855a16172..d58a8ed49 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -11,7 +11,7 @@ Migrate features tests from ReadyAPI |------------------------------|--------| | announcement | Alon - in progress | | appToken | Done | -| asset | Shmulik - in progress | +| asset | Shmulik/Alon - in progress | | assetComment | Done | | assetFile | | | assetHistory | Done | @@ -29,7 +29,7 @@ Migrate features tests from ReadyAPI | configurationGroupDevice | | | configurationGroupTag | | | configurations | | -| country | | +| country | Shmulik - in progress | | coupon | | | couponsGroup | | | currency | | From 23b419ef5c7818969acf0c53be35ffe3568afd9a Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 20 Sep 2018 10:40:17 +0300 Subject: [PATCH 558/605] coompleted test importJson() --- .../PermissionsManagementTests.java | 61 ++----- .../test/utils/PermissionManagementUtils.java | 153 ++++++++++++++++++ 2 files changed, 166 insertions(+), 48 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index 090d5b3d4..df0bd4abd 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -9,13 +9,11 @@ import org.apache.commons.io.FileUtils; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.util.List; import static com.kaltura.client.test.utils.BaseUtils.deleteFile; import static com.kaltura.client.test.utils.BaseUtils.getFileContent; -import static com.kaltura.client.test.utils.PermissionManagementUtils.executeCommandsInColsole; -import static com.kaltura.client.test.utils.PermissionManagementUtils.getConsoleCommand; +import static com.kaltura.client.test.utils.PermissionManagementUtils.*; import static com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils.*; import static org.assertj.core.api.Assertions.assertThat; @@ -26,20 +24,6 @@ @Test(groups = {"Permission management"}) public class PermissionsManagementTests { - String mainFile = "PermissionsDeployment.exe"; - // that file generated automatically - String path2Log = "C:\\log\\permissions\\permissions.log"; - String path2Util = "C:\\123\\PermissionsExport\\bin\\Debug\\"; - - // these files are generated - String dataFilePath = path2Util + "333\\" + "exp1.txt"; - String path2JsonFolder = path2Util + "333\\JSON\\"; - String generatedDataFilePath = path2Util + "333\\" + "import.txt"; - String path2JsonRoles = path2JsonFolder + "roles.json"; - String path2JsonPermissions = path2JsonFolder + "permissions.json"; - String path2JsonMethods = path2JsonFolder + "permission_items\\controllers\\"; - String fullPath2Util = path2Util + mainFile; - // these files added into project String importOnly4TablesFilePath; String path2EmptyFile; @@ -458,45 +442,26 @@ public void importJson() throws IOException { String roleName = "MaxTest" + suffix; String permissionItemName = "Asset_List_Max" + suffix; String serviceName = "asset"; - fillFilesWithImportData(roleName, permissionItemName, "partner*", serviceName, "list"); + PermissionManagementUtils.fillFilesWithImportData(roleName, permissionItemName, "partner*", serviceName, "list"); - PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", - permissionItemName, serviceName, "list", "permissionItemObject" + suffix, - "parameter" + suffix, true); + // import command + commands = getConsoleCommand(fullPath2Util, IMPORT_JSON_KEY + path2JsonFolder); + executeCommandsInColsole(commands); - String importFileContent = getFileContent(generatedDataFilePath); - assertThat(importFileContent).contains(roleName); - assertThat(importFileContent).contains(permissionItemName); - checkActionResult(serviceName, importFileContent); + // find new records in DB after the import + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); + assertThat(idRoleHavingName).isGreaterThan(0); + assertThat(idPermissionItemHavingName).isGreaterThan(0); + assertThat(idPermissionHavingName).isGreaterThan(0); // cleaning - int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); - int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); - int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); } - private void fillFilesWithImportData(String roleName, String permissionItemName, String usersGroup, String serviceName, String actionName) { - fillRolesFile(roleName); - fillPermissionsFile(roleName, usersGroup); - fillServiceFile(roleName, permissionItemName, serviceName, actionName); - } - - private void fillServiceFile(String roleName, String permissionItemName, String serviceName, String actionName) { - // TODO: - - } - - private void fillPermissionsFile(String roleName, String usersGroup) { - // TODO: - } - - private void fillRolesFile(String roleName) { - // TODO: - } - // method checks that all related files contain information related to service /** * diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index 2b122b264..297d7c06b 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -1,6 +1,8 @@ package com.kaltura.client.test.utils; +import com.google.gson.*; import com.kaltura.client.Logger; +import com.kaltura.client.test.tests.featuresTests.versions.four_eight.PermissionsManagementTests; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -10,6 +12,39 @@ public class PermissionManagementUtils extends BaseUtils { + // that file generated automatically + public static String path2Log = "C:\\log\\permissions\\permissions.log"; + public static String path2Util = "C:\\123\\PermissionsExport\\bin\\Debug\\"; + public static String mainFile = "PermissionsDeployment.exe"; + public static String fullPath2Util = path2Util + mainFile; + + // these files are generated + public static String dataFilePath = path2Util + "333\\" + "exp1.txt"; + public static String path2JsonFolder = path2Util + "333\\JSON\\"; + public static String generatedDataFilePath = path2Util + "333\\" + "import.txt"; + public static String path2JsonRoles = path2JsonFolder + "roles.json"; + public static String path2JsonPermissions = path2JsonFolder + "permissions.json"; + public static String path2JsonMethods = path2JsonFolder + "permission_items\\controllers\\"; + + // json related strings + public static final String SERVICE_PERMISSION_ITEMS_NODE = "permission_items"; + public static final String SERVICE_TYPE_DEFAULT_VALUE = "Action"; + public static final String SERVICE_PERMISSIONS_NODE = "permissions"; + public static final String SERVICE_EXCLUDED_PERMISSIONS_NODE = "excluded_permissions"; + public static final String SERVICE_NAME_NODE = "name"; + public static final String SERVICE_SERVICE_NODE = "service"; + public static final String SERVICE_ACTION_NODE = "action"; + public static final String SERVICE_TYPE_NODE = "type"; + + public static final String PERMISSIONS_PERMISSIONS_NODE = "permissions"; + public static final String PERMISSIONS_NAME_NODE = "name"; + public static final String PERMISSIONS_USERS_GROUP_NODE = "users_group"; + + public static final String ROLES_ROLES_NODE = "roles"; + public static final String ROLES_PERMISSIONS_NODE = "permissions"; + public static final String ROLES_EXCLUDED_PERMISSIONS_NODE = "excluded_permissions"; + public static final String ROLES_NAME_NODE = "name"; + @Accessors(fluent = true) @Data public static class PermissionItem { @@ -36,6 +71,124 @@ public static class Role { private String name; } + private static void fillRolesFile(String roleName) { + try { + // get from file array of permissions + JsonParser parser = new JsonParser(); + JsonElement jsonElement = parser.parse(new FileReader(path2JsonRoles)); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + JsonArray array = jsonObj.getAsJsonArray(ROLES_ROLES_NODE); + + // add into array of roles new role + List excludedPermissions = new ArrayList(); + List permissions = new ArrayList(); + permissions.add(roleName); + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + jsonObj = new JsonObject(); + jsonObj.add(ROLES_PERMISSIONS_NODE, gson.toJsonTree(permissions).getAsJsonArray()); + jsonObj.add(ROLES_EXCLUDED_PERMISSIONS_NODE, gson.toJsonTree(excludedPermissions).getAsJsonArray()); + jsonObj.addProperty(ROLES_NAME_NODE, roleName); + array.add(jsonObj); + + // overwrite role file + jsonObj = new JsonObject(); + jsonObj.add(ROLES_ROLES_NODE, array); + try (Writer writer = new FileWriter(path2JsonRoles, false)) { + gson.toJson(jsonObj, writer); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + private static void fillServiceFile(String roleName, String permissionItemName, String serviceName, String actionName) { + try { + // get from file array of permissions related to service + JsonParser parser = new JsonParser(); + String path2serviceFile = path2JsonMethods + serviceName + ".json"; + JsonElement jsonElement = parser.parse(new FileReader(path2serviceFile)); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + JsonArray array = jsonObj.getAsJsonArray(SERVICE_PERMISSION_ITEMS_NODE); + + // create PermissionItem object with new data + List permissions = new ArrayList(); + permissions.add(roleName); + PermissionItem permissionItem = new PermissionItem() + .permissions(permissions) + .excludedPermissions(new ArrayList<>()) + .name(permissionItemName) + .service(serviceName) + .action(actionName) + .type(SERVICE_TYPE_DEFAULT_VALUE); + + // add into array of permissions the PermissionItem object + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + jsonObj = getPermissionItemAsJsonObject(permissionItem, gson); + array.add(jsonObj); + + // overwrite service file + jsonObj = new JsonObject(); + jsonObj.add(SERVICE_PERMISSION_ITEMS_NODE, array); + jsonObj.addProperty(SERVICE_TYPE_NODE, SERVICE_TYPE_DEFAULT_VALUE); + + try (Writer writer = new FileWriter(path2serviceFile, false)) { + gson.toJson(jsonObj, writer); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + private static JsonObject getPermissionItemAsJsonObject(PermissionItem permissionItem, Gson gson) { + JsonObject result = new JsonObject(); + + result.add(SERVICE_PERMISSIONS_NODE, gson.toJsonTree(permissionItem.permissions()).getAsJsonArray()); + result.add(SERVICE_EXCLUDED_PERMISSIONS_NODE, gson.toJsonTree(permissionItem.excludedPermissions()).getAsJsonArray()); + result.addProperty(SERVICE_NAME_NODE, permissionItem.name()); + result.addProperty(SERVICE_SERVICE_NODE, permissionItem.service()); + result.addProperty(SERVICE_ACTION_NODE, permissionItem.action()); + result.addProperty(SERVICE_TYPE_NODE, SERVICE_TYPE_DEFAULT_VALUE); + + return result; + } + + private static void fillPermissionsFile(String roleName, String usersGroup) { + try { + // get from file array of permissions + JsonParser parser = new JsonParser(); + JsonElement jsonElement = parser.parse(new FileReader(path2JsonPermissions)); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + JsonArray array = jsonObj.getAsJsonArray(PERMISSIONS_PERMISSIONS_NODE); + + // add into array of permissions new permission data + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + jsonObj = new JsonObject(); + jsonObj.addProperty(PERMISSIONS_NAME_NODE, roleName); + jsonObj.addProperty(PERMISSIONS_USERS_GROUP_NODE, usersGroup); + array.add(jsonObj); + + // overwrite permissions file + jsonObj = new JsonObject(); + jsonObj.add(PERMISSIONS_PERMISSIONS_NODE, array); + try (Writer writer = new FileWriter(path2JsonPermissions, false)) { + gson.toJson(jsonObj, writer); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + public static void fillFilesWithImportData(String roleName, String permissionItemName, String usersGroup, String serviceName, String actionName) { + fillRolesFile(roleName); + fillPermissionsFile(roleName, usersGroup); + fillServiceFile(roleName, permissionItemName, serviceName, actionName); + } public static void printPermissionPermissionItem(PrintWriter writer, long id, long permissionId, long permissionItemId, int isExcluded, String permissionItemName, String permissionName) { From 3abcb40b911c8a14b3fb686007f1b8ccfd47047c Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 10:51:52 +0300 Subject: [PATCH 559/605] Updated tc - "CountryListTests" --- .../countryList/CountryListTests.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java index 0d56911e1..7ea5c08b2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java @@ -1,4 +1,33 @@ package com.kaltura.client.test.tests.servicesTests.countryList; -public class CountryListTests { +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.Country; +import com.kaltura.client.types.CountryFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; +import io.qameta.allure.Description; +import io.qameta.allure.Severity; +import io.qameta.allure.SeverityLevel; +import org.testng.annotations.Test; + +import static com.kaltura.client.services.CountryService.*; + +public class CountryListTests extends BaseTest { + + private void list_tests_before_class() { + + } + + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - empty filter - get all countries") + @Test + private void listCountry() { + CountryFilter countryFilter = new CountryFilter(); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + + } + + } From 15aa7ac588c7dab8c73d34fa5fe8380aa3f35d2a Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Thu, 20 Sep 2018 14:33:22 +0300 Subject: [PATCH 560/605] Ingest issue was commented to fix regression compilation --- .../five_zero_two/IngestVodOpcTests.java | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index c20c78080..0e78906dc 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.services.PpvService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; @@ -19,7 +18,6 @@ import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -353,37 +351,37 @@ public void insertWithInvalidCredentials() { assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); } - @Severity(SeverityLevel.NORMAL) - @Test(description = "try insert with invalid meta or tag field") - public void insertWithInvalidMetaOrTagField() { - String suffix = "_" + getEpoch(); - VodData vodData = getVodData(MOVIE, INSERT); - - String updatedField = mediaNumberFieldName + suffix; - vodData.numbers(Map.of(updatedField, getRandomDouble())); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.numbers(Map.of()); - - updatedField = mediaBooleanFieldName + suffix; - vodData.booleans(Map.of(updatedField, getRandomBoolean())); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.booleans(Map.of()); - - updatedField = mediaTagFieldName + suffix; - vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); - assertInvalidMovieField(vodData, updatedField, "tag"); - vodData.tags(Map.of()); - - updatedField = mediaTextFieldName + suffix; - vodData.strings(Map.of(updatedField, getRandomString())); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.strings(Map.of()); - - updatedField = mediaDateFieldName + suffix; - vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.dates(Map.of()); - } +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "try insert with invalid meta or tag field") +// public void insertWithInvalidMetaOrTagField() { +// String suffix = "_" + getEpoch(); +// VodData vodData = getVodData(MOVIE, INSERT); +// +// String updatedField = mediaNumberFieldName + suffix; +// vodData.numbers(Map.of(updatedField, getRandomDouble())); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.numbers(Map.of()); +// +// updatedField = mediaBooleanFieldName + suffix; +// vodData.booleans(Map.of(updatedField, getRandomBoolean())); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.booleans(Map.of()); +// +// updatedField = mediaTagFieldName + suffix; +// vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); +// assertInvalidMovieField(vodData, updatedField, "tag"); +// vodData.tags(Map.of()); +// +// updatedField = mediaTextFieldName + suffix; +// vodData.strings(Map.of(updatedField, getRandomString())); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.strings(Map.of()); +// +// updatedField = mediaDateFieldName + suffix; +// vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.dates(Map.of()); +// } @Severity(SeverityLevel.NORMAL) @Test(description = "insert multilingual fields", enabled = false) From f18bbe51bb643071e344294a1baa132591c33fe4 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 15:09:18 +0300 Subject: [PATCH 561/605] Updated class - "CountryListTests" --- .../countryList/CountryListTests.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java index 7ea5c08b2..31dc9696d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java @@ -1,6 +1,8 @@ package com.kaltura.client.test.tests.servicesTests.countryList; +import com.kaltura.client.enums.CountryOrderBy; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.types.Collection; import com.kaltura.client.types.Country; import com.kaltura.client.types.CountryFilter; import com.kaltura.client.types.ListResponse; @@ -10,7 +12,11 @@ import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; +import java.util.*; +import java.util.stream.Collectors; + import static com.kaltura.client.services.CountryService.*; +import static org.assertj.core.api.Assertions.assertThat; public class CountryListTests extends BaseTest { @@ -25,9 +31,31 @@ private void listCountry() { CountryFilter countryFilter = new CountryFilter(); ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) .setKs(getOperatorKs()); - Response> countryResponse = executor.executeSync(listCountryBuilder); + // country/action/list + Response> countryResponse = executor.executeSync(listCountryBuilder); + assertThat(countryResponse.error).isNull(); + assertThat(countryResponse.results.getTotalCount()).isGreaterThan(200); } + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - verify results order (by name)") + @Test + private void listCountryOrder() { + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setOrderBy(CountryOrderBy.NAME_ASC.toString()); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + + // country/action/list + Response> countryResponse = executor.executeSync(listCountryBuilder); + List newList = new ArrayList<>(); + for (Country country: countryResponse.results.getObjects()) { + newList.add(country.getName()); + } + ArrayList temp = new ArrayList<>(newList); + Collections.sort(temp); + assertThat(temp).isEqualTo(newList); + } } From 27ea5a62c476491521ed47ffd1d24d116c4bb912 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 15:10:00 +0300 Subject: [PATCH 562/605] Updated class - "CountryListTests" --- .../test/tests/servicesTests/countryList/CountryListTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java index 31dc9696d..9184ce153 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java @@ -2,7 +2,6 @@ import com.kaltura.client.enums.CountryOrderBy; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.types.Collection; import com.kaltura.client.types.Country; import com.kaltura.client.types.CountryFilter; import com.kaltura.client.types.ListResponse; @@ -13,7 +12,6 @@ import org.testng.annotations.Test; import java.util.*; -import java.util.stream.Collectors; import static com.kaltura.client.services.CountryService.*; import static org.assertj.core.api.Assertions.assertThat; From d4f3e0744b5fa2cf6f549ca9a8ced9b49450411e Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 15:37:03 +0300 Subject: [PATCH 563/605] Updated json file - ListResponse --- src/test/resources/schemas/ListResponse.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 1a29854b4..0ec4eba54 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -94,7 +94,8 @@ "KalturaDynamicChannelListResponse", "KalturaDiscountDetailsListResponse", "KalturaAssetStructMetaListResponse", - "KalturaAssetStructListResponse" + "KalturaAssetStructListResponse", + "KalturaCountryListResponse" ] } }, From d6a92a0fb5e5a02a5095136e734c997542828ce5 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 15:47:31 +0300 Subject: [PATCH 564/605] Updated package name to - "countryTests" --- .../CountryListTests.java | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) rename src/test/java/com/kaltura/client/test/tests/servicesTests/{countryList => countryTests}/CountryListTests.java (57%) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java similarity index 57% rename from src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java rename to src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java index 9184ce153..c8fab5298 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryList/CountryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java @@ -1,4 +1,4 @@ -package com.kaltura.client.test.tests.servicesTests.countryList; +package com.kaltura.client.test.tests.servicesTests.countryTests; import com.kaltura.client.enums.CountryOrderBy; import com.kaltura.client.test.tests.BaseTest; @@ -46,7 +46,7 @@ private void listCountryOrder() { ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) .setKs(getOperatorKs()); - // country/action/list + // country/action/list - order by name ASC Response> countryResponse = executor.executeSync(listCountryBuilder); List newList = new ArrayList<>(); for (Country country: countryResponse.results.getObjects()) { @@ -56,4 +56,39 @@ private void listCountryOrder() { Collections.sort(temp); assertThat(temp).isEqualTo(newList); } + + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - filter by country id's") + @Test + private void listCountryByIds() { + + String countryId = "1"; + String countryId2 = "2"; + + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIdIn(countryId + "," + countryId2); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + + // Total count = 2 + assertThat(countryResponse.results.getTotalCount()).isEqualTo(2); + // object[0] country id = 1 + assertThat(countryResponse.results.getObjects().get(0).getId()).isEqualTo(countryId); + // object[0] country id = 2 + assertThat(countryResponse.results.getObjects().get(1).getId()).isEqualTo(countryId2); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - filter by current country ip") + @Test + private void listCountryByCurrentIp() { + + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIpEqualCurrent(true); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + + } } From 50b8a2b7d4852331dc1cba736546882358516331 Mon Sep 17 00:00:00 2001 From: "KALTURA\\shmulik.kummer" Date: Thu, 20 Sep 2018 16:54:46 +0300 Subject: [PATCH 565/605] Add additional tests to class - "CountryListTests" --- .../countryTests/CountryListTests.java | 112 ++++++++++++++++-- 1 file changed, 103 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java index c8fab5298..ec3c4dd50 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java @@ -10,17 +10,16 @@ import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; import org.testng.annotations.Test; - import java.util.*; import static com.kaltura.client.services.CountryService.*; +import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; import static org.assertj.core.api.Assertions.assertThat; public class CountryListTests extends BaseTest { - private void list_tests_before_class() { - - } + private String countryId = "1"; + private String countryId2 = "2"; @Severity(SeverityLevel.CRITICAL) @Description("country/action/list - empty filter - get all countries") @@ -62,9 +61,6 @@ private void listCountryOrder() { @Test private void listCountryByIds() { - String countryId = "1"; - String countryId2 = "2"; - CountryFilter countryFilter = new CountryFilter(); countryFilter.setIdIn(countryId + "," + countryId2); ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) @@ -79,16 +75,114 @@ private void listCountryByIds() { assertThat(countryResponse.results.getObjects().get(1).getId()).isEqualTo(countryId2); } + //TODO - Ask alon how to get country code dynamically (in order to assert). + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - filter by current country") + @Test + private void listCountryByCurrentLocation() { + + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIpEqualCurrent(true); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + assertThat(countryResponse.results.getTotalCount()).isEqualTo(1); + } + + // TODO - Remove hardcoded values + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - filter by specific ip") + @Test + private void listCountryBySepcificIp() { + String usaIp = "74.240.65.157"; + String usaCountryCode = "US"; + String currency = "USD"; + String currencySign = "$"; + String langCode = "eng"; + + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIpEqual(usaIp); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + + assertThat(countryResponse.results.getTotalCount()).isEqualTo(1); + assertThat(countryResponse.results.getObjects().get(0).getCode()).isEqualTo(usaCountryCode); + assertThat(countryResponse.results.getObjects().get(0).getCurrency()).isEqualTo(currency); + assertThat(countryResponse.results.getObjects().get(0).getMainLanguageCode()).isEqualTo(langCode); + assertThat(countryResponse.results.getObjects().get(0).getCurrencySign()).isEqualTo(currencySign); + } + + // Error validations + + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - 4025 - CountryNotFound") + @Test + private void invalidCountryIp() { + + String invalidIp = "8.8"; + + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIpEqual(invalidIp); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + + // Assert error code + assertThat(countryResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(4025).getCode()); + } + @Severity(SeverityLevel.CRITICAL) - @Description("country/action/list - filter by current country ip") + @Description("country/action/list - Invalid country id") @Test - private void listCountryByCurrentIp() { + private void invalidCountryId() { + + String invalidCountryId = "88888"; CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIdIn(invalidCountryId); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + + // Assert error code + assertThat(countryResponse.results.getTotalCount()).isEqualTo(0); + } + + + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - 500038 - Only one of IpEqual or IpEqualCurrent can be used, not both of them") + @Test + private void ipEqualandUpEqualCurrent() { + + String iranIp = "5.232.189.218"; + + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIpEqual(iranIp); countryFilter.setIpEqualCurrent(true); + + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) + .setKs(getOperatorKs()); + Response> countryResponse = executor.executeSync(listCountryBuilder); + + // Assert error code + assertThat(countryResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500038).getCode()); + } + + @Severity(SeverityLevel.CRITICAL) + @Description("country/action/list - 500038 - Only one of IdIn or IpEqualCurrent can be used, not both of them") + @Test + private void idInandUpEqualCurrent() { + + CountryFilter countryFilter = new CountryFilter(); + countryFilter.setIdIn(countryId + "" + countryId2); + countryFilter.setIpEqualCurrent(true); + ListCountryBuilder listCountryBuilder = new ListCountryBuilder(countryFilter) .setKs(getOperatorKs()); Response> countryResponse = executor.executeSync(listCountryBuilder); + // Assert error code + assertThat(countryResponse.error.getCode()).isEqualTo(getAPIExceptionFromList(500038).getCode()); } } From 98486b91af3fbdf1a31589d1a055f4db7fafd57b Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Sun, 23 Sep 2018 09:23:58 +0300 Subject: [PATCH 566/605] fixing regression --- .../assetCommentTests/AssetCommentAddTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java index 799373c19..6c09f5394 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetCommentTests/AssetCommentAddTests.java @@ -9,6 +9,7 @@ import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Description; +import org.assertj.core.data.Offset; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -62,7 +63,7 @@ private void addCommentForVod() { assertThat(assetCommentResponse.results.getText()).isEqualTo(text); assertThat(assetCommentResponse.results.getSubHeader()).isEqualTo(subHeader); assertThat(assetCommentResponse.results.getHeader()).isEqualTo(header); - assertThat(assetCommentResponse.results.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpoch()); + assertThat(assetCommentResponse.results.getCreateDate()).isCloseTo(BaseUtils.getEpoch(), Offset.offset ((long)10)); //Initialize assetCommentFilter object @@ -83,7 +84,7 @@ private void addCommentForVod() { assertThat(assetCommentObjectResponse.getHeader()).isEqualTo(assetCommentResponse.results.getHeader()); assertThat(assetCommentObjectResponse.getText()).isEqualTo(assetCommentResponse.results.getText()); assertThat(assetCommentObjectResponse.getWriter()).isEqualTo(assetCommentResponse.results.getWriter()); - assertThat(assetCommentObjectResponse.getCreateDate()).isLessThanOrEqualTo(BaseUtils.getEpoch()); + assertThat(assetCommentObjectResponse.getCreateDate()).isCloseTo(BaseUtils.getEpoch(), Offset.offset ((long)10)); } From a719a5fa92f3c3f48541a623080d75213f1fa588 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 23 Sep 2018 10:47:48 +0300 Subject: [PATCH 567/605] completed sandboxRemoveMetasAndTags() --- .../ParentChildMetadataInheritanceTests.java | 80 +++++++++++-------- .../test/utils/dbUtils/DBConstants.java | 4 + .../client/test/utils/dbUtils/DBUtils.java | 26 +++--- 3 files changed, 64 insertions(+), 46 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index f04b4c8c9..16ffbe047 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -1,9 +1,12 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; -import com.kaltura.client.services.AssetStructMetaService; +import com.kaltura.client.enums.AssetReferenceType; +import com.kaltura.client.enums.MetaOrderBy; +import com.kaltura.client.services.*; +import com.kaltura.client.services.AssetService.RemoveMetasAndTagsAssetBuilder; +import com.kaltura.client.services.AssetService.GetAssetBuilder; import com.kaltura.client.services.AssetStructMetaService.ListAssetStructMetaBuilder; import com.kaltura.client.services.AssetStructMetaService.UpdateAssetStructMetaBuilder; -import com.kaltura.client.services.AssetStructService; import com.kaltura.client.services.AssetStructService.AddAssetStructBuilder; import com.kaltura.client.services.AssetStructService.DeleteAssetStructBuilder; import com.kaltura.client.services.AssetStructService.ListAssetStructBuilder; @@ -16,12 +19,13 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - import java.util.ArrayList; +import java.util.HashSet; import java.util.List; - +import java.util.Set; import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMetaIdByName; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; @@ -40,7 +44,7 @@ public void setUp() { } // added to play with methods that are going to be checked - @Test(groups = {"opc"}) + @Test public void sandbox() { String prefix = "MaxTest_assetStruct_"; @@ -109,24 +113,40 @@ public void sandboxRemoveMetasAndTags() { IngestVodUtils.VodData vodData = getVodData(MOVIE, INSERT); MediaAsset movie = insertVod(vodData, true); -// assertThat(movie.getName()).isEqualTo(movie.getExternalId()); -// assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); -// assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaValue); -// assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(numberMetaValue); -// assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateMetaValue); -// assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanMetaValue); -// -// Map tags = movie.getTags(); -// Map.Entry entry = tags.entrySet().iterator().next(); -// List tagsValues = entry.getValue().getObjects(); -// for (MultilingualStringValue tagValue: tagsValues) { -// assertThat(tagMetaValue).contains(tagValue.getValue()); -// } -// assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size()); - - // TODO: update idIn with real values from DB to check metas and tags are really deleted - /*RemoveMetasAndTagsAssetBuilder removeMetasAndTagsAssetBuilder = - AssetService.removeMetasAndTags(movie.getId(), AssetReferenceType.MEDIA, ""); + assertThat(movie.getName()).isEqualTo(movie.getExternalId()); + assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); + // get all metas + Set movieMetasNames = movie.getMetas().keySet(); + int metasSizeAfterCreation = movieMetasNames.size(); + int nonBasicMediaMetasCount = 0; + assertThat(metasSizeAfterCreation).isGreaterThan(0); + + // get all tags + Set movieTagsNames = movie.getTags().keySet(); + int tagsSizeAfterCreation = movieTagsNames.size(); + assertThat(tagsSizeAfterCreation).isGreaterThan(0); + + // get all metas and tags info to remove them from media + List metaIds = new ArrayList<>(); + int metaId; + for (String metaName: movieMetasNames) { + metaId = getMetaIdByName(metaName, false); + if (metaId !=-1) { + metaIds.add(String.valueOf(metaId)); + nonBasicMediaMetasCount++; + } + } + for (String metaName: movieTagsNames) { + metaId = getMetaIdByName(metaName, true); + if (metaId !=-1) { + metaIds.add(String.valueOf(metaId)); + } + } + String metaIdsIn = String.join(",", metaIds); + + // removeMetasAndTags + RemoveMetasAndTagsAssetBuilder removeMetasAndTagsAssetBuilder = + AssetService.removeMetasAndTags(movie.getId(), AssetReferenceType.MEDIA, metaIdsIn); Response booleanResponse = executor.executeSync(removeMetasAndTagsAssetBuilder .setKs(getOperatorKs())); assertThat(booleanResponse.results).isEqualTo(true); @@ -139,18 +159,8 @@ public void sandboxRemoveMetasAndTags() { assertThat(movie.getName()).isEqualTo(movie.getExternalId()); assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); - assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaValue); - assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(numberMetaValue); - assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(dateMetaValue); - assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(booleanMetaValue); - - tags = movie.getTags(); - entry = tags.entrySet().iterator().next(); - tagsValues = entry.getValue().getObjects(); - for (MultilingualStringValue tagValue: tagsValues) { - assertThat(tagMetaValue).contains(tagValue.getValue()); - } - assertThat(tagsValues.size()).isEqualTo(tagsMetaMap.entrySet().iterator().next().getValue().size());*/ + assertThat(movie.getMetas().keySet().size()).isEqualTo(metasSizeAfterCreation - nonBasicMediaMetasCount); + assertThat(movie.getTags().keySet().size()).isEqualTo(0); // cleanup deleteVod(movie.getExternalId()); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index c7ea5bfe8..8c71456fa 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -14,6 +14,7 @@ public class DBConstants { static final String ID = "id"; static final String INT_DISCOUNT_ID = "internal_discount_id"; static final String IS_ACTIVATION_NEEDED = "is_activation_needed"; + static final String IS_BASIC = "is_basic"; static final String IS_RENEWED = "is_renew"; static final String MAX_VIEWS_COUNT = "max_views_number"; static final String NAME = "name"; @@ -83,6 +84,9 @@ public class DBConstants { "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=? and is_active=1 and [status]=1 order by UPDATE_DATE DESC"; + static final String META_OR_TAG_SELECT_BY_NAME = "SELECT * FROM [TVinci].[dbo].[topics]\n" + + "WHERE [STATUS]=1 AND GROUP_ID=? AND SYSTEM_NAME=?\n"; + static final String PPV_SELECT_BY_PRICE_PLAN = "select top 1 * from [Pricing].[dbo].[ppv_modules]\n" + "where [status]=1 and is_active=1\n" + "and group_id=? and usage_module_code=?\n" + diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 813b95a0d..4eee921ba 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -5,10 +5,7 @@ import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.tests.enums.PremiumService; import com.kaltura.client.test.utils.BaseUtils; -import com.kaltura.client.types.Ppv; -import com.kaltura.client.types.PricePlan; -import com.kaltura.client.types.Subscription; -import com.kaltura.client.types.SubscriptionFilter; +import com.kaltura.client.types.*; import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import org.apache.commons.dbutils.DbUtils; import org.apache.commons.lang3.StringUtils; @@ -217,7 +214,7 @@ public static JSONArray getLinearAssetIdAndEpgChannelNameJsonArray() { public static int getUnActiveAsset() { return getJsonArrayFromQueryResult(UNACTIVE_ASSET_ID_SELECT, partnerId + 1) .getJSONObject(0) - .getInt("id"); + .getInt(ID); } public static Subscription getSubscriptionWithPremiumService(PremiumService premiumService) { @@ -268,18 +265,18 @@ public static int getMediaTypeId(MediaType mediaType) { if (isOpcGroup) { return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId, partnerId, mediaType.getValue()) .getJSONObject(0) - .getInt("id"); + .getInt(ID); } else { return getJsonArrayFromQueryResult(MEDIA_TYPE_ID_SELECT, partnerId + 1, partnerId + 2, mediaType.getValue()) .getJSONObject(0) - .getInt("id"); + .getInt(ID); } } public static String getMediaFileTypeName(int mediaFileId) { return getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_ID_SELECT, partnerId + 1, mediaFileId) .getJSONObject(0) - .getString("name"); + .getString(NAME); } public static List getMediaFileTypeNames(int amount) { @@ -288,14 +285,14 @@ public static List getMediaFileTypeNames(int amount) { return arrayToStream(jsonArray) .map(JSONObject.class::cast) - .map(jsonObject -> jsonObject.getString("name")) + .map(jsonObject -> jsonObject.getString(NAME)) .collect(Collectors.toList()); } else { JSONArray jsonArray = getJsonArrayFromQueryResult(MEDIA_FILE_TYPE_IDS_SELECT, amount, partnerId + 1); return arrayToStream(jsonArray) .map(JSONObject.class::cast) - .map(jsonObject -> jsonObject.getString("name")) + .map(jsonObject -> jsonObject.getString(NAME)) .collect(Collectors.toList()); } } @@ -319,7 +316,14 @@ public static List getPpvNames(int amount) { return arrayToStream(jsonArray) .map(JSONObject.class::cast) - .map(jsonObject -> jsonObject.getString("name")) + .map(jsonObject -> jsonObject.getString(NAME)) .collect(Collectors.toList()); } + + public static int getMetaIdByName(String metaName, boolean processBasicFields) { + JSONObject jsonObject = + getJsonArrayFromQueryResult(META_OR_TAG_SELECT_BY_NAME, partnerId, metaName) + .getJSONObject(0); + return (processBasicFields || (jsonObject.getInt(IS_BASIC) == 0)) ? jsonObject.getInt(ID) : -1; + } } From 2162db30059bc96f45d8fd755261b3fe37a45b57 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Sun, 23 Sep 2018 13:24:27 +0300 Subject: [PATCH 568/605] added more tests related inheritance feature --- .../ParentChildMetadataInheritanceTests.java | 99 ++++++++++++------- .../test/utils/AssetStructMetaUtils.java | 18 ++++ .../client/test/utils/AssetStructUtils.java | 31 ++++++ 3 files changed, 111 insertions(+), 37 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java create mode 100644 src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 16ffbe047..9eff47d88 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -1,7 +1,6 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.enums.MetaOrderBy; import com.kaltura.client.services.*; import com.kaltura.client.services.AssetService.RemoveMetasAndTagsAssetBuilder; import com.kaltura.client.services.AssetService.GetAssetBuilder; @@ -20,11 +19,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set; import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; +import static com.kaltura.client.test.utils.AssetStructMetaUtils.getAssetStructMeta; +import static com.kaltura.client.test.utils.AssetStructUtils.getAssetStruct; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMetaIdByName; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; @@ -39,8 +39,66 @@ @Test(groups = { "opc", "Parent Child Metadata Inheritance" }) public class ParentChildMetadataInheritanceTests extends BaseTest { + private String metaIds; + private Response> sharedAssetStructListResponse; + @BeforeClass() public void setUp() { + // assetStructList to fill default metaIds + AssetStructFilter filter = new AssetStructFilter(); + ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); + sharedAssetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + assertThat(sharedAssetStructListResponse.results.getTotalCount()).isGreaterThan(0); + metaIds = sharedAssetStructListResponse.results.getObjects().get(0).getMetaIds(); + } + + @Test + public void testAssetStructListSecurity() { + // assetStructList Master + AssetStructFilter filter = new AssetStructFilter(); + ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); + Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(SharedHousehold.getSharedMasterUserKs())); + assertThat(assetStructListResponse.error.getMessage()).isEqualToIgnoringCase("Service Forbidden"); + + // TODO: check if there is a new bug + // assetStructList Operator + filter = new AssetStructFilter(); + listAssetStructBuilder = AssetStructService.list(filter); + assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getManagerKs())); + assertThat(assetStructListResponse.error.getMessage()).isEqualToIgnoringCase("Service Forbidden"); + } + + @Test + public void testCreateInheritance() { + List assetStructs = loadAssetStructsWithoutHierarchy(3, sharedAssetStructListResponse.results.getObjects()); + AssetStruct assetStructGrandParent = assetStructs.get(0); + AssetStruct assetStructParent = assetStructs.get(1); + AssetStruct assetStructChildren = assetStructs.get(2); + + /*System.out.println(assetStructGrandParent.getId()); + System.out.println(assetStructParent.getId()); + System.out.println(assetStructChildren.getId()); + + System.out.println(assetStructGrandParent.getMetaIds()); + System.out.println(assetStructParent.getMetaIds()); + System.out.println(assetStructChildren.getMetaIds());*/ + + // TODO: complete + //assetStructParent.setConnectedParentMetaId(); + //UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update(assetStructParent.getId(), assetStructParent); + } + + private List loadAssetStructsWithoutHierarchy(int countOfAssetStructs, List listOfAssetStructs) { + List result = new ArrayList<>(); + for (AssetStruct assetStruct: listOfAssetStructs) { + if ((result.size() < countOfAssetStructs) && (assetStruct.getParentId() == 0)) { + result.add(assetStruct); + } + } + return result; } // added to play with methods that are going to be checked @@ -48,14 +106,7 @@ public void setUp() { public void sandbox() { String prefix = "MaxTest_assetStruct_"; - // assetStructList - AssetStructFilter filter = new AssetStructFilter(); - ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); - Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder - .setKs(getOperatorKs())); - assertThat(assetStructListResponse.results.getTotalCount()).isGreaterThan(0); - String metaIds = assetStructListResponse.results.getObjects().get(0).getMetaIds(); - Long assetStructId = assetStructListResponse.results.getObjects().get(0).getId(); + Long assetStructId = sharedAssetStructListResponse.results.getObjects().get(0).getId(); AssetStructMetaFilter assetStructMetaFilter = new AssetStructMetaFilter(); assetStructMetaFilter.setAssetStructIdEqual(assetStructId); @@ -84,8 +135,7 @@ public void sandbox() { //assertThat(assetStructMetaResponse.results.getInherited()).isEqualTo(isInherited); // assetStructAdd - AssetStruct assetStruct = getAssetStruct(prefix, "eng"); - assetStruct.setMetaIds(metaIds); + AssetStruct assetStruct = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(assetStruct); Response assetStructResponse = executor.executeSync(addAssetStructBuilder .setKs(getOperatorKs()).setLanguage("*")); @@ -177,29 +227,4 @@ public void sandboxDelete() { @AfterClass() public void tearDown() { } - - private AssetStructMeta getAssetStructMeta(String defaultIngestValue, String ingestReferencePath, - boolean isProtectFromIngest, boolean isInherited) { - AssetStructMeta assetStructMeta = new AssetStructMeta(); - assetStructMeta.setDefaultIngestValue(defaultIngestValue); - assetStructMeta.setIngestReferencePath(ingestReferencePath); - assetStructMeta.setProtectFromIngest(isProtectFromIngest); - // TODO: update library to have options update it - //assetStructMeta.setIsInherited(isInherited); - return assetStructMeta; - } - - AssetStruct getAssetStruct(String prefix, String language) { - AssetStruct assetStruct = new AssetStruct(); - assetStruct.setSystemName(prefix + "_System_name"); - List translationTokens = new ArrayList<>(); - TranslationToken translationToken = new TranslationToken(); - translationToken.setValue(prefix + "_multiLingualName"); - translationToken.setLanguage(language); - translationTokens.add(translationToken); - assetStruct.setMultilingualName(translationTokens); - assetStruct.setIsProtected(false); - assetStruct.setMetaIds(""); - return assetStruct; - } } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java new file mode 100644 index 000000000..5cf032182 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java @@ -0,0 +1,18 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.types.AssetStructMeta; + +public class AssetStructMetaUtils extends BaseUtils { + + public static AssetStructMeta getAssetStructMeta(String defaultIngestValue, String ingestReferencePath, + boolean isProtectFromIngest, boolean isInherited) { + AssetStructMeta assetStructMeta = new AssetStructMeta(); + assetStructMeta.setDefaultIngestValue(defaultIngestValue); + assetStructMeta.setIngestReferencePath(ingestReferencePath); + assetStructMeta.setProtectFromIngest(isProtectFromIngest); + // TODO: update library to have options update it + //assetStructMeta.setIsInherited(isInherited); + + return assetStructMeta; + } +} diff --git a/src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java new file mode 100644 index 000000000..26859b9bd --- /dev/null +++ b/src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java @@ -0,0 +1,31 @@ +package com.kaltura.client.test.utils; + +import com.kaltura.client.types.AssetStruct; +import com.kaltura.client.types.TranslationToken; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class AssetStructUtils extends BaseUtils { + + public static AssetStruct getAssetStruct(String prefix, String language, boolean isProtected, String metaIds, + @Nullable Long parentId, @Nullable Long connectingMetaId, + @Nullable Long connectedParentMetaId) { + AssetStruct assetStruct = new AssetStruct(); + assetStruct.setSystemName(prefix + "_System_name"); + List translationTokens = new ArrayList<>(); + TranslationToken translationToken = new TranslationToken(); + translationToken.setValue(prefix + "_multiLingualName"); + translationToken.setLanguage(language); + translationTokens.add(translationToken); + assetStruct.setMultilingualName(translationTokens); + assetStruct.setIsProtected(isProtected); + assetStruct.setMetaIds(metaIds); + assetStruct.setParentId(parentId); + assetStruct.setConnectingMetaId(connectingMetaId); + assetStruct.setConnectedParentMetaId(connectedParentMetaId); + + return assetStruct; + } +} From 7bf11f7bbab94d339387f851c0a87a1c33aef90b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 25 Sep 2018 08:52:09 +0300 Subject: [PATCH 569/605] fuxed testAssetStructListSecurity() --- .../ParentChildMetadataInheritanceTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 9eff47d88..e1f3aab27 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -62,13 +62,13 @@ public void testAssetStructListSecurity() { .setKs(SharedHousehold.getSharedMasterUserKs())); assertThat(assetStructListResponse.error.getMessage()).isEqualToIgnoringCase("Service Forbidden"); - // TODO: check if there is a new bug // assetStructList Operator filter = new AssetStructFilter(); listAssetStructBuilder = AssetStructService.list(filter); assetStructListResponse = executor.executeSync(listAssetStructBuilder - .setKs(getManagerKs())); - assertThat(assetStructListResponse.error.getMessage()).isEqualToIgnoringCase("Service Forbidden"); + .setKs(getOperatorKs())); + assertThat(assetStructListResponse.results).isNotNull(); + assertThat(assetStructListResponse.error).isNull(); } @Test From 340ec68eee32a719e952f808ba600a237f6f4aca Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 25 Sep 2018 09:46:49 +0300 Subject: [PATCH 570/605] commented useless tests. Added shared data creation. --- .../ParentChildMetadataInheritanceTests.java | 265 ++++++++++-------- 1 file changed, 150 insertions(+), 115 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index e1f3aab27..69154d07d 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -25,6 +25,7 @@ import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; import static com.kaltura.client.test.utils.AssetStructMetaUtils.getAssetStructMeta; import static com.kaltura.client.test.utils.AssetStructUtils.getAssetStruct; +import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMetaIdByName; import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; @@ -41,9 +42,11 @@ public class ParentChildMetadataInheritanceTests extends BaseTest { private String metaIds; private Response> sharedAssetStructListResponse; + private AssetStruct sharedAssetStruct1, sharedAssetStruct2; @BeforeClass() public void setUp() { + // TODO: check if assetStructList be useful at the end // assetStructList to fill default metaIds AssetStructFilter filter = new AssetStructFilter(); ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); @@ -51,6 +54,23 @@ public void setUp() { .setKs(getOperatorKs())); assertThat(sharedAssetStructListResponse.results.getTotalCount()).isGreaterThan(0); metaIds = sharedAssetStructListResponse.results.getObjects().get(0).getMetaIds(); + + // create shared assetStruct1 + String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + sharedAssetStruct1 = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); + AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(sharedAssetStruct1); + Response assetStructResponse = executor.executeSync(addAssetStructBuilder + .setKs(getOperatorKs()).setLanguage("*")); + sharedAssetStruct1 = assetStructResponse.results; + assertThat(sharedAssetStruct1.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); + // create shared assetStruct2 + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + sharedAssetStruct2 = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); + addAssetStructBuilder = AssetStructService.add(sharedAssetStruct2); + assetStructResponse = executor.executeSync(addAssetStructBuilder + .setKs(getOperatorKs()).setLanguage("*")); + sharedAssetStruct2 = assetStructResponse.results; + assertThat(sharedAssetStruct2.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); } @Test @@ -73,6 +93,11 @@ public void testAssetStructListSecurity() { @Test public void testCreateInheritance() { + // add assetStruct1 with fields to connect + // add assetStruct2 with fields to connect + // check fields have link as it can be done in API and additionally on Tvm + + List assetStructs = loadAssetStructsWithoutHierarchy(3, sharedAssetStructListResponse.results.getObjects()); AssetStruct assetStructGrandParent = assetStructs.get(0); AssetStruct assetStructParent = assetStructs.get(1); @@ -102,129 +127,139 @@ private List loadAssetStructsWithoutHierarchy(int countOfAssetStruc } // added to play with methods that are going to be checked - @Test - public void sandbox() { - String prefix = "MaxTest_assetStruct_"; - - Long assetStructId = sharedAssetStructListResponse.results.getObjects().get(0).getId(); - - AssetStructMetaFilter assetStructMetaFilter = new AssetStructMetaFilter(); - assetStructMetaFilter.setAssetStructIdEqual(assetStructId); - ListAssetStructMetaBuilder listAssetStructMetaBuilder = AssetStructMetaService.list(assetStructMetaFilter); - Response> listAssetMetaStructResponse = executor.executeSync(listAssetStructMetaBuilder - .setKs(getOperatorKs())); - assertThat(listAssetMetaStructResponse.results.getTotalCount()).isGreaterThan(0); - Long metaId = listAssetMetaStructResponse.results.getObjects().get(0).getMetaId(); - - String defaultIngestValue = prefix + "_defaultIngestValue"; - String ingestReferencePath = prefix + "ingestReferencePath"; - boolean isProtectFromIngest = false; - boolean isInherited = true; - AssetStructMeta assetStructMeta = getAssetStructMeta(defaultIngestValue, - ingestReferencePath, isProtectFromIngest, isInherited); - UpdateAssetStructMetaBuilder updateAssetStructMetaBuilder = - new UpdateAssetStructMetaBuilder(assetStructId, metaId, assetStructMeta); - Response assetStructMetaResponse = executor.executeSync(updateAssetStructMetaBuilder - .setKs(getOperatorKs())); - assertThat(assetStructMetaResponse.results.getAssetStructId()).isEqualTo(assetStructId); - assertThat(assetStructMetaResponse.results.getMetaId()).isEqualTo(metaId); - assertThat(assetStructMetaResponse.results.getDefaultIngestValue()).isEqualToIgnoringCase(defaultIngestValue); - assertThat(assetStructMetaResponse.results.getIngestReferencePath()).isEqualToIgnoringCase(ingestReferencePath); - assertThat(assetStructMetaResponse.results.getProtectFromIngest()).isEqualTo(isProtectFromIngest); - //TODO: update library to have options compare it - //assertThat(assetStructMetaResponse.results.getInherited()).isEqualTo(isInherited); - - // assetStructAdd - AssetStruct assetStruct = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); - AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(assetStruct); - Response assetStructResponse = executor.executeSync(addAssetStructBuilder - .setKs(getOperatorKs()).setLanguage("*")); - AssetStruct assetStructFromResponse = assetStructResponse.results; - assertThat(assetStructResponse.results.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); +// @Test +// public void sandbox() { +// String prefix = "MaxTest_assetStruct_"; +// +// Long assetStructId = sharedAssetStructListResponse.results.getObjects().get(0).getId(); +// +// AssetStructMetaFilter assetStructMetaFilter = new AssetStructMetaFilter(); +// assetStructMetaFilter.setAssetStructIdEqual(assetStructId); +// ListAssetStructMetaBuilder listAssetStructMetaBuilder = AssetStructMetaService.list(assetStructMetaFilter); +// Response> listAssetMetaStructResponse = executor.executeSync(listAssetStructMetaBuilder +// .setKs(getOperatorKs())); +// assertThat(listAssetMetaStructResponse.results.getTotalCount()).isGreaterThan(0); +// Long metaId = listAssetMetaStructResponse.results.getObjects().get(0).getMetaId(); +// +// String defaultIngestValue = prefix + "_defaultIngestValue"; +// String ingestReferencePath = prefix + "ingestReferencePath"; +// boolean isProtectFromIngest = false; +// boolean isInherited = true; +// AssetStructMeta assetStructMeta = getAssetStructMeta(defaultIngestValue, +// ingestReferencePath, isProtectFromIngest, isInherited); +// UpdateAssetStructMetaBuilder updateAssetStructMetaBuilder = +// new UpdateAssetStructMetaBuilder(assetStructId, metaId, assetStructMeta); +// Response assetStructMetaResponse = executor.executeSync(updateAssetStructMetaBuilder +// .setKs(getOperatorKs())); +// assertThat(assetStructMetaResponse.results.getAssetStructId()).isEqualTo(assetStructId); +// assertThat(assetStructMetaResponse.results.getMetaId()).isEqualTo(metaId); +// assertThat(assetStructMetaResponse.results.getDefaultIngestValue()).isEqualToIgnoringCase(defaultIngestValue); +// assertThat(assetStructMetaResponse.results.getIngestReferencePath()).isEqualToIgnoringCase(ingestReferencePath); +// assertThat(assetStructMetaResponse.results.getProtectFromIngest()).isEqualTo(isProtectFromIngest); +// //TODO: update library to have options compare it +// //assertThat(assetStructMetaResponse.results.getInherited()).isEqualTo(isInherited); +// +// // assetStructAdd +// AssetStruct assetStruct = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); +// AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(assetStruct); +// Response assetStructResponse = executor.executeSync(addAssetStructBuilder +// .setKs(getOperatorKs()).setLanguage("*")); +// AssetStruct assetStructFromResponse = assetStructResponse.results; +// assertThat(assetStructResponse.results.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); +// +// assetStruct.setSystemName(prefix + "_System_name_upd"); +// +// // assetStructUpdate +// UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update(assetStructFromResponse.getId(), assetStruct); +// assetStructResponse = executor.executeSync(updateAssetStructBuilder +// .setKs(getOperatorKs()) +// .setLanguage("*")); +// assertThat(assetStructResponse.results.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name_upd"); +// +// // assetStructDelete +// DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(assetStructFromResponse.getId()); +// Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder +// .setKs(getOperatorKs())); +// assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); +// } - assetStruct.setSystemName(prefix + "_System_name_upd"); +// @Test +// public void sandboxRemoveMetasAndTags() { +// IngestVodUtils.VodData vodData = getVodData(MOVIE, INSERT); +// MediaAsset movie = insertVod(vodData, true); +// +// assertThat(movie.getName()).isEqualTo(movie.getExternalId()); +// assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); +// // get all metas +// Set movieMetasNames = movie.getMetas().keySet(); +// int metasSizeAfterCreation = movieMetasNames.size(); +// int nonBasicMediaMetasCount = 0; +// assertThat(metasSizeAfterCreation).isGreaterThan(0); +// +// // get all tags +// Set movieTagsNames = movie.getTags().keySet(); +// int tagsSizeAfterCreation = movieTagsNames.size(); +// assertThat(tagsSizeAfterCreation).isGreaterThan(0); +// +// // get all metas and tags info to remove them from media +// List metaIds = new ArrayList<>(); +// int metaId; +// for (String metaName: movieMetasNames) { +// metaId = getMetaIdByName(metaName, false); +// if (metaId !=-1) { +// metaIds.add(String.valueOf(metaId)); +// nonBasicMediaMetasCount++; +// } +// } +// for (String metaName: movieTagsNames) { +// metaId = getMetaIdByName(metaName, true); +// if (metaId !=-1) { +// metaIds.add(String.valueOf(metaId)); +// } +// } +// String metaIdsIn = String.join(",", metaIds); +// +// // removeMetasAndTags +// RemoveMetasAndTagsAssetBuilder removeMetasAndTagsAssetBuilder = +// AssetService.removeMetasAndTags(movie.getId(), AssetReferenceType.MEDIA, metaIdsIn); +// Response booleanResponse = executor.executeSync(removeMetasAndTagsAssetBuilder +// .setKs(getOperatorKs())); +// assertThat(booleanResponse.results).isEqualTo(true); +// +// // check results +// GetAssetBuilder getAssetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA); +// Response assetResponse = executor.executeSync(getAssetBuilder +// .setKs(getOperatorKs())); +// movie = (MediaAsset) assetResponse.results; +// +// assertThat(movie.getName()).isEqualTo(movie.getExternalId()); +// assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); +// assertThat(movie.getMetas().keySet().size()).isEqualTo(metasSizeAfterCreation - nonBasicMediaMetasCount); +// assertThat(movie.getTags().keySet().size()).isEqualTo(0); +// +// // cleanup +// deleteVod(movie.getExternalId()); +// } - // assetStructUpdate - UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update(assetStructFromResponse.getId(), assetStruct); - assetStructResponse = executor.executeSync(updateAssetStructBuilder - .setKs(getOperatorKs()) - .setLanguage("*")); - assertThat(assetStructResponse.results.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name_upd"); +// @Test +// public void sandboxDelete() { +// DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(2381); +// Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder +// .setKs(getOperatorKs())); +// assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); +// } - // assetStructDelete - DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(assetStructFromResponse.getId()); + @AfterClass() + public void tearDown() { + // cleaning created shared assetStructs + DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(sharedAssetStruct1.getId()); Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder .setKs(getOperatorKs())); assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); - } - @Test - public void sandboxRemoveMetasAndTags() { - IngestVodUtils.VodData vodData = getVodData(MOVIE, INSERT); - MediaAsset movie = insertVod(vodData, true); - - assertThat(movie.getName()).isEqualTo(movie.getExternalId()); - assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); - // get all metas - Set movieMetasNames = movie.getMetas().keySet(); - int metasSizeAfterCreation = movieMetasNames.size(); - int nonBasicMediaMetasCount = 0; - assertThat(metasSizeAfterCreation).isGreaterThan(0); - - // get all tags - Set movieTagsNames = movie.getTags().keySet(); - int tagsSizeAfterCreation = movieTagsNames.size(); - assertThat(tagsSizeAfterCreation).isGreaterThan(0); - - // get all metas and tags info to remove them from media - List metaIds = new ArrayList<>(); - int metaId; - for (String metaName: movieMetasNames) { - metaId = getMetaIdByName(metaName, false); - if (metaId !=-1) { - metaIds.add(String.valueOf(metaId)); - nonBasicMediaMetasCount++; - } - } - for (String metaName: movieTagsNames) { - metaId = getMetaIdByName(metaName, true); - if (metaId !=-1) { - metaIds.add(String.valueOf(metaId)); - } - } - String metaIdsIn = String.join(",", metaIds); - - // removeMetasAndTags - RemoveMetasAndTagsAssetBuilder removeMetasAndTagsAssetBuilder = - AssetService.removeMetasAndTags(movie.getId(), AssetReferenceType.MEDIA, metaIdsIn); - Response booleanResponse = executor.executeSync(removeMetasAndTagsAssetBuilder - .setKs(getOperatorKs())); - assertThat(booleanResponse.results).isEqualTo(true); - - // check results - GetAssetBuilder getAssetBuilder = AssetService.get(movie.getId().toString(), AssetReferenceType.MEDIA); - Response assetResponse = executor.executeSync(getAssetBuilder - .setKs(getOperatorKs())); - movie = (MediaAsset) assetResponse.results; - - assertThat(movie.getName()).isEqualTo(movie.getExternalId()); - assertThat(movie.getDescription()).isEqualTo("description of " + movie.getExternalId()); - assertThat(movie.getMetas().keySet().size()).isEqualTo(metasSizeAfterCreation - nonBasicMediaMetasCount); - assertThat(movie.getTags().keySet().size()).isEqualTo(0); - - // cleanup - deleteVod(movie.getExternalId()); - } - - @Test - public void sandboxDelete() { - DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(2381); - Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder + deleteAssetStructBuilder = AssetStructService.delete(sharedAssetStruct2.getId()); + deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder .setKs(getOperatorKs())); assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); } - - @AfterClass() - public void tearDown() { - } } From 0a128e9d8e97719fb95711e0d35bc09ca940e669 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 25 Sep 2018 10:19:16 +0300 Subject: [PATCH 571/605] no message --- pom.xml | 7 -- .../five_zero_two/IngestVodOpcTests.java | 64 ++++++++++--------- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/pom.xml b/pom.xml index 0a321525a..948be4d8f 100644 --- a/pom.xml +++ b/pom.xml @@ -225,13 +225,6 @@ test - - - - - - - org.jsoup jsoup diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 0e78906dc..c20c78080 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.services.PpvService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; @@ -18,6 +19,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -351,37 +353,37 @@ public void insertWithInvalidCredentials() { assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); } -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "try insert with invalid meta or tag field") -// public void insertWithInvalidMetaOrTagField() { -// String suffix = "_" + getEpoch(); -// VodData vodData = getVodData(MOVIE, INSERT); -// -// String updatedField = mediaNumberFieldName + suffix; -// vodData.numbers(Map.of(updatedField, getRandomDouble())); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.numbers(Map.of()); -// -// updatedField = mediaBooleanFieldName + suffix; -// vodData.booleans(Map.of(updatedField, getRandomBoolean())); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.booleans(Map.of()); -// -// updatedField = mediaTagFieldName + suffix; -// vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); -// assertInvalidMovieField(vodData, updatedField, "tag"); -// vodData.tags(Map.of()); -// -// updatedField = mediaTextFieldName + suffix; -// vodData.strings(Map.of(updatedField, getRandomString())); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.strings(Map.of()); -// -// updatedField = mediaDateFieldName + suffix; -// vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.dates(Map.of()); -// } + @Severity(SeverityLevel.NORMAL) + @Test(description = "try insert with invalid meta or tag field") + public void insertWithInvalidMetaOrTagField() { + String suffix = "_" + getEpoch(); + VodData vodData = getVodData(MOVIE, INSERT); + + String updatedField = mediaNumberFieldName + suffix; + vodData.numbers(Map.of(updatedField, getRandomDouble())); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.numbers(Map.of()); + + updatedField = mediaBooleanFieldName + suffix; + vodData.booleans(Map.of(updatedField, getRandomBoolean())); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.booleans(Map.of()); + + updatedField = mediaTagFieldName + suffix; + vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); + assertInvalidMovieField(vodData, updatedField, "tag"); + vodData.tags(Map.of()); + + updatedField = mediaTextFieldName + suffix; + vodData.strings(Map.of(updatedField, getRandomString())); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.strings(Map.of()); + + updatedField = mediaDateFieldName + suffix; + vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.dates(Map.of()); + } @Severity(SeverityLevel.NORMAL) @Test(description = "insert multilingual fields", enabled = false) From deb10676841fa0e8084bf80c56b2eb0bc05fda9b Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Tue, 25 Sep 2018 13:07:51 +0300 Subject: [PATCH 572/605] orderVodAssetsByViews regression fix --- .../SearchAssetFilterTests.java | 29 ++++++++++++++++--- .../kaltura/client/test/utils/AssetUtils.java | 13 ++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index db0fd3282..9830e1038 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -19,6 +19,7 @@ import org.testng.annotations.Test; import java.util.*; +import java.util.concurrent.TimeUnit; import static com.kaltura.client.services.AssetService.ListAssetBuilder; import static com.kaltura.client.services.AssetService.list; @@ -35,6 +36,7 @@ import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.*; import static java.util.TimeZone.getTimeZone; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; public class SearchAssetFilterTests extends BaseTest { @@ -52,7 +54,7 @@ public class SearchAssetFilterTests extends BaseTest { - @BeforeClass + @BeforeClass(alwaysRun = true) private void asset_list_searchAssetFilter_before_class() { // Get asset from shared asset method tagValue = getRandomValue(tagName + "_"); @@ -342,8 +344,8 @@ private void listVodAssetsFilteredByType() { @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - order by VIEWS") - @Test - private void orderVodAssetsByViews() { + @Test(groups = "slowBefore") + private void orderVodAssetsByViews_before_wait() { int numOfActionsAsset = 3; int numOfActionsAsset2 = 2; @@ -363,7 +365,11 @@ private void orderVodAssetsByViews() { for (int i = 0; i < numOfActionsAsset3; i++) { addViewToAsset(asset3, AssetType.MEDIA); } - + } + @Severity(SeverityLevel.CRITICAL) + @Description("asset/action/list - VOD - order by VIEWS") + @Test(groups = "slowAfter", dependsOnGroups = "slowBefore") + private void orderVodAssetsByViews_after_wait() { String query = new KsqlBuilder() .openOr() .equal(MEDIA_ID.getValue(), Math.toIntExact(asset.getId())) @@ -373,9 +379,24 @@ private void orderVodAssetsByViews() { .toString(); assetFilter = getSearchAssetFilter(query, null, null, null, null, AssetOrderBy.VIEWS_DESC.getValue()); + // prepare variables for await() functionality + int delayBetweenRetriesInSeconds = 15; + int maxTimeExpectingValidResponseInSeconds = 80; + // wait for pin to expire + await() + .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) + .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) + .until(() -> { + List assetsList = executor.executeSync(list(assetFilter).setKs(getSharedMasterUserKs())).results.getObjects(); + return assetsList.get(0).getId().equals(asset.getId()) && + assetsList.get(1).getId().equals(asset2.getId()) && + assetsList.get(2).getId().equals(asset3.getId()); + }); + Response> assetListResponse = executor.executeSync(list(assetFilter) .setKs(getSharedMasterUserKs())); + assertThat(assetListResponse.error).isNull(); assertThat(assetListResponse.results.getTotalCount()).isEqualTo(3); assertThat(assetListResponse.results.getObjects().get(0).getId()).isEqualTo(asset.getId()); assertThat(assetListResponse.results.getObjects().get(1).getId()).isEqualTo(asset2.getId()); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index e618e97f9..4ab279e01 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -99,21 +99,14 @@ public static void addViewToAsset(Asset asset, AssetType assetType) { HouseholdUser householdUser = HouseholdUtils.getMasterUser(household); // Login user - String ks = OttUserUtils.getKs(Integer.parseInt(householdUser.getUserId())); + String ks = OttUserUtils.getKs(Integer.parseInt(householdUser.getUserId()), HouseholdUtils.getDevicesList(household).get(0).getUdid()); // Purchase PPV (to allow bookmark PurchaseUtils.purchasePpv(ks,Optional.of(Math.toIntExact(asset.getId())),Optional.empty(),Optional.empty()); - PlaybackContextOptions playbackContextOptions = new PlaybackContextOptions(); - playbackContextOptions.setContext(PlaybackContextType.PLAYBACK); - //asset/action/getPlaybackContext - AssetService.getPlaybackContext(String.valueOf(asset.getId()),assetType, playbackContextOptions) - .setKs(ks); Bookmark bookmark = BookmarkUtils.addBookmark(0, String.valueOf(asset.getId()), asset.getMediaFiles().get(0).getId(), assetType, BookmarkActionType.FIRST_PLAY); - - //bookmark/action/add - AddBookmarkBuilder addBookmarkBuilder = add(bookmark) - .setKs(getSharedMasterUserKs()); + //bookmark/action/add + AddBookmarkBuilder addBookmarkBuilder = add(bookmark).setKs(ks); executor.executeSync(addBookmarkBuilder); } From e276a750f0910e4e05ba038ba1aa4ed359346f17 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 25 Sep 2018 13:20:35 +0300 Subject: [PATCH 573/605] added insertVodMediaBaseWithEmptyImageUrl() --- pom.xml | 4 +- .../kaltura/client/test/tests/BaseTest.java | 2 +- .../five_zero_two/IngestVodOpcTests.java | 22 ++++++----- .../utils/ingestUtils/IngestVodOpcUtils.java | 38 ++++--------------- .../utils/ingestUtils/IngestVodUtils.java | 6 ++- 5 files changed, 28 insertions(+), 44 deletions(-) diff --git a/pom.xml b/pom.xml index 948be4d8f..52bcb1082 100644 --- a/pom.xml +++ b/pom.xml @@ -260,8 +260,8 @@ maven-compiler-plugin 2.3.2 - 1.8 - 1.8 + 1.10 + 1.10 diff --git a/src/test/java/com/kaltura/client/test/tests/BaseTest.java b/src/test/java/com/kaltura/client/test/tests/BaseTest.java index 8cc83fa2c..923872969 100644 --- a/src/test/java/com/kaltura/client/test/tests/BaseTest.java +++ b/src/test/java/com/kaltura/client/test/tests/BaseTest.java @@ -125,7 +125,7 @@ public class BaseTest { @Parameters({"accountType"}) @BeforeSuite(alwaysRun = true) - public void baseTest_beforeSuite(@org.testng.annotations.Optional("regular") String accountType, ITestContext testContext) { + public void baseTest_beforeSuite(@org.testng.annotations.Optional("opc") String accountType, ITestContext testContext) { XmlSuite suite = testContext.getCurrentXmlTest().getSuite(); Logger.getLogger(BaseTest.class).debug("Start suite >>> Suite: " + suite.getName()); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index c20c78080..2e06874b5 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -448,8 +448,19 @@ public void insertMultiLingualFields() { } @Severity(SeverityLevel.MINOR) - @Test(description = "ingest VOD with empty images and thumb fields") - public void insertVodMediaBaseEmptyImagesAndFields() { + @Test(description = "ingest VOD with empty images urls") + public void insertVodMediaBaseWithEmptyImageUrl() { + // empty thumb tag + VodData vodData = getVodData(MOVIE, INSERT).thumbUrl(""); + String ingestXml = buildIngestVodXml(vodData, INSERT); + + Response resp = executeIngestVodRequest(ingestXml); + assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageInvalidUrlForImage"); + } + + @Severity(SeverityLevel.MINOR) + @Test(description = "ingest VOD files with same coguid") + public void insertVodMediaBaseFilesWithSameCoguid() { // empty images tag VodData vodData = getVodData(MOVIE, INSERT); long epoch = getEpoch(); @@ -459,13 +470,6 @@ public void insertVodMediaBaseEmptyImagesAndFields() { Response resp = executeIngestVodRequest(ingestXml); assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("MediaFileExternalIdMustBeUnique"); - - // empty thumb tag - VodData vodData1 = getVodData(MOVIE, INSERT).thumbUrl(""); - ingestXml = buildIngestVodXml(vodData1, INSERT); - - resp = executeIngestVodRequest(ingestXml); - assertThat(from(resp.asString()).getString(ingestAssetStatusWarningMessagePath)).contains("InvalidUrlForImageInvalidUrlForImage"); } @Issue("BEO-5584") diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index cda4756ea..09fb83255 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -20,20 +20,12 @@ public class IngestVodOpcUtils extends BaseIngestUtils { - private static String name; - private static String description; private static String stringMetaValue; private static String dateMetaValue; private static double numberMetaValue; private static boolean booleanMetaValue; private static List tagMetaValue; - private static final String FILE_TYPE_1 = "Test130301"; - private static final String FILE_TYPE_2 = "new file type1"; - - public static final String EMPTY_FILE_1_TAG = "\n"; - public static final String EMPTY_FILE_2_TAG = "\n"; - // TODO: how to get these data from DB or request? // Movie fields public static final String mediaTextFieldName = "BoxOffice"; @@ -57,14 +49,14 @@ public class IngestVodOpcUtils extends BaseIngestUtils { public static final String seriesTagFieldName = "Studio"; // fields & values - public static HashMap stringMetaMap = new HashMap<>(); - public static HashMap numberMetaMap = new HashMap<>(); - public static HashMap booleanHashMap = new HashMap<>(); - public static HashMap datesMetaMap = new HashMap<>(); - public static HashMap> tagsMetaMap = new HashMap<>(); + private static HashMap stringMetaMap = new HashMap<>(); + private static HashMap numberMetaMap = new HashMap<>(); + private static HashMap booleanHashMap = new HashMap<>(); + private static HashMap datesMetaMap = new HashMap<>(); + private static HashMap> tagsMetaMap = new HashMap<>(); - public static String tagValue1 = "Jack Nicholson"; - public static String tagValue2 = "Natalie Portman"; + private static String tagValue1 = "Jack Nicholson"; + private static String tagValue2 = "Natalie Portman"; public static VodData getVodData(MediaType mediaType, IngestAction action) { if (action == INSERT) { @@ -75,9 +67,6 @@ public static VodData getVodData(MediaType mediaType, IngestAction action) { VodData data = new VodData() .setDefaultValues() -// .name(name) -// .description(description) -// .thumbUrl(DEFAULT_THUMB) .strings(stringMetaMap) .booleans(booleanHashMap) .numbers(numberMetaMap) @@ -199,17 +188,4 @@ public static boolean isTagValueFound(String value2Found, Asset asset) { } return false; } - - public static String getUpdatedIngestXml(String ingestXml, String openTag2Update, String closeTag2Update, String updateOnString) { - int positionBeginTag = ingestXml.indexOf(openTag2Update); - int positionEndTag; - if ("/>".equals(closeTag2Update)) { - positionEndTag = ingestXml.indexOf(closeTag2Update, positionBeginTag); - } else { - positionEndTag = ingestXml.indexOf(closeTag2Update); - } - - String string2Delete = ingestXml.substring(positionBeginTag, positionEndTag + closeTag2Update.length()); - return ingestXml.replace(string2Delete, updateOnString); - } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 3e81c38a9..8f3d5cfa6 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -122,6 +122,9 @@ public static class VodFile { @Setter private String ppvModule; + + public VodFile() {} + public VodFile(String type, String ppvModule) { quality = "HIGH"; handling_type = "CLIP"; @@ -130,12 +133,13 @@ public VodFile(String type, String ppvModule) { alt_cdn_code = "http://alt_cdntesting.qa.mkaltura.com/p/231/sp/23100/playManifest/entryId/0_3ugsts44/format/hdnetworkmanifest/tags/mbr/protocol/http/f/a.a4m"; billing_type = "Tvinci"; product_code = "productExampleCode"; - assetDuration = "1000"; + coguid = "file_" + getEpoch() + "_" + getRandomLong(); this.type = type; this.ppvModule = ppvModule; } + } /** From cd5d43572f8e7be0121741eb9fc9f7d981ef4225 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Tue, 25 Sep 2018 13:45:48 +0300 Subject: [PATCH 574/605] uncomment Map.of --- .../five_zero_two/IngestVodOpcTests.java | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 0e78906dc..c20c78080 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -5,6 +5,7 @@ import com.kaltura.client.services.PpvService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; @@ -18,6 +19,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -351,37 +353,37 @@ public void insertWithInvalidCredentials() { assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); } -// @Severity(SeverityLevel.NORMAL) -// @Test(description = "try insert with invalid meta or tag field") -// public void insertWithInvalidMetaOrTagField() { -// String suffix = "_" + getEpoch(); -// VodData vodData = getVodData(MOVIE, INSERT); -// -// String updatedField = mediaNumberFieldName + suffix; -// vodData.numbers(Map.of(updatedField, getRandomDouble())); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.numbers(Map.of()); -// -// updatedField = mediaBooleanFieldName + suffix; -// vodData.booleans(Map.of(updatedField, getRandomBoolean())); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.booleans(Map.of()); -// -// updatedField = mediaTagFieldName + suffix; -// vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); -// assertInvalidMovieField(vodData, updatedField, "tag"); -// vodData.tags(Map.of()); -// -// updatedField = mediaTextFieldName + suffix; -// vodData.strings(Map.of(updatedField, getRandomString())); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.strings(Map.of()); -// -// updatedField = mediaDateFieldName + suffix; -// vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); -// assertInvalidMovieField(vodData, updatedField, "meta"); -// vodData.dates(Map.of()); -// } + @Severity(SeverityLevel.NORMAL) + @Test(description = "try insert with invalid meta or tag field") + public void insertWithInvalidMetaOrTagField() { + String suffix = "_" + getEpoch(); + VodData vodData = getVodData(MOVIE, INSERT); + + String updatedField = mediaNumberFieldName + suffix; + vodData.numbers(Map.of(updatedField, getRandomDouble())); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.numbers(Map.of()); + + updatedField = mediaBooleanFieldName + suffix; + vodData.booleans(Map.of(updatedField, getRandomBoolean())); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.booleans(Map.of()); + + updatedField = mediaTagFieldName + suffix; + vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); + assertInvalidMovieField(vodData, updatedField, "tag"); + vodData.tags(Map.of()); + + updatedField = mediaTextFieldName + suffix; + vodData.strings(Map.of(updatedField, getRandomString())); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.strings(Map.of()); + + updatedField = mediaDateFieldName + suffix; + vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); + assertInvalidMovieField(vodData, updatedField, "meta"); + vodData.dates(Map.of()); + } @Severity(SeverityLevel.NORMAL) @Test(description = "insert multilingual fields", enabled = false) From cedeb8c37119732fb367e4f89e383eba4233efe0 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 25 Sep 2018 15:01:53 +0300 Subject: [PATCH 575/605] completed permissionsManagementTests --- .../com/kaltura/client/test/Properties.java | 4 + .../PermissionsManagementTests.java | 91 ++++++++++--------- .../test/utils/PermissionManagementUtils.java | 13 ++- 3 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/Properties.java b/src/test/java/com/kaltura/client/test/Properties.java index 740255197..14e35439b 100644 --- a/src/test/java/com/kaltura/client/test/Properties.java +++ b/src/test/java/com/kaltura/client/test/Properties.java @@ -90,6 +90,10 @@ public class Properties { public static final String MAX_CODE_PERCENTAGE = "max_code_percentage"; public static final String MAX_EXECUTION_TIME_IN_SEC = "max_execution_time_in_sec"; + // permissions management + public static final String PERMISSION_LOG_FILE = "permission_log_file"; + public static final String PERMISSION_CONSOLE_UTIL_FILE = "permission_console_util_file"; + public static String getProperty(String propertyKey) { if (resourceBundle == null) { resourceBundle = ResourceBundle.getBundle("test"); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java index df0bd4abd..e6b742035 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/four_eight/PermissionsManagementTests.java @@ -47,7 +47,7 @@ public void setUp() { @Test(description = "execute console util without parameters") public void runningWithoutParameters() { List commands = getConsoleCommand(fullPath2Util, ""); - String consoleOutput = executeCommandsInColsole(commands); + String consoleOutput = executeCommandsInConsole(commands); assertThat(consoleOutput).contains("Permissions deployment tool"); assertThat(consoleOutput).contains("Shortcut: e"); @@ -62,7 +62,7 @@ public void runningWithoutParameters() { @Test(description = "execute console util to export without mentioned file") public void runningExportWithoutFile() { List commands = getConsoleCommand(fullPath2Util, EXPORT_KEY); - String consoleOutput = executeCommandsInColsole(commands); + String consoleOutput = executeCommandsInConsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); } @@ -72,7 +72,7 @@ public void runningExportWithoutFile() { @Test(description = "execute console util to import without mentioned file") public void runningImportWithoutFile() { List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY); - String consoleOutput = executeCommandsInColsole(commands); + String consoleOutput = executeCommandsInConsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); } @@ -82,7 +82,7 @@ public void runningImportWithoutFile() { @Test(description = "execute console util to delete without mentioned file") public void runningDeleteWithoutFile() { List commands = getConsoleCommand(fullPath2Util, DELETE_KEY); - String consoleOutput = executeCommandsInColsole(commands); + String consoleOutput = executeCommandsInConsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); } @@ -100,7 +100,7 @@ public void export() { // export from DB List commands = getConsoleCommand(fullPath2Util, EXPORT_KEY + dataFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // checks that created file contains inserted data String fileContent = getFileContent(dataFilePath); @@ -126,7 +126,7 @@ public void runningImportFromFileNotHavingAllTables() { // try to import into DB List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + importOnly4TablesFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); String fileContent = getFileContent(path2Log); assertThat(fileContent).contains("Import failed: reading from XML resulted in empty data set or data set with less than 5 tables"); @@ -140,7 +140,7 @@ public void runningImportFromEmptyFile() { // try to import into DB List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + path2EmptyFile); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); String fileContent = getFileContent(path2Log); assertThat(fileContent).contains("Failed importing permissions, ex = System.Xml.XmlException: Root element is missing"); @@ -154,7 +154,7 @@ public void runningDeleteUsingEmptyFile() { // try to import into DB List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + path2EmptyFile); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); String fileContent = getFileContent(path2Log); assertThat(fileContent).contains("Failed deleting permissions, ex = System.Xml.XmlException: Root element is missing"); @@ -172,7 +172,7 @@ public void importFromFile() { // import into DB List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // check data in DB int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); @@ -203,41 +203,48 @@ public void importFromFile() { @Severity(SeverityLevel.NORMAL) @Test(description = "execute console util to check items from DB not mentioned in import file should be mentioned in log") public void runningImportToCheckLogHasItemsFromDBNotMentionedInFile() { - // TODO: update test // remove log file deleteFile(path2Log); - // insert data in DB - String suffix = String.valueOf(BaseUtils.getEpoch()) + "inserted"; - String roleName = "MaxTest" + suffix; - String permissionItemName = "Asset_List_Max" + suffix; - PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName, "partner*", - permissionItemName, "asset", "list", "permissionItemObject" + suffix, - "parameter" + suffix, false); - int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); + // insert data in DB to check they will be mentioned in log file + String suffix1 = String.valueOf(BaseUtils.getEpoch()) + "inserted"; + String roleName1 = "MaxTest" + suffix1; + String permissionItemName1 = "Asset_List_Max" + suffix1; + PermissionManagementUtils.insertDataInAllTables(generatedDataFilePath, roleName1, "partner*", + permissionItemName1, "asset", "list", "permissionItemObject" + suffix1, + "parameter" + suffix1, false); + String filePath2Check = generatedDataFilePath; // generate import file data - suffix = String.valueOf(BaseUtils.getEpoch()); - roleName = "MaxTest" + suffix; - permissionItemName = "Asset_List_Max" + suffix; + String suffix = String.valueOf(BaseUtils.getEpoch()); + String roleName = "MaxTest" + suffix; + String permissionItemName = "Asset_List_Max" + suffix; PermissionManagementUtils.generateFileWithInsertedIntoDBData(generatedDataFilePath, roleName, "partner*", permissionItemName, "asset", "list", "permissionItemObject" + suffix, "parameter" + suffix, 1, 2, 3, 4, 5, false); - // try to import into DB - List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + path2EmptyFile); - String outputInConsole = executeCommandsInColsole(commands); + // import into DB + List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + generatedDataFilePath); + executeCommandsInConsole(commands); String fileContent = getFileContent(path2Log); - assertThat(fileContent).contains("ex = System.Xml.XmlException: Root element is missing"); - assertThat(outputInConsole).contains("ex = System.Xml.XmlException: Root element is missing"); + int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName1, 0); + assertThat(fileContent).contains("!!NOT EXISTS IN SOURCE!! Table : role Id : " + idRoleHavingName + " Name : " + "MaxTest" + suffix1); // cleaning -// PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); -// int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); -// PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); -// int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); -// PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); + PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); + int idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName1); + PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); + int idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName1, 0); + PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); + + idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); + PermissionsManagementDBUtils.deleteRoleAndItsPermissions(idRoleHavingName); + idPermissionItemHavingName = getIdRecordHavingNameInPermissionItems(permissionItemName); + PermissionsManagementDBUtils.deletePermissionItem(idPermissionItemHavingName); + idPermissionHavingName = getIdRecordHavingRoleNameInPermissions(roleName, 0); + PermissionsManagementDBUtils.deletePermission(idPermissionHavingName); + } @Severity(SeverityLevel.CRITICAL) @@ -252,7 +259,7 @@ public void deleteFromDB() { // import into DB List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // check data in DB int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); @@ -279,7 +286,7 @@ public void deleteFromDB() { // delete from DB commands = getConsoleCommand(fullPath2Util, DELETE_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // DB should be empty rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); @@ -304,10 +311,10 @@ public void importAlreadyExistedFromFile() { // import into DB List commands = getConsoleCommand(fullPath2Util, IMPORT_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // retry import - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // check data in DB int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); @@ -348,7 +355,7 @@ public void runningDeleteUsingFileWithInvalidTags() { // try delete List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // check data still in DB int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); @@ -368,7 +375,7 @@ public void deleteOnlyFromOneTable() { // delete List commands = getConsoleCommand(fullPath2Util, DELETE_KEY + generatedDataFilePath); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // check data deleted from DB int rowsInRolesHavingName = getCountRowsHavingRoleNameInRoles(roleName, 0); @@ -380,7 +387,7 @@ public void deleteOnlyFromOneTable() { @Test(description = "execute console util to export in JSON without mentioned file") public void runningExportJsonWithoutFile() { List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY); - String consoleOutput = executeCommandsInColsole(commands); + String consoleOutput = executeCommandsInConsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); } @@ -390,7 +397,7 @@ public void runningExportJsonWithoutFile() { @Test(description = "execute console util to import in JSON without mentioned file") public void runningImportJsonWithoutFile() { List commands = getConsoleCommand(fullPath2Util, IMPORT_JSON_KEY); - String consoleOutput = executeCommandsInColsole(commands); + String consoleOutput = executeCommandsInConsole(commands); assertThat(consoleOutput).contains("The system cannot find the file specified"); } @@ -411,7 +418,7 @@ public void exportJson() throws IOException { "parameter" + suffix, true); // command List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); String importFileContent = getFileContent(generatedDataFilePath); assertThat(importFileContent).contains(roleName); @@ -435,7 +442,7 @@ public void importJson() throws IOException { // export command to get results and not break the system List commands = getConsoleCommand(fullPath2Util, EXPORT_JSON_KEY + path2JsonFolder); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // prepare data String suffix = String.valueOf(BaseUtils.getEpoch()); @@ -446,7 +453,7 @@ public void importJson() throws IOException { // import command commands = getConsoleCommand(fullPath2Util, IMPORT_JSON_KEY + path2JsonFolder); - executeCommandsInColsole(commands); + executeCommandsInConsole(commands); // find new records in DB after the import int idRoleHavingName = getIdRecordHavingRoleNameInRoles(roleName, 0); diff --git a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java index 297d7c06b..a349c7eb3 100644 --- a/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/PermissionManagementUtils.java @@ -2,7 +2,6 @@ import com.google.gson.*; import com.kaltura.client.Logger; -import com.kaltura.client.test.tests.featuresTests.versions.four_eight.PermissionsManagementTests; import com.kaltura.client.test.utils.dbUtils.PermissionsManagementDBUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -10,11 +9,15 @@ import java.util.ArrayList; import java.util.List; +import static com.kaltura.client.test.Properties.PERMISSION_CONSOLE_UTIL_FILE; +import static com.kaltura.client.test.Properties.PERMISSION_LOG_FILE; +import static com.kaltura.client.test.Properties.getProperty; + public class PermissionManagementUtils extends BaseUtils { // that file generated automatically - public static String path2Log = "C:\\log\\permissions\\permissions.log"; - public static String path2Util = "C:\\123\\PermissionsExport\\bin\\Debug\\"; + public static String path2Log = getProperty(PERMISSION_LOG_FILE); + public static String path2Util = getProperty(PERMISSION_CONSOLE_UTIL_FILE); public static String mainFile = "PermissionsDeployment.exe"; public static String fullPath2Util = path2Util + mainFile; @@ -243,8 +246,8 @@ public static void printRole(PrintWriter writer, Long roleId, String roleName) { writer.println(""); } - public static String executeCommandsInColsole(List commands) { - Logger.getLogger(PermissionManagementUtils.class).debug("started executeCommandsInColsole"); + public static String executeCommandsInConsole(List commands) { + Logger.getLogger(PermissionManagementUtils.class).debug("started executeCommandsInConsole"); StringBuilder output = new StringBuilder(); StringBuilder input = new StringBuilder(); for(String command: commands){ From 645e92cdcab51573e7cdf34a6b1b7154da95be69 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 25 Sep 2018 15:51:54 +0300 Subject: [PATCH 576/605] updated name --- .../five_zero_three/ParentChildMetadataInheritanceTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 69154d07d..910b5e04b 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -64,7 +64,7 @@ public void setUp() { sharedAssetStruct1 = assetStructResponse.results; assertThat(sharedAssetStruct1.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); // create shared assetStruct2 - prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; sharedAssetStruct2 = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); addAssetStructBuilder = AssetStructService.add(sharedAssetStruct2); assetStructResponse = executor.executeSync(addAssetStructBuilder From 35651243235fefc70d3e2db38b9181caca8ed41a Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Tue, 25 Sep 2018 21:53:09 +0300 Subject: [PATCH 577/605] ProductPrice regression fix --- .../productPriceTests/ProductPriceListTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java index c1cde6941..01bb52b2f 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/productPriceTests/ProductPriceListTests.java @@ -170,7 +170,7 @@ public void ppvTest() { ListProductPriceBuilder productPriceListAfterPurchaseForAnotherFileFromTheSameMedia = ProductPriceService.list(ppFilter); productPriceResponse = executor.executeSync(productPriceListAfterPurchaseForAnotherFileFromTheSameMedia.setKs(classMasterUserKs)); assertThat(productPriceResponse.results.getTotalCount()).isEqualTo(1); - assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.PPV_PURCHASED); + assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isIn(PurchaseStatus.FOR_PURCHASE, PurchaseStatus.FOR_PURCHASE_SUBSCRIPTION_ONLY); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(0)).getFileId()).isEqualTo(mobileMediaFileId); } @@ -335,10 +335,10 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { assertThat(productPriceResponse.results.getObjects().get(0).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); assertThat(productPriceResponse.results.getObjects().get(0).getProductType()).isEqualTo(TransactionType.SUBSCRIPTION); assertThat(productPriceResponse.results.getObjects().get(0).getProductId()).isEqualTo(String.valueOf(webHDFileOnlySubId)); - assertThat(productPriceResponse.results.getObjects().get(1).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(1).getPurchaseStatus()).isIn(PurchaseStatus.FOR_PURCHASE, PurchaseStatus.FOR_PURCHASE_SUBSCRIPTION_ONLY); assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); - assertThat(productPriceResponse.results.getObjects().get(2).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(2).getPurchaseStatus()).isIn(PurchaseStatus.FOR_PURCHASE, PurchaseStatus.FOR_PURCHASE_SUBSCRIPTION_ONLY); assertThat(productPriceResponse.results.getObjects().get(2).getProductType()).isEqualTo(TransactionType.PPV); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(2)).getFileId()).isEqualTo(getSharedMobileMediaFile().getId()); @@ -354,7 +354,7 @@ public void productPriceSubscriptionWebHDFileTypeOnlyTest() { assertThat(productPriceResponse.results.getObjects().get(1).getProductType()).isEqualTo(TransactionType.PPV); assertThat(productPriceResponse.results.getObjects().get(1).getPrice().getAmount()).isEqualTo(0); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(1)).getFileId()).isEqualTo(getSharedWebMediaFile().getId()); - assertThat(productPriceResponse.results.getObjects().get(2).getPurchaseStatus()).isEqualTo(PurchaseStatus.FOR_PURCHASE); + assertThat(productPriceResponse.results.getObjects().get(2).getPurchaseStatus()).isIn(PurchaseStatus.FOR_PURCHASE, PurchaseStatus.FOR_PURCHASE_SUBSCRIPTION_ONLY); assertThat(productPriceResponse.results.getObjects().get(2).getProductType()).isEqualTo(TransactionType.PPV); assertThat(productPriceResponse.results.getObjects().get(2).getPrice().getAmount()).isGreaterThan(0); assertThat(((PpvPrice) productPriceResponse.results.getObjects().get(2)).getFileId()).isEqualTo(getSharedMobileMediaFile().getId()); From 0a89f831d17757676badfb02c1d2d1cf5fef46a1 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 26 Sep 2018 09:12:01 +0300 Subject: [PATCH 578/605] updating pom for java 10 --- pom.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 0a321525a..c085acacb 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,10 @@ jar - 1.8 + 10 1.8.10 + 10 + 10 @@ -265,10 +267,10 @@ maven-compiler-plugin - 2.3.2 + 3.7.0 - 1.8 - 1.8 + 10 + 10 From d1272b5071eaef02ace5b9a1595a5b557d6d587f Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 26 Sep 2018 09:23:20 +0300 Subject: [PATCH 579/605] Revert "updating pom for java 10" This reverts commit 0a89f831d17757676badfb02c1d2d1cf5fef46a1. --- pom.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index c085acacb..0a321525a 100644 --- a/pom.xml +++ b/pom.xml @@ -15,10 +15,8 @@ jar - 10 + 1.8 1.8.10 - 10 - 10 @@ -267,10 +265,10 @@ maven-compiler-plugin - 3.7.0 + 2.3.2 - 10 - 10 + 1.8 + 1.8 From 9b6b01a735b56516effd43d947bacb456112c7b0 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 26 Sep 2018 09:45:45 +0300 Subject: [PATCH 580/605] comment back java10 related code --- .../five_zero_two/IngestVodOpcTests.java | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index c20c78080..0e78906dc 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -5,7 +5,6 @@ import com.kaltura.client.services.PpvService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.BaseUtils; import com.kaltura.client.test.utils.KsqlBuilder; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; @@ -19,7 +18,6 @@ import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -353,37 +351,37 @@ public void insertWithInvalidCredentials() { assertThat(from(resp.asString()).getString(ingestStatusPath)).isEqualTo(status); } - @Severity(SeverityLevel.NORMAL) - @Test(description = "try insert with invalid meta or tag field") - public void insertWithInvalidMetaOrTagField() { - String suffix = "_" + getEpoch(); - VodData vodData = getVodData(MOVIE, INSERT); - - String updatedField = mediaNumberFieldName + suffix; - vodData.numbers(Map.of(updatedField, getRandomDouble())); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.numbers(Map.of()); - - updatedField = mediaBooleanFieldName + suffix; - vodData.booleans(Map.of(updatedField, getRandomBoolean())); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.booleans(Map.of()); - - updatedField = mediaTagFieldName + suffix; - vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); - assertInvalidMovieField(vodData, updatedField, "tag"); - vodData.tags(Map.of()); - - updatedField = mediaTextFieldName + suffix; - vodData.strings(Map.of(updatedField, getRandomString())); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.strings(Map.of()); - - updatedField = mediaDateFieldName + suffix; - vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); - assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.dates(Map.of()); - } +// @Severity(SeverityLevel.NORMAL) +// @Test(description = "try insert with invalid meta or tag field") +// public void insertWithInvalidMetaOrTagField() { +// String suffix = "_" + getEpoch(); +// VodData vodData = getVodData(MOVIE, INSERT); +// +// String updatedField = mediaNumberFieldName + suffix; +// vodData.numbers(Map.of(updatedField, getRandomDouble())); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.numbers(Map.of()); +// +// updatedField = mediaBooleanFieldName + suffix; +// vodData.booleans(Map.of(updatedField, getRandomBoolean())); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.booleans(Map.of()); +// +// updatedField = mediaTagFieldName + suffix; +// vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); +// assertInvalidMovieField(vodData, updatedField, "tag"); +// vodData.tags(Map.of()); +// +// updatedField = mediaTextFieldName + suffix; +// vodData.strings(Map.of(updatedField, getRandomString())); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.strings(Map.of()); +// +// updatedField = mediaDateFieldName + suffix; +// vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); +// assertInvalidMovieField(vodData, updatedField, "meta"); +// vodData.dates(Map.of()); +// } @Severity(SeverityLevel.NORMAL) @Test(description = "insert multilingual fields", enabled = false) From 1af594ec3f4237e7a7e19fc529733b072cd0fc6f Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 10:29:25 +0300 Subject: [PATCH 581/605] change java source to 10 in pom --- pom.xml | 11 ++++++++++- .../test/utils/ingestUtils/IngestVodUtils.java | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 52bcb1082..524233ef0 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ jar - 1.8 + 1.10 1.8.10 @@ -365,6 +365,15 @@ + + + + + + + + + diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 8f3d5cfa6..4c021ba7b 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -74,6 +74,7 @@ public static class VodData { private Map dates; private Map numbers; private Map booleans; + private Map multiLingualName; private List thumbRatios; private List files; @@ -122,9 +123,6 @@ public static class VodFile { @Setter private String ppvModule; - - public VodFile() {} - public VodFile(String type, String ppvModule) { quality = "HIGH"; handling_type = "CLIP"; @@ -139,7 +137,6 @@ public VodFile(String type, String ppvModule) { this.type = type; this.ppvModule = ppvModule; } - } /** @@ -303,6 +300,19 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { return uncommentCdataSection(docToString(doc)); } + // multilingual name + if (vodData.multiLingualName() != null) { + vodData.name(null); + + Element nameElement = (Element) media.getElementsByTagName("name").item(0); + vodData.multiLingualName().forEach((lang, name) -> { + Element value = doc.createElement("value"); + value.setAttribute("lang", lang); + value.setTextContent(name); + nameElement.appendChild(value); + }); + } + // name if (vodData.name() != null) { Element nameElement = (Element) media.getElementsByTagName("name").item(0); From 0180bcf29dd94b6e9da239a0fa1b4a4a65c5fa3f Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 10:34:20 +0300 Subject: [PATCH 582/605] no message --- pom.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 524233ef0..96325b1b8 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ jar - 1.10 + 1.8 1.8.10 @@ -260,8 +260,8 @@ maven-compiler-plugin 2.3.2 - 1.10 - 1.10 + 1.8 + 1.8 @@ -365,14 +365,14 @@ - - - - - - - - + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + From b9ff0273cbef67c7c91e76dd0fcd41495b67d28a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 11:14:23 +0300 Subject: [PATCH 583/605] update pom to java 10 --- .gitignore | 1 + pom.xml | 20 +++++--------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 4870d616b..cd9787469 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ src/test/resources/db_utils_list.txt src/test/resources/utils_list.txt src/test/resources/testXml.xml logs/ +surefire/ diff --git a/pom.xml b/pom.xml index 96325b1b8..f35a4c3d3 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ jar - 1.8 + 1.10 1.8.10 @@ -257,11 +257,12 @@ + org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + 3.8.0 - 1.8 - 1.8 + 1.10 + 1.10 @@ -354,7 +355,6 @@ - io.qameta.allure allure-maven @@ -364,16 +364,6 @@ - - - org.apache.maven.plugins - maven-compiler-plugin - - 10 - 10 - - - From 0b06542edcab8892bc79b4c50285925e7183fd31 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 14:19:13 +0300 Subject: [PATCH 584/605] no message --- pom.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f35a4c3d3..f4297c70e 100644 --- a/pom.xml +++ b/pom.xml @@ -261,9 +261,15 @@ maven-compiler-plugin 3.8.0 - 1.10 - 1.10 + 10 + + + org.ow2.asm + asm + 6.2 + + From 02f5e89a9ed4fda5e9b66a07dc0d66d49c0a9c22 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 14:23:02 +0300 Subject: [PATCH 585/605] no message --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f4297c70e..186a1ba99 100644 --- a/pom.xml +++ b/pom.xml @@ -259,7 +259,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.7.0 10 From f01a2c9f2b8bbbb67861d7210e7b72bc09b6f725 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 14:25:36 +0300 Subject: [PATCH 586/605] no message --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 186a1ba99..f264da367 100644 --- a/pom.xml +++ b/pom.xml @@ -259,9 +259,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.8.0 - 10 + 1.10 + 1.10 From 61e87533bf48385afa1fbe5dfb960c32f025def8 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 14:26:44 +0300 Subject: [PATCH 587/605] no message --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f264da367..a8016bd3a 100644 --- a/pom.xml +++ b/pom.xml @@ -261,8 +261,8 @@ maven-compiler-plugin 3.8.0 - 1.10 - 1.10 + 10 + 10 From 2d58b93e0bb15ae579cdb9e7afaeb38a5f90e341 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 14:37:32 +0300 Subject: [PATCH 588/605] no message --- pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a8016bd3a..186a1ba99 100644 --- a/pom.xml +++ b/pom.xml @@ -259,10 +259,9 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.7.0 - 10 - 10 + 10 From bec599f9316c96770ae9087b5f39fa7b86737983 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 14:42:45 +0300 Subject: [PATCH 589/605] no message --- pom.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 186a1ba99..7779bdbe5 100644 --- a/pom.xml +++ b/pom.xml @@ -261,15 +261,16 @@ maven-compiler-plugin 3.7.0 - 10 + 1.9 + 1.9 - - - org.ow2.asm - asm - 6.2 - - + + + + + + + From 279a78e343b4e7d74b11ac6801d2655404811a77 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 14:43:55 +0300 Subject: [PATCH 590/605] no message --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7779bdbe5..2ab46e565 100644 --- a/pom.xml +++ b/pom.xml @@ -261,8 +261,8 @@ maven-compiler-plugin 3.7.0 - 1.9 - 1.9 + 1.8 + 1.8 From 93acf145813b71dc0891de59c153c0a7ba35138c Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 15:44:47 +0300 Subject: [PATCH 591/605] no message --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2ab46e565..24a45d064 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ jar - 1.10 + 1.9 1.8.10 @@ -261,8 +261,8 @@ maven-compiler-plugin 3.7.0 - 1.8 - 1.8 + 1.9 + 1.9 From 77d97ba65d63a440908edec042664240d3a43653 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 15:46:49 +0300 Subject: [PATCH 592/605] no message --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 24a45d064..432aec05a 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ jar - 1.9 + 1.10 1.8.10 @@ -259,10 +259,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.8.0 - 1.9 - 1.9 + 1.10 + 1.10 From 845ffd06ec5e77fe451d0ab653b0432cdd15292a Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 26 Sep 2018 17:08:20 +0300 Subject: [PATCH 593/605] no message --- pom.xml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 432aec05a..856ca6371 100644 --- a/pom.xml +++ b/pom.xml @@ -242,7 +242,6 @@ - @@ -256,6 +255,7 @@ true + org.apache.maven.plugins maven-compiler-plugin @@ -264,13 +264,6 @@ 1.10 1.10 - - - - - - - From 43c38344afaa17fa5b8483c86afb873d8e704ecb Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 26 Sep 2018 23:07:29 +0300 Subject: [PATCH 594/605] adding alwaysRun to slow tests --- .../AssetListTests/SearchAssetFilterTests.java | 2 +- .../servicesTests/appTokenTests/AppTokenAddTests.java | 2 +- .../assetHistoryTests/AssetHistoryCleanTests.java | 10 +++++----- .../assetHistoryTests/AssetHistoryListTests.java | 10 +++++----- .../servicesTests/bookmarkTests/BookmarkAddTests.java | 10 +++++----- .../servicesTests/bookmarkTests/BookmarkListTests.java | 2 +- .../householdTests/HouseholdSuspendTests.java | 2 +- .../ottUserTests/OttUserLoginWithPinTests.java | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 9830e1038..c693a1596 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -368,7 +368,7 @@ private void orderVodAssetsByViews_before_wait() { } @Severity(SeverityLevel.CRITICAL) @Description("asset/action/list - VOD - order by VIEWS") - @Test(groups = "slowAfter", dependsOnGroups = "slowBefore") + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void orderVodAssetsByViews_after_wait() { String query = new KsqlBuilder() .openOr() diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java index b886e3b15..15d7cbd1c 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/appTokenTests/AppTokenAddTests.java @@ -107,7 +107,7 @@ private void addAppTokenWithExpiryDate_before_wait() { } - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void addAppTokenWithExpiryDate_after_wait() { // prepare builder and variables for await() functionality GetAppTokenBuilder getAppTokenBuilder = AppTokenService.get(addAppTokenResponseSlowTest.results.getId()) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index 9d2eb6779..f4b7a197d 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -100,7 +100,7 @@ private void cleanHistory_before_wait() { } @Description("assetHistory/action/clean - no filtering") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void cleanHistory_after_wait() { // assetHistory/action/list - both assets should returned AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -170,7 +170,7 @@ private void cleanSpecifcAssetHistory_before_wait() { } @Description("assetHistory/action/clean - filtered by asset id") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void cleanSpecifcAssetHistory_after_wait() { // assetHistory/action/clean AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -239,7 +239,7 @@ private void cleanSpecifcAssetTypeHistory_before_wait() { } @Description("assetHistory/action/clean - filtered by asset type") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void cleanSpecifcAssetTypeHistory_after_wait() { //assetHistory/action/clean - only episode type (episode) AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -308,7 +308,7 @@ private void cleanAssetsAccordingToWatchStatusDone_before_wait() { } @Description("assetHistory/action/clean - filtered by asset finished") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void cleanAssetsAccordingToWatchStatusDone_after_wait() { //assetHistory/action/clean - only asset that were finished (episode) AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -375,7 +375,7 @@ private void cleanAssetsAccordingToWatchStatusProgress_before_wait() { } @Description("assetHistory/action/clean - filtered by asset in progress") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void cleanAssetsAccordingToWatchStatusProgress_after_wait() { // assetHistory/action/clean - only asset that in progress (movie) AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java index 96a7d7072..6be9373b0 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryListTests.java @@ -101,7 +101,7 @@ private void assetHistory_vod_with_one_device_and_two_media_before_wait() { } @Description("assetHistory/action/list - with no filter and one device and two media") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void assetHistory_vod_with_one_device_and_two_media_after_wait() { // assetHistory/action/list - both assets should returned AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -185,7 +185,7 @@ private void assetHistory_vod_with_two_devices_and_one_media_before_wait() { } @Description("assetHistory/action/list - with no filter and two devices and one media") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void assetHistory_vod_with_two_devices_and_one_media_after_wait() { // assetHistory/action/list - both assets should returned AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -265,7 +265,7 @@ private void vodAssetHistoryFilteredByAssetId_before_wait() { } @Description("assetHistory/action/list - filtered by movie asset id") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void vodAssetHistoryFilteredByAssetId_after_wait() { //assetHistory/action/list - filter by asset 2 id AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -336,7 +336,7 @@ private void vodAssetHistoryFilteredByAssetType_before_wait() { } @Description("assetHistory/action/list - filtered by movie type id") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void vodAssetHistoryFilteredByAssetType_after_wait() { //assetHistory/action/list - filter by in progress assets only AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); @@ -397,7 +397,7 @@ private void vodAssetHistoryFilteredByAssetProgress_before_wait() { } @Description("assetHistory/action/list - filtered by assets progress") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void vodAssetHistoryFilteredByAssetProgress_after_wait() { //assetHistory/action/list - filter by in progress assets only AssetHistoryFilter assetHistoryFilter = new AssetHistoryFilter(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java index 0f1a87a10..cda95feb2 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkAddTests.java @@ -64,7 +64,7 @@ private void firstPlayback_before_wait() { assertThat(booleanResponse.error).isNull(); } @Description("bookmark/action/add - first play") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void firstPlayback_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; @@ -118,7 +118,7 @@ private void pausePlayback_before_wait() { } @Description("bookmark/action/add - pause") - @Test(groups = {"slowAfter"}, dependsOnMethods = {"pausePlayback_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"pausePlayback_before_wait"}, alwaysRun = true) private void pausePlayback_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; @@ -156,7 +156,7 @@ private void watchingNinetyFive_before_wait() { } @Description("bookmark/action/add - 95% watching == finish watching") - @Test(groups = {"slowAfter"}, dependsOnMethods = {"watchingNinetyFive_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"watchingNinetyFive_before_wait"}, alwaysRun = true) private void watchingNinetyFive_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; @@ -192,7 +192,7 @@ private void backToStart_before_wait() { } @Description("bookmark/action/add - back to start - position:0") - @Test(groups = {"slowAfter"}, dependsOnMethods = {"backToStart_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"backToStart_before_wait"}, alwaysRun = true) private void backToStart_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; @@ -230,7 +230,7 @@ private void finishWatching_before_wait() { } @Description("bookmark/action/add - finish watching") - @Test(groups = {"slowAfter"}, dependsOnMethods = {"finishWatching_before_wait"}) + @Test(groups = {"slowAfter"}, dependsOnMethods = {"finishWatching_before_wait"}, alwaysRun = true) private void finishWatching_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 15; diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java index a91135077..8001675cd 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/bookmarkTests/BookmarkListTests.java @@ -88,7 +88,7 @@ private void BookmarkOrderBy_before_wait() { } @Description("bookmark/action/list - order by") - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void BookmarkOrderBy_after_wait() { // set filter BookmarkFilter bookmarkFilter = BookmarkUtils.listBookmark(BookmarkOrderBy.POSITION_DESC,AssetType.MEDIA, assetList); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java index 08d281e0b..f6f239ac6 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/householdTests/HouseholdSuspendTests.java @@ -463,7 +463,7 @@ private void suspend_with_renew_subscription_role_before_wait() { assertThat(booleanResponse.results).isTrue(); } - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void suspend_with_renew_subscription_role_after_wait() { // get productprice list for asset in subscription - after renew Asset asset = SubscriptionUtils.getAssetsListBySubscription(Integer.parseInt(fiveMinRenewSubscriptionSlowTest.getId()), Optional.empty(), false).get(0); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java index a3915ad61..0beb4c3bf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/ottUserTests/OttUserLoginWithPinTests.java @@ -91,7 +91,7 @@ private void loginWithPin_with_expired_pinCode_before_wait() { userLoginPinResponse = executor.executeSync(addUserLoginPinBuilder); } - @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}) + @Test(groups = {"slowAfter"}, dependsOnGroups = {"slowBefore"}, alwaysRun = true) private void loginWithPin_with_expired_pinCode_after_wait() { // prepare variables for await() functionality int delayBetweenRetriesInSeconds = 10; From 0ff8ec4b8e5f05cae9501800b4f1aa61ff53aee4 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Thu, 27 Sep 2018 00:34:46 +0300 Subject: [PATCH 595/605] Completed test createInheritance() --- .../ParentChildMetadataInheritanceTests.java | 172 ++++++++++++------ .../test/utils/AssetStructMetaUtils.java | 23 +++ .../test/utils/dbUtils/DBConstants.java | 6 + .../client/test/utils/dbUtils/DBUtils.java | 60 +++++- 4 files changed, 202 insertions(+), 59 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 910b5e04b..70f0f7e63 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -1,17 +1,9 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; -import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.*; -import com.kaltura.client.services.AssetService.RemoveMetasAndTagsAssetBuilder; -import com.kaltura.client.services.AssetService.GetAssetBuilder; -import com.kaltura.client.services.AssetStructMetaService.ListAssetStructMetaBuilder; -import com.kaltura.client.services.AssetStructMetaService.UpdateAssetStructMetaBuilder; -import com.kaltura.client.services.AssetStructService.AddAssetStructBuilder; -import com.kaltura.client.services.AssetStructService.DeleteAssetStructBuilder; -import com.kaltura.client.services.AssetStructService.ListAssetStructBuilder; -import com.kaltura.client.services.AssetStructService.UpdateAssetStructBuilder; +import com.kaltura.client.services.AssetStructService.*; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Link; @@ -20,16 +12,10 @@ import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; -import java.util.Set; -import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; -import static com.kaltura.client.test.tests.enums.MediaType.MOVIE; -import static com.kaltura.client.test.utils.AssetStructMetaUtils.getAssetStructMeta; + +import static com.kaltura.client.test.utils.AssetStructMetaUtils.loadAssetStructMeta; import static com.kaltura.client.test.utils.AssetStructUtils.getAssetStruct; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; -import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMetaIdByName; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; /** @@ -43,34 +29,43 @@ public class ParentChildMetadataInheritanceTests extends BaseTest { private String metaIds; private Response> sharedAssetStructListResponse; private AssetStruct sharedAssetStruct1, sharedAssetStruct2; + private AssetStructMeta sharedMetaString1, sharedMetaString2, sharedMetaNumber1, sharedMetaNumber2; + private AssetStructMeta sharedMetaDate1, sharedMetaDate2, sharedMetaBoolean1, sharedMetaBoolean2; + private String sharedBasicMetaIds; @BeforeClass() public void setUp() { // TODO: check if assetStructList be useful at the end // assetStructList to fill default metaIds - AssetStructFilter filter = new AssetStructFilter(); - ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); - sharedAssetStructListResponse = executor.executeSync(listAssetStructBuilder - .setKs(getOperatorKs())); - assertThat(sharedAssetStructListResponse.results.getTotalCount()).isGreaterThan(0); - metaIds = sharedAssetStructListResponse.results.getObjects().get(0).getMetaIds(); +// AssetStructFilter filter = new AssetStructFilter(); +// ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); +// sharedAssetStructListResponse = executor.executeSync(listAssetStructBuilder +// .setKs(getOperatorKs())); +// assertThat(sharedAssetStructListResponse.results.getTotalCount()).isGreaterThan(0); +// metaIds = sharedAssetStructListResponse.results.getObjects().get(0).getMetaIds(); + + // identify shared assetStructMetas + List assetStructNames = DBUtils.getAllAssetStructMetas("", 2); + sharedMetaString1 = loadAssetStructMeta(assetStructNames.get(0)); + sharedMetaString2 = loadAssetStructMeta(assetStructNames.get(1)); + sharedMetaNumber1 = loadAssetStructMeta(assetStructNames.get(2)); + sharedMetaNumber2 = loadAssetStructMeta(assetStructNames.get(3)); + sharedMetaDate1 = loadAssetStructMeta(assetStructNames.get(4)); + sharedMetaDate2 = loadAssetStructMeta(assetStructNames.get(5)); + sharedMetaBoolean1 = loadAssetStructMeta(assetStructNames.get(6)); + sharedMetaBoolean2 = loadAssetStructMeta(assetStructNames.get(7)); + // TODO: ask Lior why ONLY these ids are obvious when DB has more basic metas? + sharedBasicMetaIds = "58,629,1482,1493,1494,1495,1496,1497,566";//loadBasicAssetStructMetaId(); // create shared assetStruct1 String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); - sharedAssetStruct1 = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); - AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(sharedAssetStruct1); - Response assetStructResponse = executor.executeSync(addAssetStructBuilder - .setKs(getOperatorKs()).setLanguage("*")); - sharedAssetStruct1 = assetStructResponse.results; - assertThat(sharedAssetStruct1.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); + String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + sharedAssetStruct1 = createAssetStruct(prefix, metaIds); + // create shared assetStruct2 prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; - sharedAssetStruct2 = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); - addAssetStructBuilder = AssetStructService.add(sharedAssetStruct2); - assetStructResponse = executor.executeSync(addAssetStructBuilder - .setKs(getOperatorKs()).setLanguage("*")); - sharedAssetStruct2 = assetStructResponse.results; - assertThat(sharedAssetStruct2.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); + metaIds = sharedMetaString2.getMetaId().toString() + "," + sharedBasicMetaIds; + sharedAssetStruct2 = createAssetStruct(prefix, metaIds); } @Test @@ -93,29 +88,78 @@ public void testAssetStructListSecurity() { @Test public void testCreateInheritance() { - // add assetStruct1 with fields to connect - // add assetStruct2 with fields to connect - // check fields have link as it can be done in API and additionally on Tvm + // create assetStruct1 + String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + AssetStruct assetStruct1 = createAssetStruct(prefix, metaIds); + // create assetStruct2 + metaIds = sharedMetaString2.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; + AssetStruct assetStruct2 = createAssetStruct(prefix, metaIds); + // set inheritance + AssetStruct assetStruct2Update = copyAssetStructObject(assetStruct2); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStruct1.getId(), + sharedMetaString1.getMetaId(), sharedMetaString2.getMetaId()); + updateAssetStruct(assetStruct2.getId(), assetStruct2Update); - List assetStructs = loadAssetStructsWithoutHierarchy(3, sharedAssetStructListResponse.results.getObjects()); - AssetStruct assetStructGrandParent = assetStructs.get(0); - AssetStruct assetStructParent = assetStructs.get(1); - AssetStruct assetStructChildren = assetStructs.get(2); + // check parent doesn't have changes in related inheritance fields + AssetStructFilter filter = new AssetStructFilter(); + filter.setIdIn(assetStruct1.getId().toString()); + ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); + Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + AssetStruct assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); + assertThat(assetStructFromResponse.getParentId()).isEqualTo(0L); + assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(0L); + assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(0L); - /*System.out.println(assetStructGrandParent.getId()); - System.out.println(assetStructParent.getId()); - System.out.println(assetStructChildren.getId()); + // check children asset struct has changes + filter.setIdIn(assetStruct2.getId().toString()); + listAssetStructBuilder = AssetStructService.list(filter); + assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); + assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStruct1.getId()); + assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); + assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); - System.out.println(assetStructGrandParent.getMetaIds()); - System.out.println(assetStructParent.getMetaIds()); - System.out.println(assetStructChildren.getMetaIds());*/ + // remove assetStructs + deleteAssetStruct(assetStruct2.getId()); // firstly should be deleted children + deleteAssetStruct(assetStruct1.getId()); + } + + AssetStruct copyAssetStructObject(AssetStruct assetStruct2Copy) { + AssetStruct result = new AssetStruct(); + result.setConnectedParentMetaId(assetStruct2Copy.getConnectedParentMetaId()); + result.setConnectingMetaId(assetStruct2Copy.getConnectingMetaId()); + result.setParentId(assetStruct2Copy.getParentId()); + result.setMetaIds(assetStruct2Copy.getMetaIds()); + result.setSystemName(assetStruct2Copy.getSystemName()); + result.setIsProtected(assetStruct2Copy.getIsProtected()); + result.setPluralName(assetStruct2Copy.getPluralName()); + result.setMultilingualName(assetStruct2Copy.getMultilingualName()); + result.setFeatures(assetStruct2Copy.getFeatures()); + + return result; + } - // TODO: complete - //assetStructParent.setConnectedParentMetaId(); - //UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update(assetStructParent.getId(), assetStructParent); + void setInheritanceFieldsInAssetStruct(AssetStruct assetStruct, Long parentAssetStructId, + Long connectedParentMetaId, Long connectingMetaId) { + assetStruct.setParentId(parentAssetStructId); + assetStruct.setConnectedParentMetaId(connectedParentMetaId); + assetStruct.setConnectingMetaId(connectingMetaId); } + void updateAssetStruct(Long assetStructId, AssetStruct updatedAssetStruct) { + UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update( + assetStructId, updatedAssetStruct); + Response assetStructResponse = executor.executeSync(updateAssetStructBuilder + .setKs(getOperatorKs()).setLanguage("*")); + assertThat(assetStructResponse.results).isNotNull(); + } + + // TODO: Check if it used after implementation private List loadAssetStructsWithoutHierarchy(int countOfAssetStructs, List listOfAssetStructs) { List result = new ArrayList<>(); for (AssetStruct assetStruct: listOfAssetStructs) { @@ -252,14 +296,28 @@ private List loadAssetStructsWithoutHierarchy(int countOfAssetStruc @AfterClass() public void tearDown() { // cleaning created shared assetStructs - DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(sharedAssetStruct1.getId()); + deleteAssetStruct(sharedAssetStruct1.getId()); + deleteAssetStruct(sharedAssetStruct2.getId()); + } + + void deleteAssetStruct(Long assetStructId) { + DeleteAssetStructBuilder deleteAssetStructBuilder = AssetStructService.delete(assetStructId); Response deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder .setKs(getOperatorKs())); assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); + } - deleteAssetStructBuilder = AssetStructService.delete(sharedAssetStruct2.getId()); - deleteAssetStructResponse = executor.executeSync(deleteAssetStructBuilder - .setKs(getOperatorKs())); - assertThat(deleteAssetStructResponse.results.booleanValue()).isEqualTo(true); + AssetStruct createAssetStruct(String prefix, String metaIds) { + AssetStruct result = getAssetStruct(prefix, "eng", false, metaIds, null, + null, null); + + AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(result); + Response assetStructResponse = executor.executeSync(addAssetStructBuilder + .setKs(getOperatorKs()).setLanguage("*")); + result = assetStructResponse.results; + + assertThat(result.getSystemName()).isEqualToIgnoringCase(prefix + "_System_name"); + + return result; } } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java index 5cf032182..68fd8c5b2 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java @@ -1,9 +1,32 @@ package com.kaltura.client.test.utils; +import com.kaltura.client.services.AssetStructMetaService; +import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.types.AssetStructMeta; +import com.kaltura.client.types.AssetStructMetaFilter; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.utils.response.base.Response; + +import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; public class AssetStructMetaUtils extends BaseUtils { + public static TestAPIOkRequestsExecutor executor = TestAPIOkRequestsExecutor.getExecutor(); + + public static AssetStructMeta loadAssetStructMeta(String metaName) { + Long metaId = DBUtils.getMetaIdByName(metaName, false); + AssetStructMetaFilter assetStructMetaFilter = new AssetStructMetaFilter(); + //assetStructMetaFilter.setAssetStructIdEqual(assetStructId); + assetStructMetaFilter.setMetaIdEqual(metaId); + AssetStructMetaService.ListAssetStructMetaBuilder listAssetStructMetaBuilder = AssetStructMetaService.list(assetStructMetaFilter); + Response> listAssetMetaStructResponse = executor.executeSync(listAssetStructMetaBuilder + .setKs(getOperatorKs())); + + return listAssetMetaStructResponse.results.getObjects().get(0); + } + + // TODO: probably can be useless as we do not have assetStructMeta/Add (only list and update) public static AssetStructMeta getAssetStructMeta(String defaultIngestValue, String ingestReferencePath, boolean isProtectFromIngest, boolean isInherited) { AssetStructMeta assetStructMeta = new AssetStructMeta(); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 8c71456fa..6d72d3157 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -36,6 +36,9 @@ public class DBConstants { static final String AND_ACTIVE_STATUS = " and u.activate_status=1"; + static final String BASIC_META_SELECT = "SELECT * FROM [TVinci].[dbo].[topics]\n" + + "WHERE [STATUS]=1 AND IS_BASIC=1 AND GROUP_ID=?\n"; + static final String RESET_PASSWORD_TOKEN_SELECT = "SELECT [CP_TOKEN] FROM [Users].[dbo].[users] WHERE [USERNAME] = ?"; static final String CHANNEL_EXPRESSION_SELECT = "select t.tag_type_id as tag_name, t.value as tag_value\n" + @@ -84,6 +87,9 @@ public class DBConstants { "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=? and is_active=1 and [status]=1 order by UPDATE_DATE DESC"; + static final String META_SELECT = "SELECT TOP (?) * FROM [TVinci].[dbo].[topics]\n" + + "WHERE IS_BASIC=? AND GROUP_ID=? AND [STATUS]=1"; + static final String META_OR_TAG_SELECT_BY_NAME = "SELECT * FROM [TVinci].[dbo].[topics]\n" + "WHERE [STATUS]=1 AND GROUP_ID=? AND SYSTEM_NAME=?\n"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 4eee921ba..a765d241d 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -15,6 +15,7 @@ import javax.annotation.Nonnull; import java.sql.*; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -320,10 +321,65 @@ public static List getPpvNames(int amount) { .collect(Collectors.toList()); } - public static int getMetaIdByName(String metaName, boolean processBasicFields) { + public static Long getMetaIdByName(String metaName, boolean processBasicFields) { JSONObject jsonObject = getJsonArrayFromQueryResult(META_OR_TAG_SELECT_BY_NAME, partnerId, metaName) .getJSONObject(0); - return (processBasicFields || (jsonObject.getInt(IS_BASIC) == 0)) ? jsonObject.getInt(ID) : -1; + return (processBasicFields || (jsonObject.getInt(IS_BASIC) == 0)) ? jsonObject.getLong(ID) : -1; + } + + // TODO: check if it be used after completing functionality + public static Long loadBasicAssetStructMetaId() { + return getJsonArrayFromQueryResult(BASIC_META_SELECT, partnerId) + .getJSONObject(0) + .getLong(ID); + } + + public static List getAllAssetStructMetas(String type, int countItems) { + List result = new ArrayList<>(); + // TODO: ask developers about ids for assetStructMeta types + List idTypes = new ArrayList<>(); + idTypes.add(6); + idTypes.add(2); + idTypes.add(5); + idTypes.add(3); + int idOfType =-1; + switch (type) { + case "Text": + idOfType = idTypes.get(0); + break; + case "Number": + idOfType = idTypes.get(1); + break; + case "Date": + idOfType = idTypes.get(2); + break; + case "Boolean": + idOfType = idTypes.get(3); + break; + default: + // all types + break; + } + + JSONArray dbResult; + if (idOfType ==-1) { + // if type was not specified + for (int i=0; i < idTypes.size(); i++) { + dbResult = getJsonArrayFromQueryResult(META_SELECT, countItems, 0, partnerId); + addSystemNamesFromResponse2List(result, dbResult); + } + } else { + dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idOfType); + addSystemNamesFromResponse2List(result, dbResult); + } + + return result; + } + + static void addSystemNamesFromResponse2List(List result, JSONArray dbResult) { + for (int i=0; i < dbResult.length(); i++) { + result.add(dbResult.getJSONObject(i).getString("system_name")); + } } } From 6055811e5225c21df69df7e29f49d67cc66945af Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Thu, 27 Sep 2018 16:25:40 +0300 Subject: [PATCH 596/605] ingest vod utils added multilingual support to VodData object --- .../five_zero_two/IngestVodOpcTests.java | 64 +++---- .../AssetTests/AssetCountTests.java | 4 +- .../SearchAssetFilterTests.java | 4 +- .../utils/ingestUtils/IngestVodOpcUtils.java | 8 +- .../utils/ingestUtils/IngestVodUtils.java | 164 +++++++++++++----- src/test/resources/schemas/Language.json | 49 ++++++ src/test/resources/schemas/ListResponse.json | 6 +- 7 files changed, 214 insertions(+), 85 deletions(-) create mode 100644 src/test/resources/schemas/Language.json diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 2e06874b5..e5db8165a 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -64,10 +64,10 @@ public void insertVodMediaTagFieldName() { assertThat(movie.getName()).isEqualTo(vodData.name()); assertThat(movie.getDescription()).isEqualTo(vodData.description()); - assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(vodData.strings().get(mediaTextFieldName)); - assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(mediaNumberFieldName)); - assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(mediaDateFieldName)); - assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(mediaBooleanFieldName)); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(vodData.stringsMeta().get(mediaTextFieldName)); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(vodData.numbersMeta().get(mediaNumberFieldName)); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.datesMeta().get(mediaDateFieldName)); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(vodData.booleansMeta().get(mediaBooleanFieldName)); assertThat(movie.getTags().get(mediaTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(mediaTagFieldName)); assertFiles(vodData.files(), movie.getId().toString()); assertThat(movie.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); @@ -111,10 +111,10 @@ public void updateVodMediaBaseFieldsWithoutErase() { assertThat(movie.getName()).isEqualTo(vodData.name()); assertThat(movie.getDescription()).isEqualTo(vodData.description()); - assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(vodData.strings().get(mediaTextFieldName)); - assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(mediaNumberFieldName)); - assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(mediaDateFieldName)); - assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(mediaBooleanFieldName)); + assertThat(((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(vodData.stringsMeta().get(mediaTextFieldName)); + assertThat(((DoubleValue)movie.getMetas().get(mediaNumberFieldName)).getValue()).isEqualTo(vodData.numbersMeta().get(mediaNumberFieldName)); + assertThat(getFormattedDate(((LongValue)movie.getMetas().get(mediaDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.datesMeta().get(mediaDateFieldName)); + assertThat(((BooleanValue)movie.getMetas().get(mediaBooleanFieldName)).getValue()).isEqualTo(vodData.booleansMeta().get(mediaBooleanFieldName)); assertThat(movie.getTags().get(mediaTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(mediaTagFieldName)); assertFiles(vodData.files(), movie.getId().toString()); assertThat(movie.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); @@ -128,10 +128,10 @@ public void insertVodEpisodeBaseFields() { assertThat(episode.getName()).isEqualTo(vodData.name()); assertThat(episode.getDescription()).isEqualTo(vodData.description()); - assertThat(((MultilingualStringValue) episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(vodData.strings().get(episodeTextFieldName)); - assertThat(((DoubleValue) episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(episodeNumberFieldName)); - assertThat(getFormattedDate(((LongValue) episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(episodeDateFieldName)); - assertThat(((BooleanValue) episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(episodeBooleanFieldName)); + assertThat(((MultilingualStringValue) episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(vodData.stringsMeta().get(episodeTextFieldName)); + assertThat(((DoubleValue) episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(vodData.numbersMeta().get(episodeNumberFieldName)); + assertThat(getFormattedDate(((LongValue) episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.datesMeta().get(episodeDateFieldName)); + assertThat(((BooleanValue) episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(vodData.booleansMeta().get(episodeBooleanFieldName)); assertThat(episode.getTags().get(episodeTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(episodeTagFieldName)); assertFiles(vodData.files(), episode.getId().toString()); assertThat(episode.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); @@ -148,10 +148,10 @@ public void insertVodSeriesBaseFields() { assertThat(series.getName()).isEqualTo(vodData.name()); assertThat(series.getDescription()).isEqualTo(vodData.description()); - assertThat(((StringValue) series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(vodData.strings().get(seriesTextFieldName)); - assertThat(((DoubleValue) series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(seriesNumberFieldName)); - assertThat(getFormattedDate(((LongValue) series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(seriesDateFieldName)); - assertThat(((BooleanValue) series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(seriesBooleanFieldName)); + assertThat(((StringValue) series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(vodData.stringsMeta().get(seriesTextFieldName)); + assertThat(((DoubleValue) series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(vodData.numbersMeta().get(seriesNumberFieldName)); + assertThat(getFormattedDate(((LongValue) series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.datesMeta().get(seriesDateFieldName)); + assertThat(((BooleanValue) series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(vodData.booleansMeta().get(seriesBooleanFieldName)); assertThat(series.getTags().get(seriesTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(seriesTagFieldName)); assertFiles(vodData.files(), series.getId().toString()); assertThat(series.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); @@ -170,10 +170,10 @@ public void updateVodEpisodeBaseFields() { assertThat(episode.getName()).isEqualTo(vodData.name()); assertThat(episode.getDescription()).isEqualTo(vodData.description()); - assertThat(((MultilingualStringValue) episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(vodData.strings().get(episodeTextFieldName)); - assertThat(((DoubleValue) episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(episodeNumberFieldName)); - assertThat(getFormattedDate(((LongValue) episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(episodeDateFieldName)); - assertThat(((BooleanValue) episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(episodeBooleanFieldName)); + assertThat(((MultilingualStringValue) episode.getMetas().get(episodeTextFieldName)).getValue()).isEqualTo(vodData.stringsMeta().get(episodeTextFieldName)); + assertThat(((DoubleValue) episode.getMetas().get(episodeNumberFieldName)).getValue()).isEqualTo(vodData.numbersMeta().get(episodeNumberFieldName)); + assertThat(getFormattedDate(((LongValue) episode.getMetas().get(episodeDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.datesMeta().get(episodeDateFieldName)); + assertThat(((BooleanValue) episode.getMetas().get(episodeBooleanFieldName)).getValue()).isEqualTo(vodData.booleansMeta().get(episodeBooleanFieldName)); assertThat(episode.getTags().get(episodeTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(episodeTagFieldName)); // assertFiles(vodData.files(), episode.getId().toString()); assertThat(episode.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); @@ -189,10 +189,10 @@ public void updateVodSeriesBaseFields() { assertThat(series.getName()).isEqualTo(vodData.name()); assertThat(series.getDescription()).isEqualTo(vodData.description()); - assertThat(((StringValue) series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(vodData.strings().get(seriesTextFieldName)); - assertThat(((DoubleValue) series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(vodData.numbers().get(seriesNumberFieldName)); - assertThat(getFormattedDate(((LongValue) series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.dates().get(seriesDateFieldName)); - assertThat(((BooleanValue) series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(vodData.booleans().get(seriesBooleanFieldName)); + assertThat(((StringValue) series.getMetas().get(seriesTextFieldName)).getValue()).isEqualTo(vodData.stringsMeta().get(seriesTextFieldName)); + assertThat(((DoubleValue) series.getMetas().get(seriesNumberFieldName)).getValue()).isEqualTo(vodData.numbersMeta().get(seriesNumberFieldName)); + assertThat(getFormattedDate(((LongValue) series.getMetas().get(seriesDateFieldName)).getValue(), getTimeZone("UTC"), "MM/dd/yyyy")).isEqualTo(vodData.datesMeta().get(seriesDateFieldName)); + assertThat(((BooleanValue) series.getMetas().get(seriesBooleanFieldName)).getValue()).isEqualTo(vodData.booleansMeta().get(seriesBooleanFieldName)); assertThat(series.getTags().get(seriesTagFieldName).getObjects()).extracting("value").containsExactlyElementsOf(vodData.tags().get(seriesTagFieldName)); // assertFiles(vodData.files(), series.getId().toString()); assertThat(series.getImages()).extracting("ratio").containsAll(vodData.thumbRatios()); @@ -360,14 +360,14 @@ public void insertWithInvalidMetaOrTagField() { VodData vodData = getVodData(MOVIE, INSERT); String updatedField = mediaNumberFieldName + suffix; - vodData.numbers(Map.of(updatedField, getRandomDouble())); + vodData.numbersMeta(Map.of(updatedField, getRandomDouble())); assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.numbers(Map.of()); + vodData.numbersMeta(Map.of()); updatedField = mediaBooleanFieldName + suffix; - vodData.booleans(Map.of(updatedField, getRandomBoolean())); + vodData.booleansMeta(Map.of(updatedField, getRandomBoolean())); assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.booleans(Map.of()); + vodData.booleansMeta(Map.of()); updatedField = mediaTagFieldName + suffix; vodData.tags(Map.of(updatedField, List.of(String.valueOf(getEpochInMillis())))); @@ -375,14 +375,14 @@ public void insertWithInvalidMetaOrTagField() { vodData.tags(Map.of()); updatedField = mediaTextFieldName + suffix; - vodData.strings(Map.of(updatedField, getRandomString())); + vodData.stringsMeta(Map.of(updatedField, getRandomString())); assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.strings(Map.of()); + vodData.stringsMeta(Map.of()); updatedField = mediaDateFieldName + suffix; - vodData.dates(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); + vodData.datesMeta(Map.of(updatedField, BaseUtils.getCurrentDateInFormat("yyyyMMddHHmmss"))); assertInvalidMovieField(vodData, updatedField, "meta"); - vodData.dates(Map.of()); + vodData.datesMeta(Map.of()); } @Severity(SeverityLevel.NORMAL) diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java index d1b1d06fa..4e6239b88 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetCountTests.java @@ -70,7 +70,7 @@ private void asset_count_before_class() { // ingest asset 1 VodData vodData1 = new VodData() .mediaType(MOVIE) - .strings(stringMetaMap) + .stringsMeta(stringMetaMap) .tags(stringTagMap); asset = insertVod(vodData1, true); @@ -82,7 +82,7 @@ private void asset_count_before_class() { // ingest asset 2 VodData vodData2 = new VodData() .mediaType(MOVIE) - .strings(stringMetaMap2); + .stringsMeta(stringMetaMap2); asset2 = insertVod(vodData2, true); HashMap epgMetas = new HashMap<>(); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java index 9830e1038..15f5061d3 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/AssetTests/AssetListTests/SearchAssetFilterTests.java @@ -86,7 +86,7 @@ private void asset_list_searchAssetFilter_before_class() { .mediaType(MOVIE) .catalogStartDate(getFormattedTime(Calendar.MINUTE,-100, getTimeZone("UTC"))) .tags(tagMap) - .strings(stringMetaMap1) + .stringsMeta(stringMetaMap1) .geoBlockRule(geoBlockRule); asset2 = insertVod(vodData2, true); @@ -96,7 +96,7 @@ private void asset_list_searchAssetFilter_before_class() { .mediaType(EPISODE) .catalogStartDate(getFormattedTime(Calendar.MINUTE,-10, getTimeZone("UTC"))) .tags(tagMap) - .strings(stringMetaMap2); + .stringsMeta(stringMetaMap2); asset3 = insertVod(vodData3, true); // ingest epg 1 diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 09fb83255..0f7271832 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -67,10 +67,10 @@ public static VodData getVodData(MediaType mediaType, IngestAction action) { VodData data = new VodData() .setDefaultValues() - .strings(stringMetaMap) - .booleans(booleanHashMap) - .numbers(numberMetaMap) - .dates(datesMetaMap) + .stringsMeta(stringMetaMap) + .booleansMeta(booleanHashMap) + .numbersMeta(numberMetaMap) + .datesMeta(datesMetaMap) .tags(tagsMetaMap); switch (mediaType) { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 4c021ba7b..3c04f1ab7 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -70,11 +70,15 @@ public static class VodData { private MediaType mediaType; private Map> tags; - private Map strings; - private Map dates; - private Map numbers; - private Map booleans; - private Map multiLingualName; + private Map stringsMeta; + private Map datesMeta; + private Map numbersMeta; + private Map booleansMeta; + + private Map multilingualName; + private Map multilingualDescription; + private Map> multilingualStringsMeta; + private Map>> multilingualTags; private List thumbRatios; private List files; @@ -91,16 +95,41 @@ public VodData setDefaultValues() { endDate = endDateValue; mediaType = MediaType.MOVIE; tags = getDefaultTags(); - strings = getDefaultStrings(); - dates = getDefaultDates(); - numbers = getDefaultNumbers(); - ppvWebName = ppvNames.get(0); - ppvMobileName = ppvNames.get(1); + stringsMeta = getDefaultStrings(); + datesMeta = getDefaultDates(); + numbersMeta = getDefaultNumbers(); + ppvWebName = ppvNames.get(0); + ppvMobileName = ppvNames.get(1); files = getDefaultAssetFiles(ppvWebName, ppvMobileName); thumbRatios = Arrays.asList("4:3", "16:9"); return this; } + + // custom setters for multilingual fields to reset the parallel regular fields + public VodData multilingualName(Map multilingualName) { + this.name = null; + this.multilingualName = multilingualName; + return this; + } + + public VodData multilingualDescription(Map multilingualDescription) { + this.description = null; + this.multilingualDescription = multilingualDescription; + return this; + } + + public VodData multilingualStringsMeta(Map> multilingualStringsMeta) { + this.stringsMeta = null; + this.multilingualStringsMeta = multilingualStringsMeta; + return this; + } + + public VodData multilingualTags(Map>> multilingualTags) { + this.tags = null; + this.multilingualTags = multilingualTags; + return this; + } } @Accessors(fluent = true) @@ -178,20 +207,20 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { if (vodData.tags == null) { vodData.tags = getDefaultTags(); } - if (vodData.strings == null) { - vodData.strings = getDefaultStrings(); + if (vodData.stringsMeta == null) { + vodData.stringsMeta = getDefaultStrings(); } - if (vodData.dates == null) { - vodData.dates = getDefaultDates(); + if (vodData.datesMeta == null) { + vodData.datesMeta = getDefaultDates(); } - if (vodData.numbers == null) { - vodData.numbers = getDefaultNumbers(); + if (vodData.numbersMeta == null) { + vodData.numbersMeta = getDefaultNumbers(); } if (vodData.ppvWebName == null) { - vodData.ppvWebName = ppvNames.get(0); + vodData.ppvWebName = ppvNames.get(0); } if (vodData.ppvMobileName == null) { - vodData.ppvMobileName = ppvNames.get(1); + vodData.ppvMobileName = ppvNames.get(1); } if (vodData.files == null) { vodData.files = getDefaultAssetFiles(vodData.ppvWebName, vodData.ppvMobileName); @@ -300,19 +329,6 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { return uncommentCdataSection(docToString(doc)); } - // multilingual name - if (vodData.multiLingualName() != null) { - vodData.name(null); - - Element nameElement = (Element) media.getElementsByTagName("name").item(0); - vodData.multiLingualName().forEach((lang, name) -> { - Element value = doc.createElement("value"); - value.setAttribute("lang", lang); - value.setTextContent(name); - nameElement.appendChild(value); - }); - } - // name if (vodData.name() != null) { Element nameElement = (Element) media.getElementsByTagName("name").item(0); @@ -373,10 +389,10 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { media.getElementsByTagName("geo_block_rule").item(0).setTextContent(vodData.geoBlockRule()); } - // strings - if (vodData.strings() != null) { + // stringsMeta + if (vodData.stringsMeta() != null) { Element stringsElement = (Element) media.getElementsByTagName("strings").item(0); - for (Map.Entry entry : vodData.strings().entrySet()) { + for (Map.Entry entry : vodData.stringsMeta().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, stringsElement, entry.getKey()); @@ -388,37 +404,37 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { } } - // booleans - if (vodData.booleans() != null) { + // booleansMeta + if (vodData.booleansMeta() != null) { Element booleansElement = (Element) media.getElementsByTagName("booleans").item(0); - for (Map.Entry entry : vodData.booleans().entrySet()) { + for (Map.Entry entry : vodData.booleansMeta().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, booleansElement, entry.getKey()); meta.setTextContent(String.valueOf(entry.getValue())); } } - // doubles - if (vodData.numbers() != null) { + // doublesMeta + if (vodData.numbersMeta() != null) { Element doublesElement = (Element) media.getElementsByTagName("doubles").item(0); - for (Map.Entry entry : vodData.numbers().entrySet()) { + for (Map.Entry entry : vodData.numbersMeta().entrySet()) { // meta node Element meta = generateAndAppendMetaNode(doc, doublesElement, entry.getKey()); meta.setTextContent(String.valueOf(entry.getValue())); } } - // dates - if (vodData.dates() != null) { + // datesMeta + if (vodData.datesMeta() != null) { Element datesMetaElement = (Element) media.getElementsByTagName("dates").item(1); - for (Map.Entry entry : vodData.dates().entrySet()) { + for (Map.Entry entry : vodData.datesMeta().entrySet()) { // meta node Element metaElement = generateAndAppendMetaNode(doc, datesMetaElement, entry.getKey()); metaElement.setTextContent(entry.getValue()); } } - // metas + // tags if (vodData.tags() != null) { Element metasElement = (Element) media.getElementsByTagName("metas").item(0); for (Map.Entry> entry : vodData.tags().entrySet()) { @@ -449,6 +465,66 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { } } + // multilingual fields + // multilingual name + if (vodData.multilingualName() != null) { + Element nameElement = (Element) media.getElementsByTagName("name").item(0); + vodData.multilingualName().forEach((lang, name) -> { + Element value = doc.createElement("value"); + value.setAttribute("lang", lang); + value.setTextContent(name); + nameElement.appendChild(value); + }); + } + + // multilingual description + if (vodData.multilingualDescription() != null) { + Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); + vodData.multilingualDescription.forEach((lang, name) -> { + Element value = doc.createElement("value"); + value.setAttribute("lang", lang); + value.setTextContent(name); + descriptionElement.appendChild(value); + }); + } + + // multilingual stringsMeta + if (vodData.multilingualStringsMeta() != null) { + Element stringsElement = (Element) media.getElementsByTagName("strings").item(0); + vodData.multilingualStringsMeta().forEach((meta, langValueMap) -> { + // meta node + Element metaElement = generateAndAppendMetaNode(doc, stringsElement, meta); + langValueMap.forEach((lang, name) -> { + // value node + Element value = doc.createElement("value"); + value.setAttribute("lang", lang); + value.setTextContent(name); + metaElement.appendChild(value); + }); + }); + } + + // multilingual tags + if (vodData.multilingualTags() != null) { + Element metasElement = (Element) media.getElementsByTagName("metas").item(0); + vodData.multilingualTags().forEach((tag, tagsValuesMap) -> { + // meta node + Element metaElement = generateAndAppendMetaNode(doc, metasElement, tag); + tagsValuesMap.forEach(langValueMap -> { + // container node + Element container = doc.createElement("container"); + metaElement.appendChild(container); + langValueMap.forEach((lang, name) -> { + // value node + Element value = doc.createElement("value"); + value.setAttribute("lang", lang); + value.setTextContent(name); + container.appendChild(value); + }); + }); + }); + } + // uncomment cdata String docAsString = docToString(doc); return uncommentCdataSection(docAsString); diff --git a/src/test/resources/schemas/Language.json b/src/test/resources/schemas/Language.json new file mode 100644 index 000000000..0e0a03f2b --- /dev/null +++ b/src/test/resources/schemas/Language.json @@ -0,0 +1,49 @@ +{ + "$id": "Language", + "definitions": { + "Language": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "enum": ["KalturaLanguage"] + }, + "code": { + "type": "string", + "minLength": 0 + }, + "direction": { + "type": "string", + "minLength": 0 + }, + "isDefault": { + "type": "boolean" + }, + "name": { + "type": "string", + "minLength": 0 + }, + "systemName": { + "type": "string", + "minLength": 0 + } + }, + "required": [ + "objectType", + "code", + "direction", + "isDefault", + "name", + "systemName" + ] + } + }, + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/Language" + }, + "executionTime": {"type": "number"} + }, + "required": ["result", "executionTime"] +} diff --git a/src/test/resources/schemas/ListResponse.json b/src/test/resources/schemas/ListResponse.json index 0ec4eba54..ff4981682 100644 --- a/src/test/resources/schemas/ListResponse.json +++ b/src/test/resources/schemas/ListResponse.json @@ -65,6 +65,9 @@ }, { "$ref": "AssetStruct.json#/definitions/AssetStruct" + }, + { + "$ref": "Language.json#/definitions/Language" } ] } @@ -95,7 +98,8 @@ "KalturaDiscountDetailsListResponse", "KalturaAssetStructMetaListResponse", "KalturaAssetStructListResponse", - "KalturaCountryListResponse" + "KalturaCountryListResponse", + "KalturaLanguageListResponse" ] } }, From a92a3c7e1e16987cc9ab7a2dae9fb0d4ff86bd4b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 2 Oct 2018 11:01:59 +0300 Subject: [PATCH 597/605] Small refactoring regarding default language was done. added more tests for inheritance checking --- .../ParentChildMetadataInheritanceTests.java | 333 ++++++++++++++++-- .../five_zero_two/IngestVodOpcTests.java | 2 +- .../countryTests/CountryListTests.java | 3 +- .../client/test/utils/AssetStructUtils.java | 31 +- .../kaltura/client/test/utils/AssetUtils.java | 22 +- .../kaltura/client/test/utils/BaseUtils.java | 3 +- .../test/utils/dbUtils/DBConstants.java | 6 +- .../client/test/utils/dbUtils/DBUtils.java | 9 +- .../utils/ingestUtils/BaseIngestUtils.java | 6 +- .../utils/ingestUtils/IngestEpgUtils.java | 12 +- .../utils/ingestUtils/IngestVodUtils.java | 12 +- 11 files changed, 385 insertions(+), 54 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 70f0f7e63..a460eb16b 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -4,6 +4,7 @@ import com.kaltura.client.services.AssetStructService.*; import com.kaltura.client.test.tests.BaseTest; import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Link; @@ -11,11 +12,23 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; +import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; +import static com.kaltura.client.test.tests.enums.MediaType.SERIES; import static com.kaltura.client.test.utils.AssetStructMetaUtils.loadAssetStructMeta; +import static com.kaltura.client.test.utils.AssetStructUtils.copyAssetStructObject; import static com.kaltura.client.test.utils.AssetStructUtils.getAssetStruct; +import static com.kaltura.client.test.utils.AssetStructUtils.setInheritanceFieldsInAssetStruct; +import static com.kaltura.client.test.utils.AssetUtils.getMediaAsset; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.DEFAULT_LANGUAGE; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; /** @@ -32,9 +45,14 @@ public class ParentChildMetadataInheritanceTests extends BaseTest { private AssetStructMeta sharedMetaString1, sharedMetaString2, sharedMetaNumber1, sharedMetaNumber2; private AssetStructMeta sharedMetaDate1, sharedMetaDate2, sharedMetaBoolean1, sharedMetaBoolean2; private String sharedBasicMetaIds; + private String language1; + private Map> metas = new HashMap<>(); @BeforeClass() public void setUp() { + List languages = executor.executeSync(LanguageService.list(new LanguageFilter()) + .setKs(getOperatorKs())).results.getObjects(); + language1 = languages.get(0).getCode(); // TODO: check if assetStructList be useful at the end // assetStructList to fill default metaIds // AssetStructFilter filter = new AssetStructFilter(); @@ -57,6 +75,16 @@ public void setUp() { // TODO: ask Lior why ONLY these ids are obvious when DB has more basic metas? sharedBasicMetaIds = "58,629,1482,1493,1494,1495,1496,1497,566";//loadBasicAssetStructMetaId(); + // TODO: check if type of metas should be updated???? + metas.put(assetStructNames.get(0), Map.of(language1, "Default string value1")); + metas.put(assetStructNames.get(1), Map.of(language1, "Default string value2")); + metas.put(assetStructNames.get(2), Map.of(language1, "1111")); + metas.put(assetStructNames.get(3), Map.of(language1, "1112")); + metas.put(assetStructNames.get(4), Map.of(language1, "01/01/2001")); + metas.put(assetStructNames.get(5), Map.of(language1, "01/01/2002")); + metas.put(assetStructNames.get(6), Map.of(language1, "true")); + metas.put(assetStructNames.get(7), Map.of(language1, "false")); + // create shared assetStruct1 String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; @@ -101,7 +129,7 @@ public void testCreateInheritance() { AssetStruct assetStruct2Update = copyAssetStructObject(assetStruct2); setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStruct1.getId(), sharedMetaString1.getMetaId(), sharedMetaString2.getMetaId()); - updateAssetStruct(assetStruct2.getId(), assetStruct2Update); + updateAssetStruct(assetStruct2.getId(), assetStruct2Update, false); // check parent doesn't have changes in related inheritance fields AssetStructFilter filter = new AssetStructFilter(); @@ -129,36 +157,275 @@ public void testCreateInheritance() { deleteAssetStruct(assetStruct1.getId()); } - AssetStruct copyAssetStructObject(AssetStruct assetStruct2Copy) { - AssetStruct result = new AssetStruct(); - result.setConnectedParentMetaId(assetStruct2Copy.getConnectedParentMetaId()); - result.setConnectingMetaId(assetStruct2Copy.getConnectingMetaId()); - result.setParentId(assetStruct2Copy.getParentId()); - result.setMetaIds(assetStruct2Copy.getMetaIds()); - result.setSystemName(assetStruct2Copy.getSystemName()); - result.setIsProtected(assetStruct2Copy.getIsProtected()); - result.setPluralName(assetStruct2Copy.getPluralName()); - result.setMultilingualName(assetStruct2Copy.getMultilingualName()); - result.setFeatures(assetStruct2Copy.getFeatures()); + @Test(enabled = false) // TODO: remove after deletion + public void testInheritance4TextAndNumericFieldsOnly() { + // create assetStruct1 + String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + AssetStruct assetStruct1 = createAssetStruct(prefix, metaIds); + // create assetStruct2 + metaIds = sharedMetaString2.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; + AssetStruct assetStruct2 = createAssetStruct(prefix, metaIds); + + // set inheritance // to try set inheritance between different types of meta + AssetStruct assetStruct2Update = copyAssetStructObject(assetStruct2); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStruct1.getId(), + sharedMetaString1.getMetaId(), sharedMetaDate2.getMetaId()); + updateAssetStruct(assetStruct2.getId(), assetStruct2Update, true); - return result; + // TODO: wait response from Anat and depends on it continue the test with other types + // check children asset struct has changes +// AssetStructFilter filter = new AssetStructFilter(); +// filter.setIdIn(assetStruct2.getId().toString()); +// ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); +// Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder +// .setKs(getOperatorKs())); +// AssetStruct assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); +// assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStruct1.getId()); +// assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); +// assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + + // remove assetStructs + deleteAssetStruct(assetStruct2.getId()); // firstly should be deleted children + deleteAssetStruct(assetStruct1.getId()); } - void setInheritanceFieldsInAssetStruct(AssetStruct assetStruct, Long parentAssetStructId, - Long connectedParentMetaId, Long connectingMetaId) { - assetStruct.setParentId(parentAssetStructId); - assetStruct.setConnectedParentMetaId(connectedParentMetaId); - assetStruct.setConnectingMetaId(connectingMetaId); + @Test + public void testInheritance3Levels() { + // create granpa + String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + AssetStruct assetStructGrandParent = createAssetStruct(prefix, metaIds); + // create parent + metaIds = sharedMetaString2.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; + AssetStruct assetStructParent = createAssetStruct(prefix, metaIds); + // create children + metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedMetaString2.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "3"; + AssetStruct assetStructChildren = createAssetStruct(prefix, metaIds); + + // set inheritance between Children and Parent + AssetStruct assetStruct2Update = copyAssetStructObject(assetStructChildren); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStructParent.getId(), + sharedMetaString2.getMetaId(), sharedMetaDate2.getMetaId()); + updateAssetStruct(assetStructChildren.getId(), assetStruct2Update, false); + + // set inheritance between Parent and GrandParent + assetStruct2Update = copyAssetStructObject(assetStructParent); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStructGrandParent.getId(), + sharedMetaString1.getMetaId(), sharedMetaDate2.getMetaId()); + updateAssetStruct(assetStructParent.getId(), assetStruct2Update, false); + + // check children asset struct has changes + AssetStructFilter filter = new AssetStructFilter(); + filter.setIdIn(assetStructChildren.getId().toString()); + ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); + Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + AssetStruct assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); + assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStructParent.getId()); + assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + + // check parent asset struct has changes + filter = new AssetStructFilter(); + filter.setIdIn(assetStructParent.getId().toString()); + listAssetStructBuilder = AssetStructService.list(filter); + assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); + assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStructGrandParent.getId()); + assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); + assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + + // remove assetStructs + deleteAssetStruct(assetStructChildren.getId()); // firstly should be deleted children + deleteAssetStruct(assetStructParent.getId()); // secondly should be deleted parent + deleteAssetStruct(assetStructGrandParent.getId()); } - void updateAssetStruct(Long assetStructId, AssetStruct updatedAssetStruct) { - UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update( - assetStructId, updatedAssetStruct); - Response assetStructResponse = executor.executeSync(updateAssetStructBuilder - .setKs(getOperatorKs()).setLanguage("*")); - assertThat(assetStructResponse.results).isNotNull(); + // checking that on BE level it is doesn't supported limitation about 1 children maximum + @Test + public void testInheritanceParentWith2Childrens() { + // create parent + String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + AssetStruct assetStructParent = createAssetStruct(prefix, metaIds); + // create children1 + metaIds = sharedMetaString2.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; + AssetStruct assetStructChildren1 = createAssetStruct(prefix, metaIds); + // create children2 + metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedMetaString2.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "3"; + AssetStruct assetStructChildren2 = createAssetStruct(prefix, metaIds); + + // set inheritance between Children2 and Parent + AssetStruct assetStruct2Update = copyAssetStructObject(assetStructChildren2); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStructParent.getId(), + sharedMetaString1.getMetaId(), sharedMetaDate2.getMetaId()); + updateAssetStruct(assetStructChildren2.getId(), assetStruct2Update, false); + + // set inheritance between Children1 and Parent + assetStruct2Update = copyAssetStructObject(assetStructChildren1); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStructParent.getId(), + sharedMetaString1.getMetaId(), sharedMetaDate2.getMetaId()); + updateAssetStruct(assetStructChildren1.getId(), assetStruct2Update, false); + + // check children asset2 struct has changes + AssetStructFilter filter = new AssetStructFilter(); + filter.setIdIn(assetStructChildren2.getId().toString()); + ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); + Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + AssetStruct assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); + assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStructParent.getId()); + assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); + assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + + // check children asset1 struct has changes + filter = new AssetStructFilter(); + filter.setIdIn(assetStructChildren1.getId().toString()); + listAssetStructBuilder = AssetStructService.list(filter); + assetStructListResponse = executor.executeSync(listAssetStructBuilder + .setKs(getOperatorKs())); + assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); + assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStructParent.getId()); + assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); + assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + + // remove assetStructs + deleteAssetStruct(assetStructChildren2.getId()); // firstly should be deleted childrens + deleteAssetStruct(assetStructChildren1.getId()); // firstly should be deleted childrens + deleteAssetStruct(assetStructParent.getId()); + + // TODO: check if it completed + } + + @Test + public void testInheritanceWithIngest() { + // create parent + String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + AssetStruct assetStructParent = createAssetStruct(prefix, metaIds); + // create children1 + metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; + AssetStruct assetStructChildren1 = createAssetStruct(prefix, metaIds); + + // set inheritance between Children1 and Parent + AssetStruct assetStruct2Update = copyAssetStructObject(assetStructChildren1); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStructParent.getId(), + sharedMetaString1.getMetaId(), sharedMetaDate2.getMetaId()); + updateAssetStruct(assetStructChildren1.getId(), assetStruct2Update, false); + +// // check children asset1 struct has changes +// AssetStructFilter filter = new AssetStructFilter(); +// filter.setIdIn(assetStructChildren1.getId().toString()); +// ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); +// Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder +// .setKs(getOperatorKs())); +// AssetStruct assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); +// assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStructParent.getId()); +// assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); +// assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + + // ingest metas of needed type +// IngestVodUtils.VodData vodData = getVodData(null, INSERT) +// .multilingualStringMeta(metas); + + + // remove assetStructs + deleteAssetStruct(assetStructChildren1.getId()); // firstly should be deleted childrens + deleteAssetStruct(assetStructParent.getId()); + } + +// @Test TODO: after ingest +// public void testIngestRules() { +// IngestVodUtils.VodData vodData = getVodData(SERIES, INSERT); +// MediaAsset series = insertVod(vodData, true); +// assertThat(series.getExternalId()).isNotNull(); +// +// vodData = getVodData(EPISODE, INSERT); +// MediaAsset episode = insertVod(vodData, true); +// assertThat(episode.getExternalId()).isNotNull(); +// +// // cleanup +// deleteVod(series.getExternalId()); +// deleteVod(episode.getExternalId()); +// } + + @Test + public void testApiCreationOfAssetsWithInheritance() { + // create parent + String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); + AssetStruct assetStructParent = createAssetStruct(prefix, metaIds); + // create children + metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; + AssetStruct assetStructChildren = createAssetStruct(prefix, metaIds); + Map metas = new HashMap<>(); + metas.put(DBUtils.getMetaNameById(sharedMetaString1.getMetaId(), false), "some default value"); + // set inheritance between Children and Parent + AssetStruct assetStruct2Update = copyAssetStructObject(assetStructChildren); + setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStructParent.getId(), + sharedMetaString1.getMetaId(), sharedMetaDate2.getMetaId()); + updateAssetStruct(assetStructChildren.getId(), assetStruct2Update, false); + + // TODO: complete + MediaAsset asset = getMediaAsset(assetStructParent.getId(), "testName", "testDescription"); + asset.setMetas(loadMetas(metas)); + AssetService.AddAssetBuilder addAssetBuilder = AssetService.add(asset); + Response response = executor.executeSync(addAssetBuilder + .setKs(getOperatorKs()) + .setLanguage("*")); + asset = (MediaAsset) response.results; + + MediaAsset asset2 = getMediaAsset(assetStructChildren.getId(), "testName2", "testDescription2"); + asset2.setMetas(loadMetas(metas)); + addAssetBuilder = AssetService.add(asset2); + response = executor.executeSync(addAssetBuilder + .setKs(getOperatorKs()) + .setLanguage("*")); + asset2 = (MediaAsset) response.results; +// +// // check children asset1 struct has changes +// AssetStructFilter filter = new AssetStructFilter(); +// filter.setIdIn(assetStructChildren.getId().toString()); +// ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); +// Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder +// .setKs(getOperatorKs())); +// AssetStruct assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); +// assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStructParent.getId()); +// assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); +// assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + + // 4rent folder has some logic + + // remove assetStructs + deleteVod(asset.getExternalId()); + deleteVod(asset2.getExternalId()); + deleteAssetStruct(assetStructChildren.getId()); // firstly should be deleted children + deleteAssetStruct(assetStructParent.getId()); + } + + // TODO: find better name and option to use it in the whole project + private Map loadMetas(Map metas) { + Map result = new HashMap<>(); + for (Map.Entry entry: metas.entrySet()) { + StringValue value = new StringValue(); + value.setValue(entry.getValue()); + //value.value(entry.getValue()); + result.put(entry.getKey(), value); + } + + return result; } + // TODO: Check if it used after implementation private List loadAssetStructsWithoutHierarchy(int countOfAssetStructs, List listOfAssetStructs) { List result = new ArrayList<>(); @@ -204,7 +471,7 @@ private List loadAssetStructsWithoutHierarchy(int countOfAssetStruc // //assertThat(assetStructMetaResponse.results.getInherited()).isEqualTo(isInherited); // // // assetStructAdd -// AssetStruct assetStruct = getAssetStruct(prefix, "eng", false, metaIds, null, null, null); +// AssetStruct assetStruct = getAssetStruct(prefix, DEFAULT_LANGUAGE, false, metaIds, null, null, null); // AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(assetStruct); // Response assetStructResponse = executor.executeSync(addAssetStructBuilder // .setKs(getOperatorKs()).setLanguage("*")); @@ -308,7 +575,7 @@ void deleteAssetStruct(Long assetStructId) { } AssetStruct createAssetStruct(String prefix, String metaIds) { - AssetStruct result = getAssetStruct(prefix, "eng", false, metaIds, null, + AssetStruct result = getAssetStruct(prefix, DEFAULT_LANGUAGE, false, metaIds, null, null, null); AddAssetStructBuilder addAssetStructBuilder = AssetStructService.add(result); @@ -320,4 +587,18 @@ AssetStruct createAssetStruct(String prefix, String metaIds) { return result; } + + Response updateAssetStruct(Long assetStructId, AssetStruct updatedAssetStruct, boolean isErrorExpected) { + UpdateAssetStructBuilder updateAssetStructBuilder = AssetStructService.update( + assetStructId, updatedAssetStruct); + Response assetStructResponse = executor.executeSync(updateAssetStructBuilder + .setKs(getOperatorKs()).setLanguage("*")); + if (isErrorExpected) { + assertThat(assetStructResponse.error).isNotNull(); + } else { + assertThat(assetStructResponse.results).isNotNull(); + } + + return assetStructResponse; + } } diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index 2e06874b5..2d2e8013d 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -391,7 +391,7 @@ public void insertMultiLingualFields() { // TODO: 9/17/2018 complete test // // ingested Movie for checking multilanguage // final String JAP = "jap"; -// final String ENG = "eng"; +// final String ENG = DEFAULT_LANGUAGE; // String suffix = "multilingual"; // //// name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java index ec3c4dd50..cd9b076cf 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/countryTests/CountryListTests.java @@ -14,6 +14,7 @@ import static com.kaltura.client.services.CountryService.*; import static com.kaltura.client.test.utils.BaseUtils.getAPIExceptionFromList; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.DEFAULT_LANGUAGE; import static org.assertj.core.api.Assertions.assertThat; public class CountryListTests extends BaseTest { @@ -98,7 +99,7 @@ private void listCountryBySepcificIp() { String usaCountryCode = "US"; String currency = "USD"; String currencySign = "$"; - String langCode = "eng"; + String langCode = DEFAULT_LANGUAGE; CountryFilter countryFilter = new CountryFilter(); countryFilter.setIpEqual(usaIp); diff --git a/src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java index 26859b9bd..8bb809c60 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetStructUtils.java @@ -2,9 +2,7 @@ import com.kaltura.client.types.AssetStruct; import com.kaltura.client.types.TranslationToken; - import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.List; public class AssetStructUtils extends BaseUtils { @@ -14,12 +12,7 @@ public static AssetStruct getAssetStruct(String prefix, String language, boolean @Nullable Long connectedParentMetaId) { AssetStruct assetStruct = new AssetStruct(); assetStruct.setSystemName(prefix + "_System_name"); - List translationTokens = new ArrayList<>(); - TranslationToken translationToken = new TranslationToken(); - translationToken.setValue(prefix + "_multiLingualName"); - translationToken.setLanguage(language); - translationTokens.add(translationToken); - assetStruct.setMultilingualName(translationTokens); + assetStruct.setMultilingualName(setTranslationToken(prefix + "_multiLingualName")); assetStruct.setIsProtected(isProtected); assetStruct.setMetaIds(metaIds); assetStruct.setParentId(parentId); @@ -28,4 +21,26 @@ public static AssetStruct getAssetStruct(String prefix, String language, boolean return assetStruct; } + + public static AssetStruct copyAssetStructObject(AssetStruct assetStruct2Copy) { + AssetStruct result = new AssetStruct(); + result.setConnectedParentMetaId(assetStruct2Copy.getConnectedParentMetaId()); + result.setConnectingMetaId(assetStruct2Copy.getConnectingMetaId()); + result.setParentId(assetStruct2Copy.getParentId()); + result.setMetaIds(assetStruct2Copy.getMetaIds()); + result.setSystemName(assetStruct2Copy.getSystemName()); + result.setIsProtected(assetStruct2Copy.getIsProtected()); + result.setPluralName(assetStruct2Copy.getPluralName()); + result.setMultilingualName(assetStruct2Copy.getMultilingualName()); + result.setFeatures(assetStruct2Copy.getFeatures()); + + return result; + } + + public static void setInheritanceFieldsInAssetStruct(AssetStruct assetStruct, Long parentAssetStructId, + Long connectedParentMetaId, Long connectingMetaId) { + assetStruct.setParentId(parentAssetStructId); + assetStruct.setConnectedParentMetaId(connectedParentMetaId); + assetStruct.setConnectingMetaId(connectingMetaId); + } } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java index 4ab279e01..11a5bff90 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetUtils.java @@ -10,7 +10,9 @@ import com.kaltura.client.utils.response.base.Response; import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; @@ -238,9 +240,27 @@ public static Asset getAssetByPurchaeStatus(List assets, PurchaseStatus p } public static String getCoguid(Asset asset) { - // TODO: 7/1/2018 finsih util + // TODO: 7/1/2018 finish util + //asset.getExternalId() can be used for ingested items return null; } + + public static MediaAsset getMediaAsset(Long type, String name, String description) { + MediaAsset result = new MediaAsset(); + result.setType(type.intValue()); + result.setMultilingualName(setTranslationToken(name)); + result.setMultilingualDescription(setTranslationToken(description)); + String currentDate = getCurrentDateInFormat("yyMMddHHmmss"); + result.setExternalId("Media_" + currentDate); + result.setStatus(true); + result.setEntryId(currentDate); + + //TODO: add others fields if needed + //result.setMetas(metas); + //result.setTags(tags); + + return result; + } } diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index 5496816aa..aef16a7d4 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -20,6 +20,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.config; +import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.DEFAULT_LANGUAGE; import static io.restassured.RestAssured.given; public class BaseUtils { @@ -252,7 +253,7 @@ public static void clearCache() { public static List setTranslationToken(String value) { TranslationToken translationToken = new TranslationToken(); - translationToken.setLanguage("eng"); + translationToken.setLanguage(DEFAULT_LANGUAGE); translationToken.setValue(value); List translationTokens = new ArrayList<>(); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 6d72d3157..18f36ab1c 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -26,6 +26,7 @@ public class DBConstants { static final String SERV_ID = "serv_id"; static final String SUBSCRIPTION_ONLY = "subscription_only"; static final String SUB_ID = "sub_id"; + static final String SYSTEM_NAME = "system_name"; static final String TAG_NAME = "tag_name"; static final String TAG_VALUE = "tag_value"; static final String USERNAME = "username"; @@ -88,7 +89,10 @@ public class DBConstants { "where [group_id]=? and is_active=1 and [status]=1 order by UPDATE_DATE DESC"; static final String META_SELECT = "SELECT TOP (?) * FROM [TVinci].[dbo].[topics]\n" + - "WHERE IS_BASIC=? AND GROUP_ID=? AND [STATUS]=1"; + "WHERE IS_BASIC=? AND GROUP_ID=? AND [STATUS]=1 AND TOPIC_TYPE_ID !=4"; // 4 IS FOR TAGS + + static final String META_NAME_SELECT_BY_ID = "SELECT * FROM [TVinci].[dbo].[topics]\n" + + "WHERE [STATUS]=1 AND GROUP_ID=? AND ID=?\n"; static final String META_OR_TAG_SELECT_BY_NAME = "SELECT * FROM [TVinci].[dbo].[topics]\n" + "WHERE [STATUS]=1 AND GROUP_ID=? AND SYSTEM_NAME=?\n"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index a765d241d..9d7f55936 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -328,6 +328,13 @@ public static Long getMetaIdByName(String metaName, boolean processBasicFields) return (processBasicFields || (jsonObject.getInt(IS_BASIC) == 0)) ? jsonObject.getLong(ID) : -1; } + public static String getMetaNameById(Long id, boolean processBasicFields) { + JSONObject jsonObject = + getJsonArrayFromQueryResult(META_NAME_SELECT_BY_ID, partnerId, id) + .getJSONObject(0); + return (processBasicFields || (jsonObject.getInt(IS_BASIC) == 0)) ? jsonObject.getString(SYSTEM_NAME) : null; + } + // TODO: check if it be used after completing functionality public static Long loadBasicAssetStructMetaId() { return getJsonArrayFromQueryResult(BASIC_META_SELECT, partnerId) @@ -366,7 +373,7 @@ public static List getAllAssetStructMetas(String type, int countItems) { if (idOfType ==-1) { // if type was not specified for (int i=0; i < idTypes.size(); i++) { - dbResult = getJsonArrayFromQueryResult(META_SELECT, countItems, 0, partnerId); + dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idTypes.get(i)); addSystemNamesFromResponse2List(result, dbResult); } } else { diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java index ad614d811..ba9340e9f 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/BaseIngestUtils.java @@ -41,8 +41,10 @@ public class BaseIngestUtils { // data public static final String DEFAULT_THUMB = "http://opengameart.org/sites/default/files/styles/thumbnail/public/pictures/picture-1760-1321510314.png"; - /* - // PG adapter data + // language + public static final String DEFAULT_LANGUAGE = "eng"; + + /*// PG adapter data public static final String PG_DEFAULT_ADAPTER_URL = "http://172.31.6.89:90/PGAdapter/Service.svc"; public static final String PG_DEFAULT_RENEW_URL = PG_DEFAULT_ADAPTER_URL + "?StateCode=0"; public static final String PG_DEFAULT_SHARED_SECRET = "123456"; diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java index 339c0d0c0..1b7aaef7d 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestEpgUtils.java @@ -198,7 +198,7 @@ private static Element getProgrammeNode(Document doc, int episodeNum, int season // title Element title = doc.createElement("title"); - title.setAttribute("lang", "eng"); + title.setAttribute("lang", DEFAULT_LANGUAGE); title.setTextContent(name); programme.appendChild(title); @@ -209,7 +209,7 @@ private static Element getProgrammeNode(Document doc, int episodeNum, int season // desc Element desc = doc.createElement("desc"); - desc.setAttribute("lang", "eng"); + desc.setAttribute("lang", DEFAULT_LANGUAGE); desc.setTextContent(startDate + " until " + endDate); programme.appendChild(desc); @@ -220,8 +220,8 @@ private static Element getProgrammeNode(Document doc, int episodeNum, int season // language Element lang = doc.createElement("language"); - lang.setAttribute("lang", "eng"); - lang.setTextContent("eng"); + lang.setAttribute("lang", DEFAULT_LANGUAGE); + lang.setTextContent(DEFAULT_LANGUAGE); programme.appendChild(lang); // icon @@ -269,7 +269,7 @@ private static Element generateMetasNode(Document doc, String metaTypeString, St // metaValues Element metaValues = doc.createElement("MetaValues"); - metaValues.setAttribute("lang", "eng"); + metaValues.setAttribute("lang", DEFAULT_LANGUAGE); metaValues.setTextContent(metaValuesString); metas.appendChild(metaValues); @@ -287,7 +287,7 @@ private static Element generateTagsNode(Document doc, String tagTypeString, Stri // TagValues Element tagValues = doc.createElement("TagValues"); - tagValues.setAttribute("lang", "eng"); + tagValues.setAttribute("lang", DEFAULT_LANGUAGE); tagValues.setTextContent(tagValuesString); tags.appendChild(tagValues); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 4c021ba7b..471937a08 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -83,7 +83,7 @@ public VodData setDefaultValues() { coguid = String.valueOf(getEpochInMillis()); name = coguid; description = "description of " + coguid; - lang = "eng"; + lang = DEFAULT_LANGUAGE; thumbUrl = DEFAULT_THUMB; catalogStartDate = offsetDateValue; catalogEndDate = endDateValue; @@ -155,7 +155,7 @@ public static MediaAsset insertVod(VodData vodData, boolean useDefaultValues) { vodData.description = "description of " + vodData.coguid; } if (vodData.lang == null) { - vodData.lang = "eng"; + vodData.lang = DEFAULT_LANGUAGE; } if (vodData.thumbUrl == null) { vodData.thumbUrl = DEFAULT_THUMB; @@ -317,7 +317,7 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { if (vodData.name() != null) { Element nameElement = (Element) media.getElementsByTagName("name").item(0); Element value = doc.createElement("value"); - value.setAttribute("lang", vodData.lang != null ? vodData.lang : "eng"); + value.setAttribute("lang", vodData.lang != null ? vodData.lang : DEFAULT_LANGUAGE); value.setTextContent(vodData.name); nameElement.appendChild(value); } @@ -332,7 +332,7 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { if (vodData.description() != null) { Element descriptionElement = (Element) media.getElementsByTagName("description").item(0); Element value = doc.createElement("value"); - value.setAttribute("lang", vodData.lang != null ? vodData.lang : "eng"); + value.setAttribute("lang", vodData.lang != null ? vodData.lang : DEFAULT_LANGUAGE); value.setTextContent(vodData.description); descriptionElement.appendChild(value); } @@ -382,7 +382,7 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { // value node Element value = doc.createElement("value"); - value.setAttribute("lang", "eng"); + value.setAttribute("lang", DEFAULT_LANGUAGE); value.setTextContent(entry.getValue()); meta.appendChild(value); } @@ -433,7 +433,7 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { // value node Element value = doc.createElement("value"); value.setTextContent(s); - value.setAttribute("lang", "eng"); + value.setAttribute("lang", DEFAULT_LANGUAGE); container.appendChild(value); } } From 59e1b494d2ecaa03bd60eaa9331eb30acf46a87b Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 2 Oct 2018 12:19:07 +0300 Subject: [PATCH 598/605] small additions --- .../ParentChildMetadataInheritanceTests.java | 24 ++++++++++++++----- .../utils/ingestUtils/IngestVodOpcUtils.java | 6 +++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index a460eb16b..8ff9f1ba0 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -17,8 +17,7 @@ import java.util.Map; import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; -import static com.kaltura.client.test.tests.enums.MediaType.EPISODE; -import static com.kaltura.client.test.tests.enums.MediaType.SERIES; +import static com.kaltura.client.test.tests.enums.MediaType.*; import static com.kaltura.client.test.utils.AssetStructMetaUtils.loadAssetStructMeta; import static com.kaltura.client.test.utils.AssetStructUtils.copyAssetStructObject; import static com.kaltura.client.test.utils.AssetStructUtils.getAssetStruct; @@ -300,11 +299,9 @@ public void testInheritanceParentWith2Childrens() { deleteAssetStruct(assetStructChildren2.getId()); // firstly should be deleted childrens deleteAssetStruct(assetStructChildren1.getId()); // firstly should be deleted childrens deleteAssetStruct(assetStructParent.getId()); - - // TODO: check if it completed } - @Test + @Test // TODO: wait response from Alon public void testInheritanceWithIngest() { // create parent String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; @@ -342,7 +339,7 @@ public void testInheritanceWithIngest() { deleteAssetStruct(assetStructParent.getId()); } -// @Test TODO: after ingest +// @Test //TODO: after ingest // public void testIngestRules() { // IngestVodUtils.VodData vodData = getVodData(SERIES, INSERT); // MediaAsset series = insertVod(vodData, true); @@ -352,7 +349,22 @@ public void testInheritanceWithIngest() { // MediaAsset episode = insertVod(vodData, true); // assertThat(episode.getExternalId()).isNotNull(); // +// vodData = getVodData(MOVIE, INSERT); +// MediaAsset movie = insertVod(vodData, true); +// assertThat(movie.getExternalId()).isNotNull(); +// +// vodData = getVodData(LINEAR, INSERT); +// MediaAsset linear = insertVod(vodData, true); +// assertThat(linear.getExternalId()).isNotNull(); +// +// System.out.println("SERIES POLICY: " + series.getInheritancePolicy().getValue()); +// System.out.println("EPISODE POLICY: " + episode.getInheritancePolicy().getValue()); +// System.out.println("MOVIE POLICY: " + movie.getInheritancePolicy().getValue()); +// System.out.println("LINEAR POLICY: " + linear.getInheritancePolicy().getValue()); +// // // cleanup +// deleteVod(linear.getExternalId()); +// deleteVod(movie.getExternalId()); // deleteVod(series.getExternalId()); // deleteVod(episode.getExternalId()); // } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 0f7271832..590d53ebb 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -83,8 +83,14 @@ public static VodData getVodData(MediaType mediaType, IngestAction action) { case SERIES: data.mediaType(MediaType.SERIES).isVirtual(true); return data; +// case LINEAR: +// data.mediaType(MediaType.LINEAR).isVirtual(false); +// return data; default: +// data.isVirtual(false); +// return data; return null; + } } From b2ca518b3985ff2ae287c30d3771015e6c1614af Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 2 Oct 2018 14:58:02 +0300 Subject: [PATCH 599/605] Added enum AssetStructMetaType --- .../test/tests/enums/AssetStructMetaType.java | 41 +++++++++++++++++++ .../ParentChildMetadataInheritanceTests.java | 13 ++++-- .../client/test/utils/dbUtils/DBUtils.java | 19 +++++---- .../utils/ingestUtils/IngestVodOpcUtils.java | 9 +++- 4 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java diff --git a/src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java b/src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java new file mode 100644 index 000000000..d14051b49 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java @@ -0,0 +1,41 @@ +package com.kaltura.client.test.tests.enums; + +import com.kaltura.client.enums.EnumAsString; + +public enum AssetStructMetaType implements EnumAsString { + TEXT("Text"), + NUMBER("Number"), + DATE("Date"), + BOOLEAN("Boolean"), + ALL("All"); + + private String value; + + AssetStructMetaType(String value) { + this.value = value; + } + + @Override + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public static AssetStructMetaType get(String value) { + if(value == null) { + return null; + } + + // goes over defined values and compare the inner value with the given one: + for(AssetStructMetaType item: values()) { + if(item.getValue().equals(value)) { + return item; + } + } + // in case the requested value was not found in the enum values, we return the first item as default. + return AssetStructMetaType.values().length > 0 ? AssetStructMetaType.values()[0]: null; + } +} diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 8ff9f1ba0..5a4bcfce7 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -3,6 +3,8 @@ import com.kaltura.client.services.*; import com.kaltura.client.services.AssetStructService.*; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.AssetStructMetaType; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.dbUtils.DBUtils; import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; @@ -16,6 +18,7 @@ import java.util.List; import java.util.Map; +import static com.kaltura.client.test.tests.enums.AssetStructMetaType.ALL; import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; import static com.kaltura.client.test.tests.enums.MediaType.*; import static com.kaltura.client.test.utils.AssetStructMetaUtils.loadAssetStructMeta; @@ -62,7 +65,7 @@ public void setUp() { // metaIds = sharedAssetStructListResponse.results.getObjects().get(0).getMetaIds(); // identify shared assetStructMetas - List assetStructNames = DBUtils.getAllAssetStructMetas("", 2); + List assetStructNames = DBUtils.getAllAssetStructMetas(ALL, 2); sharedMetaString1 = loadAssetStructMeta(assetStructNames.get(0)); sharedMetaString2 = loadAssetStructMeta(assetStructNames.get(1)); sharedMetaNumber1 = loadAssetStructMeta(assetStructNames.get(2)); @@ -330,11 +333,13 @@ public void testInheritanceWithIngest() { // assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); // ingest metas of needed type -// IngestVodUtils.VodData vodData = getVodData(null, INSERT) -// .multilingualStringMeta(metas); - +// IngestVodUtils.VodData vodData = getVodData(MediaType.PACKAGE, INSERT) +// .multilingualStringsMeta(metas); +// MediaAsset mediaAsset = insertVod(vodData, false); +// assertThat(mediaAsset.getExternalId()).isNotNull(); // remove assetStructs +// deleteVod(mediaAsset.getExternalId()); deleteAssetStruct(assetStructChildren1.getId()); // firstly should be deleted childrens deleteAssetStruct(assetStructParent.getId()); } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 9d7f55936..d9547256c 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -2,6 +2,7 @@ import com.kaltura.client.Logger; import com.kaltura.client.services.SubscriptionService; +import com.kaltura.client.test.tests.enums.AssetStructMetaType; import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.tests.enums.PremiumService; import com.kaltura.client.test.utils.BaseUtils; @@ -342,26 +343,26 @@ public static Long loadBasicAssetStructMetaId() { .getLong(ID); } - public static List getAllAssetStructMetas(String type, int countItems) { + public static List getAllAssetStructMetas(AssetStructMetaType type, int countItems) { List result = new ArrayList<>(); // TODO: ask developers about ids for assetStructMeta types List idTypes = new ArrayList<>(); - idTypes.add(6); - idTypes.add(2); - idTypes.add(5); - idTypes.add(3); + idTypes.add(6); // text + idTypes.add(2); // number + idTypes.add(5); // date + idTypes.add(3); // boolean int idOfType =-1; switch (type) { - case "Text": + case TEXT: idOfType = idTypes.get(0); break; - case "Number": + case NUMBER: idOfType = idTypes.get(1); break; - case "Date": + case DATE: idOfType = idTypes.get(2); break; - case "Boolean": + case BOOLEAN: idOfType = idTypes.get(3); break; default: diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 590d53ebb..9193410e7 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -87,10 +87,15 @@ public static VodData getVodData(MediaType mediaType, IngestAction action) { // data.mediaType(MediaType.LINEAR).isVirtual(false); // return data; default: -// data.isVirtual(false); +// data +// .tags(null) +// .stringsMeta(null) +// .datesMeta(null) +// .numbersMeta(null) +// .booleansMeta(null) +// .isVirtual(false); // return data; return null; - } } From 490386f8a3195b915a65998a9395186789702fe9 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 2 Oct 2018 16:09:16 +0300 Subject: [PATCH 600/605] add custom media type as string to vodData object --- .../five_zero_two/IngestVodOpcTests.java | 111 ++++++++++-------- .../utils/ingestUtils/IngestVodUtils.java | 7 ++ 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index e5db8165a..7e8799131 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -1,7 +1,7 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_two; import com.kaltura.client.enums.AssetReferenceType; -import com.kaltura.client.services.AssetService; +import com.kaltura.client.services.LanguageService; import com.kaltura.client.services.PpvService; import com.kaltura.client.services.ProductPriceService; import com.kaltura.client.test.tests.BaseTest; @@ -18,12 +18,14 @@ import org.testng.annotations.Test; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import static com.kaltura.client.services.AssetService.list; +import static com.kaltura.client.services.AssetService.*; +import static com.kaltura.client.services.AssetService.get; import static com.kaltura.client.test.tests.enums.IngestAction.*; import static com.kaltura.client.test.tests.enums.KsqlKey.MEDIA_ID; import static com.kaltura.client.test.tests.enums.MediaType.*; @@ -389,57 +391,66 @@ public void insertWithInvalidMetaOrTagField() { @Test(description = "insert multilingual fields", enabled = false) public void insertMultiLingualFields() { // TODO: 9/17/2018 complete test -// // ingested Movie for checking multilanguage -// final String JAP = "jap"; -// final String ENG = "eng"; -// String suffix = "multilingual"; -// -//// name = "Name_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update name automatically -//// description = "Description_" + localCoguid.substring(0, localCoguid.length() - 2); // to not update description automatically -//// -// VodData vodData = getVodData(MOVIE, INSERT); -// MediaAsset movie = insertVod(vodData, true); -// String nameData = "" + movie.getName() + ""; -// String descriptionData = "" + movie.getDescription() + ""; -// String stringMetaDataValue = ((MultilingualStringValue)movie.getMetas().get(mediaTextFieldName)).getValue(); -// String stringMetaData = "" + stringMetaDataValue + ""; -// String tagData = "" + tagValue1 + ""; -// -// // to get xml having all fields supporting multilingual -// String ingestXml = ingestXmlRequest.replaceAll(localCoguid, localCoguid + suffix); -// ingestXml = ingestXml.replaceAll(nameData, nameData + nameData.replaceAll(ENG, JAP) -// .replaceAll(movie.getName(), movie.getName() + JAP)); -// ingestXml = ingestXml.replaceAll(descriptionData, descriptionData + descriptionData.replaceAll(ENG, JAP) -// .replaceAll(movie.getDescription(), movie.getDescription() + JAP)); -// ingestXml = ingestXml.replaceAll(stringMetaData, stringMetaData + stringMetaData.replaceAll(ENG, JAP) -// .replaceAll(stringMetaDataValue, stringMetaDataValue + JAP)); -// ingestXml = ingestXml.replaceAll(tagData, tagData + tagData.replaceAll(ENG, JAP)) -// .replaceAll("lang=\"jap\">" + tagValue1, "lang=\"jap\">" + tagValue1 + JAP); -// -// Response resp = executeIngestVodRequest(ingestXml); -// -// assertThat(from(resp.asString()).getString(ingestAssetStatusMessagePath)).isEqualTo("OK"); -// String id = from(resp.asString()).get(ingestAssetIdPath).toString(); -// assertThat(id).isEqualTo(movie.getId().toString()); -// -// AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) -// .setKs(getAnonymousKs()) -// .setLanguage(JAP); -// Asset asset = executor.executeSync(getAssetBuilder).results; -// assertThat(asset.getName()).isEqualTo(movie.getName() + JAP); -// assertThat(asset.getDescription()).isEqualTo(movie.getDescription() + JAP); + // set multi languages + List languages = executor.executeSync(LanguageService.list(new LanguageFilter()) + .setKs(getOperatorKs())) + .results + .getObjects(); + String lang1 = languages.get(0).getCode(); + String lang2 = languages.get(1).getCode(); + + // prepare data + String lang1Name = getRandomString(); + String lang2Name = getRandomString(); + String lang1Description = "description_" + lang1Name; + String lang2Description = "description_" + lang2Name; + String lang1Meta = "meta_" + lang1Name; + String lang2Meta = "meta_" + lang2Name; + String lang1Tag = "tag_" + lang1Name; + String lang2Tag = "tag_" + lang2Name; + + // set strings meta + Map> metas = new HashMap<>(); + metas.put("shmulik_str3", Map.of(lang1, lang1Meta, lang2, lang2Meta)); + metas.put("BoxOffice", Map.of(lang1, lang1Meta, lang2, lang2Meta)); + metas.put("alon_test2", Map.of(lang1, lang1Meta, lang2, lang2Meta)); + + // set tags + Map>> tags = new HashMap<>(); + tags.put("Actors", Arrays.asList(Map.of(lang1, lang1Tag, lang2, lang2Tag), Map.of(lang1, lang1Tag, lang2, lang2Tag), Map.of(lang1, lang1Tag, lang2, lang2Tag))); + tags.put("TagsTest", Arrays.asList(Map.of(lang1, lang1Tag, lang2, lang2Tag), Map.of(lang1, lang1Tag, lang2, lang2Tag), Map.of(lang1, lang1Tag, lang2, lang2Tag))); + + // ingest vod + VodData vodData = getVodData(MOVIE, INSERT) + .multilingualName(Map.of(lang1, lang1Name, lang2, lang2Name)) + .multilingualDescription(Map.of(lang1, lang1Description, lang2, lang2Description)) + .multilingualStringsMeta(metas) + .multilingualTags(tags); + MediaAsset asset = insertVod(vodData, false); + + // assert multilingual data + // lang1 + Asset lang1Asset = executor.executeSync(get(String.valueOf(asset.getId()), AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()) + .setLanguage(lang1)) + .results; + + assertThat(lang1Asset.getName()).isEqualTo(lang1Name); + assertThat(lang1Asset.getDescription()).isEqualTo(lang1Description); // assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) // .isEqualTo(stringMetaDataValue + JAP); // // check tag value // boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); // assertThat(isTagValueFound).isEqualTo(true); -// -// getAssetBuilder = AssetService.get(id, AssetReferenceType.MEDIA) -// .setKs(getAnonymousKs()) -// .setLanguage(ENG); -// asset = executor.executeSync(getAssetBuilder).results; -// assertThat(asset.getName()).isEqualTo(movie.getName()); -// assertThat(asset.getDescription()).isEqualTo(movie.getDescription()); + + // lang2 + Asset lang2Asset = executor.executeSync(get(String.valueOf(asset.getId()), AssetReferenceType.MEDIA) + .setKs(getAnonymousKs()) + .setLanguage(lang2)) + .results; + + assertThat(lang2Asset.getName()).isEqualTo(lang2Name); + assertThat(lang2Asset.getDescription()).isEqualTo(lang2Description); // assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()).isEqualTo(stringMetaDataValue); // // check tag value // isTagValueFound = isTagValueFound(tagValue1, asset); @@ -601,7 +612,7 @@ void assertVodDeletion(String coguid) { deleteVod(coguid); - AssetService.ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); + ListAssetBuilder listAssetBuilder = list(assetFilter).setKs(getAnonymousKs()); await() .pollInterval(delayBetweenRetriesInSeconds, TimeUnit.SECONDS) .atMost(maxTimeExpectingValidResponseInSeconds, TimeUnit.SECONDS) @@ -612,7 +623,7 @@ void assertVodDeletion(String coguid) { private void assertFiles(List ingestAssetFiles, String assetId) { boolean isFileWasFound = false; - AssetService.GetAssetBuilder assetBuilder = AssetService.get(assetId, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); + GetAssetBuilder assetBuilder = get(assetId, AssetReferenceType.MEDIA).setKs(getAnonymousKs()); com.kaltura.client.utils.response.base.Response assetGetResponse = executor.executeSync(assetBuilder); List getMediaFiles = assetGetResponse.results.getMediaFiles(); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index 3c04f1ab7..dc609eff7 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -83,6 +83,8 @@ public static class VodData { private List thumbRatios; private List files; + private String customMediaType; + public VodData setDefaultValues() { coguid = String.valueOf(getEpochInMillis()); name = coguid; @@ -380,6 +382,11 @@ public static String buildIngestVodXml(VodData vodData, IngestAction action) { } // media type + if (vodData.customMediaType() != null) { + vodData.mediaType(null); + media.getElementsByTagName("media_type").item(0).setTextContent(vodData.customMediaType()); + } + if (vodData.mediaType() != null) { media.getElementsByTagName("media_type").item(0).setTextContent(vodData.mediaType().getValue()); } From 08a79dfa5d5d4c41ba633b490812caf3ccba6e59 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Tue, 2 Oct 2018 17:21:51 +0300 Subject: [PATCH 601/605] Added method setDefaultTagsAndMetas --- .../ParentChildMetadataInheritanceTests.java | 3 ++- .../utils/ingestUtils/IngestVodOpcUtils.java | 16 +++++----------- .../test/utils/ingestUtils/IngestVodUtils.java | 13 +++++++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 5a4bcfce7..c4e0db59e 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -334,7 +334,8 @@ public void testInheritanceWithIngest() { // ingest metas of needed type // IngestVodUtils.VodData vodData = getVodData(MediaType.PACKAGE, INSERT) -// .multilingualStringsMeta(metas); +// .multilingualStringsMeta(metas) +// .mediaType(assetStructParent.getSystemName()); // MediaAsset mediaAsset = insertVod(vodData, false); // assertThat(mediaAsset.getExternalId()).isNotNull(); diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 9193410e7..8e37d96fc 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -75,25 +75,19 @@ public static VodData getVodData(MediaType mediaType, IngestAction action) { switch (mediaType) { case MOVIE: - data.mediaType(MediaType.MOVIE).isVirtual(false); + data.mediaType(MediaType.MOVIE).isVirtual(false).setDefaultTagsAndMetas(); return data; case EPISODE: - data.mediaType(MediaType.EPISODE).isVirtual(false); + data.mediaType(MediaType.EPISODE).isVirtual(false).setDefaultTagsAndMetas(); return data; case SERIES: - data.mediaType(MediaType.SERIES).isVirtual(true); + data.mediaType(MediaType.SERIES).isVirtual(true).setDefaultTagsAndMetas(); return data; // case LINEAR: -// data.mediaType(MediaType.LINEAR).isVirtual(false); +// data.mediaType(MediaType.LINEAR).isVirtual(false).setDefaultTagsAndMetas(); // return data; default: -// data -// .tags(null) -// .stringsMeta(null) -// .datesMeta(null) -// .numbersMeta(null) -// .booleansMeta(null) -// .isVirtual(false); +// data.isVirtual(false); // return data; return null; } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java index eb81919ef..effee691a 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodUtils.java @@ -94,10 +94,6 @@ public VodData setDefaultValues() { startDate = offsetDateValue; endDate = endDateValue; mediaType = MediaType.MOVIE; - tags = getDefaultTags(); - stringsMeta = getDefaultStrings(); - datesMeta = getDefaultDates(); - numbersMeta = getDefaultNumbers(); ppvWebName = ppvNames.get(0); ppvMobileName = ppvNames.get(1); files = getDefaultAssetFiles(ppvWebName, ppvMobileName); @@ -106,6 +102,15 @@ public VodData setDefaultValues() { return this; } + public VodData setDefaultTagsAndMetas() { + tags = getDefaultTags(); + stringsMeta = getDefaultStrings(); + datesMeta = getDefaultDates(); + numbersMeta = getDefaultNumbers(); + + return this; + } + // custom setters for multilingual fields to reset the parallel regular fields public VodData multilingualName(Map multilingualName) { this.name = null; From 4783fa30d43d5b6fa8d692fce157b8d79e9b97b7 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Tue, 2 Oct 2018 17:33:05 +0300 Subject: [PATCH 602/605] no message --- .../ParentChildMetadataInheritanceTests.java | 9 +------- .../five_zero_two/IngestVodOpcTests.java | 21 +++++++++++++------ .../client/test/utils/dbUtils/DBUtils.java | 16 +++++++------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 5a4bcfce7..514e57340 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -3,10 +3,7 @@ import com.kaltura.client.services.*; import com.kaltura.client.services.AssetStructService.*; import com.kaltura.client.test.tests.BaseTest; -import com.kaltura.client.test.tests.enums.AssetStructMetaType; -import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.dbUtils.DBUtils; -import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Link; @@ -19,8 +16,6 @@ import java.util.Map; import static com.kaltura.client.test.tests.enums.AssetStructMetaType.ALL; -import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; -import static com.kaltura.client.test.tests.enums.MediaType.*; import static com.kaltura.client.test.utils.AssetStructMetaUtils.loadAssetStructMeta; import static com.kaltura.client.test.utils.AssetStructUtils.copyAssetStructObject; import static com.kaltura.client.test.utils.AssetStructUtils.getAssetStruct; @@ -28,9 +23,7 @@ import static com.kaltura.client.test.utils.AssetUtils.getMediaAsset; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.DEFAULT_LANGUAGE; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; -import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; import static org.assertj.core.api.Assertions.assertThat; /** @@ -65,7 +58,7 @@ public void setUp() { // metaIds = sharedAssetStructListResponse.results.getObjects().get(0).getMetaIds(); // identify shared assetStructMetas - List assetStructNames = DBUtils.getAllAssetStructMetas(ALL, 2); + List assetStructNames = DBUtils.getAssetStructMetas(ALL, 2); sharedMetaString1 = loadAssetStructMeta(assetStructNames.get(0)); sharedMetaString2 = loadAssetStructMeta(assetStructNames.get(1)); sharedMetaNumber1 = loadAssetStructMeta(assetStructNames.get(2)); diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java index bd3145cf5..bd2d88a5d 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java @@ -388,7 +388,7 @@ public void insertWithInvalidMetaOrTagField() { } @Severity(SeverityLevel.NORMAL) - @Test(description = "insert multilingual fields", enabled = false) + @Test(description = "insert multilingual fields", enabled = true) public void insertMultiLingualFields() { // TODO: 9/17/2018 complete test // set multi languages @@ -410,10 +410,11 @@ public void insertMultiLingualFields() { String lang2Tag = "tag_" + lang2Name; // set strings meta + List metaNames = Arrays.asList("shmulik_str3", "BoxOffice", "alon_test2"); Map> metas = new HashMap<>(); - metas.put("shmulik_str3", Map.of(lang1, lang1Meta, lang2, lang2Meta)); - metas.put("BoxOffice", Map.of(lang1, lang1Meta, lang2, lang2Meta)); - metas.put("alon_test2", Map.of(lang1, lang1Meta, lang2, lang2Meta)); + metas.put(metaNames.get(0), Map.of(lang1, lang1Meta, lang2, lang2Meta)); + metas.put(metaNames.get(1), Map.of(lang1, lang1Meta, lang2, lang2Meta)); + metas.put(metaNames.get(2), Map.of(lang1, lang1Meta, lang2, lang2Meta)); // set tags Map>> tags = new HashMap<>(); @@ -429,17 +430,25 @@ public void insertMultiLingualFields() { MediaAsset asset = insertVod(vodData, false); // assert multilingual data - // lang1 + // assert lang1 asset Asset lang1Asset = executor.executeSync(get(String.valueOf(asset.getId()), AssetReferenceType.MEDIA) .setKs(getAnonymousKs()) .setLanguage(lang1)) .results; + // assert name assertThat(lang1Asset.getName()).isEqualTo(lang1Name); + + // assert description assertThat(lang1Asset.getDescription()).isEqualTo(lang1Description); + + // aasert metas + assertThat(lang1Asset.getMetas().keySet()).containsAll(metaNames); + lang1Asset.getMetas().forEach((s, value) -> System.out.println(s + "_" + value.getDescription())); // assertThat(((MultilingualStringValue)asset.getMetas().get(mediaTextFieldName)).getValue()) // .isEqualTo(stringMetaDataValue + JAP); -// // check tag value + + // assert tags // boolean isTagValueFound = isTagValueFound(tagValue1 + JAP, asset); // assertThat(isTagValueFound).isEqualTo(true); diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index d9547256c..9dc32129c 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -343,7 +343,7 @@ public static Long loadBasicAssetStructMetaId() { .getLong(ID); } - public static List getAllAssetStructMetas(AssetStructMetaType type, int countItems) { + public static List getAssetStructMetas(AssetStructMetaType type, int countItems) { List result = new ArrayList<>(); // TODO: ask developers about ids for assetStructMeta types List idTypes = new ArrayList<>(); @@ -375,19 +375,17 @@ public static List getAllAssetStructMetas(AssetStructMetaType type, int // if type was not specified for (int i=0; i < idTypes.size(); i++) { dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idTypes.get(i)); - addSystemNamesFromResponse2List(result, dbResult); + for (int j=0; j < dbResult.length(); j++) { + result.add(dbResult.getJSONObject(j).getString("system_name")); + } } } else { dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idOfType); - addSystemNamesFromResponse2List(result, dbResult); + for (int i=0; i < dbResult.length(); i++) { + result.add(dbResult.getJSONObject(i).getString("system_name")); + } } return result; } - - static void addSystemNamesFromResponse2List(List result, JSONArray dbResult) { - for (int i=0; i < dbResult.length(); i++) { - result.add(dbResult.getJSONObject(i).getString("system_name")); - } - } } From 9c9095b2227c4cd650f22e63fe76f62edea57916 Mon Sep 17 00:00:00 2001 From: "KALTURA\\michael.Kondratiev" Date: Wed, 3 Oct 2018 08:51:17 +0300 Subject: [PATCH 603/605] AssetStatistics new test --- .../AssetHistoryCleanTests.java | 2 +- .../AssetStatisticsQueryTests.java | 48 +++++++++++++++++++ src/test/resources/WORK_PLAN.md | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/kaltura/client/test/tests/servicesTests/assetStatisticsTests/AssetStatisticsQueryTests.java diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java index f4b7a197d..0752bd9f7 100644 --- a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetHistoryTests/AssetHistoryCleanTests.java @@ -69,7 +69,7 @@ private void assetHistory_clean_tests_before_class() { @Description("assetHistory/action/clean - no filtering") - @Test(groups = {"slowBefore"}, priority = -1) + @Test(groups = {"slowBefore"}) private void cleanHistory_before_wait() { // create household Household household = createHousehold(numOfUsers, numOfDevices, true); diff --git a/src/test/java/com/kaltura/client/test/tests/servicesTests/assetStatisticsTests/AssetStatisticsQueryTests.java b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetStatisticsTests/AssetStatisticsQueryTests.java new file mode 100644 index 000000000..b629c5783 --- /dev/null +++ b/src/test/java/com/kaltura/client/test/tests/servicesTests/assetStatisticsTests/AssetStatisticsQueryTests.java @@ -0,0 +1,48 @@ +package com.kaltura.client.test.tests.servicesTests.assetStatisticsTests; + +import com.kaltura.client.enums.AssetType; +import com.kaltura.client.services.AssetStatisticsService.QueryAssetStatisticsBuilder; +import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; +import com.kaltura.client.test.utils.AssetUtils; +import com.kaltura.client.types.AssetStatistics; +import com.kaltura.client.types.AssetStatisticsQuery; +import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.MediaAsset; +import com.kaltura.client.utils.response.base.Response; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +import static com.kaltura.client.services.AssetStatisticsService.query; + +public class AssetStatisticsQueryTests extends BaseTest{ + + private MediaAsset media1; + private MediaAsset media2; + private MediaAsset media3; + + @BeforeClass(enabled = false) + private void assetStatistics_before_class(){ + List medias = AssetUtils.getAssets(3, MediaType.MOVIE); + media1 = medias.get(0); + media2 = medias.get(1); + media3 = medias.get(2); + } + + @Test(enabled = false) + public void asset(){ + + AssetStatisticsQuery assetStatisticsQuery = new AssetStatisticsQuery(); + assetStatisticsQuery.setAssetIdIn(String.valueOf(media1.getId())); + assetStatisticsQuery.setAssetTypeEqual(AssetType.MEDIA); + + QueryAssetStatisticsBuilder queryAssetStatisticsBuilder = query(assetStatisticsQuery); + Response> assetStatistics = executor.executeSync(queryAssetStatisticsBuilder); + + + } + + +} diff --git a/src/test/resources/WORK_PLAN.md b/src/test/resources/WORK_PLAN.md index d58a8ed49..29efc3b4f 100644 --- a/src/test/resources/WORK_PLAN.md +++ b/src/test/resources/WORK_PLAN.md @@ -16,7 +16,7 @@ Migrate features tests from ReadyAPI | assetFile | | | assetHistory | Done | | assetRule | | -| assetStatistics | | +| assetStatistics | Michael | | assetUserRule | | | bookmark | Done | | cDVRAdapterProfile | | From aaeb843ce335115970f29c2ab0c3be880fd6bef8 Mon Sep 17 00:00:00 2001 From: "alon.basin" Date: Wed, 3 Oct 2018 13:10:50 +0300 Subject: [PATCH 604/605] no message --- src/test/java/com/kaltura/client/test/utils/BaseUtils.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java index aef16a7d4..aae41b653 100644 --- a/src/test/java/com/kaltura/client/test/utils/BaseUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/BaseUtils.java @@ -25,7 +25,7 @@ public class BaseUtils { - private static final String API_SCHEMA_URL = getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION) + "/clientlibs/KalturaClient.xml"; + public static final String API_SCHEMA_URL = getProperty(API_BASE_URL) + "/" + getProperty(API_VERSION) + "/clientlibs/KalturaClient.xml"; private static List exceptions; // to get e.g. yesterday date in specific date format need call the method so: getOffsetDateInFormat(-1, pattern); @@ -182,11 +182,10 @@ private static List getApiExceptionList() { e.printStackTrace(); } Document doc = null; + Logger.getLogger(BaseUtils.class).debug(API_SCHEMA_URL); try { doc = db.parse(new URL(API_SCHEMA_URL).openStream()); - } catch (SAXException e) { - e.printStackTrace(); - } catch (IOException e) { + } catch (SAXException | IOException e) { e.printStackTrace(); } NodeList nodeList = doc.getElementsByTagName("error"); From f0e8e0a4e04743f6e9e06dae06f2181462085894 Mon Sep 17 00:00:00 2001 From: "KALTURA\\Maksim.Superfin" Date: Wed, 3 Oct 2018 13:39:15 +0300 Subject: [PATCH 605/605] More updates for inheritance task --- .../test/tests/enums/AssetStructMetaType.java | 44 +++++- .../ParentChildMetadataInheritanceTests.java | 132 +++++++++++++----- .../test/utils/AssetStructMetaUtils.java | 37 ++++- .../test/utils/dbUtils/DBConstants.java | 6 + .../client/test/utils/dbUtils/DBUtils.java | 89 ++++++++---- .../utils/ingestUtils/IngestVodOpcUtils.java | 12 +- 6 files changed, 247 insertions(+), 73 deletions(-) diff --git a/src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java b/src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java index d14051b49..3a5366c01 100644 --- a/src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java +++ b/src/test/java/com/kaltura/client/test/tests/enums/AssetStructMetaType.java @@ -2,14 +2,56 @@ import com.kaltura.client.enums.EnumAsString; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + public enum AssetStructMetaType implements EnumAsString { - TEXT("Text"), + MULTI_LINGUAL_TEXT("Text"), + STRING("String"), NUMBER("Number"), DATE("Date"), BOOLEAN("Boolean"), + //TAG("tag"), ALL("All"); private String value; + private static List idsOfMetaTypes = null; +// private static Map types2IdsInDb = null; + + /*Data chosen from that ENUM provided by Lior + public enum MetaType + { + All = 0, + String = 1, + Number = 2, + Bool = 3, + Tag = 4, + DateTime = 5, + MultilingualString = 6 + }*/ + public static List getIdsOfMetaTypes() { + if (idsOfMetaTypes == null) { + idsOfMetaTypes = new ArrayList<>(); + idsOfMetaTypes.add(6); // text multilingual + idsOfMetaTypes.add(2); // number + idsOfMetaTypes.add(5); // date + idsOfMetaTypes.add(3); // boolean + idsOfMetaTypes.add(1); // String + } + return idsOfMetaTypes; + } + +// public static Map getTypes2IdsInDb() { +// if (types2IdsInDb == null) { +// types2IdsInDb.put("Text", 6); +// types2IdsInDb.put("Number", 2); +// types2IdsInDb.put("Date", 5); +// types2IdsInDb.put("Boolean", 3); +// types2IdsInDb.put("String", 1); +// } +// return types2IdsInDb; +// } AssetStructMetaType(String value) { this.value = value; diff --git a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java index 8de6e6a30..84806399a 100644 --- a/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java +++ b/src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_three/ParentChildMetadataInheritanceTests.java @@ -1,9 +1,12 @@ package com.kaltura.client.test.tests.featuresTests.versions.five_zero_three; +import com.kaltura.client.enums.AssetReferenceType; import com.kaltura.client.services.*; import com.kaltura.client.services.AssetStructService.*; import com.kaltura.client.test.tests.BaseTest; +import com.kaltura.client.test.tests.enums.MediaType; import com.kaltura.client.test.utils.dbUtils.DBUtils; +import com.kaltura.client.test.utils.ingestUtils.IngestVodUtils; import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; import io.qameta.allure.Link; @@ -16,6 +19,7 @@ import java.util.Map; import static com.kaltura.client.test.tests.enums.AssetStructMetaType.ALL; +import static com.kaltura.client.test.tests.enums.IngestAction.INSERT; import static com.kaltura.client.test.utils.AssetStructMetaUtils.loadAssetStructMeta; import static com.kaltura.client.test.utils.AssetStructUtils.copyAssetStructObject; import static com.kaltura.client.test.utils.AssetStructUtils.getAssetStruct; @@ -23,7 +27,10 @@ import static com.kaltura.client.test.utils.AssetUtils.getMediaAsset; import static com.kaltura.client.test.utils.BaseUtils.getCurrentDateInFormat; import static com.kaltura.client.test.utils.ingestUtils.BaseIngestUtils.DEFAULT_LANGUAGE; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodOpcUtils.getVodData; import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.deleteVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.insertVod; +import static com.kaltura.client.test.utils.ingestUtils.IngestVodUtils.updateVod; import static org.assertj.core.api.Assertions.assertThat; /** @@ -35,13 +42,16 @@ public class ParentChildMetadataInheritanceTests extends BaseTest { private String metaIds; + private String allMetaIds; private Response> sharedAssetStructListResponse; private AssetStruct sharedAssetStruct1, sharedAssetStruct2; private AssetStructMeta sharedMetaString1, sharedMetaString2, sharedMetaNumber1, sharedMetaNumber2; private AssetStructMeta sharedMetaDate1, sharedMetaDate2, sharedMetaBoolean1, sharedMetaBoolean2; private String sharedBasicMetaIds; private String language1; - private Map> metas = new HashMap<>(); + private Map> partMetas = new HashMap<>(); + private Map> allMetas = new HashMap<>(); + private Map> allUpdatedMetas = new HashMap<>(); @BeforeClass() public void setUp() { @@ -67,18 +77,33 @@ public void setUp() { sharedMetaDate2 = loadAssetStructMeta(assetStructNames.get(5)); sharedMetaBoolean1 = loadAssetStructMeta(assetStructNames.get(6)); sharedMetaBoolean2 = loadAssetStructMeta(assetStructNames.get(7)); - // TODO: ask Lior why ONLY these ids are obvious when DB has more basic metas? + // TODO: ask Lior why ONLY these ids are obvious when DB has more basic partMetas? sharedBasicMetaIds = "58,629,1482,1493,1494,1495,1496,1497,566";//loadBasicAssetStructMetaId(); - // TODO: check if type of metas should be updated???? - metas.put(assetStructNames.get(0), Map.of(language1, "Default string value1")); - metas.put(assetStructNames.get(1), Map.of(language1, "Default string value2")); - metas.put(assetStructNames.get(2), Map.of(language1, "1111")); - metas.put(assetStructNames.get(3), Map.of(language1, "1112")); - metas.put(assetStructNames.get(4), Map.of(language1, "01/01/2001")); - metas.put(assetStructNames.get(5), Map.of(language1, "01/01/2002")); - metas.put(assetStructNames.get(6), Map.of(language1, "true")); - metas.put(assetStructNames.get(7), Map.of(language1, "false")); + // fill allMetaIds with fixture partMetas + allMetaIds = getAllFixtureMetaIds(); + + // TODO: check if type of partMetas should be updated???? + partMetas.put(assetStructNames.get(0), Map.of(language1, "Default string value1")); + //partMetas.put(assetStructNames.get(1), Map.of(language1, "Default string value2")); + partMetas.put(assetStructNames.get(2), Map.of(language1, "1111")); + //partMetas.put(assetStructNames.get(3), Map.of(language1, "1112")); + partMetas.put(assetStructNames.get(4), Map.of(language1, "01/01/2001")); + //partMetas.put(assetStructNames.get(5), Map.of(language1, "01/01/2002")); + partMetas.put(assetStructNames.get(6), Map.of(language1, "true")); + //partMetas.put(assetStructNames.get(7), Map.of(language1, "false")); + + allMetas.putAll(partMetas); + allMetas.put(assetStructNames.get(1), Map.of(language1, "Default string value2")); + allMetas.put(assetStructNames.get(3), Map.of(language1, "1112")); + allMetas.put(assetStructNames.get(5), Map.of(language1, "01/01/2002")); + allMetas.put(assetStructNames.get(7), Map.of(language1, "false")); + + allUpdatedMetas.putAll(allMetas); + allUpdatedMetas.put(assetStructNames.get(1), Map.of(language1, "Default string value22")); + allUpdatedMetas.put(assetStructNames.get(3), Map.of(language1, "11122")); + allUpdatedMetas.put(assetStructNames.get(5), Map.of(language1, "01/01/2022")); + allUpdatedMetas.put(assetStructNames.get(7), Map.of(language1, "true")); // create shared assetStruct1 String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); @@ -91,6 +116,27 @@ public void setUp() { sharedAssetStruct2 = createAssetStruct(prefix, metaIds); } + String getAllFixtureMetaIds() { + StringBuilder allMetaIdsSb = new StringBuilder(); + allMetaIdsSb + .append(sharedMetaString1.getMetaId().toString()) + .append(",") + .append(sharedMetaString2.getMetaId().toString()) + .append(",") + .append(sharedMetaNumber1.getMetaId().toString()) + .append(",") + .append(sharedMetaNumber2.getMetaId().toString()) + .append(",") + .append(sharedMetaDate1.getMetaId().toString()) + .append(",") + .append(sharedMetaDate2.getMetaId().toString()) + .append(",") + .append(sharedMetaBoolean1.getMetaId().toString()) + .append(",") + .append(sharedMetaBoolean2.getMetaId().toString()); + return allMetaIdsSb.toString(); + } + @Test public void testAssetStructListSecurity() { // assetStructList Master @@ -297,44 +343,54 @@ public void testInheritanceParentWith2Childrens() { deleteAssetStruct(assetStructParent.getId()); } - @Test // TODO: wait response from Alon + @Test // TODO: wait response from Anat why children wasn't changed public void testInheritanceWithIngest() { // create parent - String metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + String metaIds = allMetaIds + "," + sharedBasicMetaIds; String prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss"); AssetStruct assetStructParent = createAssetStruct(prefix, metaIds); // create children1 - metaIds = sharedMetaString1.getMetaId().toString() + "," + sharedBasicMetaIds; + metaIds = allMetaIds + "," + sharedBasicMetaIds; prefix = "AssetStruct_" + getCurrentDateInFormat("yyMMddHHmmss") + "2"; - AssetStruct assetStructChildren1 = createAssetStruct(prefix, metaIds); + AssetStruct assetStructChildren = createAssetStruct(prefix, metaIds); - // set inheritance between Children1 and Parent - AssetStruct assetStruct2Update = copyAssetStructObject(assetStructChildren1); + // set inheritance between Children and Parent + AssetStruct assetStruct2Update = copyAssetStructObject(assetStructChildren); setInheritanceFieldsInAssetStruct(assetStruct2Update, assetStructParent.getId(), - sharedMetaString1.getMetaId(), sharedMetaDate2.getMetaId()); - updateAssetStruct(assetStructChildren1.getId(), assetStruct2Update, false); - -// // check children asset1 struct has changes -// AssetStructFilter filter = new AssetStructFilter(); -// filter.setIdIn(assetStructChildren1.getId().toString()); -// ListAssetStructBuilder listAssetStructBuilder = AssetStructService.list(filter); -// Response> assetStructListResponse = executor.executeSync(listAssetStructBuilder -// .setKs(getOperatorKs())); -// AssetStruct assetStructFromResponse = assetStructListResponse.results.getObjects().get(0); -// assertThat(assetStructFromResponse.getParentId()).isEqualTo(assetStructParent.getId()); -// assertThat(assetStructFromResponse.getConnectedParentMetaId()).isEqualTo(sharedMetaString1.getMetaId()); -// assertThat(assetStructFromResponse.getConnectingMetaId()).isEqualTo(sharedMetaString2.getMetaId()); + sharedMetaString1.getMetaId(), sharedMetaString1.getMetaId()); + updateAssetStruct(assetStructChildren.getId(), assetStruct2Update, false); - // ingest metas of needed type -// IngestVodUtils.VodData vodData = getVodData(MediaType.PACKAGE, INSERT) -// .multilingualStringsMeta(metas) -// .mediaType(assetStructParent.getSystemName()); -// MediaAsset mediaAsset = insertVod(vodData, false); -// assertThat(mediaAsset.getExternalId()).isNotNull(); + // ingest all metas of needed type // TODO: it does not work with NULL - discuss with Alon what MediaType use instead of it + IngestVodUtils.VodData parentVodData = getVodData(MediaType.PACKAGE, INSERT) + .multilingualStringsMeta(partMetas) + .customMediaType(assetStructParent.getSystemName()); + MediaAsset parentAsset = insertVod(parentVodData, false); + assertThat(parentAsset.getExternalId()).isNotNull(); + + IngestVodUtils.VodData childrenVodData = getVodData(MediaType.PACKAGE, INSERT) + .multilingualStringsMeta(allMetas) + .customMediaType(assetStructChildren.getSystemName()); + MediaAsset childrenAsset = insertVod(childrenVodData, false); + assertThat(childrenAsset.getExternalId()).isNotNull(); + // TODO: check metas on children + + String coguid = parentAsset.getExternalId(); + parentVodData = new IngestVodUtils.VodData() + .multilingualStringsMeta(allUpdatedMetas) + .customMediaType(assetStructParent.getSystemName()); + parentAsset = updateVod(coguid, parentVodData); + + // TODO: check metas on children after parent update + + AssetService.GetAssetBuilder getAssetBuilder = AssetService.get(childrenAsset.getId().toString(), AssetReferenceType.MEDIA); + Response assetResponse = executor.executeSync(getAssetBuilder + .setKs(getOperatorKs())); + assertThat(assetResponse.results).isNotNull(); // remove assetStructs -// deleteVod(mediaAsset.getExternalId()); - deleteAssetStruct(assetStructChildren1.getId()); // firstly should be deleted childrens + deleteVod(childrenAsset.getExternalId()); + deleteVod(parentAsset.getExternalId()); + deleteAssetStruct(assetStructChildren.getId()); // firstly should be deleted children deleteAssetStruct(assetStructParent.getId()); } diff --git a/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java b/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java index 68fd8c5b2..751a7847b 100644 --- a/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/AssetStructMetaUtils.java @@ -1,14 +1,20 @@ package com.kaltura.client.test.utils; import com.kaltura.client.services.AssetStructMetaService; +import com.kaltura.client.services.AssetStructService; import com.kaltura.client.test.TestAPIOkRequestsExecutor; +import com.kaltura.client.test.tests.enums.AssetStructMetaType; import com.kaltura.client.test.utils.dbUtils.DBUtils; -import com.kaltura.client.types.AssetStructMeta; -import com.kaltura.client.types.AssetStructMetaFilter; -import com.kaltura.client.types.ListResponse; +import com.kaltura.client.types.*; import com.kaltura.client.utils.response.base.Response; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; import static com.kaltura.client.test.tests.BaseTest.getOperatorKs; +import static com.kaltura.client.test.utils.dbUtils.DBUtils.getMetaNameById; +import static org.assertj.core.api.Assertions.assertThat; public class AssetStructMetaUtils extends BaseUtils { @@ -38,4 +44,29 @@ public static AssetStructMeta getAssetStructMeta(String defaultIngestValue, Stri return assetStructMeta; } + +// TODO: COMPLETE THE METHOD +// public static List getAssetStructMetas(Long assetStructId, AssetStructMetaType type, boolean processBasicFields) { +// List result = new ArrayList<>(); +// +// AssetStructMetaFilter assetStructMetaFilter = new AssetStructMetaFilter(); +// assetStructMetaFilter.setAssetStructIdEqual(assetStructId); +// AssetStructMetaService.ListAssetStructMetaBuilder listAssetStructMetaBuilder = AssetStructMetaService.list(assetStructMetaFilter); +// Response> listAssetMetaStructResponse = executor.executeSync(listAssetStructMetaBuilder +// .setKs(getOperatorKs())); +// +// String name; +// for (AssetStructMeta assetStructMeta: listAssetMetaStructResponse.results.getObjects()) { +// name = getMetaNameById(assetStructMeta.getMetaId(), processBasicFields); +// if (StringUtils.isNotEmpty(name)) { +// if (!AssetStructMetaType.ALL.equals(type)) { +// +// } +// } +// } +// +// //assertThat(assetStructFromResponse.getParentId()).isEqualTo(0L); +// +// return result; +// } } diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java index 18f36ab1c..8eaf8aa60 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBConstants.java @@ -88,11 +88,17 @@ public class DBConstants { "from [Tvinci].[dbo].[groups_passwords]\n" + "where [group_id]=? and is_active=1 and [status]=1 order by UPDATE_DATE DESC"; + static final String META_ID_SELECT_BY_ASSET_STRUCT_ID = "SELECT * FROM [TVinci].[dbo].[template_topics]\n" + + "WHERE [STATUS]=1 AND GROUP_ID=? AND TEMPLATE_ID=?\n"; + static final String META_SELECT = "SELECT TOP (?) * FROM [TVinci].[dbo].[topics]\n" + "WHERE IS_BASIC=? AND GROUP_ID=? AND [STATUS]=1 AND TOPIC_TYPE_ID !=4"; // 4 IS FOR TAGS static final String META_NAME_SELECT_BY_ID = "SELECT * FROM [TVinci].[dbo].[topics]\n" + "WHERE [STATUS]=1 AND GROUP_ID=? AND ID=?\n"; +// +// static final String META_NAME_SELECT_BY_IDS = "SELECT * FROM [TVinci].[dbo].[topics]\n" + +// "WHERE [STATUS]=1 AND GROUP_ID=? AND ID in (?)\n"; static final String META_OR_TAG_SELECT_BY_NAME = "SELECT * FROM [TVinci].[dbo].[topics]\n" + "WHERE [STATUS]=1 AND GROUP_ID=? AND SYSTEM_NAME=?\n"; diff --git a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java index 9dc32129c..f6e26c1d5 100644 --- a/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/dbUtils/DBUtils.java @@ -25,6 +25,7 @@ import static com.kaltura.client.test.Properties.*; import static com.kaltura.client.test.tests.BaseTest.*; +import static com.kaltura.client.test.tests.enums.AssetStructMetaType.getIdsOfMetaTypes; import static com.kaltura.client.test.utils.dbUtils.DBConstants.*; import static com.kaltura.client.test.utils.dbUtils.IngestFixtureData.loadFirstPricePlanFromJsonArray; import static org.assertj.core.api.Assertions.fail; @@ -335,6 +336,41 @@ public static String getMetaNameById(Long id, boolean processBasicFields) { .getJSONObject(0); return (processBasicFields || (jsonObject.getInt(IS_BASIC) == 0)) ? jsonObject.getString(SYSTEM_NAME) : null; } +// TODO: probably have to be removed as has select with IN that we aren't process +// public static List getMetaNamesByAssetStructId(Long assetStructId, AssetStructMetaType type) { +// List result = new ArrayList<>(); +// +// List metaIds = new ArrayList<>(); +// JSONArray jsonArrayFromQueryResult = getJsonArrayFromQueryResult(META_ID_SELECT_BY_ASSET_STRUCT_ID, partnerId, assetStructId); +// for (int i=0; i < jsonArrayFromQueryResult.length(); i++) { +// metaIds.add(String.valueOf(jsonArrayFromQueryResult.getJSONObject(i).getLong("topic_id"))); +// } +// if (metaIds.size() > 0) { +// List idsOfMetaTypes = getIdsOfMetaTypes(); +// int idOfType = getIdOfSelectedMetaType(type, idsOfMetaTypes); +// +// String ids = String.join(",", metaIds); +// JSONArray dbResult; +// if (idOfType ==-1) { +// // if type was not specified +// for (int i=0; i < idsOfMetaTypes.size(); i++) { +// dbResult = getJsonArrayFromQueryResult(META_NAME_SELECT_BY_IDS + " AND TOPIC_TYPE_ID=?", +// partnerId, ids, idsOfMetaTypes.get(i)); +// for (int j=0; j < dbResult.length(); j++) { +// result.add(dbResult.getJSONObject(j).getString(SYSTEM_NAME)); +// } +// } +// } else { +// dbResult = getJsonArrayFromQueryResult(META_NAME_SELECT_BY_IDS + " AND TOPIC_TYPE_ID=?", +// partnerId, ids, idOfType); +// for (int i=0; i < dbResult.length(); i++) { +// result.add(dbResult.getJSONObject(i).getString(SYSTEM_NAME)); +// } +// } +// } +// +// return result; +// } // TODO: check if it be used after completing functionality public static Long loadBasicAssetStructMetaId() { @@ -345,15 +381,32 @@ public static Long loadBasicAssetStructMetaId() { public static List getAssetStructMetas(AssetStructMetaType type, int countItems) { List result = new ArrayList<>(); - // TODO: ask developers about ids for assetStructMeta types - List idTypes = new ArrayList<>(); - idTypes.add(6); // text - idTypes.add(2); // number - idTypes.add(5); // date - idTypes.add(3); // boolean + List idsOfMetaTypes = getIdsOfMetaTypes(); + int idOfType = getIdOfSelectedMetaType(type, idsOfMetaTypes); + + JSONArray dbResult; + if (idOfType ==-1) { + // if type was not specified + for (int i=0; i < idsOfMetaTypes.size(); i++) { + dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idsOfMetaTypes.get(i)); + for (int j=0; j < dbResult.length(); j++) { + result.add(dbResult.getJSONObject(j).getString(SYSTEM_NAME)); + } + } + } else { + dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idOfType); + for (int i=0; i < dbResult.length(); i++) { + result.add(dbResult.getJSONObject(i).getString(SYSTEM_NAME)); + } + } + + return result; + } + + static int getIdOfSelectedMetaType(AssetStructMetaType type, List idTypes) { int idOfType =-1; switch (type) { - case TEXT: + case MULTI_LINGUAL_TEXT: idOfType = idTypes.get(0); break; case NUMBER: @@ -365,27 +418,13 @@ public static List getAssetStructMetas(AssetStructMetaType type, int cou case BOOLEAN: idOfType = idTypes.get(3); break; + case STRING: + idOfType = idTypes.get(4); + break; default: // all types break; } - - JSONArray dbResult; - if (idOfType ==-1) { - // if type was not specified - for (int i=0; i < idTypes.size(); i++) { - dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idTypes.get(i)); - for (int j=0; j < dbResult.length(); j++) { - result.add(dbResult.getJSONObject(j).getString("system_name")); - } - } - } else { - dbResult = getJsonArrayFromQueryResult(META_SELECT + " AND TOPIC_TYPE_ID=?", countItems, 0, partnerId, idOfType); - for (int i=0; i < dbResult.length(); i++) { - result.add(dbResult.getJSONObject(i).getString("system_name")); - } - } - - return result; + return idOfType; } } diff --git a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java index 8e37d96fc..822eee162 100644 --- a/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java +++ b/src/test/java/com/kaltura/client/test/utils/ingestUtils/IngestVodOpcUtils.java @@ -83,13 +83,13 @@ public static VodData getVodData(MediaType mediaType, IngestAction action) { case SERIES: data.mediaType(MediaType.SERIES).isVirtual(true).setDefaultTagsAndMetas(); return data; -// case LINEAR: -// data.mediaType(MediaType.LINEAR).isVirtual(false).setDefaultTagsAndMetas(); -// return data; + case LINEAR: + data.mediaType(MediaType.LINEAR).isVirtual(false).setDefaultTagsAndMetas(); + return data; default: -// data.isVirtual(false); -// return data; - return null; + data.isVirtual(false); + return data; +// return null; } }