Esempio n. 1
0
        private List <BdioNode> GetBdioNodes()
        {
            BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
            BdioNodeFactory    bdioNodeFactory    = new BdioNodeFactory(bdioPropertyHelper);

            string projectGroup      = "com.blackducksoftware.gradle.test";
            string projectName       = "gradleTestProject";
            string projectVersion    = "99.5-SNAPSHOT";
            string projectExternalId = bdioPropertyHelper.CreateMavenExternalId(projectGroup, projectName, projectVersion);
            string projectBdioId     = bdioPropertyHelper.CreateBdioId(projectGroup, projectName, projectVersion);

            BdioBillOfMaterials bdioBillOfMaterials = bdioNodeFactory.CreateBillOfMaterials("", projectName, projectVersion);

            // we are overriding the default value of a new uuid just to pass the json comparison
            bdioBillOfMaterials.Id = "uuid:45772d33-5353-44f1-8681-3d8a15540646";

            BdioProject bdioProject = bdioNodeFactory.CreateProject(projectName, projectVersion, projectBdioId, "maven", projectExternalId);

            BdioComponent cxfBundle = bdioNodeFactory.CreateComponent("cxf-bundle", "2.7.7",
                                                                      bdioPropertyHelper.CreateBdioId("org.apache.cxf", "cxf-bundle", "2.7.7"),
                                                                      "maven", bdioPropertyHelper.CreateMavenExternalId("org.apache.cxf", "cxf-bundle", "2.7.7"));
            BdioComponent velocity = bdioNodeFactory.CreateComponent("velocity", "1.7",
                                                                     bdioPropertyHelper.CreateBdioId("org.apache.velocity", "velocity", "1.7"),
                                                                     "maven", bdioPropertyHelper.CreateMavenExternalId("org.apache.velocity", "velocity", "1.7"));
            BdioComponent commonsCollections = bdioNodeFactory.CreateComponent("commons-collections", "3.2.1",
                                                                               bdioPropertyHelper.CreateBdioId("commons-collections", "commons-collections", "3.2.1"),
                                                                               "maven", bdioPropertyHelper.CreateMavenExternalId("commons-collections", "commons-collections", "3.2.1"));
            BdioComponent commonsLang = bdioNodeFactory.CreateComponent("commons-lang", "2.6",
                                                                        bdioPropertyHelper.CreateBdioId("commons-lang", "commons-lang", "2.6"),
                                                                        "maven", bdioPropertyHelper.CreateMavenExternalId("commons-lang", "commons-lang", "2.6"));

            // we will now relate the constructed bdio nodes

            // first, add the cxfBundle component as a child of the project - this project has a single direct dependency
            bdioPropertyHelper.AddRelationship(bdioProject, cxfBundle);

            // now, the cxfBundle component itself has two dependencies, which will appear in the final BOM as they are
            // transitive dependencies of the project
            bdioPropertyHelper.AddRelationships(cxfBundle, new List <BdioNode> {
                velocity, commonsLang
            });

            // and the velocity component also has two dependencies - it will only add one additional entry to our final BOM
            // as the commonsLang component was already included from the cxfBundle component above
            bdioPropertyHelper.AddRelationships(velocity, new List <BdioNode> {
                commonsCollections, commonsLang
            });

            List <BdioNode> bdioNodes = new List <BdioNode>
            {
                bdioBillOfMaterials,
                bdioProject,
                cxfBundle,
                velocity,
                commonsCollections,
                commonsLang
            };

            return(bdioNodes);
        }
Esempio n. 2
0
        public void TestCodeLocationOverride()
        {
            BdioPropertyHelper  bdioPropertyHelper  = new BdioPropertyHelper();
            BdioNodeFactory     bdioNodeFactory     = new BdioNodeFactory(bdioPropertyHelper);
            BdioBillOfMaterials bdioBillOfMaterials = bdioNodeFactory.CreateBillOfMaterials("", "name", "version");

            Assert.AreEqual("name/version Black Duck I/O Export", bdioBillOfMaterials.SpdxName);

            bdioBillOfMaterials = bdioNodeFactory.CreateBillOfMaterials("override", "name", "version");
            Assert.AreEqual("override", bdioBillOfMaterials.SpdxName);
        }
 public BdioNodeFactory(BdioPropertyHelper bdioPropertyHelper)
 {
     this.BdioPropertyHelper = bdioPropertyHelper;
 }