Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
9b05326f
Commit
9b05326f
authored
Apr 19, 2013
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Option 相关单元测试
parent
bf8cb4f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
826 additions
and
525 deletions
+826
-525
core/src/main/java/org/b3log/solo/service/OptionMgmtService.java
...c/main/java/org/b3log/solo/service/OptionMgmtService.java
+28
-31
core/src/test/java/org/b3log/solo/AbstractTestCase.java
core/src/test/java/org/b3log/solo/AbstractTestCase.java
+569
-494
core/src/test/java/org/b3log/solo/repository/impl/OptionRepositoryImplTestCase.java
...og/solo/repository/impl/OptionRepositoryImplTestCase.java
+58
-0
core/src/test/java/org/b3log/solo/service/OptionMgmtServiceTestCase.java
...ava/org/b3log/solo/service/OptionMgmtServiceTestCase.java
+106
-0
core/src/test/java/org/b3log/solo/service/OptionQueryServiceTestCase.java
...va/org/b3log/solo/service/OptionQueryServiceTestCase.java
+65
-0
No files found.
core/src/main/java/org/b3log/solo/service/OptionMgmtService.java
View file @
9b05326f
...
@@ -47,24 +47,36 @@ public final class OptionMgmtService {
...
@@ -47,24 +47,36 @@ public final class OptionMgmtService {
private
OptionRepository
optionRepository
=
OptionRepositoryImpl
.
getInstance
();
private
OptionRepository
optionRepository
=
OptionRepositoryImpl
.
getInstance
();
/**
/**
*
Updates the specified option, if not found the old version of the specified option by id, creates it
.
*
Adds or updates the specified option
.
*
*
* @param option the specified option
* @param option the specified option
* @throws ServiceException service exception
* @return option id
* @throws ServiceException
*/
*/
public
void
updateOption
(
final
JSONObject
option
)
throws
ServiceException
{
public
String
addOrUpdateOption
(
final
JSONObject
option
)
throws
ServiceException
{
final
String
id
=
option
.
optString
(
Keys
.
OBJECT_ID
);
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
try
{
try
{
if
(
null
!=
optionRepository
.
get
(
id
))
{
String
id
=
option
.
optString
(
Keys
.
OBJECT_ID
);
optionRepository
.
update
(
id
,
option
);
if
(
Strings
.
isEmptyOrNull
(
id
))
{
id
=
optionRepository
.
add
(
option
);
}
else
{
}
else
{
optionRepository
.
add
(
option
);
final
JSONObject
old
=
optionRepository
.
get
(
id
);
if
(
null
==
old
)
{
// The id is specified by caller
id
=
optionRepository
.
add
(
option
);
}
else
{
old
.
put
(
Option
.
OPTION_CATEGORY
,
option
.
optString
(
Option
.
OPTION_CATEGORY
));
old
.
put
(
Option
.
OPTION_VALUE
,
option
.
optString
(
Option
.
OPTION_VALUE
));
optionRepository
.
update
(
id
,
old
);
}
}
}
transaction
.
commit
();
transaction
.
commit
();
return
id
;
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
if
(
transaction
.
isActive
())
{
if
(
transaction
.
isActive
())
{
transaction
.
rollback
();
transaction
.
rollback
();
...
@@ -73,34 +85,19 @@ public final class OptionMgmtService {
...
@@ -73,34 +85,19 @@ public final class OptionMgmtService {
throw
new
ServiceException
(
e
);
throw
new
ServiceException
(
e
);
}
}
}
}
/**
/**
*
Adds or updates the specified option.
*
Removes the option specified by the given option id.
*
*
* @param option
the specified option
* @param option
Id the given option id
* @throws ServiceException
* @throws ServiceException
service exception
*/
*/
public
void
addOrUpdateOption
(
final
JSONObject
option
)
throws
ServiceException
{
public
void
removeOption
(
final
String
optionId
)
throws
ServiceException
{
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
try
{
try
{
final
String
id
=
option
.
optString
(
Keys
.
OBJECT_ID
);
optionRepository
.
remove
(
optionId
);
if
(
Strings
.
isEmptyOrNull
(
id
))
{
optionRepository
.
add
(
option
);
}
else
{
final
JSONObject
old
=
optionRepository
.
get
(
id
);
if
(
null
==
old
)
{
// The id is specified by caller
optionRepository
.
add
(
option
);
}
else
{
old
.
put
(
Option
.
OPTION_CATEGORY
,
option
.
optString
(
Option
.
OPTION_CATEGORY
));
old
.
put
(
Option
.
OPTION_VALUE
,
option
.
optString
(
Option
.
OPTION_VALUE
));
optionRepository
.
update
(
id
,
old
);
}
}
transaction
.
commit
();
transaction
.
commit
();
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
if
(
transaction
.
isActive
())
{
if
(
transaction
.
isActive
())
{
...
...
core/src/test/java/org/b3log/solo/AbstractTestCase.java
View file @
9b05326f
/*
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org
.
b3log
.
solo
;
package
org
.
b3log
.
solo
;
import
com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig
;
import
com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig
;
import
com.google.appengine.tools.development.testing.LocalServiceTestHelper
;
import
com.google.appengine.tools.development.testing.LocalServiceTestHelper
;
import
java.util.Locale
;
import
java.util.Locale
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.solo.repository.ArchiveDateArticleRepository
;
import
org.b3log.solo.repository.ArchiveDateArticleRepository
;
import
org.b3log.solo.repository.ArchiveDateRepository
;
import
org.b3log.solo.repository.ArchiveDateRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.LinkRepository
;
import
org.b3log.solo.repository.LinkRepository
;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.repository.OptionRepository
;
import
org.b3log.solo.repository.PluginRepository
;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.repository.PreferenceRepository
;
import
org.b3log.solo.repository.PluginRepository
;
import
org.b3log.solo.repository.StatisticRepository
;
import
org.b3log.solo.repository.PreferenceRepository
;
import
org.b3log.solo.repository.TagArticleRepository
;
import
org.b3log.solo.repository.StatisticRepository
;
import
org.b3log.solo.repository.TagRepository
;
import
org.b3log.solo.repository.TagArticleRepository
;
import
org.b3log.solo.repository.UserRepository
;
import
org.b3log.solo.repository.TagRepository
;
import
org.b3log.solo.repository.impl.ArchiveDateArticleRepositoryImpl
;
import
org.b3log.solo.repository.UserRepository
;
import
org.b3log.solo.repository.impl.ArchiveDateRepositoryImpl
;
import
org.b3log.solo.repository.impl.ArchiveDateArticleRepositoryImpl
;
import
org.b3log.solo.repository.impl.ArticleRepositoryImpl
;
import
org.b3log.solo.repository.impl.ArchiveDateRepositoryImpl
;
import
org.b3log.solo.repository.impl.CommentRepositoryImpl
;
import
org.b3log.solo.repository.impl.ArticleRepositoryImpl
;
import
org.b3log.solo.repository.impl.LinkRepositoryImpl
;
import
org.b3log.solo.repository.impl.CommentRepositoryImpl
;
import
org.b3log.solo.repository.impl.PageRepositoryImpl
;
import
org.b3log.solo.repository.impl.LinkRepositoryImpl
;
import
org.b3log.solo.repository.impl.PluginRepositoryImpl
;
import
org.b3log.solo.repository.impl.OptionRepositoryImpl
;
import
org.b3log.solo.repository.impl.PreferenceRepositoryImpl
;
import
org.b3log.solo.repository.impl.PageRepositoryImpl
;
import
org.b3log.solo.repository.impl.StatisticRepositoryImpl
;
import
org.b3log.solo.repository.impl.PluginRepositoryImpl
;
import
org.b3log.solo.repository.impl.TagArticleRepositoryImpl
;
import
org.b3log.solo.repository.impl.PreferenceRepositoryImpl
;
import
org.b3log.solo.repository.impl.TagRepositoryImpl
;
import
org.b3log.solo.repository.impl.StatisticRepositoryImpl
;
import
org.b3log.solo.repository.impl.UserRepositoryImpl
;
import
org.b3log.solo.repository.impl.TagArticleRepositoryImpl
;
import
org.b3log.solo.service.*
;
import
org.b3log.solo.repository.impl.TagRepositoryImpl
;
import
org.testng.annotations.AfterClass
;
import
org.b3log.solo.repository.impl.UserRepositoryImpl
;
import
org.testng.annotations.BeforeClass
;
import
org.b3log.solo.service.*
;
import
org.testng.annotations.AfterClass
;
/**
import
org.testng.annotations.BeforeClass
;
* Abstract test case.
*
/**
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* Abstract test case.
* @version 1.0.0.5, Feb 8, 2013
*
* @see #beforeClass()
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @see #afterClass()
* @version 1.0.0.6, Apr 19, 2013
*/
* @see #beforeClass()
public
abstract
class
AbstractTestCase
{
* @see #afterClass()
*/
/**
public
abstract
class
AbstractTestCase
{
* Local service test helper.
*/
/**
private
final
LocalServiceTestHelper
localServiceTestHelper
=
* Local service test helper.
new
LocalServiceTestHelper
(
new
LocalDatastoreServiceTestConfig
());
*/
/**
private
final
LocalServiceTestHelper
localServiceTestHelper
=
* User repository.
new
LocalServiceTestHelper
(
new
LocalDatastoreServiceTestConfig
());
*/
private
UserRepository
userRepository
;
/**
/**
* User repository.
* Link repository.
*/
*/
private
UserRepository
userRepository
;
private
LinkRepository
linkRepository
;
/**
/**
* Article repository.
* Link repository.
*/
*/
private
ArticleRepository
articleRepository
;
private
LinkRepository
linkRepository
;
/**
* Tag repository.
/**
*/
* Article repository.
private
TagRepository
tagRepository
;
*/
/**
private
ArticleRepository
articleRepository
;
* Tag-Article repository.
*/
/**
private
TagArticleRepository
tagArticleRepository
;
* Tag repository.
/**
*/
* Page repository.
private
TagRepository
tagRepository
;
*/
private
PageRepository
pageRepository
;
/**
/**
* Tag-Article repository.
* Comment repository.
*/
*/
private
TagArticleRepository
tagArticleRepository
;
private
CommentRepository
commentRepository
;
/**
/**
* Archive date repository.
* Page repository.
*/
*/
private
ArchiveDateRepository
archiveDateRepository
;
private
PageRepository
pageRepository
;
/**
* Archive date article repository.
/**
*/
* Comment repository.
private
ArchiveDateArticleRepository
archiveDateArticleRepository
;
*/
/**
private
CommentRepository
commentRepository
;
* Plugin repository.
*/
/**
private
PluginRepository
pluginRepository
;
* Archive date repository.
/**
*/
* Preference repository.
private
ArchiveDateRepository
archiveDateRepository
;
*/
private
PreferenceRepository
preferenceRepository
;
/**
/**
* Archive date article repository.
* Statistic repository.
*/
*/
private
ArchiveDateArticleRepository
archiveDateArticleRepository
;
private
StatisticRepository
statisticRepository
;
/**
/**
* Initialization service.
* Plugin repository.
*/
*/
private
InitService
initService
;
private
PluginRepository
pluginRepository
;
/**
* User management service.
/**
*/
* Preference repository.
private
UserMgmtService
userMgmtService
;
*/
/**
private
PreferenceRepository
preferenceRepository
;
* User query service.
*/
/**
private
UserQueryService
userQueryService
;
* Statistic repository.
/**
*/
* Article management service.
private
StatisticRepository
statisticRepository
;
*/
private
ArticleMgmtService
articleMgmtService
;
/**
/**
* Option repository.
* Article query service.
*/
*/
private
OptionRepository
optionRepository
;
private
ArticleQueryService
articleQueryService
;
/**
/**
* Page management service.
* Initialization service.
*/
*/
private
PageMgmtService
pageMgmtService
;
private
InitService
initService
;
/**
* Page query service.
/**
*/
* User management service.
private
PageQueryService
pageQueryService
;
*/
/**
private
UserMgmtService
userMgmtService
;
* Link management service.
*/
/**
private
LinkMgmtService
linkMgmtService
;
* User query service.
/**
*/
* Link query service.
private
UserQueryService
userQueryService
;
*/
private
LinkQueryService
linkQueryService
;
/**
/**
* Article management service.
* Preference management service.
*/
*/
private
ArticleMgmtService
articleMgmtService
;
private
PreferenceMgmtService
preferenceMgmtService
;
/**
/**
* Preference query service.
* Article query service.
*/
*/
private
PreferenceQueryService
preferenceQueryService
;
private
ArticleQueryService
articleQueryService
;
/**
* Tag query service.
/**
*/
* Page management service.
private
TagQueryService
tagQueryService
;
*/
/**
private
PageMgmtService
pageMgmtService
;
* Tag management service.
*/
/**
private
TagMgmtService
tagMgmtService
;
* Page query service.
/**
*/
* Comment query service.
private
PageQueryService
pageQueryService
;
*/
private
CommentQueryService
commentQueryService
;
/**
/**
* Link management service.
* Comment management service.
*/
*/
private
LinkMgmtService
linkMgmtService
;
private
CommentMgmtService
commentMgmtService
;
/**
/**
* Archive date query service.
* Link query service.
*/
*/
private
ArchiveDateQueryService
archiveDateQueryService
;
private
LinkQueryService
linkQueryService
;
/**
/**
* Before class.
* Preference management service.
*
*/
* <ol>
private
PreferenceMgmtService
preferenceMgmtService
;
* <li>Sets up GAE unit test runtime environment</li>
* <li>Initializes Latke runtime</li>
/**
* <li>Instantiates repositories</li>
* Preference query service.
* </ol>
*/
*/
private
PreferenceQueryService
preferenceQueryService
;
@BeforeClass
public
void
beforeClass
()
{
/**
localServiceTestHelper
.
setUp
();
* Tag query service.
*/
Latkes
.
initRuntimeEnv
();
private
TagQueryService
tagQueryService
;
Latkes
.
setLocale
(
Locale
.
SIMPLIFIED_CHINESE
);
/**
// Repositories
* Tag management service.
userRepository
=
UserRepositoryImpl
.
getInstance
();
*/
linkRepository
=
LinkRepositoryImpl
.
getInstance
();
private
TagMgmtService
tagMgmtService
;
articleRepository
=
ArticleRepositoryImpl
.
getInstance
();
tagRepository
=
TagRepositoryImpl
.
getInstance
();
/**
tagArticleRepository
=
TagArticleRepositoryImpl
.
getInstance
();
* Comment query service.
pageRepository
=
PageRepositoryImpl
.
getInstance
();
*/
commentRepository
=
CommentRepositoryImpl
.
getInstance
();
private
CommentQueryService
commentQueryService
;
archiveDateRepository
=
ArchiveDateRepositoryImpl
.
getInstance
();
archiveDateArticleRepository
=
/**
ArchiveDateArticleRepositoryImpl
.
getInstance
();
* Comment management service.
pluginRepository
=
PluginRepositoryImpl
.
getInstance
();
*/
preferenceRepository
=
PreferenceRepositoryImpl
.
getInstance
();
private
CommentMgmtService
commentMgmtService
;
statisticRepository
=
StatisticRepositoryImpl
.
getInstance
();
/**
// Services
* Archive date query service.
initService
=
InitService
.
getInstance
();
*/
userMgmtService
=
UserMgmtService
.
getInstance
();
private
ArchiveDateQueryService
archiveDateQueryService
;
userQueryService
=
UserQueryService
.
getInstance
();
articleMgmtService
=
ArticleMgmtService
.
getInstance
();
/**
articleQueryService
=
ArticleQueryService
.
getInstance
();
* Option management service.
pageMgmtService
=
PageMgmtService
.
getInstance
();
*/
pageQueryService
=
PageQueryService
.
getInstance
();
private
OptionMgmtService
optionMgmtService
;
linkMgmtService
=
LinkMgmtService
.
getInstance
();
linkQueryService
=
LinkQueryService
.
getInstance
();
/**
preferenceMgmtService
=
PreferenceMgmtService
.
getInstance
();
* Option query service.
preferenceQueryService
=
PreferenceQueryService
.
getInstance
();
*/
tagQueryService
=
TagQueryService
.
getInstance
();
private
OptionQueryService
optionQueryService
;
tagMgmtService
=
TagMgmtService
.
getInstance
();
commentQueryService
=
CommentQueryService
.
getInstance
();
/**
commentMgmtService
=
CommentMgmtService
.
getInstance
();
* Before class.
archiveDateQueryService
=
ArchiveDateQueryService
.
getInstance
();
*
}
* <ol>
* <li>Sets up GAE unit test runtime environment</li>
/**
* <li>Initializes Latke runtime</li>
* After class.
* <li>Instantiates repositories</li>
*
* </ol>
* <ol>
*/
* <li>Tears down GAE unit test runtime environment</li>
@BeforeClass
* <li>Shutdowns Latke runtime</li>
public
void
beforeClass
()
{
* </ol>
localServiceTestHelper
.
setUp
();
*/
@AfterClass
Latkes
.
initRuntimeEnv
();
public
void
afterClass
()
{
Latkes
.
setLocale
(
Locale
.
SIMPLIFIED_CHINESE
);
localServiceTestHelper
.
tearDown
();
// Repositories
Latkes
.
shutdown
();
userRepository
=
UserRepositoryImpl
.
getInstance
();
}
linkRepository
=
LinkRepositoryImpl
.
getInstance
();
articleRepository
=
ArticleRepositoryImpl
.
getInstance
();
/**
tagRepository
=
TagRepositoryImpl
.
getInstance
();
* Gets user repository.
tagArticleRepository
=
TagArticleRepositoryImpl
.
getInstance
();
*
pageRepository
=
PageRepositoryImpl
.
getInstance
();
* @return user repository
commentRepository
=
CommentRepositoryImpl
.
getInstance
();
*/
archiveDateRepository
=
ArchiveDateRepositoryImpl
.
getInstance
();
public
UserRepository
getUserRepository
()
{
archiveDateArticleRepository
=
return
userRepository
;
ArchiveDateArticleRepositoryImpl
.
getInstance
();
}
pluginRepository
=
PluginRepositoryImpl
.
getInstance
();
preferenceRepository
=
PreferenceRepositoryImpl
.
getInstance
();
/**
statisticRepository
=
StatisticRepositoryImpl
.
getInstance
();
* Gets link repository.
optionRepository
=
OptionRepositoryImpl
.
getInstance
();
*
* @return link repository
// Services
*/
initService
=
InitService
.
getInstance
();
public
LinkRepository
getLinkRepository
()
{
userMgmtService
=
UserMgmtService
.
getInstance
();
return
linkRepository
;
userQueryService
=
UserQueryService
.
getInstance
();
}
articleMgmtService
=
ArticleMgmtService
.
getInstance
();
articleQueryService
=
ArticleQueryService
.
getInstance
();
/**
pageMgmtService
=
PageMgmtService
.
getInstance
();
* Gets article repository.
pageQueryService
=
PageQueryService
.
getInstance
();
*
linkMgmtService
=
LinkMgmtService
.
getInstance
();
* @return article repository
linkQueryService
=
LinkQueryService
.
getInstance
();
*/
preferenceMgmtService
=
PreferenceMgmtService
.
getInstance
();
public
ArticleRepository
getArticleRepository
()
{
preferenceQueryService
=
PreferenceQueryService
.
getInstance
();
return
articleRepository
;
tagQueryService
=
TagQueryService
.
getInstance
();
}
tagMgmtService
=
TagMgmtService
.
getInstance
();
commentQueryService
=
CommentQueryService
.
getInstance
();
/**
commentMgmtService
=
CommentMgmtService
.
getInstance
();
* Gets tag repository.
archiveDateQueryService
=
ArchiveDateQueryService
.
getInstance
();
*
optionMgmtService
=
OptionMgmtService
.
getInstance
();
* @return tag repository
optionQueryService
=
OptionQueryService
.
getInstance
();
*/
}
public
TagRepository
getTagRepository
()
{
return
tagRepository
;
/**
}
* After class.
*
/**
* <ol>
* Gets tag-article repository.
* <li>Tears down GAE unit test runtime environment</li>
*
* <li>Shutdowns Latke runtime</li>
* @return tag-article repository
* </ol>
*/
*/
public
TagArticleRepository
getTagArticleRepository
()
{
@AfterClass
return
tagArticleRepository
;
public
void
afterClass
()
{
}
// XXX: NPE, localServiceTestHelper.tearDown();
/**
Latkes
.
shutdown
();
* Gets page repository.
}
*
* @return page repository
/**
*/
* Gets user repository.
public
PageRepository
getPageRepository
()
{
*
return
pageRepository
;
* @return user repository
}
*/
public
UserRepository
getUserRepository
()
{
/**
return
userRepository
;
* Gets comment repository.
}
*
* @return comment repository
/**
*/
* Gets link repository.
public
CommentRepository
getCommentRepository
()
{
*
return
commentRepository
;
* @return link repository
}
*/
public
LinkRepository
getLinkRepository
()
{
/**
return
linkRepository
;
* Gets archive date repository.
}
*
* @return archive date repository
/**
*/
* Gets article repository.
public
ArchiveDateRepository
getArchiveDateRepository
()
{
*
return
archiveDateRepository
;
* @return article repository
}
*/
public
ArticleRepository
getArticleRepository
()
{
/**
return
articleRepository
;
* Archive date article repository.
}
*
* @return archive date article repository
/**
*/
* Gets tag repository.
public
ArchiveDateArticleRepository
getArchiveDateArticleRepository
()
{
*
return
archiveDateArticleRepository
;
* @return tag repository
}
*/
public
TagRepository
getTagRepository
()
{
/**
return
tagRepository
;
* Gets plugin repository.
}
*
* @return plugin repository
/**
*/
* Gets tag-article repository.
public
PluginRepository
getPluginRepository
()
{
*
return
pluginRepository
;
* @return tag-article repository
}
*/
public
TagArticleRepository
getTagArticleRepository
()
{
/**
return
tagArticleRepository
;
* Gets preference repository.
}
*
* @return preference repository
/**
*/
* Gets page repository.
public
PreferenceRepository
getPreferenceRepository
()
{
*
return
preferenceRepository
;
* @return page repository
}
*/
public
PageRepository
getPageRepository
()
{
/**
return
pageRepository
;
* Gets statistic repository.
}
*
* @return statistic repository
/**
*/
* Gets comment repository.
public
StatisticRepository
getStatisticRepository
()
{
*
return
statisticRepository
;
* @return comment repository
}
*/
public
CommentRepository
getCommentRepository
()
{
/**
return
commentRepository
;
* Gets initialization service.
}
*
* @return initialization service
/**
*/
* Gets archive date repository.
public
InitService
getInitService
()
{
*
return
initService
;
* @return archive date repository
}
*/
public
ArchiveDateRepository
getArchiveDateRepository
()
{
/**
return
archiveDateRepository
;
* Gets user management service.
}
*
* @return user management service
/**
*/
* Archive date article repository.
public
UserMgmtService
getUserMgmtService
()
{
*
return
userMgmtService
;
* @return archive date article repository
}
*/
public
ArchiveDateArticleRepository
getArchiveDateArticleRepository
()
{
/**
return
archiveDateArticleRepository
;
* Gets user query service.
}
*
* @return user query service
/**
*/
* Gets plugin repository.
public
UserQueryService
getUserQueryService
()
{
*
return
userQueryService
;
* @return plugin repository
}
*/
public
PluginRepository
getPluginRepository
()
{
/**
return
pluginRepository
;
* Gets article management service.
}
*
* @return article management service
/**
*/
* Gets preference repository.
public
ArticleMgmtService
getArticleMgmtService
()
{
*
return
articleMgmtService
;
* @return preference repository
}
*/
public
PreferenceRepository
getPreferenceRepository
()
{
/**
return
preferenceRepository
;
* Gets article query service.
}
*
* @return article query service
/**
*/
* Gets statistic repository.
public
ArticleQueryService
getArticleQueryService
()
{
*
return
articleQueryService
;
* @return statistic repository
}
*/
public
StatisticRepository
getStatisticRepository
()
{
/**
return
statisticRepository
;
* Gets page management service.
}
*
* @return page management service
/**
*/
* Gets option repository.
public
PageMgmtService
getPageMgmtService
()
{
*
return
pageMgmtService
;
* @return option repository
}
*/
public
OptionRepository
getOptionRepository
()
{
/**
return
optionRepository
;
* Gets page query service.
}
*
* @return page query service
/**
*/
* Gets initialization service.
public
PageQueryService
getPageQueryService
()
{
*
return
pageQueryService
;
* @return initialization service
}
*/
public
InitService
getInitService
()
{
/**
return
initService
;
* Gets link management service.
}
*
* @return link management service
/**
*/
* Gets user management service.
public
LinkMgmtService
getLinkMgmtService
()
{
*
return
linkMgmtService
;
* @return user management service
}
*/
public
UserMgmtService
getUserMgmtService
()
{
/**
return
userMgmtService
;
* Gets link query service.
}
*
* @return link query service
/**
*/
* Gets user query service.
public
LinkQueryService
getLinkQueryService
()
{
*
return
linkQueryService
;
* @return user query service
}
*/
public
UserQueryService
getUserQueryService
()
{
/**
return
userQueryService
;
* Gets preference management service.
}
*
* @return preference management service
/**
*/
* Gets article management service.
public
PreferenceMgmtService
getPreferenceMgmtService
()
{
*
return
preferenceMgmtService
;
* @return article management service
}
*/
public
ArticleMgmtService
getArticleMgmtService
()
{
/**
return
articleMgmtService
;
* Gets preference query service.
}
*
* @return preference query service
/**
*/
* Gets article query service.
public
PreferenceQueryService
getPreferenceQueryService
()
{
*
return
preferenceQueryService
;
* @return article query service
}
*/
public
ArticleQueryService
getArticleQueryService
()
{
/**
return
articleQueryService
;
* Gets tag query service.
}
*
* @return tag query service
/**
*/
* Gets page management service.
public
TagQueryService
getTagQueryService
()
{
*
return
tagQueryService
;
* @return page management service
}
*/
public
PageMgmtService
getPageMgmtService
()
{
/**
return
pageMgmtService
;
* Gets tag management service.
}
*
* @return tag management service
/**
*/
* Gets page query service.
public
TagMgmtService
getTagMgmtService
()
{
*
return
tagMgmtService
;
* @return page query service
}
*/
public
PageQueryService
getPageQueryService
()
{
/**
return
pageQueryService
;
* Gets comment query service.
}
*
* @return comment query service
/**
*/
* Gets link management service.
public
CommentQueryService
getCommentQueryService
()
{
*
return
commentQueryService
;
* @return link management service
}
*/
public
LinkMgmtService
getLinkMgmtService
()
{
/**
return
linkMgmtService
;
* Gets comment management service.
}
*
* @return comment management service
/**
*/
* Gets link query service.
public
CommentMgmtService
getCommentMgmtService
()
{
*
return
commentMgmtService
;
* @return link query service
}
*/
public
LinkQueryService
getLinkQueryService
()
{
/**
return
linkQueryService
;
* Gets archive date query service.
}
*
* @return archive date query service
/**
*/
* Gets preference management service.
public
ArchiveDateQueryService
getArchiveDateQueryService
()
{
*
return
archiveDateQueryService
;
* @return preference management service
}
*/
}
public
PreferenceMgmtService
getPreferenceMgmtService
()
{
return
preferenceMgmtService
;
}
/**
* Gets preference query service.
*
* @return preference query service
*/
public
PreferenceQueryService
getPreferenceQueryService
()
{
return
preferenceQueryService
;
}
/**
* Gets tag query service.
*
* @return tag query service
*/
public
TagQueryService
getTagQueryService
()
{
return
tagQueryService
;
}
/**
* Gets tag management service.
*
* @return tag management service
*/
public
TagMgmtService
getTagMgmtService
()
{
return
tagMgmtService
;
}
/**
* Gets comment query service.
*
* @return comment query service
*/
public
CommentQueryService
getCommentQueryService
()
{
return
commentQueryService
;
}
/**
* Gets comment management service.
*
* @return comment management service
*/
public
CommentMgmtService
getCommentMgmtService
()
{
return
commentMgmtService
;
}
/**
* Gets archive date query service.
*
* @return archive date query service
*/
public
ArchiveDateQueryService
getArchiveDateQueryService
()
{
return
archiveDateQueryService
;
}
/**
* Gets option management service.
*
* @return option management service
*/
public
OptionMgmtService
getOptionMgmtService
()
{
return
optionMgmtService
;
}
/**
* Gets option query service.
*
* @return option query service
*/
public
OptionQueryService
getOptionQueryService
()
{
return
optionQueryService
;
}
}
core/src/test/java/org/b3log/solo/repository/impl/OptionRepositoryImplTestCase.java
0 → 100644
View file @
9b05326f
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.repository.OptionRepository
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* {@link OptionRepositoryImpl} test case.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.0, Apr 19, 2013
* @since 0.6.0
*/
@Test
(
suiteName
=
"repository"
)
public
final
class
OptionRepositoryImplTestCase
extends
AbstractTestCase
{
/**
* Tests.
*
* @throws Exception exception
*/
@Test
public
void
test
()
throws
Exception
{
final
OptionRepository
optionRepository
=
getOptionRepository
();
final
JSONObject
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_BROADCAST
);
option
.
put
(
Option
.
OPTION_VALUE
,
0L
);
Transaction
transaction
=
optionRepository
.
beginTransaction
();
optionRepository
.
add
(
option
);
transaction
.
commit
();
Assert
.
assertEquals
(
optionRepository
.
count
(),
1
);
Assert
.
assertNotNull
(
optionRepository
.
get
(
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
));
}
}
core/src/test/java/org/b3log/solo/service/OptionMgmtServiceTestCase.java
0 → 100644
View file @
9b05326f
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
b3log
.
solo
.
service
;
import
org.b3log.latke.Keys
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Option
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* {@link OptionMgmtService} test case.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.0, Apr 19, 2013
* @since 0.6.0
*/
@Test
(
suiteName
=
"service"
)
public
class
OptionMgmtServiceTestCase
extends
AbstractTestCase
{
/**
* Add.
*
* @throws Exception exception
*/
@Test
public
void
add
()
throws
Exception
{
final
OptionMgmtService
optionMgmtService
=
getOptionMgmtService
();
final
JSONObject
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_BROADCAST
);
option
.
put
(
Option
.
OPTION_VALUE
,
0L
);
final
String
id
=
optionMgmtService
.
addOrUpdateOption
(
option
);
System
.
out
.
println
(
id
);
Assert
.
assertNotNull
(
id
);
}
/**
* Update.
*
* @throws Exception exception
*/
@Test
public
void
update
()
throws
Exception
{
final
OptionMgmtService
optionMgmtService
=
getOptionMgmtService
();
JSONObject
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_BROADCAST
);
option
.
put
(
Option
.
OPTION_VALUE
,
0L
);
final
String
id
=
optionMgmtService
.
addOrUpdateOption
(
option
);
// Add
System
.
out
.
println
(
id
);
Assert
.
assertNotNull
(
id
);
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_BROADCAST
);
option
.
put
(
Option
.
OPTION_VALUE
,
1L
);
optionMgmtService
.
addOrUpdateOption
(
option
);
// Update
final
JSONObject
opt
=
getOptionQueryService
().
getOptionById
(
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
Assert
.
assertEquals
(
opt
.
getInt
(
Option
.
OPTION_VALUE
),
1L
);
}
/**
* Remove.
*
* @throws Exception exception
*/
@Test
public
void
remove
()
throws
Exception
{
final
OptionMgmtService
optionMgmtService
=
getOptionMgmtService
();
final
JSONObject
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_BROADCAST
);
option
.
put
(
Option
.
OPTION_VALUE
,
0L
);
final
String
id
=
optionMgmtService
.
addOrUpdateOption
(
option
);
Assert
.
assertNotNull
(
id
);
optionMgmtService
.
removeOption
(
id
);
final
JSONObject
opt
=
getOptionQueryService
().
getOptionById
(
id
);
Assert
.
assertNull
(
opt
);
}
}
core/src/test/java/org/b3log/solo/service/OptionQueryServiceTestCase.java
0 → 100644
View file @
9b05326f
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
b3log
.
solo
.
service
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Link
;
import
org.b3log.solo.model.Option
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* {@link OptionQueryService} test case.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.0, Apr 19, 2013
* @since 0.6.0
*/
@Test
(
suiteName
=
"service"
)
public
class
OptionQueryServiceTestCase
extends
AbstractTestCase
{
/**
* Gets.
*
* @throws Exception exception
*/
@Test
public
void
get
()
throws
Exception
{
// Check
final
OptionQueryService
optionQueryService
=
getOptionQueryService
();
JSONObject
options
=
optionQueryService
.
getOptions
(
Option
.
CATEGORY_C_BROADCAST
);
Assert
.
assertNull
(
options
);
// Add one
final
OptionMgmtService
optionMgmtService
=
getOptionMgmtService
();
final
JSONObject
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BROADCAST_CHANCE_EXPIRATION_TIME
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_BROADCAST
);
option
.
put
(
Option
.
OPTION_VALUE
,
0L
);
final
String
id
=
optionMgmtService
.
addOrUpdateOption
(
option
);
Assert
.
assertNotNull
(
id
);
// Check again
options
=
optionQueryService
.
getOptions
(
Option
.
CATEGORY_C_BROADCAST
);
Assert
.
assertNotNull
(
options
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment