@CheckForNull private static String removeNewLineCharacters(@Nullable String text) { String removedCRLF = StringUtils.remove(text, "\n"); removedCRLF = StringUtils.remove(removedCRLF, "\r"); removedCRLF = StringUtils.remove(removedCRLF, "\n\r"); removedCRLF = StringUtils.remove(removedCRLF, "\r\n"); return removedCRLF; }
@Override public String getName() { final Class c = category.getClass(); final Symbol symbol = (Symbol) c.getAnnotation(Symbol.class); if (symbol != null) return symbol.value()[0]; String name = c.getSimpleName(); name = StringUtils.remove(name, "Global"); name = StringUtils.remove(name, "Configuration"); name = StringUtils.remove(name, "Category"); return name.toLowerCase(); }
/** * Removes all <code>extensions</code> from <code>path</code> if they exist. * * <pre> * PathUtils.removeExtention("file.txt", ".txt") = file * PathUtils.removeExtention("file.txt.gpg", ".txt", ".gpg") = file * PathUtils.removeExtention("file", ".txt") = file * PathUtils.removeExtention("file.txt", ".tar.gz") = file.txt * PathUtils.removeExtention("file.txt.gpg", ".txt") = file.gpg * PathUtils.removeExtention("file.txt.gpg", ".gpg") = file.txt * </pre> * * @param path in which the <code>extensions</code> need to be removed * @param extensions to be removed * * @return a new {@link Path} without <code>extensions</code> */ public static Path removeExtension(Path path, String... extensions) { String pathString = path.toString(); for (String extension : extensions) { pathString = StringUtils.remove(pathString, extension); } return new Path(pathString); }
String tarEntryRootName = StringUtils.remove(tarEntry.getName(), Path.SEPARATOR);
@Test public void display_component_key_if_no_component_name() throws Exception { Notification notification = generateNotification() .setFieldValue("componentName", null); EmailMessage email = underTest.format(notification); assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE"); assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE"); String message = email.getMessage(); String expected = Resources.toString(Resources.getResource( "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt"), StandardCharsets.UTF_8); expected = StringUtils.remove(expected, '\r'); assertThat(message).isEqualTo(expected); }
@Test public void test_email_with_issue_on_branch() throws Exception { Notification notification = generateNotification() .setFieldValue("branch", "feature1"); EmailMessage email = underTest.format(notification); assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE"); assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE"); String message = email.getMessage(); String expected = Resources.toString(Resources.getResource( "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_issue_on_branch.txt"), StandardCharsets.UTF_8); expected = StringUtils.remove(expected, '\r'); assertThat(message).isEqualTo(expected); }
@Test public void email_should_display_plan_change() throws Exception { Notification notification = generateNotification() .setFieldValue("old.actionPlan", null) .setFieldValue("new.actionPlan", "ABC 1.0"); EmailMessage email = underTest.format(notification); assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE"); assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE"); String message = email.getMessage(); String expected = Resources.toString(Resources.getResource( "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt"), StandardCharsets.UTF_8); expected = StringUtils.remove(expected, '\r'); assertThat(message).isEqualTo(expected); assertThat(email.getFrom()).isNull(); }
@Test public void email_should_display_assignee_change() throws Exception { Notification notification = generateNotification() .setFieldValue("old.assignee", "simon") .setFieldValue("new.assignee", "louis"); EmailMessage email = underTest.format(notification); assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE"); assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE"); String message = email.getMessage(); String expected = Resources.toString(Resources.getResource( "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt"), StandardCharsets.UTF_8); expected = StringUtils.remove(expected, '\r'); assertThat(message).isEqualTo(expected); assertThat(email.getFrom()).isNull(); }
@Test public void email_should_display_resolution_change() throws Exception { Notification notification = generateNotification() .setFieldValue("old.resolution", "FALSE-POSITIVE") .setFieldValue("new.resolution", "FIXED"); EmailMessage email = underTest.format(notification); assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE"); assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE"); String message = email.getMessage(); String expected = Resources.toString(Resources.getResource( "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_should_display_resolution_change.txt"), StandardCharsets.UTF_8); expected = StringUtils.remove(expected, '\r'); assertThat(message).isEqualTo(expected); assertThat(email.getFrom()).isNull(); }
@Test public void test_email_with_multiple_changes() throws Exception { Notification notification = generateNotification() .setFieldValue("comment", "How to fix it?") .setFieldValue("old.assignee", "simon") .setFieldValue("new.assignee", "louis") .setFieldValue("new.resolution", "FALSE-POSITIVE") .setFieldValue("new.status", "RESOLVED") .setFieldValue("new.type", "BUG") .setFieldValue("new.tags", "bug performance"); EmailMessage email = underTest.format(notification); assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE"); assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE"); String message = email.getMessage(); String expected = Resources.toString(Resources.getResource( "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt"), StandardCharsets.UTF_8); expected = StringUtils.remove(expected, '\r'); assertThat(message).isEqualTo(expected); assertThat(email.getFrom()).isNull(); }
if ( meta.getProtocol().equals( MailConnectionMeta.PROTOCOL_STRING_MBOX ) && StringUtils.startsWith( realserver, "file://" ) ) { realserver = StringUtils.remove( realserver, "file://" );
@CheckForNull private String removeNewLineCharacters(@Nullable String text) { String removedCRLF = StringUtils.remove(text, "\n"); removedCRLF = StringUtils.remove(removedCRLF, "\r"); removedCRLF = StringUtils.remove(removedCRLF, "\n\r"); removedCRLF = StringUtils.remove(removedCRLF, "\r\n"); return removedCRLF; }
public static String buildNodeName(String label) { String suffix; if (label == null) { suffix = StringUtils.EMPTY; } else { suffix = StringUtils.remove("-" + label, " "); } return StringUtils.left("mesos-jenkins-" + StringUtils.remove(UUID.randomUUID().toString(), '-') + suffix, MAX_HOSTNAME_LENGTH); } }
/** * * @param pem (e.g. "-----BEGIN CERTIFICATE-----MIICsDCCAZigAwIBAgIIdF+Wcca7gzkwDQYJKoZIhvcNAQELBQAwGDEWMBQGA1UEAwwNY2FvajdicjRpcHc2dTAeFw0xNzA4MDcxNDMyMzVaFw0xODA4MDcxNDMyMzZaMBgxFjAUBgNVBAMMDWNhb2o3YnI0aXB3NnUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCdrt40Otrveq46K3BzZuds6wDqsP0kZV+C3GdyTQWl53orBRtPIiEh6BauP17Rr19qadh7t4yFBb5thrXwBewseSNEL4j7sB0YoeNwRsmA29Fjfoe0yeNpLixFadL6dz7ej9xW2suPppIO6jA5SYgL6+S42ZlIauCnSQBKFcdP8QRvgDZBZ4A7CmuloRJst7GQzppa+YWR+Zg3V5reV8Ekrkjxhwgd+rMsGahxijY7Juf2zMgLOXwe68y41SGnn+1RwezAhnJgioGiwY2gP7z2m8yNZXhpUiX+KAP2xvYb60wNYOswuqfpya68rSmYT8mQjld1EPR21dBMjRQ8HfUBAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAAIUlqltRlbqiolGETmAUF8AiC008UCUmI+IsnORbHFSaACKW04m1iFH0OlxuAE1ECj1mlTcKb4md6i7n+Fy+fdGXFL73yhlSiBLu7XW5uN1/dAkynA+mXC5BDFijmvkEAgNLKyh40u/U1u75v2SFS+kLyMeqmVxvUHA7qA8VgyHi/FZzXCfEvxK5jye4L8tkAR34x5j5MpPDMfLkwLegUG+ygX+h/f8luKiQAk7eD4C59c/F0PpigvzcMpyg8+SE9loIEuJ9dRaRaTwIzez3QA7PJtrhu9h0TooTtkmF/Zw9HARrO0qXgT8uNtQDcRXZCItt1Qr7cOJyx2IjTFR2rE=-----END CERTIFICATE-----";) * @return x509 certificate */ public static X509Certificate x509CertificateFromPem(String pem) { pem = StringUtils.remove(pem, "-----BEGIN CERTIFICATE-----"); pem = StringUtils.remove(pem, "-----END CERTIFICATE-----"); return x509CertificateFromBytes(Base64.decode(pem)); }
public String capitalizeTrailingWords(String name) { char[] wordDelimiters = generationConfig.getPropertyWordDelimiters(); if (containsAny(name, wordDelimiters)) { String capitalizedNodeName = WordUtils.capitalize(name, wordDelimiters); name = name.charAt(0) + capitalizedNodeName.substring(1); for (char c : wordDelimiters) { name = remove(name, c); } } return name; } }
@Override public void visitNode(Tree tree) { ClassPropertyDeclarationTree property = (ClassPropertyDeclarationTree) tree; for (VariableDeclarationTree variableDeclarationTree : property.declarations()) { String propertyName = variableDeclarationTree.identifier().text(); if (!pattern.matcher(StringUtils.remove(propertyName, "$")).matches()) { context().newIssue(this, variableDeclarationTree.identifier(), String.format(MESSAGE, propertyName, format)); } } }
@Override public void visitNode(Tree tree) { ClassPropertyDeclarationTree property = (ClassPropertyDeclarationTree) tree; for (VariableDeclarationTree variableDeclarationTree : property.declarations()) { String propertyName = variableDeclarationTree.identifier().text(); if (!pattern.matcher(StringUtils.remove(propertyName, "$")).matches()) { context().newIssue(this, variableDeclarationTree.identifier(), String.format(MESSAGE, propertyName, format)); } } }