Unable to mock the table in slickHow to add methods to Slick tables?Slick table does not take type parametercreate a class Table for an inexisting table slick scala (Slick 3.0.0, scala)Slick 3.0 Insert and then get Auto Increment ValueSlick 3 simple join on tablesMock database in Slick 3.xSlick 3.0. How to map slick table of tuples to my domain class?Exporting Slick table in PlaySlick DAOCreating a single column table with SlickDeleting Rows from multiple tables in a slick query

What instances can be solved today by modern solvers (pure LP)?

How frequently do Russian people still refer to others by their patronymic (отчество)?

Why does mean tend be more stable in different samples than median?

A positive integer functional equation

Why no parachutes in the Orion AA2 abort test?

Can you take the Dodge action while prone?

Isn't "Dave's protocol" good if only the database, and not the code, is leaked?

Taking my Ph.D. advisor out for dinner after graduation

Are "confidant" and "confident" homophones?

What do I need to see before Spider-Man: Far From Home?

Did William Shakespeare hide things in his writings?

Is it possible to spoof an IP address to an exact number?

What is the maximum amount of diamond in one Minecraft game?

How can I create a dashed line that slowly changes into a solid line in Illustrator?

How to supply water to a coastal desert town with no rain and no freshwater aquifers?

Why do Martians have to wear space helmets?

What causes a fastener to lock?

Do intermediate subdomains need to exist?

Why did moving the mouse cursor cause Windows 95 to run more quickly?

Has there ever been a cold war other than between the U.S. and the U.S.S.R.?

Is it acceptable that I plot a time-series figure with years increasing from right to left?

What happens if the limit of 4 billion files was exceeded in an ext4 partition?

How can select a specific triangle in my Delaunay mesh?

Why do we need a bootloader separate from our application program in microcontrollers?



Unable to mock the table in slick


How to add methods to Slick tables?Slick table does not take type parametercreate a class Table for an inexisting table slick scala (Slick 3.0.0, scala)Slick 3.0 Insert and then get Auto Increment ValueSlick 3 simple join on tablesMock database in Slick 3.xSlick 3.0. How to map slick table of tuples to my domain class?Exporting Slick table in PlaySlick DAOCreating a single column table with SlickDeleting Rows from multiple tables in a slick query






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am having a scala-play-slick application and am using Google guice for dependency injection.
Slick version 3.0.3
My repository looks as follows



