41
41
import org .jboss .pnc .dto .BuildConfigurationRevisionRef ;
42
42
import org .jboss .pnc .dto .BuildRef ;
43
43
import org .jboss .pnc .dto .User ;
44
- import org .jboss .pnc .dto .requests .BuildPushParameters ;
44
+ import org .jboss .pnc .dto .response .Edge ;
45
+ import org .jboss .pnc .dto .response .Graph ;
45
46
import org .jboss .pnc .enums .ArtifactQuality ;
46
47
import org .jboss .pnc .enums .BuildCategory ;
47
48
import org .jboss .pnc .enums .BuildStatus ;
102
103
public class BuildEndpointTest {
103
104
104
105
private static final Logger logger = LoggerFactory .getLogger (BuildEndpointTest .class );
105
- private static String buildId ;
106
- private static String build2Id ;
107
- private static String build3Id ;
106
+ private static String buildId ; // buildRecord1
107
+ private static String build2Id ; // tempRecord1
108
+ private static String build3Id ; // buildRecord2
109
+ private static String build5Id ; // buildRecord3
110
+ private static String build6Id ; // buildRecord4
108
111
109
112
@ Deployment
110
113
public static EnterpriseArchive deploy () {
@@ -126,6 +129,9 @@ public static void prepareData() throws Exception {
126
129
buildId = it .next ().getId ();
127
130
build2Id = it .next ().getId ();
128
131
build3Id = it .next ().getId ();
132
+ it .next ().getId ();
133
+ build5Id = it .next ().getId ();
134
+ build6Id = it .next ().getId ();
129
135
}
130
136
131
137
@ Test
@@ -736,6 +742,51 @@ public void shouldReportLeafTempBuildThatDependsOnItself() throws RemoteResource
736
742
assertThat (attributes ).containsEntry (org .jboss .pnc .api .constants .Attributes .BUILD_BREW_VERSION , "1.2.4" );
737
743
}
738
744
745
+ @ Test
746
+ @ InSequence (1 )
747
+ public void testGetBuildArtifactDependencyGraph () throws ClientException {
748
+ // arrange
749
+ BuildClient client = new BuildClient (RestClientConfiguration .asAnonymous ());
750
+
751
+ Set <String > expectedVerticesKeys = Set .of (build6Id , buildId , build2Id , build5Id );
752
+ List <Edge <Build >> expectedEdges = List .of (
753
+ Edge .<Build > builder ().source (build6Id ).target (buildId ).cost (1 ).build (), // importedArtifact1 (set to be
754
+ // part of buildId Build in
755
+ // shouldSetBuiltArtifacts)
756
+ Edge .<Build > builder ().source (buildId ).target (build2Id ).cost (1 ).build (), // builtArtifact3 (set as a
757
+ // dependency of buildId Build
758
+ // in
759
+ // shouldSetDependentArtifacts)
760
+ Edge .<Build > builder ().source (build6Id ).target (build5Id ).cost (1 ).build ()); // builtArtifact10
761
+
762
+ // act
763
+ Graph <Build > actualGraph = client .getBuildArtifactDependencyGraph (build6Id , null );
764
+
765
+ // assert
766
+ assertThat (actualGraph .getVertices ().keySet ()).containsExactlyInAnyOrderElementsOf (expectedVerticesKeys );
767
+ assertThat (actualGraph .getEdges ()).containsExactlyInAnyOrderElementsOf (expectedEdges );
768
+ }
769
+
770
+ @ Test
771
+ @ InSequence (2 )
772
+ public void testGetBuildArtifactDependencyGraphWithDependants () throws ClientException {
773
+ // arrange
774
+ BuildClient client = new BuildClient (RestClientConfiguration .asAnonymous ());
775
+
776
+ Set <String > expectedVerticesKeys = Set .of (build6Id , buildId , build2Id , build3Id );
777
+ List <Edge <Build >> expectedEdges = List .of (
778
+ Edge .<Build > builder ().source (build6Id ).target (buildId ).cost (1 ).build (), // importedArtifact1
779
+ Edge .<Build > builder ().source (build3Id ).target (buildId ).cost (1 ).build (), // importedArtifact1
780
+ Edge .<Build > builder ().source (buildId ).target (build2Id ).cost (1 ).build ()); // builtArtifact3
781
+
782
+ // act
783
+ Graph <Build > actualGraph = client .getBuildArtifactDependencyGraph (buildId , null );
784
+
785
+ // assert
786
+ assertThat (actualGraph .getVertices ().keySet ()).containsExactlyInAnyOrderElementsOf (expectedVerticesKeys );
787
+ assertThat (actualGraph .getEdges ()).containsExactlyInAnyOrderElementsOf (expectedEdges );
788
+ }
789
+
739
790
private Set <Integer > artifactIds (RemoteCollection <Artifact > artifacts ) {
740
791
Set <Integer > artifactIds = new HashSet <>();
741
792
for (Artifact a : artifacts ) {
0 commit comments