Exemplo n.º 1
0
        protected ChangeRequest MakeChangeRequest(String mediaType)
        {
            CREATED_CHANGE_REQUEST_URI = null;

            ChangeRequest changeRequest = new ChangeRequest();

            changeRequest.AddContributor(new Uri("http://myserver/mycmapp/users/bob"));
            changeRequest.AddCreator(new Uri("http://myserver/mycmapp/users/bob"));
            changeRequest.AddDctermsType(ChangeManagement.Type.Defect.ToString());
            changeRequest.SetDescription("Invalid installation instructions indicating invalid patches to be applied.");
            changeRequest.SetDiscussedBy(new Uri("http://example.com/bugs/2314/discussion"));
            changeRequest.SetInstanceShape(new Uri("http://example.com/shapes/defect"));
            changeRequest.AddRelatedChangeRequest(new Link(new Uri("http://myserver/mycmapp/bugs/1235"), "Bug 1235"));
            changeRequest.SetSeverity(Severity.Major.ToString());
            changeRequest.SetShortTitle("Bug 2314");
            changeRequest.SetStatus("InProgress");
            changeRequest.AddSubject("doc");
            changeRequest.AddSubject("install");
            changeRequest.SetTitle("Invalid installation instructions");
            changeRequest.AddTracksRequirement(new Link(new Uri("http://myserver/reqtool/req/34ef31af")));
            changeRequest.AddTracksRequirement(new Link(new Uri("http://remoteserver/reqrepo/project1/req456"), "Requirement 456"));

            String creation = GetCreation(mediaType, Constants.TYPE_CHANGE_REQUEST);

            OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                               creation,
                                                               mediaType);

            ChangeRequest addedChangeRequest = oslcRestClient.AddOslcResource(changeRequest);

            CREATED_CHANGE_REQUEST_URI = addedChangeRequest.GetAbout();

            return(addedChangeRequest);
        }
Exemplo n.º 2
0
        protected void TestRetrieves(String mediaType)
        {
            Assert.IsNotNull(CREATED_CHANGE_REQUEST_URI);

            String queryBase = GetQueryBase(mediaType,
                                            Constants.TYPE_CHANGE_REQUEST);

            Assert.IsNotNull(queryBase);

            OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                               queryBase,
                                                               mediaType);

            ChangeRequest[] changeRequests = oslcRestClient.GetOslcResources <ChangeRequest>();

            Assert.IsNotNull(changeRequests);
            Assert.IsTrue(changeRequests.Length > 0);

            bool found = false;

            foreach (ChangeRequest changeRequest in changeRequests)
            {
                VerifyChangeRequest(mediaType,
                                    changeRequest,
                                    true);

                if (CREATED_CHANGE_REQUEST_URI.Equals(changeRequest.GetAbout()))
                {
                    found = true;
                }
            }

            Assert.IsTrue(found);
        }
Exemplo n.º 3
0
        protected void TestRetrieve(String mediaType)
        {
            Assert.IsNotNull(CREATED_CHANGE_REQUEST_URI);

            OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                               CREATED_CHANGE_REQUEST_URI,
                                                               mediaType);

            ChangeRequest changeRequest = oslcRestClient.GetOslcResource <ChangeRequest>();

            VerifyChangeRequest(mediaType,
                                changeRequest,
                                true);
        }
Exemplo n.º 4
0
        protected void TestCompact(String compactMediaType,
                                   String normalMediaType)
        {
            Assert.IsNotNull(CREATED_CHANGE_REQUEST_URI);

            OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                               CREATED_CHANGE_REQUEST_URI,
                                                               compactMediaType);

            Compact compact = oslcRestClient.GetOslcResource <Compact>();

            VerifyCompact(normalMediaType,
                          compact);
        }
Exemplo n.º 5
0
        protected void TestDelete(String mediaType)
        {
            OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                               CREATED_CHANGE_REQUEST_URI,
                                                               mediaType);

            Assert.IsNotNull(CREATED_CHANGE_REQUEST_URI);

            HttpResponseMessage clientResponse = DeleteChangeRequest(mediaType);

            Assert.IsNotNull(clientResponse);
            Assert.AreEqual(HttpStatusCode.NoContent, clientResponse.StatusCode);

            Assert.IsNull(oslcRestClient.GetOslcResource <ChangeRequest>());
        }
