Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
2250ad6b
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
2250ad6b
编写于
12月 21, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add basic test for call
上级
3025c083
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
106 addition
and
13 deletion
+106
-13
_fixtures/call/BookController.java
_fixtures/call/BookController.java
+45
-0
cmd/concept.go
cmd/concept.go
+7
-1
core/adapter/call/JavaCallApp_test.go
core/adapter/call/JavaCallApp_test.go
+17
-0
core/adapter/identifier/JavaIdentifierApp_test.go
core/adapter/identifier/JavaIdentifierApp_test.go
+5
-3
core/domain/concept/concept_analyser.go
core/domain/concept/concept_analyser.go
+4
-9
core/domain/concept/concept_analyser_test.go
core/domain/concept/concept_analyser_test.go
+28
-0
未找到文件。
_fixtures/call/BookController.java
0 → 100644
浏览文件 @
2250ad6b
package
com.phodal.pholedge.book
;
import
com.phodal.pholedge.book.model.BookRepresentaion
;
import
com.phodal.pholedge.book.model.command.CreateBookCommand
;
import
com.phodal.pholedge.book.model.command.UpdateBookCommand
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
google
.
common
.
collect
.
ImmutableSortedMap
.
of
;
@RestController
@RequestMapping
(
value
=
"/books"
)
public
class
BookController
{
private
final
BookService
applicationService
;
public
BookController
(
BookService
applicationService
)
{
this
.
applicationService
=
applicationService
;
}
@PostMapping
@ResponseStatus
(
HttpStatus
.
CREATED
)
public
Map
<
String
,
String
>
createBook
(
@RequestBody
@Valid
CreateBookCommand
command
)
{
return
of
(
"id"
,
applicationService
.
createBook
(
command
));
}
@PutMapping
(
"/{id}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BookRepresentaion
updateBook
(
@PathVariable
(
name
=
"id"
)
String
id
,
@RequestBody
@Valid
UpdateBookCommand
command
)
{
return
applicationService
.
updateBook
(
id
,
command
);
}
@GetMapping
(
"/"
)
public
List
<
BookRepresentaion
>
getBookList
()
{
return
applicationService
.
getBooksLists
();
}
@GetMapping
(
"/{id}"
)
public
BookRepresentaion
getBookById
(
@PathVariable
(
name
=
"id"
)
String
id
)
{
return
applicationService
.
getBookById
(
id
);
}
}
cmd/concept.go
浏览文件 @
2250ad6b
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"coca/core/models"
"coca/core/models"
.
"coca/core/support"
.
"coca/core/support"
"encoding/json"
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"log"
"log"
)
)
...
@@ -28,7 +29,12 @@ var conceptCmd = &cobra.Command{
...
@@ -28,7 +29,12 @@ var conceptCmd = &cobra.Command{
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
analyser
.
Analysis
(
&
parsedDeps
)
wordCounts
:=
analyser
.
Analysis
(
&
parsedDeps
)
for
_
,
word
:=
range
wordCounts
{
if
word
.
Value
>
0
{
fmt
.
Println
(
word
.
Key
,
word
.
Value
)
}
}
}
}
},
},
}
}
...
...
core/adapter/call/JavaCallApp_test.go
浏览文件 @
2250ad6b
package
call
package
call
import
(
import
(
"coca/core/adapter/identifier"
"fmt"
.
"github.com/onsi/gomega"
"testing"
"testing"
)
)
func
TestJavaCallApp_AnalysisPath
(
t
*
testing
.
T
)
{
func
TestJavaCallApp_AnalysisPath
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
codePath
:=
"../../../_fixtures/call"
identifierApp
:=
new
(
identifier
.
JavaIdentifierApp
)
iNodes
:=
identifierApp
.
AnalysisPath
(
codePath
)
var
classes
[]
string
=
nil
for
_
,
node
:=
range
iNodes
{
classes
=
append
(
classes
,
node
.
Package
+
"."
+
node
.
ClassName
)
}
callApp
:=
new
(
JavaCallApp
)
callNodes
:=
callApp
.
AnalysisPath
(
codePath
,
classes
,
iNodes
)
g
.
Expect
(
len
(
callNodes
))
.
To
(
Equal
(
1
))
}
}
\ No newline at end of file
core/adapter/identifier/JavaIdentifierApp_test.go
浏览文件 @
2250ad6b
...
@@ -9,9 +9,11 @@ func TestJavaIdentifierApp_AnalysisPath(t *testing.T) {
...
@@ -9,9 +9,11 @@ func TestJavaIdentifierApp_AnalysisPath(t *testing.T) {
g
:=
NewGomegaWithT
(
t
)
g
:=
NewGomegaWithT
(
t
)
identApp
:=
new
(
JavaIdentifierApp
)
identApp
:=
new
(
JavaIdentifierApp
)
identifiers
:=
identApp
.
AnalysisPath
(
"../../../
examples/method-
call"
)
identifiers
:=
identApp
.
AnalysisPath
(
"../../../
_fixtures/
call"
)
g
.
Expect
(
len
(
identifiers
))
.
To
(
Equal
(
1
))
g
.
Expect
(
len
(
identifiers
))
.
To
(
Equal
(
1
))
g
.
Expect
(
identifiers
[
0
]
.
ClassName
)
.
To
(
Equal
(
"BlogRepositoryImpl"
))
g
.
Expect
(
identifiers
[
0
]
.
ClassName
)
.
To
(
Equal
(
"BookController"
))
g
.
Expect
(
identifiers
[
0
]
.
Methods
[
0
]
.
Name
)
.
To
(
Equal
(
"save"
))
g
.
Expect
(
identifiers
[
0
]
.
Methods
[
0
]
.
Name
)
.
To
(
Equal
(
"createBook"
))
g
.
Expect
(
identifiers
[
0
]
.
Annotations
[
0
]
.
QualifiedName
)
.
To
(
Equal
(
"RestController"
))
}
}
\ No newline at end of file
core/domain/concept/concept_analyser.go
浏览文件 @
2250ad6b
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
languages2
"coca/core/domain/call_graph/stop_words/languages"
languages2
"coca/core/domain/call_graph/stop_words/languages"
"coca/core/models"
"coca/core/models"
"coca/core/support"
"coca/core/support"
"fmt"
)
)
type
ConceptAnalyser
struct
{
type
ConceptAnalyser
struct
{
...
@@ -18,11 +17,11 @@ func (c ConceptAnalyser) run() {
...
@@ -18,11 +17,11 @@ func (c ConceptAnalyser) run() {
}
}
func
(
c
ConceptAnalyser
)
Analysis
(
clzs
*
[]
models
.
JClassNode
)
{
func
(
c
ConceptAnalyser
)
Analysis
(
clzs
*
[]
models
.
JClassNode
)
support
.
PairList
{
buildMethodsFromDeps
(
*
clzs
)
return
buildMethodsFromDeps
(
*
clzs
)
}
}
func
buildMethodsFromDeps
(
clzs
[]
models
.
JClassNode
)
{
func
buildMethodsFromDeps
(
clzs
[]
models
.
JClassNode
)
support
.
PairList
{
var
methodsName
[]
string
var
methodsName
[]
string
var
methodStr
string
var
methodStr
string
for
_
,
clz
:=
range
clzs
{
for
_
,
clz
:=
range
clzs
{
...
@@ -38,11 +37,7 @@ func buildMethodsFromDeps(clzs []models.JClassNode) {
...
@@ -38,11 +37,7 @@ func buildMethodsFromDeps(clzs []models.JClassNode) {
words
=
removeNormalWords
(
words
)
words
=
removeNormalWords
(
words
)
wordCounts
:=
support
.
RankByWordCount
(
words
)
wordCounts
:=
support
.
RankByWordCount
(
words
)
for
_
,
word
:=
range
wordCounts
{
return
wordCounts
if
word
.
Value
>
0
{
fmt
.
Println
(
word
.
Key
,
word
.
Value
)
}
}
}
}
var
itStopWords
=
[]
string
{
var
itStopWords
=
[]
string
{
...
...
core/domain/concept/concept_analyser_test.go
0 → 100644
浏览文件 @
2250ad6b
package
concept
import
(
"coca/core/models"
"coca/core/support"
"encoding/json"
"log"
"testing"
.
"github.com/onsi/gomega"
)
func
TestConceptAnalyser_Analysis
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
models
.
JClassNode
analyser
:=
NewConceptAnalyser
()
file
:=
support
.
ReadFile
(
"../../../_fixtures/call_api_test.json"
)
if
file
==
nil
{
log
.
Fatal
(
"lost file"
)
}
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
counts
:=
analyser
.
Analysis
(
&
parsedDeps
)
g
.
Expect
(
counts
.
Len
())
.
To
(
Equal
(
4
))
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录