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;
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
add a comment |
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
add a comment |
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
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
scala guice slick slick-3.0
asked Mar 25 at 19:51
Chaitanya WaikarChaitanya Waikar
2,0754 silver badges20 bronze badges
2,0754 silver badges20 bronze badges
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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