You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2017/11/14 21:32:34 UTC
[6/6] nifi-registry git commit: NIFIREG-53 Populating Bucket and
VersionedFlow on creation of VersionedFlowSnapshot. This closes #38.
NIFIREG-53 Populating Bucket and VersionedFlow on creation of VersionedFlowSnapshot. This closes #38.
Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/3deda91c
Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/3deda91c
Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/3deda91c
Branch: refs/heads/master
Commit: 3deda91c997ecf9154079abaeef691c4bd090ff4
Parents: fc4050d
Author: Bryan Bende <bb...@apache.org>
Authored: Tue Nov 14 16:05:14 2017 -0500
Committer: Mark Payne <ma...@hotmail.com>
Committed: Tue Nov 14 16:32:16 2017 -0500
----------------------------------------------------------------------
.../org/apache/nifi/registry/service/RegistryService.java | 6 ++++--
.../apache/nifi/registry/service/TestRegistryService.java | 10 ++++++----
.../java/org/apache/nifi/registry/web/api/FlowsIT.java | 4 ++++
3 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3deda91c/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
index 7d44b9a..d0802de 100644
--- a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
+++ b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/RegistryService.java
@@ -487,8 +487,8 @@ public class RegistryService {
throw new ResourceNotFoundException("Bucket does not exist for identifier: " + snapshotMetadata.getBucketIdentifier());
}
- // ensure the flow exists
- final FlowEntity existingFlow = metadataService.getFlowById(snapshotMetadata.getBucketIdentifier(), snapshotMetadata.getFlowIdentifier());
+ // ensure the flow exists, we need to use "with counts" here so we can return this is a part of the response
+ final FlowEntity existingFlow = metadataService.getFlowByIdWithSnapshotCounts(snapshotMetadata.getBucketIdentifier(), snapshotMetadata.getFlowIdentifier());
if (existingFlow == null) {
throw new ResourceNotFoundException("VersionedFlow does not exist for identifier: " + snapshotMetadata.getFlowIdentifier());
}
@@ -533,6 +533,8 @@ public class RegistryService {
existingFlow.setModified(new Date());
metadataService.updateFlow(existingFlow);
+ flowSnapshot.setBucket(bucket);
+ flowSnapshot.setFlow(versionedFlow);
return flowSnapshot;
} finally {
writeLock.unlock();
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3deda91c/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java
index a0828af..31b921c 100644
--- a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestRegistryService.java
@@ -669,7 +669,7 @@ public class TestRegistryService {
existingFlow.setSnapshots(Collections.singleton(existingSnapshot));
- when(metadataService.getFlowById(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
+ when(metadataService.getFlowByIdWithSnapshotCounts(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
registryService.createFlowSnapshot(snapshot);
}
@@ -708,7 +708,7 @@ public class TestRegistryService {
existingFlow.setSnapshots(Collections.singleton(existingSnapshot));
- when(metadataService.getFlowById(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
+ when(metadataService.getFlowByIdWithSnapshotCounts(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
// set the version to something that is not the next one-up version
snapshot.getSnapshotMetadata().setVersion(100);
@@ -736,11 +736,13 @@ public class TestRegistryService {
existingFlow.setModified(new Date());
existingFlow.setBucket(existingBucket);
- when(metadataService.getFlowById(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
+ when(metadataService.getFlowByIdWithSnapshotCounts(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
final VersionedFlowSnapshot createdSnapshot = registryService.createFlowSnapshot(snapshot);
assertNotNull(createdSnapshot);
assertNotNull(createdSnapshot.getSnapshotMetadata());
+ assertNotNull(createdSnapshot.getFlow());
+ assertNotNull(createdSnapshot.getBucket());
verify(snapshotSerializer, times(1)).serialize(eq(snapshot.getFlowContents()), any(OutputStream.class));
verify(flowPersistenceProvider, times(1)).saveFlowContent(any(), any());
@@ -768,7 +770,7 @@ public class TestRegistryService {
existingFlow.setModified(new Date());
existingFlow.setBucket(existingBucket);
- when(metadataService.getFlowById(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
+ when(metadataService.getFlowByIdWithSnapshotCounts(existingBucket.getId(), existingFlow.getId())).thenReturn(existingFlow);
// set the first version to something other than 1
snapshot.getSnapshotMetadata().setVersion(100);
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/3deda91c/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java
----------------------------------------------------------------------
diff --git a/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java b/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java
index 58959b7..427bef9 100644
--- a/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java
+++ b/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java
@@ -349,6 +349,8 @@ public class FlowsIT extends UnsecuredITBase {
assertEquals("anonymous", createdFlowSnapshot.getSnapshotMetadata().getAuthor());
assertNotNull(createdFlowSnapshot.getSnapshotMetadata().getLink());
assertNotNull(createdFlowSnapshot.getSnapshotMetadata().getLink().getUri());
+ assertNotNull(createdFlowSnapshot.getFlow());
+ assertNotNull(createdFlowSnapshot.getBucket());
// And when .../flows/{id}/versions is queried, then the newly created flow snapshot is returned in the list
@@ -372,6 +374,8 @@ public class FlowsIT extends UnsecuredITBase {
final VersionedFlowSnapshot flowSnapshotByVersionNumber = clientRequestTarget.path("/1").request().get(VersionedFlowSnapshot.class);
assertFlowSnapshotsEqual(createdFlowSnapshot, flowSnapshotByVersionNumber, true);
+ assertNotNull(flowSnapshotByVersionNumber.getFlow());
+ assertNotNull(flowSnapshotByVersionNumber.getBucket());
// And when the latest URI is queried, then the newly created flow snapshot is returned