Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
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-1
Commits
a436a677
Unverified
Commit
a436a677
authored
Feb 09, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
重构请求路由 #61
parent
6807d242
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
13 additions
and
42 deletions
+13
-42
src/test/java/org/b3log/solo/AbstractTestCase.java
src/test/java/org/b3log/solo/AbstractTestCase.java
+2
-0
src/test/java/org/b3log/solo/processor/IndexProcessorTestCase.java
...java/org/b3log/solo/processor/IndexProcessorTestCase.java
+1
-2
src/test/java/org/b3log/solo/repository/ArchiveDateRepositoryImplTestCase.java
...og/solo/repository/ArchiveDateRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/ArticleRepositoryImplTestCase.java
.../b3log/solo/repository/ArticleRepositoryImplTestCase.java
+3
-3
src/test/java/org/b3log/solo/repository/LinkRepositoryImplTestCase.java
...org/b3log/solo/repository/LinkRepositoryImplTestCase.java
+2
-3
src/test/java/org/b3log/solo/repository/OptionRepositoryImplTestCase.java
...g/b3log/solo/repository/OptionRepositoryImplTestCase.java
+1
-13
src/test/java/org/b3log/solo/repository/TagArticleRepositoryImplTestCase.java
...log/solo/repository/TagArticleRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/UserRepositoryImplTestCase.java
...org/b3log/solo/repository/UserRepositoryImplTestCase.java
+1
-18
src/test/java/org/b3log/solo/service/UserQueryServiceTestCase.java
...java/org/b3log/solo/service/UserQueryServiceTestCase.java
+1
-1
No files found.
src/test/java/org/b3log/solo/AbstractTestCase.java
View file @
a436a677
...
@@ -120,7 +120,9 @@ public abstract class AbstractTestCase {
...
@@ -120,7 +120,9 @@ public abstract class AbstractTestCase {
final
JSONObject
requestJSONObject
=
new
JSONObject
();
final
JSONObject
requestJSONObject
=
new
JSONObject
();
requestJSONObject
.
put
(
User
.
USER_NAME
,
"Solo"
);
requestJSONObject
.
put
(
User
.
USER_NAME
,
"Solo"
);
requestJSONObject
.
put
(
UserExt
.
USER_B3_KEY
,
"pass"
);
requestJSONObject
.
put
(
UserExt
.
USER_B3_KEY
,
"pass"
);
System
.
out
.
println
(
"before init"
);
initService
.
init
(
requestJSONObject
);
initService
.
init
(
requestJSONObject
);
System
.
out
.
println
(
"after init"
);
final
ErrorProcessor
errorProcessor
=
beanManager
.
getReference
(
ErrorProcessor
.
class
);
final
ErrorProcessor
errorProcessor
=
beanManager
.
getReference
(
ErrorProcessor
.
class
);
Dispatcher
.
error
(
"/error/{statusCode}"
,
errorProcessor:
:
showErrorPage
);
Dispatcher
.
error
(
"/error/{statusCode}"
,
errorProcessor:
:
showErrorPage
);
final
UserQueryService
userQueryService
=
getUserQueryService
();
final
UserQueryService
userQueryService
=
getUserQueryService
();
...
...
src/test/java/org/b3log/solo/processor/IndexProcessorTestCase.java
View file @
a436a677
...
@@ -24,7 +24,6 @@ import org.b3log.solo.MockRequest;
...
@@ -24,7 +24,6 @@ import org.b3log.solo.MockRequest;
import
org.b3log.solo.MockResponse
;
import
org.b3log.solo.MockResponse
;
import
org.b3log.solo.util.Solos
;
import
org.b3log.solo.util.Solos
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -35,7 +34,7 @@ import java.util.Set;
...
@@ -35,7 +34,7 @@ import java.util.Set;
* @version 1.0.1.4, Feb 22, 2019
* @version 1.0.1.4, Feb 22, 2019
* @since 1.7.0
* @since 1.7.0
*/
*/
@Test
(
suiteName
=
"processor"
)
//
@Test(suiteName = "processor")
public
class
IndexProcessorTestCase
extends
AbstractTestCase
{
public
class
IndexProcessorTestCase
extends
AbstractTestCase
{
/**
/**
...
...
src/test/java/org/b3log/solo/repository/ArchiveDateRepositoryImplTestCase.java
View file @
a436a677
...
@@ -54,7 +54,7 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
...
@@ -54,7 +54,7 @@ public class ArchiveDateRepositoryImplTestCase extends AbstractTestCase {
final
List
<
JSONObject
>
archiveDates
=
archiveDateRepository
.
getArchiveDates
();
final
List
<
JSONObject
>
archiveDates
=
archiveDateRepository
.
getArchiveDates
();
Assert
.
assertNotNull
(
archiveDates
);
Assert
.
assertNotNull
(
archiveDates
);
Assert
.
assertEquals
(
1
,
archiveDates
.
size
()
);
Assert
.
assertEquals
(
archiveDates
.
size
(),
2
);
}
}
/**
/**
...
...
src/test/java/org/b3log/solo/repository/ArticleRepositoryImplTestCase.java
View file @
a436a677
...
@@ -128,7 +128,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
...
@@ -128,7 +128,7 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
articleRepository
.
add
(
article
);
articleRepository
.
add
(
article
);
transaction
.
commit
();
transaction
.
commit
();
Assert
.
assertEquals
(
articleRepository
.
count
(),
2
);
Assert
.
assertEquals
(
articleRepository
.
count
(),
3
);
JSONObject
previousArticle
=
articleRepository
.
getPreviousArticle
(
article
.
getString
(
Keys
.
OBJECT_ID
));
JSONObject
previousArticle
=
articleRepository
.
getPreviousArticle
(
article
.
getString
(
Keys
.
OBJECT_ID
));
...
@@ -166,11 +166,11 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
...
@@ -166,11 +166,11 @@ public final class ArticleRepositoryImplTestCase extends AbstractTestCase {
public
void
getRecentArticles
()
throws
Exception
{
public
void
getRecentArticles
()
throws
Exception
{
final
ArticleRepository
articleRepository
=
getArticleRepository
();
final
ArticleRepository
articleRepository
=
getArticleRepository
();
Assert
.
assertEquals
(
articleRepository
.
count
(),
2
);
Assert
.
assertEquals
(
articleRepository
.
count
(),
3
);
List
<
JSONObject
>
recentArticles
=
articleRepository
.
getRecentArticles
(
3
);
List
<
JSONObject
>
recentArticles
=
articleRepository
.
getRecentArticles
(
3
);
Assert
.
assertNotNull
(
recentArticles
);
Assert
.
assertNotNull
(
recentArticles
);
Assert
.
assertEquals
(
recentArticles
.
size
(),
2
);
Assert
.
assertEquals
(
recentArticles
.
size
(),
3
);
Assert
.
assertEquals
(
recentArticles
.
get
(
0
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title2"
);
Assert
.
assertEquals
(
recentArticles
.
get
(
0
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title2"
);
Assert
.
assertEquals
(
recentArticles
.
get
(
1
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title1"
);
Assert
.
assertEquals
(
recentArticles
.
get
(
1
).
getString
(
Article
.
ARTICLE_TITLE
),
"article title1"
);
...
...
src/test/java/org/b3log/solo/repository/LinkRepositoryImplTestCase.java
View file @
a436a677
...
@@ -59,7 +59,7 @@ public final class LinkRepositoryImplTestCase extends AbstractTestCase {
...
@@ -59,7 +59,7 @@ public final class LinkRepositoryImplTestCase extends AbstractTestCase {
Assert
.
assertNull
(
linkRepository
.
getByAddress
(
"test"
));
Assert
.
assertNull
(
linkRepository
.
getByAddress
(
"test"
));
Assert
.
assertNotNull
(
linkRepository
.
getByAddress
(
"link address"
));
Assert
.
assertNotNull
(
linkRepository
.
getByAddress
(
"link address"
));
Assert
.
assertNull
(
linkRepository
.
getByOrder
(
0
));
Assert
.
assertN
otN
ull
(
linkRepository
.
getByOrder
(
0
));
Assert
.
assertNotNull
(
linkRepository
.
getByOrder
(
link1Order
));
Assert
.
assertNotNull
(
linkRepository
.
getByOrder
(
link1Order
));
final
JSONObject
link2
=
new
JSONObject
();
final
JSONObject
link2
=
new
JSONObject
();
...
@@ -88,8 +88,7 @@ public final class LinkRepositoryImplTestCase extends AbstractTestCase {
...
@@ -88,8 +88,7 @@ public final class LinkRepositoryImplTestCase extends AbstractTestCase {
transaction
.
commit
();
transaction
.
commit
();
final
int
total
=
3
;
Assert
.
assertEquals
(
linkRepository
.
count
(),
4
);
Assert
.
assertEquals
(
linkRepository
.
count
(),
total
);
link1
=
linkRepository
.
getUpper
(
link2Id
);
link1
=
linkRepository
.
getUpper
(
link2Id
);
Assert
.
assertNotNull
(
link1
);
Assert
.
assertNotNull
(
link1
);
...
...
src/test/java/org/b3log/solo/repository/OptionRepositoryImplTestCase.java
View file @
a436a677
...
@@ -17,11 +17,8 @@
...
@@ -17,11 +17,8 @@
*/
*/
package
org
.
b3log
.
solo
.
repository
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Option
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
...
@@ -44,16 +41,7 @@ public final class OptionRepositoryImplTestCase extends AbstractTestCase {
...
@@ -44,16 +41,7 @@ public final class OptionRepositoryImplTestCase extends AbstractTestCase {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
final
OptionRepository
optionRepository
=
getOptionRepository
();
final
OptionRepository
optionRepository
=
getOptionRepository
();
final
JSONObject
option
=
new
JSONObject
();
Assert
.
assertTrue
(
0
<
optionRepository
.
count
());
option
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BLOG_TITLE
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
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_BLOG_TITLE
));
Assert
.
assertNotNull
(
optionRepository
.
get
(
Option
.
ID_C_BLOG_TITLE
));
}
}
}
}
src/test/java/org/b3log/solo/repository/TagArticleRepositoryImplTestCase.java
View file @
a436a677
...
@@ -95,6 +95,6 @@ public class TagArticleRepositoryImplTestCase extends AbstractTestCase {
...
@@ -95,6 +95,6 @@ public class TagArticleRepositoryImplTestCase extends AbstractTestCase {
final
List
<
JSONObject
>
mostUsedTags
=
tagArticleRepository
.
getMostUsedTags
(
3
);
final
List
<
JSONObject
>
mostUsedTags
=
tagArticleRepository
.
getMostUsedTags
(
3
);
Assert
.
assertNotNull
(
mostUsedTags
);
Assert
.
assertNotNull
(
mostUsedTags
);
Assert
.
assertEquals
(
1
,
mostUsedTags
.
size
());
Assert
.
assertEquals
(
2
,
mostUsedTags
.
size
());
}
}
}
}
src/test/java/org/b3log/solo/repository/UserRepositoryImplTestCase.java
View file @
a436a677
...
@@ -61,24 +61,7 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
...
@@ -61,24 +61,7 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
userRepository
.
add
(
another
);
userRepository
.
add
(
another
);
transaction
.
commit
();
transaction
.
commit
();
Assert
.
assertNull
(
userRepository
.
getAdmin
());
Assert
.
assertNotNull
(
userRepository
.
getAdmin
());
JSONObject
admin
=
new
JSONObject
();
admin
.
put
(
User
.
USER_NAME
,
"test"
);
admin
.
put
(
User
.
USER_URL
,
"https://b3log.org"
);
admin
.
put
(
User
.
USER_ROLE
,
Role
.
ADMIN_ROLE
);
admin
.
put
(
UserExt
.
USER_AVATAR
,
""
);
admin
.
put
(
UserExt
.
USER_GITHUB_ID
,
""
);
admin
.
put
(
UserExt
.
USER_B3_KEY
,
""
);
transaction
=
userRepository
.
beginTransaction
();
userRepository
.
add
(
admin
);
transaction
.
commit
();
admin
=
userRepository
.
getAdmin
();
Assert
.
assertNotNull
(
admin
);
Assert
.
assertEquals
(
"test"
,
admin
.
optString
(
User
.
USER_NAME
));
final
JSONObject
result
=
userRepository
.
get
(
new
Query
().
setFilter
(
final
JSONObject
result
=
userRepository
.
get
(
new
Query
().
setFilter
(
new
PropertyFilter
(
User
.
USER_NAME
,
FilterOperator
.
EQUAL
,
"test1"
)));
new
PropertyFilter
(
User
.
USER_NAME
,
FilterOperator
.
EQUAL
,
"test1"
)));
...
...
src/test/java/org/b3log/solo/service/UserQueryServiceTestCase.java
View file @
a436a677
...
@@ -87,7 +87,7 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
...
@@ -87,7 +87,7 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
final
JSONObject
paginationRequest
=
Solos
.
buildPaginationRequest
(
"1/20/10"
);
final
JSONObject
paginationRequest
=
Solos
.
buildPaginationRequest
(
"1/20/10"
);
final
JSONObject
result
=
userQueryService
.
getUsers
(
paginationRequest
);
final
JSONObject
result
=
userQueryService
.
getUsers
(
paginationRequest
);
final
JSONArray
users
=
result
.
getJSONArray
(
User
.
USERS
);
final
JSONArray
users
=
result
.
getJSONArray
(
User
.
USERS
);
Assert
.
assertEquals
(
1
,
users
.
length
()
);
Assert
.
assertEquals
(
users
.
length
(),
2
);
}
}
/**
/**
...
...
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