@Singleton
class Repository @Inject()(dbConfigProvider: DatabaseConfigProvider)(
implicit ec: ExecutionContext) {

private val dbConfig = dbConfigProvider.get[JdbcProfile]

import dbConfig._
import profile.api._

private class MyTable(tag: Tag) extends Table[ModelObject](tag, "TableName")

def id = column[Int]("id", O.PrimaryKey, O.AutoInc)

def * =
(id) <> ((ModelObject.apply _).tupled, ModelObject.unapply)


private val myTable = TableQuery[MyTable]

def getAll: Future[Seq[ModelObject]] = db.run
myTable.result

// remaining code


Now, to unit test the code, I have the following code



class RepositoryTest extends FunSuite with Matchers with BeforeAndAfterEach 

private var databaseConfigProvider : DatabaseConfigProvider = _
private var repository : Repository = _

override def beforeEach(): Unit =
databaseConfigProvider = mock(classOf[DatabaseConfigProvider])
repository = new Repository(databaseConfigProvider)


test("should get all the model object")
val result = usersRepository.getAll(userRequest).await
result shouldBe modelObjects





While running the test case, I get the Nullpointer exception



java.lang.NullPointerException was thrown.
java.lang.NullPointerException


at the line db.run in getAll method. Now my question is, how should I mock the MyTable so as to avoid the null pointer exception.



Any pointers will be highly helpful. Thanks in advance !!!










share|improve this question




























    0















    I am having a scala-play-slick application and am using Google guice for dependency injection.
    Slick version 3.0.3
    My repository looks as follows



    @Singleton
    class Repository @Inject()(dbConfigProvider: DatabaseConfigProvider)(
    implicit ec: ExecutionContext) {

    private val dbConfig = dbConfigProvider.get[JdbcProfile]

    import dbConfig._
    import profile.api._

    private class MyTable(tag: Tag) extends Table[ModelObject](tag, "TableName")

    def id = column[Int]("id", O.PrimaryKey, O.AutoInc)

    def * =
    (id) <> ((ModelObject.apply _).tupled, ModelObject.unapply)


    private val myTable = TableQuery[MyTable]

    def getAll: Future[Seq[ModelObject]] = db.run
    myTable.result

    // remaining code


    Now, to unit test the code, I have the following code



    class RepositoryTest extends FunSuite with Matchers with BeforeAndAfterEach 

    private var databaseConfigProvider : DatabaseConfigProvider = _
    private var repository : Repository = _

    override def beforeEach(): Unit =
    databaseConfigProvider = mock(classOf[DatabaseConfigProvider])
    repository = new Repository(databaseConfigProvider)


    test("should get all the model object")
    val result = usersRepository.getAll(userRequest).await
    result shouldBe modelObjects





    While running the test case, I get the Nullpointer exception



    java.lang.NullPointerException was thrown.
    java.lang.NullPointerException


    at the line db.run in getAll method. Now my question is, how should I mock the MyTable so as to avoid the null pointer exception.



    Any pointers will be highly helpful. Thanks in advance !!!










    share|improve this question
























      0












      0








      0








      I am having a scala-play-slick application and am using Google guice for dependency injection.
      Slick version 3.0.3
      My repository looks as follows



      @Singleton
      class Repository @Inject()(dbConfigProvider: DatabaseConfigProvider)(
      implicit ec: ExecutionContext) {

      private val dbConfig = dbConfigProvider.get[JdbcProfile]

      import dbConfig._
      import profile.api._

      private class MyTable(tag: Tag) extends Table[ModelObject](tag, "TableName")

      def id = column[Int]("id", O.PrimaryKey, O.AutoInc)

      def * =
      (id) <> ((ModelObject.apply _).tupled, ModelObject.unapply)


      private val myTable = TableQuery[MyTable]

      def getAll: Future[Seq[ModelObject]] = db.run
      myTable.result

      // remaining code


      Now, to unit test the code, I have the following code



      class RepositoryTest extends FunSuite with Matchers with BeforeAndAfterEach 

      private var databaseConfigProvider : DatabaseConfigProvider = _
      private var repository : Repository = _

      override def beforeEach(): Unit =
      databaseConfigProvider = mock(classOf[DatabaseConfigProvider])
      repository = new Repository(databaseConfigProvider)


      test("should get all the model object")
      val result = usersRepository.getAll(userRequest).await
      result shouldBe modelObjects





      While running the test case, I get the Nullpointer exception



      java.lang.NullPointerException was thrown.
      java.lang.NullPointerException


      at the line db.run in getAll method. Now my question is, how should I mock the MyTable so as to avoid the null pointer exception.



      Any pointers will be highly helpful. Thanks in advance !!!










      share|improve this question














      I am having a scala-play-slick application and am using Google guice for dependency injection.
      Slick version 3.0.3
      My repository looks as follows



      @Singleton
      class Repository @Inject()(dbConfigProvider: DatabaseConfigProvider)(
      implicit ec: ExecutionContext) {

      private val dbConfig = dbConfigProvider.get[JdbcProfile]

      import dbConfig._
      import profile.api._

      private class MyTable(tag: Tag) extends Table[ModelObject](tag, "TableName")

      def id = column[Int]("id", O.PrimaryKey, O.AutoInc)

      def * =
      (id) <> ((ModelObject.apply _).tupled, ModelObject.unapply)


      private val myTable = TableQuery[MyTable]

      def getAll: Future[Seq[ModelObject]] = db.run
      myTable.result

      // remaining code


      Now, to unit test the code, I have the following code



      class RepositoryTest extends FunSuite with Matchers with BeforeAndAfterEach 

      private var databaseConfigProvider : DatabaseConfigProvider = _
      private var repository : Repository = _

      override def beforeEach(): Unit =
      databaseConfigProvider = mock(classOf[DatabaseConfigProvider])
      repository = new Repository(databaseConfigProvider)


      test("should get all the model object")
      val result = usersRepository.getAll(userRequest).await
      result shouldBe modelObjects





      While running the test case, I get the Nullpointer exception



      java.lang.NullPointerException was thrown.
      java.lang.NullPointerException


      at the line db.run in getAll method. Now my question is, how should I mock the MyTable so as to avoid the null pointer exception.



      Any pointers will be highly helpful. Thanks in advance !!!







      scala guice slick slick-3.0






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 19:51









      Chaitanya WaikarChaitanya Waikar

      2,0754 silver badges20 bronze badges




      2,0754 silver badges20 bronze badges






















          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345418%2funable-to-mock-the-table-in-slick%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345418%2funable-to-mock-the-table-in-slick%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현