Exemplo n.º 6
0
        private static void VerifyChangeRequest(String mediaType,
                                                ChangeRequest changeRequest,
                                                bool recurse)
        {
            Assert.IsNotNull(changeRequest);

            Uri      aboutURI         = changeRequest.GetAbout();
            DateTime?createdDate      = changeRequest.GetCreated();
            String   identifierString = changeRequest.GetIdentifier();
            DateTime?modifiedDate     = changeRequest.GetModified();

            Uri[] rdfTypesURIs       = changeRequest.GetRdfTypes();
            Uri   serviceProviderURI = changeRequest.GetServiceProvider();

            Assert.IsNotNull(aboutURI);
            Assert.IsNotNull(createdDate);
            Assert.IsNotNull(identifierString);
            Assert.IsNotNull(modifiedDate);
            Assert.IsNotNull(rdfTypesURIs);
            Assert.IsNotNull(serviceProviderURI);

            Assert.IsTrue(aboutURI.ToString().EndsWith(identifierString));
            Assert.IsTrue(modifiedDate.Equals(createdDate) || modifiedDate > createdDate);
            Assert.IsTrue(rdfTypesURIs.Contains(new Uri(Constants.TYPE_CHANGE_REQUEST)));

            if (recurse)
            {
                OslcRestClient aboutOSLCRestClient = new OslcRestClient(FORMATTERS,
                                                                        aboutURI,
                                                                        mediaType);

                VerifyChangeRequest(mediaType,
                                    aboutOSLCRestClient.GetOslcResource <ChangeRequest>(),
                                    false);

                OslcRestClient serviceProviderOSLCRestClient = new OslcRestClient(FORMATTERS,
                                                                                  serviceProviderURI,
                                                                                  mediaType);

                ServiceProvider serviceProvider = serviceProviderOSLCRestClient.GetOslcResource <ServiceProvider>();

                Assert.IsNotNull(serviceProvider);
            }
        }
Exemplo n.º 7
0
        protected HttpResponseMessage DeleteChangeRequest(String mediaType)
        {
            try
            {
                OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                                   CREATED_CHANGE_REQUEST_URI,
                                                                   mediaType);

                return(oslcRestClient.RemoveOslcResourceReturnClientResponse());
            }
            catch (Exception)
            {
                return(null);
            }
            finally
            {
                CREATED_CHANGE_REQUEST_URI = null;
            }
        }
        public static void VerifyVariantSet(String mediaType, VariantSet thisV, bool recurse)
        {
            Assert.IsNotNull(thisV);

            Uri      aboutURI    = thisV.GetAbout();
            DateTime?createdDate = thisV.GetCreated();

            Variant[] variants         = thisV.GetVariants();
            String    identifierString = thisV.GetIdentifier();
            String    titleString      = thisV.GetTitle();

            Uri[] rdfTypesURIs       = thisV.GetRdfTypes();
            Uri   serviceProviderURI = thisV.GetServiceProvider();

            Assert.IsNotNull(aboutURI);
            Assert.IsNotNull(createdDate);
            Assert.IsNotNull(variants);
            Assert.IsNotNull(titleString);
            Assert.IsNotNull(rdfTypesURIs);
            Assert.IsNotNull(serviceProviderURI);

            Assert.IsTrue(aboutURI.ToString().EndsWith(identifierString));
            Assert.IsTrue(rdfTypesURIs.Contains(new Uri(OSLC_ARVIDA.Constants.Scene.TYPE_SCENE_VARIANT_SET)));

            if (recurse)
            {
                OslcRestClient aboutOSLCRestClient = new OslcRestClient(FORMATTERS,
                                                                        aboutURI,
                                                                        mediaType);

                VerifyVariantSet(mediaType,
                                 aboutOSLCRestClient.GetOslcResource <VariantSet>(),
                                 false);

                OslcRestClient serviceProviderOSLCRestClient = new OslcRestClient(FORMATTERS,
                                                                                  serviceProviderURI,
                                                                                  mediaType);

                ServiceProvider serviceProvider = serviceProviderOSLCRestClient.GetOslcResource <ServiceProvider>();

                Assert.IsNotNull(serviceProvider);
            }
        }
