1*090ab8e1SEd Tanous #include "file_test_utilities.hpp" 2*090ab8e1SEd Tanous #include "metadata.hpp" 3*090ab8e1SEd Tanous 4*090ab8e1SEd Tanous #include <string> 5*090ab8e1SEd Tanous 6*090ab8e1SEd Tanous #include <gmock/gmock.h> 7*090ab8e1SEd Tanous #include <gtest/gtest.h> 8*090ab8e1SEd Tanous 9*090ab8e1SEd Tanous namespace redfish 10*090ab8e1SEd Tanous { 11*090ab8e1SEd Tanous namespace 12*090ab8e1SEd Tanous { 13*090ab8e1SEd Tanous 14*090ab8e1SEd Tanous /* 15*090ab8e1SEd Tanous Example from Redfish and OData whitepaper. 16*090ab8e1SEd Tanous 17*090ab8e1SEd Tanous https://www.dmtf.org/sites/default/files/standards/documents/DSP2052_1.0.0.pdf 18*090ab8e1SEd Tanous */ 19*090ab8e1SEd Tanous constexpr std::string_view content = 20*090ab8e1SEd Tanous "<edmx:Edmx xmlns:edms=\"http://docs.oasis-open.org/odata/ns/edmx\" Version=\"4.0\">\n" 21*090ab8e1SEd Tanous " <edmx:Reference Uri=\"http://contoso.org/schemas/ExternalSchema.xml\">\n" 22*090ab8e1SEd Tanous " <edmx:Include Namespace=\"ExternalNamespace\"/>\n" 23*090ab8e1SEd Tanous " <edmx:Include Namespace=\"Other.Namespace\"/>\n" 24*090ab8e1SEd Tanous " </edmx:Reference>\n" 25*090ab8e1SEd Tanous " <edmx:DataServices>\n" 26*090ab8e1SEd Tanous " <Schema xmlns=\"http://docs.oasis-open.org/odata/ns/edm\" Namespace=\"MyNewNamespace\">\n" 27*090ab8e1SEd Tanous " <ComplexType Name=\"MyDataType\">\n" 28*090ab8e1SEd Tanous " <Property Name=\"MyProperty\" Type=\"ExternalNamespace.ReferencedDataType\"/>\n" 29*090ab8e1SEd Tanous " <Property Name=\"MyProperty2\" Type=\"Other.Namespace.OtherDataType\"/>\n" 30*090ab8e1SEd Tanous " <Property Name=\"MyProperty3\" Type=\"Edm.Int64\"/>\n" 31*090ab8e1SEd Tanous " </ComplexType>\n" 32*090ab8e1SEd Tanous " </Schema>\n" 33*090ab8e1SEd Tanous " </edmx:DataServices>\n" 34*090ab8e1SEd Tanous "</edmx:Edmx>\n"; 35*090ab8e1SEd Tanous TEST(MetadataGet,GetOneFile)36*090ab8e1SEd TanousTEST(MetadataGet, GetOneFile) 37*090ab8e1SEd Tanous { 38*090ab8e1SEd Tanous TemporaryFileHandle file(content); 39*090ab8e1SEd Tanous 40*090ab8e1SEd Tanous std::filesystem::path path{file.stringPath}; 41*090ab8e1SEd Tanous EXPECT_EQ( 42*090ab8e1SEd Tanous getMetadataPieceForFile(path), 43*090ab8e1SEd Tanous std::format(" <edmx:Reference Uri=\"/redfish/v1/schema/{}\">\n" 44*090ab8e1SEd Tanous " <edmx:Include Namespace=\"MyNewNamespace\"/>\n" 45*090ab8e1SEd Tanous " </edmx:Reference>\n", 46*090ab8e1SEd Tanous path.filename().string())); 47*090ab8e1SEd Tanous 48*090ab8e1SEd Tanous EXPECT_EQ(getMetadataPieceForFile("DoesNotExist_v1.xml"), ""); 49*090ab8e1SEd Tanous } 50*090ab8e1SEd Tanous 51*090ab8e1SEd Tanous } // namespace 52*090ab8e1SEd Tanous } // namespace redfish 53