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

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript