PreDeployMojo extends AbstractDeployMojo { static String getRedirectHtmlFilename(String artifactFileName, String artifactId) { String search = "-"; int nthElement = 0; if (artifactFileName.endsWith(XCodeOtaHtmlGeneratorMojo.OTA_CLASSIFIER_APPENDIX + "." + XCodeOtaHtmlGeneratorMojo.OTA_HTML_FILE_APPENDIX)) { nthElement = 3; } else if (artifactFileName.endsWith("-AppStoreMetaData.zip")) { nthElement = 1; } else if (artifactFileName.endsWith("-app.dSYM.zip")) { nthElement = 3; } else if (artifactFileName.endsWith("-app.zip")) { nthElement = 3; } else if (artifactFileName.endsWith(".ipa")) { nthElement = 2; } else if (artifactFileName.endsWith("versions.xml")) { nthElement = 1; } else if (artifactFileName.endsWith(".pom")) { nthElement = 1; search = "."; } else if (artifactFileName.endsWith("-fat-binary.a")) { nthElement = 3; } else if (artifactFileName.endsWith(".a")) { nthElement = 2; } else if (artifactFileName.endsWith(".headers.tar")) { nthElement = 2; } else if (artifactFileName.endsWith(".tar")) { nthElement = 1; search = "."; } int idx = getNthIndexFromBack(artifactFileName, search, nthElement); if (idx >= 0) { String name = artifactId + artifactFileName.substring(idx); if (!name.endsWith(".htm")) { name = name + ".htm"; } return name; } return artifactId + "-" + artifactFileName + ".htm"; }  @Override void execute();  }
@Test public void testGetRedirectHtmlFilename_Unknown() { assertEquals("MyApp-MyApp-1.0.0-20120821.132955-1-Unknown.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1-Unknown.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_UnknownForFinalArtifact() { assertEquals("MyApp-MyApp-1.0.0-Unknown.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-Unknown.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_AppStoreMetaData() { assertEquals("MyApp-AppStoreMetaData.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1-AppStoreMetaData.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_AppStoreMetaDataForFinalArtifact() { assertEquals("MyApp-AppStoreMetaData.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-AppStoreMetaData.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_OtaHtm() { assertEquals("MyApp-Release-iphoneos-ota.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1-Release-iphoneos-ota.htm", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_OtaHtmForFinalArtifact() { assertEquals("MyApp-Release-iphoneos-ota.htm", getRedirectHtmlFilename("MyApp-1.0.0-Release-iphoneos-ota.htm", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_dSym() { assertEquals("MyApp-Release-iphoneos-app.dSYM.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1-Release-iphoneos-app.dSYM.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_dSymForFinalArtifact() { assertEquals("MyApp-Release-iphoneos-app.dSYM.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-Release-iphoneos-app.dSYM.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_appZip() { assertEquals("MyApp-Release-iphoneos-app.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1-Release-iphoneos-app.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_appZipForFinalArtifact() { assertEquals("MyApp-Release-iphoneos-app.zip.htm", getRedirectHtmlFilename("MyApp-1.0.0-Release-iphoneos-app.zip", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_Ipa() { assertEquals("MyApp-Release-iphoneos.ipa.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1-Release-iphoneos.ipa", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_IpaForFinalArtifact() { assertEquals("MyApp-Release-iphoneos.ipa.htm", getRedirectHtmlFilename("MyApp-1.0.0-Release-iphoneos.ipa", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_versionsXml() { assertEquals("MyApp-versions.xml.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1-versions.xml", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_versionsXmlForFinalArtifact() { assertEquals("MyApp-versions.xml.htm", getRedirectHtmlFilename("MyApp-1.0.0-versions.xml", "MyApp")); }
@Test public void testGetRedirectHtmlFilename_Pom() { assertEquals("MyApp.pom.htm", getRedirectHtmlFilename("MyApp-1.0.0-20120821.132955-1.pom", "MyApp")); }
@Test public void testGetRedirectHtmlFilenameForFinalArtifact_Pom() { assertEquals("MyApp.pom.htm", getRedirectHtmlFilename("MyApp-1.0.0.pom", "MyApp")); }