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
7449ea1e
Unverified
Commit
7449ea1e
authored
Dec 10, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
增加后台测试用例
parent
f8f7e545
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
7 deletions
+93
-7
src/test/java/org/b3log/solo/processor/console/CategoryConsoleTestCase.java
...b3log/solo/processor/console/CategoryConsoleTestCase.java
+93
-7
No files found.
src/test/java/org/b3log/solo/processor/console/CategoryConsoleTestCase.java
View file @
7449ea1e
...
...
@@ -17,22 +17,17 @@
*/
package
org
.
b3log
.
solo
.
processor
.
console
;
import
org.apache.commons.lang.RandomStringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.util.Crypts
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.MockHttpServletRequest
;
import
org.b3log.solo.MockHttpServletResponse
;
import
org.b3log.solo.model.Category
;
import
org.b3log.solo.
util.Solos
;
import
org.b3log.solo.
model.Common
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
javax.servlet.http.Cookie
;
import
java.io.BufferedReader
;
import
java.io.StringReader
;
...
...
@@ -40,7 +35,7 @@ import java.io.StringReader;
* {@link CategoryConsole} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.1, Oct 15
, 2018
* @version 1.
1.0.0, Dec 10
, 2018
* @since 2.1.0
*/
@Test
(
suiteName
=
"processor"
)
...
...
@@ -82,6 +77,28 @@ public class CategoryConsoleTestCase extends AbstractTestCase {
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"sc\":true"
));
}
/**
* getCategory.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"addCategory"
)
public
void
getCategory
()
throws
Exception
{
final
JSONObject
category
=
getCategoryQueryService
().
getByTitle
(
"分类1"
);
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/console/category/"
+
category
.
optString
(
Keys
.
OBJECT_ID
));
request
.
setMethod
(
"GET"
);
mockAdminLogin
(
request
);
final
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
String
content
=
response
.
body
();
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"sc\":true"
));
}
/**
* updateCategory.
*
...
...
@@ -115,4 +132,73 @@ public class CategoryConsoleTestCase extends AbstractTestCase {
Assert
.
assertNotNull
(
category
);
Assert
.
assertEquals
(
category
.
optInt
(
Category
.
CATEGORY_TAG_CNT
),
1
);
// https://github.com/b3log/solo/issues/12274
}
/**
* getCategories.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"updateCategory"
)
public
void
getCategories
()
throws
Exception
{
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/console/categories/1/10/20"
);
request
.
setMethod
(
"GET"
);
mockAdminLogin
(
request
);
final
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
String
content
=
response
.
body
();
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"sc\":true"
));
}
/**
* changeOrder.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"getCategories"
)
public
void
changeOrder
()
throws
Exception
{
final
JSONObject
category
=
getCategoryQueryService
().
getByTitle
(
"新的分类1"
);
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/console/category/order/"
);
request
.
setMethod
(
"PUT"
);
final
JSONObject
requestJSON
=
new
JSONObject
();
requestJSON
.
put
(
Keys
.
OBJECT_ID
,
category
.
optString
(
Keys
.
OBJECT_ID
));
requestJSON
.
put
(
Common
.
DIRECTION
,
"up"
);
final
BufferedReader
reader
=
new
BufferedReader
(
new
StringReader
(
requestJSON
.
toString
()));
request
.
setReader
(
reader
);
mockAdminLogin
(
request
);
final
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
String
content
=
response
.
body
();
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"sc\":true"
));
}
/**
* removeCategory.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"changeOrder"
)
public
void
removeCategory
()
throws
Exception
{
final
JSONObject
category
=
getCategoryQueryService
().
getByTitle
(
"新的分类1"
);
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/console/category/"
+
category
.
optString
(
Keys
.
OBJECT_ID
));
request
.
setMethod
(
"DELETE"
);
mockAdminLogin
(
request
);
final
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
String
content
=
response
.
body
();
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"sc\":true"
));
}
}
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