Beispiel #1
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());
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
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>());
        }
Beispiel #5
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);
            }
        }
        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);
            }
        }
Beispiel #7
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 + "'");
        }
Beispiel #8
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 + "'");
 }