Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
d46940e8
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d46940e8
编写于
4月 11, 2016
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add app CRUD logic in admin service
上级
76528a11
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
281 addition
and
36 deletion
+281
-36
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppController.java
...m/ctrip/apollo/adminservice/controller/AppController.java
+39
-5
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/GlobalDefaultExceptionHandler.java
...dminservice/controller/GlobalDefaultExceptionHandler.java
+71
-0
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/WebMvcConfig.java
...om/ctrip/apollo/adminservice/controller/WebMvcConfig.java
+0
-1
apollo-adminservice/src/test/java/com/ctrip/apollo/AdminServiceTestConfiguration.java
.../java/com/ctrip/apollo/AdminServiceTestConfiguration.java
+10
-0
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/AppControllerTest.java
...rip/apollo/adminservice/controller/AppControllerTest.java
+103
-0
apollo-adminservice/src/test/resources/application.properties
...lo-adminservice/src/test/resources/application.properties
+1
-1
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppService.java
...rc/main/java/com/ctrip/apollo/biz/service/AppService.java
+22
-11
apollo-biz/src/main/java/com/ctrip/apollo/biz/utils/BeanUtils.java
...z/src/main/java/com/ctrip/apollo/biz/utils/BeanUtils.java
+16
-7
apollo-biz/src/test/java/com/ctrip/apollo/biz/BizTestConfiguration.java
.../test/java/com/ctrip/apollo/biz/BizTestConfiguration.java
+1
-1
apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
...va/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
+2
-2
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
...t/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
+2
-2
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java
...va/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java
+2
-2
apollo-core/src/main/java/com/ctrip/apollo/core/exception/NotFoundException.java
...va/com/ctrip/apollo/core/exception/NotFoundException.java
+9
-1
apollo-core/src/main/java/com/ctrip/apollo/core/exception/ServiceException.java
...ava/com/ctrip/apollo/core/exception/ServiceException.java
+1
-1
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/GlobalDefaultExceptionHandler.java
...ollo/portal/controller/GlobalDefaultExceptionHandler.java
+2
-2
未找到文件。
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppController.java
浏览文件 @
d46940e8
...
...
@@ -4,8 +4,12 @@ import java.util.List;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -13,7 +17,8 @@ import com.ctrip.apollo.biz.entity.App;
import
com.ctrip.apollo.biz.service.AppService
;
import
com.ctrip.apollo.biz.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.AppDTO
;
import
com.google.common.base.Strings
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
import
com.ctrip.apollo.core.utils.StringUtils
;
@RestController
public
class
AppController
{
...
...
@@ -21,21 +26,50 @@ public class AppController {
@Autowired
private
AppService
appService
;
@RequestMapping
(
"/apps/{appId}"
)
public
AppDTO
getApp
(
@PathVariable
(
"appId"
)
String
appId
)
{
@RequestMapping
(
path
=
"/apps/"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<
AppDTO
>
createApp
(
@RequestBody
AppDTO
appDTO
)
{
App
app
=
BeanUtils
.
transfrom
(
App
.
class
,
appDTO
);
app
=
appService
.
save
(
app
);
AppDTO
dto
=
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
dto
);
}
@RequestMapping
(
path
=
"/apps/{appId}"
,
method
=
RequestMethod
.
DELETE
)
public
void
deleteApp
(
@PathVariable
(
"appId"
)
String
appId
)
{
App
app
=
appService
.
findOne
(
appId
);
return
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
if
(
app
==
null
)
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
appService
.
delete
(
app
.
getId
());
}
@RequestMapping
(
"/apps"
)
public
List
<
AppDTO
>
findApps
(
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
,
Pageable
pageable
)
{
List
<
App
>
app
=
null
;
if
(
String
s
.
isNullOrEmpty
(
name
))
{
if
(
String
Utils
.
isBlank
(
name
))
{
app
=
appService
.
findAll
(
pageable
);
}
else
{
app
=
appService
.
findByName
(
name
);
}
return
BeanUtils
.
batchTransform
(
AppDTO
.
class
,
app
);
}
@RequestMapping
(
"/apps/{appId}"
)
public
AppDTO
getApp
(
@PathVariable
(
"appId"
)
String
appId
)
{
App
app
=
appService
.
findOne
(
appId
);
if
(
app
==
null
)
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
return
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
}
@RequestMapping
(
path
=
"/apps/{appId}"
,
method
=
RequestMethod
.
PUT
)
public
AppDTO
updateApp
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestBody
AppDTO
appDTO
)
{
if
(!
appId
.
equals
(
appDTO
.
getAppId
()))
{
throw
new
IllegalArgumentException
(
String
.
format
(
"Path variable %s is not equals to object field %s"
,
appId
,
appDTO
.
getAppId
()));
}
App
app
=
appService
.
findOne
(
appId
);
if
(
app
==
null
)
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
app
=
appService
.
update
(
BeanUtils
.
transfrom
(
App
.
class
,
appDTO
));
return
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
}
}
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/GlobalDefaultExceptionHandler.java
0 → 100644
浏览文件 @
d46940e8
package
com.ctrip.apollo.adminservice.controller
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.HttpMediaTypeException
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
static
org
.
springframework
.
http
.
HttpStatus
.
BAD_REQUEST
;
import
static
org
.
springframework
.
http
.
HttpStatus
.
INTERNAL_SERVER_ERROR
;
import
static
org
.
springframework
.
http
.
HttpStatus
.
NOT_FOUND
;
import
static
org
.
springframework
.
http
.
MediaType
.
APPLICATION_JSON
;
@ControllerAdvice
public
class
GlobalDefaultExceptionHandler
{
@ExceptionHandler
(
Exception
.
class
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
exception
(
HttpServletRequest
request
,
Exception
ex
)
{
return
handleError
(
request
,
INTERNAL_SERVER_ERROR
,
ex
);
}
private
ResponseEntity
<
Map
<
String
,
Object
>>
handleError
(
HttpServletRequest
request
,
HttpStatus
status
,
Throwable
ex
)
{
return
handleError
(
request
,
status
,
ex
,
ex
.
getMessage
());
}
private
ResponseEntity
<
Map
<
String
,
Object
>>
handleError
(
HttpServletRequest
request
,
HttpStatus
status
,
Throwable
ex
,
String
message
)
{
ex
=
resolveError
(
ex
);
Map
<
String
,
Object
>
errorAttributes
=
new
LinkedHashMap
<>();
errorAttributes
.
put
(
"status"
,
status
.
value
());
errorAttributes
.
put
(
"message"
,
message
);
errorAttributes
.
put
(
"timestamp"
,
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE_TIME
));
errorAttributes
.
put
(
"exception"
,
resolveError
(
ex
).
getClass
().
getName
());
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
APPLICATION_JSON
);
return
new
ResponseEntity
<>(
errorAttributes
,
headers
,
status
);
}
@ExceptionHandler
({
HttpRequestMethodNotSupportedException
.
class
,
HttpMediaTypeException
.
class
})
public
ResponseEntity
<
Map
<
String
,
Object
>>
methodNotSupportedException
(
HttpServletRequest
request
,
ServletException
ex
)
{
return
handleError
(
request
,
BAD_REQUEST
,
ex
);
}
@ExceptionHandler
(
NotFoundException
.
class
)
@ResponseStatus
(
value
=
NOT_FOUND
)
public
void
notFound
(
HttpServletRequest
req
,
NotFoundException
ex
)
{
}
private
Throwable
resolveError
(
Throwable
ex
)
{
while
(
ex
instanceof
ServletException
&&
ex
.
getCause
()
!=
null
)
{
ex
=
((
ServletException
)
ex
).
getCause
();
}
return
ex
;
}
}
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/WebMvcConfig.java
浏览文件 @
d46940e8
...
...
@@ -8,7 +8,6 @@ import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import
org.springframework.http.MediaType
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@Configuration
...
...
apollo-adminservice/src/test/java/com/ctrip/apollo/AdminServiceTestConfiguration.java
0 → 100644
浏览文件 @
d46940e8
package
com.ctrip.apollo
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
;
@SpringBootApplication
(
exclude
=
{
SampleAdminServiceApplication
.
class
,
EurekaClientAutoConfiguration
.
class
})
public
class
AdminServiceTestConfiguration
{
}
apollo-adminservice/src/test/java/com/ctrip/apollo/adminservice/controller/AppControllerTest.java
0 → 100644
浏览文件 @
d46940e8
package
com.ctrip.apollo.adminservice.controller
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.WebIntegrationTest
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.web.client.RestTemplate
;
import
com.ctrip.apollo.AdminServiceTestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.repository.AppRepository
;
import
com.ctrip.apollo.biz.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.AppDTO
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
AdminServiceTestConfiguration
.
class
)
@WebIntegrationTest
public
class
AppControllerTest
{
RestTemplate
restTemplate
=
new
TestRestTemplate
();
@Autowired
AppRepository
appRepository
;
@Test
public
void
testCreate
()
{
AppDTO
dto
=
generateSampleDTOData
();
ResponseEntity
<
AppDTO
>
response
=
restTemplate
.
postForEntity
(
"http://localhost:8090/apps/"
,
dto
,
AppDTO
.
class
);
AppDTO
result
=
response
.
getBody
();
Assert
.
assertEquals
(
HttpStatus
.
CREATED
,
response
.
getStatusCode
());
Assert
.
assertEquals
(
dto
.
getAppId
(),
result
.
getAppId
());
Assert
.
assertTrue
(
result
.
getId
()
>
0
);
App
savedApp
=
appRepository
.
findOne
(
result
.
getId
());
Assert
.
assertEquals
(
dto
.
getAppId
(),
savedApp
.
getAppId
());
Assert
.
assertNotNull
(
savedApp
.
getDataChangeCreatedTime
());
appRepository
.
delete
(
savedApp
.
getId
());
}
@Test
public
void
testFind
()
{
AppDTO
dto
=
generateSampleDTOData
();
App
app
=
BeanUtils
.
transfrom
(
App
.
class
,
dto
);
app
=
appRepository
.
save
(
app
);
AppDTO
result
=
restTemplate
.
getForObject
(
"http://localhost:8090/apps/"
+
dto
.
getAppId
(),
AppDTO
.
class
);
Assert
.
assertEquals
(
dto
.
getAppId
(),
result
.
getAppId
());
Assert
.
assertEquals
(
dto
.
getName
(),
result
.
getName
());
appRepository
.
delete
(
app
.
getId
());
}
@Test
public
void
testFindNotExist
()
{
ResponseEntity
<
AppDTO
>
result
=
restTemplate
.
getForEntity
(
"http://localhost:8090/apps/"
+
"notExists"
,
AppDTO
.
class
);
Assert
.
assertEquals
(
HttpStatus
.
NOT_FOUND
,
result
.
getStatusCode
());
}
@Test
public
void
testDelete
()
{
AppDTO
dto
=
generateSampleDTOData
();
App
app
=
BeanUtils
.
transfrom
(
App
.
class
,
dto
);
app
=
appRepository
.
save
(
app
);
restTemplate
.
delete
(
"http://localhost:8090/apps/"
+
dto
.
getAppId
());
App
deletedApp
=
appRepository
.
findOne
(
app
.
getId
());
Assert
.
assertNull
(
deletedApp
);
}
@Test
public
void
testUpdate
()
{
AppDTO
dto
=
generateSampleDTOData
();
App
app
=
BeanUtils
.
transfrom
(
App
.
class
,
dto
);
app
=
appRepository
.
save
(
app
);
dto
.
setName
(
"newName"
);
restTemplate
.
put
(
"http://localhost:8090/apps/"
+
dto
.
getAppId
(),
dto
);
App
updatedApp
=
appRepository
.
findOne
(
app
.
getId
());
Assert
.
assertEquals
(
dto
.
getName
(),
updatedApp
.
getName
());
Assert
.
assertNotNull
(
updatedApp
.
getDataChangeLastModifiedTime
());
}
private
AppDTO
generateSampleDTOData
()
{
AppDTO
dto
=
new
AppDTO
();
dto
.
setAppId
(
"someAppId"
);
dto
.
setName
(
"someName"
);
dto
.
setOwnerName
(
"someOwner"
);
dto
.
setOwnerEmail
(
"someOwner@ctrip.com"
);
return
dto
;
}
}
apollo-adminservice/src/test/resources/application.properties
浏览文件 @
d46940e8
spring.datasource.url
=
jdbc:h2:mem:~/fxapolloconfigdb;mode=mysql
spring.datasource.url
=
jdbc:h2:mem:~/fxapolloconfigdb;mode=mysql
;DB_CLOSE_ON_EXIT=FALSE
spring.jpa.hibernate.naming_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppService.java
浏览文件 @
d46940e8
...
...
@@ -9,27 +9,38 @@ import org.springframework.stereotype.Service;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.repository.AppRepository
;
import
com.ctrip.apollo.biz.utils.BeanUtils
;
@Service
public
class
AppService
{
@Autowired
private
AppRepository
appRepository
;
public
App
save
(
App
entity
)
{
return
appRepository
.
save
(
entity
);
public
void
delete
(
long
id
)
{
appRepository
.
delete
(
id
);
}
public
List
<
App
>
findAll
(
Pageable
pageable
){
Page
<
App
>
page
=
appRepository
.
findAll
(
pageable
);
return
page
.
getContent
();
public
List
<
App
>
findAll
(
Pageable
pageable
)
{
Page
<
App
>
page
=
appRepository
.
findAll
(
pageable
);
return
page
.
getContent
();
}
public
List
<
App
>
findByName
(
String
name
){
public
List
<
App
>
findByName
(
String
name
)
{
return
appRepository
.
findByName
(
name
);
}
public
App
findOne
(
String
appId
){
public
App
findOne
(
String
appId
)
{
return
appRepository
.
findByAppId
(
appId
);
}
public
App
save
(
App
entity
)
{
return
appRepository
.
save
(
entity
);
}
public
App
update
(
App
app
)
{
App
managedApp
=
appRepository
.
findByAppId
(
app
.
getAppId
());
BeanUtils
.
copyEntityProperties
(
app
,
managedApp
);
return
appRepository
.
save
(
managedApp
);
}
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/utils/BeanUtils.java
浏览文件 @
d46940e8
package
com.ctrip.apollo.biz.utils
;
import
org.springframework.beans.BeanWrapper
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.util.CollectionUtils
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -13,6 +9,10 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.beans.BeanWrapper
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.util.CollectionUtils
;
public
class
BeanUtils
{
...
...
@@ -23,7 +23,6 @@ public class BeanUtils {
* </pre>
*/
public
static
<
T
>
List
<
T
>
batchTransform
(
final
Class
<
T
>
clazz
,
List
srcList
)
{
if
(
CollectionUtils
.
isEmpty
(
srcList
))
{
return
Collections
.
EMPTY_LIST
;
}
...
...
@@ -43,8 +42,8 @@ public class BeanUtils {
* return BeanUtil.transform(UserDTO.class, userBean);
* </pre>
*/
public
static
<
T
>
T
transfrom
(
Class
<
T
>
clazz
,
Object
src
)
{
if
(
src
==
null
){
public
static
<
T
>
T
transfrom
(
Class
<
T
>
clazz
,
Object
src
)
{
if
(
src
==
null
)
{
return
null
;
}
T
instance
=
null
;
...
...
@@ -208,4 +207,14 @@ public class BeanUtils {
public
static
List
toPropertyList
(
String
key
,
List
list
)
{
return
new
ArrayList
(
toPropertySet
(
key
,
list
));
}
/**
* The copy will ignore <em>id</em> field
*
* @param source
* @param target
*/
public
static
void
copyEntityProperties
(
Object
source
,
Object
target
)
{
org
.
springframework
.
beans
.
BeanUtils
.
copyProperties
(
source
,
target
,
"id"
);
}
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/
Spring
TestConfiguration.java
→
apollo-biz/src/test/java/com/ctrip/apollo/biz/
Biz
TestConfiguration.java
浏览文件 @
d46940e8
...
...
@@ -7,6 +7,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
@ComponentScan
(
basePackages
=
"com.ctrip.apollo.biz"
)
public
class
Spring
TestConfiguration
{
public
class
Biz
TestConfiguration
{
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
浏览文件 @
d46940e8
...
...
@@ -8,11 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
com.ctrip.apollo.biz.
Spring
TestConfiguration
;
import
com.ctrip.apollo.biz.
Biz
TestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Spring
TestConfiguration
.
class
)
@SpringApplicationConfiguration
(
classes
=
Biz
TestConfiguration
.
class
)
public
class
AppRepositoryTest
{
@Autowired
...
...
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
浏览文件 @
d46940e8
...
...
@@ -9,13 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
com.ctrip.apollo.biz.
Spring
TestConfiguration
;
import
com.ctrip.apollo.biz.
Biz
TestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.entity.Namespace
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Spring
TestConfiguration
.
class
)
@SpringApplicationConfiguration
(
classes
=
Biz
TestConfiguration
.
class
)
public
class
AdminServiceTest
{
@Autowired
...
...
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java
浏览文件 @
d46940e8
...
...
@@ -9,14 +9,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
com.ctrip.apollo.biz.
Spring
TestConfiguration
;
import
com.ctrip.apollo.biz.
Biz
TestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.entity.Namespace
;
import
com.ctrip.apollo.biz.entity.Privilege
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
Spring
TestConfiguration
.
class
)
@SpringApplicationConfiguration
(
classes
=
Biz
TestConfiguration
.
class
)
public
class
PrivilegeServiceTest
{
@Autowired
...
...
apollo-
portal/src/main/java/com/ctrip/apollo/portal
/exception/NotFoundException.java
→
apollo-
core/src/main/java/com/ctrip/apollo/core
/exception/NotFoundException.java
浏览文件 @
d46940e8
package
com.ctrip.apollo.
portal
.exception
;
package
com.ctrip.apollo.
core
.exception
;
public
class
NotFoundException
extends
RuntimeException
{
/**
*
*/
private
static
final
long
serialVersionUID
=
7611357629749481796L
;
public
NotFoundException
(){
}
public
NotFoundException
(
String
str
){
super
(
str
);
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/exception/ServiceException.java
浏览文件 @
d46940e8
package
com.ctrip.apollo.core.exception
;
public
class
ServiceException
extends
Exception
{
public
class
ServiceException
extends
Runtime
Exception
{
/**
*
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/GlobalDefaultExceptionHandler.java
浏览文件 @
d46940e8
package
com.ctrip.apollo.portal.controller
;
import
com.ctrip.apollo.portal.exception.NotFoundException
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -11,6 +9,8 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.LinkedHashMap
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录