提交 c08abef5 编写于 作者: L lepdou

bugfix: still lock branch when master modified

上级 573b1183
...@@ -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);
} }
......
...@@ -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(childNamespaceId); Namespace parentNamespace = createNamespace(parentNamespaceId);
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(parentNamespace); boolean isModified = namespaceUnlockAspect.isModified(childNamespace);
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(childNamespaceId); Namespace parentNamespace = createNamespace(parentNamespaceId);
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(parentNamespace); boolean isModified = namespaceUnlockAspect.isModified(childNamespace);
Assert.assertTrue(isModified); Assert.assertTrue(isModified);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册