Skip to content

Commit

Permalink
Merge pull request #565 from lepdou/lock
Browse files Browse the repository at this point in the history
bugfix: still lock branch when master modified
  • Loading branch information
nobodyiam committed Mar 10, 2017
2 parents 573b118 + c08abef commit d327f07
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ private Map<String, String> generateConfigurationFromItems(Namespace namespace,
if (parentNamespace == null) {
generateMapFromItems(namespaceItems, configurationFromItems);
} else {//child namespace
List<Item> parentItems = itemService.findItems(parentNamespace.getId());

generateMapFromItems(parentItems, configurationFromItems);
Release parentRelease = releaseService.findLatestActiveRelease(parentNamespace);
if (parentRelease != null) {
configurationFromItems = gson.fromJson(parentRelease.getConfigurations(), GsonType.CONFIG);
}
generateMapFromItems(namespaceItems, configurationFromItems);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ public void testNamespaceDeleteItem() {
public void testChildNamespaceModified() {
long childNamespaceId = 1, parentNamespaceId = 2;
Namespace childNamespace = createNamespace(childNamespaceId);
Namespace parentNamespace = createNamespace(childNamespaceId);
Namespace parentNamespace = createNamespace(parentNamespaceId);

Release childRelease = createRelease("{\"k1\":\"v1\", \"k2\":\"v2\"}");
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(parentNamespace)).thenReturn(parentRelease);
when(itemService.findItems(childNamespaceId)).thenReturn(childItems);
when(itemService.findItems(parentNamespaceId)).thenReturn(parentItems);
when(namespaceService.findParentNamespace(parentNamespace)).thenReturn(parentNamespace);
when(namespaceService.findParentNamespace(childNamespace)).thenReturn(parentNamespace);

boolean isModified = namespaceUnlockAspect.isModified(parentNamespace);
boolean isModified = namespaceUnlockAspect.isModified(childNamespace);

Assert.assertTrue(isModified);
}
Expand All @@ -123,18 +123,37 @@ public void testChildNamespaceModified() {
public void testChildNamespaceNotModified() {
long childNamespaceId = 1, parentNamespaceId = 2;
Namespace childNamespace = createNamespace(childNamespaceId);
Namespace parentNamespace = createNamespace(childNamespaceId);
Namespace parentNamespace = createNamespace(parentNamespaceId);

Release childRelease = createRelease("{\"k1\":\"v1\", \"k2\":\"v2\"}");
List<Item> childItems = Arrays.asList(createItem("k1", "v1"));
List<Item> parentItems = Arrays.asList(createItem("k2", "v2"));
Release childRelease = createRelease("{\"k1\":\"v3\", \"k2\":\"v2\"}");
List<Item> childItems = Arrays.asList(createItem("k1", "v3"));
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(parentNamespace)).thenReturn(null);
when(itemService.findItems(childNamespaceId)).thenReturn(childItems);
when(itemService.findItems(parentNamespaceId)).thenReturn(parentItems);
when(namespaceService.findParentNamespace(parentNamespace)).thenReturn(parentNamespace);
when(namespaceService.findParentNamespace(childNamespace)).thenReturn(parentNamespace);

boolean isModified = namespaceUnlockAspect.isModified(parentNamespace);
boolean isModified = namespaceUnlockAspect.isModified(childNamespace);

Assert.assertTrue(isModified);
}
Expand Down

0 comments on commit d327f07

Please sign in to comment.