Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
openSource
apollo
Commits
c08abef5
Commit
c08abef5
authored
Mar 10, 2017
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: still lock branch when master modified
parent
573b1183
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
15 deletions
+35
-15
NamespaceUnlockAspect.java
...mework/apollo/adminservice/aop/NamespaceUnlockAspect.java
+4
-3
NamespaceUnlockAspectTest.java
...rk/apollo/adminservice/aop/NamespaceUnlockAspectTest.java
+31
-12
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspect.java
View file @
c08abef5
...
@@ -133,9 +133,10 @@ public class NamespaceUnlockAspect {
...
@@ -133,9 +133,10 @@ public class NamespaceUnlockAspect {
if
(
parentNamespace
==
null
)
{
if
(
parentNamespace
==
null
)
{
generateMapFromItems
(
namespaceItems
,
configurationFromItems
);
generateMapFromItems
(
namespaceItems
,
configurationFromItems
);
}
else
{
//child namespace
}
else
{
//child namespace
List
<
Item
>
parentItems
=
itemService
.
findItems
(
parentNamespace
.
getId
());
Release
parentRelease
=
releaseService
.
findLatestActiveRelease
(
parentNamespace
);
if
(
parentRelease
!=
null
)
{
generateMapFromItems
(
parentItems
,
configurationFromItems
);
configurationFromItems
=
gson
.
fromJson
(
parentRelease
.
getConfigurations
(),
GsonType
.
CONFIG
);
}
generateMapFromItems
(
namespaceItems
,
configurationFromItems
);
generateMapFromItems
(
namespaceItems
,
configurationFromItems
);
}
}
...
...
apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/aop/NamespaceUnlockAspectTest.java
View file @
c08abef5
...
@@ -103,18 +103,18 @@ public class NamespaceUnlockAspectTest {
...
@@ -103,18 +103,18 @@ public class NamespaceUnlockAspectTest {
public
void
testChildNamespaceModified
()
{
public
void
testChildNamespaceModified
()
{
long
childNamespaceId
=
1
,
parentNamespaceId
=
2
;
long
childNamespaceId
=
1
,
parentNamespaceId
=
2
;
Namespace
childNamespace
=
createNamespace
(
childNamespaceId
);
Namespace
childNamespace
=
createNamespace
(
childNamespaceId
);
Namespace
parentNamespace
=
createNamespace
(
child
NamespaceId
);
Namespace
parentNamespace
=
createNamespace
(
parent
NamespaceId
);
Release
childRelease
=
createRelease
(
"{\"k1\":\"v1\", \"k2\":\"v2\"}"
);
Release
childRelease
=
createRelease
(
"{\"k1\":\"v1\", \"k2\":\"v2\"}"
);
List
<
Item
>
childItems
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v3"
));
List
<
Item
>
childItems
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v3"
));
List
<
Item
>
parentItems
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v1"
),
createItem
(
"k2"
,
"v2"
)
);
Release
parentRelease
=
createRelease
(
"{\"k1\":\"v1\", \"k2\":\"v2\"}"
);
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
parentNamespace
)).
thenReturn
(
parentRelease
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
itemService
.
findItems
(
parentNamespaceId
)).
thenReturn
(
parentItems
);
when
(
namespaceService
.
findParentNamespace
(
childNamespace
)).
thenReturn
(
parentNamespace
);
when
(
namespaceService
.
findParentNamespace
(
parentNamespace
)).
thenReturn
(
parentNamespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
parent
Namespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
child
Namespace
);
Assert
.
assertTrue
(
isModified
);
Assert
.
assertTrue
(
isModified
);
}
}
...
@@ -123,18 +123,37 @@ public class NamespaceUnlockAspectTest {
...
@@ -123,18 +123,37 @@ public class NamespaceUnlockAspectTest {
public
void
testChildNamespaceNotModified
()
{
public
void
testChildNamespaceNotModified
()
{
long
childNamespaceId
=
1
,
parentNamespaceId
=
2
;
long
childNamespaceId
=
1
,
parentNamespaceId
=
2
;
Namespace
childNamespace
=
createNamespace
(
childNamespaceId
);
Namespace
childNamespace
=
createNamespace
(
childNamespaceId
);
Namespace
parentNamespace
=
createNamespace
(
child
NamespaceId
);
Namespace
parentNamespace
=
createNamespace
(
parent
NamespaceId
);
Release
childRelease
=
createRelease
(
"{\"k1\":\"v1\", \"k2\":\"v2\"}"
);
Release
childRelease
=
createRelease
(
"{\"k1\":\"v3\", \"k2\":\"v2\"}"
);
List
<
Item
>
childItems
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v1"
));
List
<
Item
>
childItems
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v3"
));
List
<
Item
>
parentItems
=
Arrays
.
asList
(
createItem
(
"k2"
,
"v2"
));
Release
parentRelease
=
createRelease
(
"{\"k1\":\"v1\", \"k2\":\"v2\"}"
);
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
parentNamespace
)).
thenReturn
(
parentRelease
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
namespaceService
.
findParentNamespace
(
childNamespace
)).
thenReturn
(
parentNamespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
childNamespace
);
Assert
.
assertFalse
(
isModified
);
}
@Test
public
void
testParentNamespaceNotReleased
()
{
long
childNamespaceId
=
1
,
parentNamespaceId
=
2
;
Namespace
childNamespace
=
createNamespace
(
childNamespaceId
);
Namespace
parentNamespace
=
createNamespace
(
parentNamespaceId
);
Release
childRelease
=
createRelease
(
"{\"k1\":\"v3\", \"k2\":\"v2\"}"
);
List
<
Item
>
childItems
=
Arrays
.
asList
(
createItem
(
"k1"
,
"v2"
),
createItem
(
"k2"
,
"v2"
));
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
childNamespace
)).
thenReturn
(
childRelease
);
when
(
releaseService
.
findLatestActiveRelease
(
parentNamespace
)).
thenReturn
(
null
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
itemService
.
findItems
(
childNamespaceId
)).
thenReturn
(
childItems
);
when
(
itemService
.
findItems
(
parentNamespaceId
)).
thenReturn
(
parentItems
);
when
(
namespaceService
.
findParentNamespace
(
childNamespace
)).
thenReturn
(
parentNamespace
);
when
(
namespaceService
.
findParentNamespace
(
parentNamespace
)).
thenReturn
(
parentNamespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
parent
Namespace
);
boolean
isModified
=
namespaceUnlockAspect
.
isModified
(
child
Namespace
);
Assert
.
assertTrue
(
isModified
);
Assert
.
assertTrue
(
isModified
);
}
}
...
...
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