diff --git a/obp-api/src/main/scala/code/remotedata/RemotedataViews.scala b/obp-api/src/main/scala/code/remotedata/RemotedataViews.scala index e8999f00d..12e155d93 100644 --- a/obp-api/src/main/scala/code/remotedata/RemotedataViews.scala +++ b/obp-api/src/main/scala/code/remotedata/RemotedataViews.scala @@ -144,10 +144,6 @@ object RemotedataViews extends ObpActorInit with Views { (actor ? cc.getOrCreatePublicPublicView(bankId, accountId, description)).mapTo[Box[View]] ) - def createCustomRandomView(bankId: BankId, accountId: AccountId) : Box[View] = getValueFromFuture( - (actor ? cc.createRandomView(bankId, accountId)).mapTo[Box[View]] - ) - // For tests def bulkDeleteAllPermissionsAndViews(): Boolean = getValueFromFuture( (actor ? cc.bulkDeleteAllPermissionsAndViews()).mapTo[Boolean] diff --git a/obp-api/src/main/scala/code/remotedata/RemotedataViewsActor.scala b/obp-api/src/main/scala/code/remotedata/RemotedataViewsActor.scala index a731b5d74..da5a0562e 100644 --- a/obp-api/src/main/scala/code/remotedata/RemotedataViewsActor.scala +++ b/obp-api/src/main/scala/code/remotedata/RemotedataViewsActor.scala @@ -134,10 +134,6 @@ class RemotedataViewsActor extends Actor with ObpActorHelper with MdcLoggable { logger.debug("getOrCreatePublicPublicView(" + bankId +", "+ accountId +", "+ description +")") sender ! (mapper.getOrCreateCustomPublicView(bankId, accountId, description)) - case cc.createRandomView(bankId, accountId) => - logger.debug("createRandomView(" + bankId +", "+ accountId +")") - sender ! (mapper.createCustomRandomView(bankId, accountId)) - case cc.getOwners(view) => logger.debug("getOwners(" + view +")") sender ! (mapper.getOwners(view)) diff --git a/obp-api/src/main/scala/code/views/MapperViews.scala b/obp-api/src/main/scala/code/views/MapperViews.scala index c665393f8..06f209507 100644 --- a/obp-api/src/main/scala/code/views/MapperViews.scala +++ b/obp-api/src/main/scala/code/views/MapperViews.scala @@ -662,113 +662,6 @@ object MapperViews extends Views with MdcLoggable { } } - /** - * This is only for scala tests. - */ - def createCustomRandomView(bankId: BankId, accountId: AccountId) : Box[View] = { - //we set the length is to 40, try to be difficult for scala tests create the same viewName. - val viewName = "_" + randomString(40) - val viewId = MapperViews.createViewIdByName(viewName) - val description = randomString(40) - - if (!checkCustomViewIdOrName(viewName)) { - return Failure(InvalidCustomViewFormat) - } - - getExistingCustomView(bankId, accountId, viewId) match { - case Empty => { - tryo{ViewDefinition.create. - isSystem_(false). - isFirehose_(false). - name_(viewName). - metadataView_(SYSTEM_OWNER_VIEW_ID). - description_(description). - view_id(viewId). - isPublic_(false). - bank_id(bankId.value). - account_id(accountId.value). - usePrivateAliasIfOneExists_(false). - usePublicAliasIfOneExists_(false). - hideOtherAccountMetadataIfAlias_(false). - canSeeTransactionThisBankAccount_(true). - canSeeTransactionOtherBankAccount_(true). - canSeeTransactionMetadata_(true). - canSeeTransactionDescription_(true). - canSeeTransactionAmount_(true). - canSeeTransactionType_(true). - canSeeTransactionCurrency_(true). - canSeeTransactionStartDate_(true). - canSeeTransactionFinishDate_(true). - canSeeTransactionBalance_(true). - canSeeComments_(true). - canSeeOwnerComment_(true). - canSeeTags_(true). - canSeeImages_(true). - canSeeBankAccountOwners_(true). - canSeeBankAccountType_(true). - canSeeBankAccountBalance_(true). - canSeeBankAccountCurrency_(true). - canSeeBankAccountLabel_(true). - canSeeBankAccountNationalIdentifier_(true). - canSeeBankAccountSwift_bic_(true). - canSeeBankAccountIban_(true). - canSeeBankAccountNumber_(true). - canSeeBankAccountBankName_(true). - canSeeBankAccountBankPermalink_(true). - canSeeOtherAccountNationalIdentifier_(true). - canSeeOtherAccountSWIFT_BIC_(true). - canSeeOtherAccountIBAN_(true). - canSeeOtherAccountBankName_(true). - canSeeOtherAccountNumber_(true). - canSeeOtherAccountMetadata_(true). - canSeeOtherAccountKind_(true). - canSeeMoreInfo_(true). - canSeeUrl_(true). - canSeeImageUrl_(true). - canSeeOpenCorporatesUrl_(true). - canSeeCorporateLocation_(true). - canSeePhysicalLocation_(true). - canSeePublicAlias_(true). - canSeePrivateAlias_(true). - canAddMoreInfo_(true). - canAddURL_(true). - canAddImageURL_(true). - canAddOpenCorporatesUrl_(true). - canAddCorporateLocation_(true). - canAddPhysicalLocation_(true). - canAddPublicAlias_(true). - canAddPrivateAlias_(true). - canDeleteCorporateLocation_(true). - canDeletePhysicalLocation_(true). - canEditOwnerComment_(true). - canAddComment_(true). - canDeleteComment_(true). - canAddTag_(true). - canDeleteTag_(true). - canAddImage_(true). - canDeleteImage_(true). - canAddWhereTag_(true). - canSeeWhereTag_(true). - canDeleteWhereTag_(true). - canSeeBankRoutingScheme_(true). //added following in V300 - canSeeBankRoutingAddress_(true). - canSeeBankAccountRoutingScheme_(true). - canSeeBankAccountRoutingAddress_(true). - canSeeOtherBankRoutingScheme_(true). - canSeeOtherBankRoutingAddress_(true). - canSeeOtherAccountRoutingScheme_(true). - canSeeOtherAccountRoutingAddress_(true). - canAddTransactionRequestToOwnAccount_(false). //added following two for payments - canAddTransactionRequestToAnyAccount_(false). - canSeeBankAccountCreditLimit_(true). - saveMe} - } - case Full(v) => Full(v) - case Failure(msg, t, c) => Failure(msg, t, c) - case ParamFailure(x, y, z, q) => ParamFailure(x, y, z, q) - } - } - def createDefaultSystemView(name: String): Box[View] = { createAndSaveSystemView(name) } diff --git a/obp-api/src/main/scala/code/views/Views.scala b/obp-api/src/main/scala/code/views/Views.scala index 8049ec776..4abd2c425 100644 --- a/obp-api/src/main/scala/code/views/Views.scala +++ b/obp-api/src/main/scala/code/views/Views.scala @@ -113,11 +113,6 @@ trait Views { def getOrCreateSystemView(viewId: String) : Box[View] def getOrCreateCustomPublicView(bankId: BankId, accountId: AccountId, description: String) : Box[View] - /** - * this is only used for the scala test - */ - def createCustomRandomView(bankId: BankId, accountId: AccountId) : Box[View] - def getOwners(view: View): Set[User] def removeAllPermissions(bankId: BankId, accountId: AccountId) : Boolean @@ -167,7 +162,6 @@ class RemotedataViewsCaseClasses { case class getOrCreateSystemViewFromCbs(viewId: String) case class getOrCreateSystemView(viewId: String) case class getOrCreatePublicPublicView(bankId: BankId, accountId: AccountId, description: String) - case class createRandomView(bankId: BankId, accountId: AccountId) case class getOwners(view: View) diff --git a/obp-api/src/test/scala/code/setup/TestConnectorSetupWithStandardPermissions.scala b/obp-api/src/test/scala/code/setup/TestConnectorSetupWithStandardPermissions.scala index a3805d5f4..5141e4cfd 100644 --- a/obp-api/src/test/scala/code/setup/TestConnectorSetupWithStandardPermissions.scala +++ b/obp-api/src/test/scala/code/setup/TestConnectorSetupWithStandardPermissions.scala @@ -3,11 +3,15 @@ package code.setup import bootstrap.liftweb.ToSchemify import code.accountholders.AccountHolders import code.api.Constant.{CUSTOM_PUBLIC_VIEW_ID, SYSTEM_OWNER_VIEW_ID} +import code.api.util.APIUtil.checkCustomViewIdOrName import code.api.util.ErrorMessages._ import code.model._ import code.model.dataAccess._ -import code.views.Views +import code.views.MapperViews.getExistingCustomView +import code.views.system.ViewDefinition +import code.views.{MapperViews, Views} import com.openbankproject.commons.model._ +import net.liftweb.common.{Failure, Full, ParamFailure} import net.liftweb.mapper.MetaMapper import net.liftweb.util.Helpers._ @@ -32,8 +36,112 @@ trait TestConnectorSetupWithStandardPermissions extends TestConnectorSetup { Views.views.vend.getOrCreateCustomPublicView(bankId: BankId, accountId: AccountId, CUSTOM_PUBLIC_VIEW_ID).openOrThrowException(attemptedToOpenAnEmptyBox) } - protected def createCustomRandomView(bankId: BankId, accountId: AccountId) : View = { - Views.views.vend.createCustomRandomView(bankId, accountId).openOrThrowException(attemptedToOpenAnEmptyBox) + def createCustomRandomView(bankId: BankId, accountId: AccountId) : View = { + { + //we set the length is to 40, try to be difficult for scala tests create the same viewName. + val viewName = "_" + randomString(40) + val viewId = MapperViews.createViewIdByName(viewName) + val description = randomString(40) + + if (!checkCustomViewIdOrName(viewName)) { + throw new RuntimeException(InvalidCustomViewFormat) + } + + getExistingCustomView(bankId, accountId, viewId) match { + case net.liftweb.common.Empty => { + tryo { + ViewDefinition.create. + isSystem_(false). + isFirehose_(false). + name_(viewName). + metadataView_(SYSTEM_OWNER_VIEW_ID). + description_(description). + view_id(viewId). + isPublic_(false). + bank_id(bankId.value). + account_id(accountId.value). + usePrivateAliasIfOneExists_(false). + usePublicAliasIfOneExists_(false). + hideOtherAccountMetadataIfAlias_(false). + canSeeTransactionThisBankAccount_(true). + canSeeTransactionOtherBankAccount_(true). + canSeeTransactionMetadata_(true). + canSeeTransactionDescription_(true). + canSeeTransactionAmount_(true). + canSeeTransactionType_(true). + canSeeTransactionCurrency_(true). + canSeeTransactionStartDate_(true). + canSeeTransactionFinishDate_(true). + canSeeTransactionBalance_(true). + canSeeComments_(true). + canSeeOwnerComment_(true). + canSeeTags_(true). + canSeeImages_(true). + canSeeBankAccountOwners_(true). + canSeeBankAccountType_(true). + canSeeBankAccountBalance_(true). + canSeeBankAccountCurrency_(true). + canSeeBankAccountLabel_(true). + canSeeBankAccountNationalIdentifier_(true). + canSeeBankAccountSwift_bic_(true). + canSeeBankAccountIban_(true). + canSeeBankAccountNumber_(true). + canSeeBankAccountBankName_(true). + canSeeBankAccountBankPermalink_(true). + canSeeOtherAccountNationalIdentifier_(true). + canSeeOtherAccountSWIFT_BIC_(true). + canSeeOtherAccountIBAN_(true). + canSeeOtherAccountBankName_(true). + canSeeOtherAccountNumber_(true). + canSeeOtherAccountMetadata_(true). + canSeeOtherAccountKind_(true). + canSeeMoreInfo_(true). + canSeeUrl_(true). + canSeeImageUrl_(true). + canSeeOpenCorporatesUrl_(true). + canSeeCorporateLocation_(true). + canSeePhysicalLocation_(true). + canSeePublicAlias_(true). + canSeePrivateAlias_(true). + canAddMoreInfo_(true). + canAddURL_(true). + canAddImageURL_(true). + canAddOpenCorporatesUrl_(true). + canAddCorporateLocation_(true). + canAddPhysicalLocation_(true). + canAddPublicAlias_(true). + canAddPrivateAlias_(true). + canDeleteCorporateLocation_(true). + canDeletePhysicalLocation_(true). + canEditOwnerComment_(true). + canAddComment_(true). + canDeleteComment_(true). + canAddTag_(true). + canDeleteTag_(true). + canAddImage_(true). + canDeleteImage_(true). + canAddWhereTag_(true). + canSeeWhereTag_(true). + canDeleteWhereTag_(true). + canSeeBankRoutingScheme_(true). //added following in V300 + canSeeBankRoutingAddress_(true). + canSeeBankAccountRoutingScheme_(true). + canSeeBankAccountRoutingAddress_(true). + canSeeOtherBankRoutingScheme_(true). + canSeeOtherBankRoutingAddress_(true). + canSeeOtherAccountRoutingScheme_(true). + canSeeOtherAccountRoutingAddress_(true). + canAddTransactionRequestToOwnAccount_(false). //added following two for payments + canAddTransactionRequestToAnyAccount_(false). + canSeeBankAccountCreditLimit_(true). + saveMe + } + } + case Full(v) => Full(v) + case Failure(msg, t, c) => Failure(msg, t, c) + case ParamFailure(x, y, z, q) => ParamFailure(x, y, z, q) + } + }.openOrThrowException(attemptedToOpenAnEmptyBox) }