void TestDominoDocArtifact::TestCreateRelatedDocumentWithTmpFileName() { DomDocHelper dominoDocument(TEST_ARTIFACT_FILE); DominoDocArtifact artifact(m_spLibrary, dominoDocument.DocumentId, dominoDocument.GetVersionLabel()); std::wstring tempFile = _bstr_t(CTempFileManager::GetTempFileName().c_str()); std::wstring extension = PathFindExtensionW(tempFile.c_str()); std::wstring w3TempFile = tempFile.substr(0, tempFile.length() - extension.length()); w3TempFile.append(L".W3"); rename(bstr_t(tempFile.c_str()), bstr_t(w3TempFile.c_str())); std::tofstream outFile(w3TempFile.c_str()); outFile << _T("Some junk") << std::endl; outFile.close(); Artifact relatedArtifact = artifact.CreateRelatedItem(w3TempFile, L"W3", L"", false); DominoDocManager manager; manager.SetDocumentToDelete(relatedArtifact); CTempFileManager::DeleteTempFileName(w3TempFile); std::wstring dominoFileName = GetDominoDocumentFileName(relatedArtifact, m_spLibrary); extension = PathFindExtensionW(dominoFileName.c_str()); dominoFileName = dominoFileName.substr(0, dominoFileName.length() - extension.length()); assertEqualsNoCase(_T(".W3"), bstr_t(extension.c_str())); assertEquals(artifact.Name, dominoFileName); assertEquals(artifact.Name + L".W3", relatedArtifact.Name); }
void TestComArtifact::TestCreateNewVersion() { extern bool g_bCalledCreateNewVersion; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); Artifact newVersion = artifact.CreateNewVersion(L"Boo", L"formats"); assertMessage(g_bCalledCreateNewVersion, _T("Expected MockArtifact::CreateNewVersion to be called from ComArtifact::CreateNewVersion")); }
void TestComArtifact::TestDownload() { extern bool g_bCalledArtifact_Download; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); artifact.Download(); assertMessage(g_bCalledArtifact_Download, _T("Expected MockArtifact::Download to be called from ComArtifact::DownLoad")); }
void TestDominoDocArtifact::TestCreateRelatedDocumentWithNulls() { DomDocHelper dominoDocument(TEST_ARTIFACT_FILE); DominoDocArtifact artifact(m_spLibrary, dominoDocument.DocumentId, dominoDocument.GetVersionLabel()); std::wstring fileToRelate(TEST_ARTIFACT_FILE_NOEXT); assertThrows(artifact.CreateRelatedItem(fileToRelate, L"", L"", false), Workshare::ArgumentException); assertThrows(artifact.CreateRelatedItem(L"", L"W3", L"", false), Workshare::ArgumentException); }
void TestComArtifact::TestFileSize() { extern bool g_bCalledArtifact_GetFileSize; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); artifact.GetFileSize(); assertMessage(g_bCalledArtifact_GetFileSize, _T("Expected MockArtifact::get_FileSize to be called from ComArtifact::GetFileSize")); }
void TestComArtifact::TestUnlock() { extern bool g_bCalledArtifact_Unlock; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); artifact.Unlock(); assertMessage(g_bCalledArtifact_Unlock, _T("Expected MockArtifact::Unlock to be called from ComArtifact::Unlock")); }
void TestComArtifact::TestVersionLabel() { extern bool g_bCalledArtifact_GetVersionLabel; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); artifact.GetVersionLabel(); assertMessage(g_bCalledArtifact_GetVersionLabel, _T("Expected MockArtifact::get_VersionLabel to be called from ComArtifact::GetVersionLabel")); }
void TestComArtifact::TestUpload() { extern bool g_bCalledArtifact_Upload; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); artifact.Upload(L"P:/MyFileDoesn'tExist.txt"); assertMessage(g_bCalledArtifact_Upload, _T("Expected MockArtifact::Upload to be called from ComArtifact::Upload")); }
void TestComArtifact::TestClose() { extern bool g_bCalledArtifact_Close; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); artifact.Close(); assertMessage(g_bCalledArtifact_Close, _T("Expected MockArtifact::Close to be called from ComArtifact::Close")); }
void TestComArtifact::TestLaunch() { extern bool g_bCalledArtifact_Launch; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); artifact.Launch(); assertMessage(g_bCalledArtifact_Launch, _T("Expected MockArtifact::Launch to be called from ComArtifact::Launch")); }
void TestComArtifact::TestCreateRelatedItem() { extern bool g_bCalledArtifact_CreateRelatedItem; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); Artifact bridge = artifact.CreateRelatedItem(L"", L"", L"", false); assertTypeOf(bridge.GetImplementor(), const ComArtifact*); assertMessage(g_bCalledArtifact_CreateRelatedItem, _T("Expected MockArtifact::CreateRelatedArtifact to be called from ComArtifact::CreateRelatedArtifact")); }
void TestComArtifact::TestGetRelatedArtifacts() { extern bool g_bCalledArtifact_GetRelatedArtifacts; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); // The next line will throw bad_cast exception if GetVersions fails to return ComArtifacts. dynamic_cast<ComArtifacts&>(artifact.GetRelatedArtifacts()); assertMessage(g_bCalledArtifact_GetRelatedArtifacts, _T("Expected MockArtifact::get_RelatedArtifacts to be called from ComArtifact::GetRelatedArtifacts")); }
void TestComArtifact::TestGetLockStatus() { extern bool g_bCalledArtifact_GetLockStatus; _ArtifactPtr spArtifact = CreateMockArtifact(L"mock://123/123"); ComArtifact artifact(spArtifact); std::wstring lockedBy; artifact.GetLockStatus(lockedBy); assertMessage(g_bCalledArtifact_GetLockStatus, _T("Expected MockArtifact::GetLockStatus to be called from ComArtifact::GetLockStatus")); }
void TestDominoDocArtifact::TestCreateNewVersion() { DomDocHelper testDominoDocument(TEST_ARTIFACT_FILE); DominoDocArtifact artifact(m_spLibrary, testDominoDocument.DocumentId, testDominoDocument.GetVersionLabel()); long originalVersionCount = artifact.GetVersions().Count; std::wstring originalVersion = artifact.VersionLabel; Artifact newVersion = artifact.CreateNewVersion(L"This version was created by TestDominoDocArtifact::TestCreateNewVersion().", L"formats"); assertMessage(!newVersion.IsNull(), _T("Expect a non-null artifact representing the new version.")); assertMessage((originalVersionCount + 1) == artifact.GetVersions().Count, _T("Creating a new version should increase the version count by one.")); assertMessage(0 != newVersion.VersionLabel.compare(originalVersion), _T("The new artifact has the same version label as the original artifact.")); }
void TestDominoDocArtifact::TestCreateRelatedDocumentWithoutExtension() { DomDocHelper dominoDocument(TEST_ARTIFACT_FILE); DominoDocArtifact artifact(m_spLibrary, dominoDocument.DocumentId, dominoDocument.GetVersionLabel()); std::wstring fileToRelate(TEST_ARTIFACT_FILE_NOEXT); Artifact relatedArtifact = artifact.CreateRelatedItem(fileToRelate, L"W3", L"formats", false); DominoDocManager manager; manager.SetDocumentToDelete(relatedArtifact); assertEqualsNoCase(_T("W3"), bstr_t(relatedArtifact.FileExtension.c_str())); assertEquals(artifact.Name + L".W3", relatedArtifact.Name); }
void UmlClass::uml2java(bool rec) { if (isJavaExternal()) set_JavaDecl(JavaSettings::externalClassDecl()); else { QCString st = JavaSettings::classStereotype(stereotype()); UmlItem * pack = parent()->parent(); while (pack->kind() != aPackage) pack = pack->parent(); if ((st == "stereotype") || (st == "metaclass") || (pack->stereotype() == "profile")) { set_CppDecl(""); return; } if (st == "enum_pattern") set_JavaDecl(JavaSettings::enumPatternDecl()); else if (st == "enum") set_JavaDecl(JavaSettings::enumDecl()); else if (st == "interface") set_JavaDecl(JavaSettings::interfaceDecl()); else if (st == "@interface") { QCString s = JavaSettings::interfaceDecl(); int index = s.find("interface"); if (index != -1) s.insert(index, '@'); set_JavaDecl(s); } else if (st == "ignored") { set_JavaDecl(""); return; } else set_JavaDecl(JavaSettings::classDecl()); if (rec) { const QVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->uml2java(rec); } if (parent()->kind() == aClassView) // not nested artifact()->set_JavaSource(JavaSettings::sourceContent()); } }
void UmlClass::uml2idl(bool rec) { if (isIdlExternal()) set_IdlDecl(IdlSettings::externalClassDecl()); else { QCString st = IdlSettings::classStereotype(stereotype()); UmlItem * pack = parent()->parent(); while (pack->kind() != aPackage) pack = pack->parent(); if ((st == "stereotype") || (st == "metaclass") || (pack->stereotype() == "profile")) { set_CppDecl(""); return; } if (st == "struct") set_IdlDecl(IdlSettings::structDecl()); else if (st == "union") set_IdlDecl(IdlSettings::unionDecl()); else if (st == "enum") set_IdlDecl(IdlSettings::enumDecl()); else if (st == "exception") set_IdlDecl(IdlSettings::exceptionDecl()); else if (st == "typedef") set_IdlDecl(IdlSettings::typedefDecl()); else if (st == "interface") set_IdlDecl(IdlSettings::interfaceDecl()); else if (st == "ignored") { set_IdlDecl(""); return; } else set_IdlDecl(IdlSettings::valuetypeDecl()); if (rec) { const QVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->uml2idl(rec); } if (parent()->kind() == aClassView) // not nested artifact()->set_IdlSource(IdlSettings::sourceContent()); } }
void UmlClass::uml2cpp(bool rec) { if (isCppExternal()) set_CppDecl(CppSettings::externalClassDecl()); else { QCString st = CppSettings::classStereotype(stereotype()); UmlItem * pack = parent()->parent(); while (pack->kind() != aPackage) pack = pack->parent(); if ((st == "stereotype") || (st == "metaclass") || (pack->stereotype() == "profile")) { set_CppDecl(""); return; } if (st == "enum") set_CppDecl(CppSettings::enumDecl()); else if (st == "union") set_CppDecl(CppSettings::unionDecl()); else if (st == "struct") set_CppDecl(CppSettings::structDecl()); else if (st == "typedef") set_CppDecl(CppSettings::typedefDecl()); else if (st == "ignored") { set_CppDecl(""); return; } else set_CppDecl(CppSettings::classDecl()); if (rec) { const QVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->uml2cpp(rec); } if (parent()->kind() == aClassView) { // not nested UmlArtifact * art = artifact(); art->set_CppSource(CppSettings::sourceContent()); art->set_CppHeader(CppSettings::headerContent()); } } }
void UmlClass::uml2php(bool rec) { if (isPhpExternal()) set_PhpDecl(PhpSettings::externalClassDecl()); else { QCString st = PhpSettings::classStereotype(stereotype()); UmlItem * pack = parent()->parent(); while (pack->kind() != aPackage) pack = pack->parent(); if ((st == "stereotype") || (st == "metaclass") || (pack->stereotype() == "profile")) { set_CppDecl(""); return; } if (st == "enum") set_PhpDecl(PhpSettings::enumDecl()); else if (st == "interface") set_PhpDecl(PhpSettings::interfaceDecl()); else if (st == "ignored") { set_PhpDecl(""); return; } else set_PhpDecl(PhpSettings::classDecl()); if (rec) { const QVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->uml2php(rec); } if (parent()->kind() == aClassView) // not nested artifact()->set_PhpSource(PhpSettings::sourceContent()); } }
Artifact DominoDocArtifacts::AddArtifact(const std::wstring& id, const std::wstring& versionLabel, IDispatchPtr spLibrary) { Artifact artifact(new DominoDocArtifact(spLibrary, id, versionLabel)); m_artifacts.push_back(artifact); return artifact; }