Skip to content

Commit e54bd6f

Browse files
committed
🎨 Clean code
@nanolikeyou Thanks for your PR 👍
1 parent bbdded3 commit e54bd6f

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

src/main/java/org/b3log/solo/service/UserMgmtService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* @author <a href="http://88250.b3log.org">Liang Ding</a>
5050
* @author <a href="mailto:385321165@qq.com">DASHU</a>
5151
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
52-
* @version 1.1.0.10, Aug 13, 2017
52+
* @version 1.1.0.11, Aug 14, 2017
5353
* @since 0.4.0
5454
*/
5555
@Service
@@ -278,6 +278,7 @@ public String addUser(final JSONObject requestJSONObject) throws ServiceExceptio
278278
if (!Strings.isEmail(userEmail)) {
279279
throw new ServiceException(langPropsService.get("mailInvalidLabel"));
280280
}
281+
281282
final JSONObject duplicatedUser = userRepository.getByEmail(userEmail);
282283

283284
if (null != duplicatedUser) {

src/test/java/org/b3log/solo/service/UserMgmtServiceTestCase.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
*
3131
* @author <a href="http://88250.b3log.org">Liang Ding</a>
3232
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
33-
* @version 1.0.0.3, May 25, 2017
33+
* @version 1.0.0.4, Aug 14, 2017
3434
*/
3535
@Test(suiteName = "service")
3636
public class UserMgmtServiceTestCase extends AbstractTestCase {
3737

3838
/**
3939
* Add User.
40-
*
40+
*
4141
* @throws Exception exception
4242
*/
4343
@Test
@@ -56,15 +56,14 @@ public void addUser() throws Exception {
5656

5757
/**
5858
* Update User.
59-
*
59+
*
6060
* @throws Exception exception
6161
*/
6262
@Test(dependsOnMethods = "addUser")
6363
public void updateUser() throws Exception {
6464
final UserMgmtService userMgmtService = getUserMgmtService();
6565

6666
JSONObject requestJSONObject = new JSONObject();
67-
6867
requestJSONObject.put(User.USER_NAME, "user2name");
6968
requestJSONObject.put(User.USER_EMAIL, "test2@gmail.com");
7069
requestJSONObject.put(User.USER_PASSWORD, "pass2");
@@ -92,42 +91,38 @@ public void updateUser() throws Exception {
9291
Assert.assertEquals(getUserQueryService().getUser(id).getJSONObject(
9392
User.USER).getString(User.USER_PASSWORD), MD5.hash("pass2"));
9493
}
95-
94+
9695
/**
9796
* Valid User.
9897
*
99-
*@throws Exception exception
98+
* @throws Exception exception
10099
*/
101100
@Test
102-
public void ValidUser() throws Exception {
101+
public void validUser() throws Exception {
103102
final UserMgmtService userMgmtService = getUserMgmtService();
104103

105104
final JSONObject requestJSONObject = new JSONObject();
106-
107105
requestJSONObject.put(User.USER_NAME, "user1 name");
108106
requestJSONObject.put(User.USER_EMAIL, "test1@gmail.com");
109107
requestJSONObject.put(User.USER_PASSWORD, "pass1");
110-
108+
111109
try {
112110
final String id = userMgmtService.addUser(requestJSONObject);
113111
} catch (Exception e) {
114-
// TODO Auto-generated catch block
115112
Assert.assertTrue(e instanceof ServiceException);
116113
}
117-
118114
}
119-
115+
120116
/**
121-
* Vallid XSS username.
117+
* Valid XSS username.
122118
*
123-
*@throws Exception exception
119+
* @throws Exception exception
124120
*/
125121
@Test(expectedExceptions = ServiceException.class)
126122
public void XSSUser() throws Exception {
127123
final UserMgmtService userMgmtService = getUserMgmtService();
128124

129125
final JSONObject requestJSONObject = new JSONObject();
130-
131126
requestJSONObject.put(User.USER_NAME, "username");
132127
requestJSONObject.put(User.USER_EMAIL, "<script></script>");
133128

@@ -136,20 +131,18 @@ public void XSSUser() throws Exception {
136131

137132
/**
138133
* Remove User.
139-
*
134+
*
140135
* @throws Exception exception
141136
*/
142137
@Test(dependsOnMethods = "addUser")
143138
public void removeUser() throws Exception {
144139
final UserMgmtService userMgmtService = getUserMgmtService();
145140

146-
final JSONObject user =
147-
getUserQueryService().getUserByEmail("test1@gmail.com");
141+
final JSONObject user = getUserQueryService().getUserByEmail("test1@gmail.com");
148142
Assert.assertNotNull(user);
149143

150144
userMgmtService.removeUser(user.getString(Keys.OBJECT_ID));
151145

152-
Assert.assertNull(
153-
getUserQueryService().getUserByEmail("test1@gmail.com"));
146+
Assert.assertNull(getUserQueryService().getUserByEmail("test1@gmail.com"));
154147
}
155148
}

src/test/java/org/b3log/solo/service/UserQueryServiceTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
* {@link UserQueryService} test case.
2828
*
2929
* @author <a href="http://88250.b3log.org">Liang Ding</a>
30-
* @version 1.0.0.1, May 16, 2012
30+
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
31+
* @version 1.0.0.2, Aug 14, 2017
3132
*/
3233
@Test(suiteName = "service")
3334
public class UserQueryServiceTestCase extends AbstractTestCase {

0 commit comments

Comments
 (0)