Exemplo n.º 9
0
        private static ResourceShape GetResourceShape(String mediaType,
                                                      String type)
        {
            ServiceProvider[] serviceProviders = new ServiceProviderRegistryClient(FORMATTERS, mediaType).GetServiceProviders();

            foreach (ServiceProvider serviceProvider in serviceProviders)
            {
                Service[] services = serviceProvider.GetServices();

                foreach (Service service in services)
                {
                    if (Constants.CHANGE_MANAGEMENT_DOMAIN.Equals(service.GetDomain().ToString()))
                    {
                        QueryCapability[] queryCapabilities = service.GetQueryCapabilities();

                        foreach (QueryCapability queryCapability in queryCapabilities)
                        {
                            Uri[] resourceTypes = queryCapability.GetResourceTypes();

                            foreach (Uri resourceType in resourceTypes)
                            {
                                if (resourceType.ToString().Equals(type))
                                {
                                    Uri resourceShape = queryCapability.GetResourceShape();

                                    if (resourceShape != null)
                                    {
                                        OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                                                           resourceShape,
                                                                                           mediaType);

                                        return(oslcRestClient.GetOslcResource <ResourceShape>());
                                    }
                                }
                            }
                        }
                    }
                }
            }

            throw new AssertFailedException("Unable to retrieve resource shape for type '" + type + "'");
        }
Exemplo n.º 10
0
        private static void VerifyCompact(String mediaType,
                                          Compact compact)
        {
            Assert.IsNotNull(compact);

            Uri    aboutURI         = compact.GetAbout();
            String shortTitleString = compact.GetShortTitle();
            String titleString      = compact.GetTitle();

            Assert.IsNotNull(aboutURI);
            Assert.IsNotNull(shortTitleString);
            Assert.IsNotNull(titleString);

            OslcRestClient aboutOSLCRestClient = new OslcRestClient(FORMATTERS,
                                                                    aboutURI,
                                                                    mediaType);

            VerifyChangeRequest(mediaType,
                                aboutOSLCRestClient.GetOslcResource <ChangeRequest>(),
                                false);
        }
 private static ResourceShape GetResourceShapes(String mediaType, String type, Service service)
 {
     QueryCapability[] queryCapabilities = service.GetQueryCapabilities();
     foreach (QueryCapability queryCapability in queryCapabilities)
     {
         Uri[] resourceTypes = queryCapability.GetResourceTypes();
         foreach (Uri resourceType in resourceTypes)
         {
             if (resourceType.ToString().Equals(type))
             {
                 Uri resourceShape = queryCapability.GetResourceShape();
                 if (resourceShape != null)
                 {
                     OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS, resourceShape, mediaType);
                     return(oslcRestClient.GetOslcResource <ResourceShape>());
                 }
             }
         }
     }
     throw new AssertFailedException("Unable to retrieve resource shape for type '" + type + "'");
 }
Exemplo n.º 12
0
        protected void TestUpdate(String mediaType)
        {
            Assert.IsNotNull(CREATED_CHANGE_REQUEST_URI);

            OslcRestClient oslcRestClient = new OslcRestClient(FORMATTERS,
                                                               CREATED_CHANGE_REQUEST_URI,
                                                               mediaType);

            ChangeRequest changeRequest = oslcRestClient.GetOslcResource <ChangeRequest>();

            VerifyChangeRequest(mediaType,
                                changeRequest,
                                true);

            Assert.IsNull(changeRequest.IsApproved());
            Assert.IsNull(changeRequest.GetCloseDate());

            DateTime closeDate = DateTime.Now;

            changeRequest.SetApproved(true);
            changeRequest.SetCloseDate(closeDate);

            HttpResponseMessage clientResponse = oslcRestClient.UpdateOslcResourceReturnClientResponse(changeRequest);

            Assert.IsNotNull(clientResponse);
            Assert.AreEqual(HttpStatusCode.OK, clientResponse.StatusCode);

            ChangeRequest updatedChangeRequest = oslcRestClient.GetOslcResource <ChangeRequest>();

            VerifyChangeRequest(mediaType,
                                updatedChangeRequest,
                                true);

            Assert.AreEqual(changeRequest.GetAbout(), updatedChangeRequest.GetAbout());
            Assert.AreEqual(true, updatedChangeRequest.IsApproved());
            Assert.AreEqual(closeDate.ToShortDateString() + " - " + closeDate.ToShortTimeString(),
                            updatedChangeRequest.GetCloseDate().Value.ToShortDateString() + " - " + updatedChangeRequest.GetCloseDate().Value.ToShortTimeString());
            Assert.IsFalse(changeRequest.GetModified().Equals(updatedChangeRequest.GetModified()));
            Assert.IsTrue(updatedChangeRequest.GetModified() > updatedChangeRequest.GetCreated());
        }