Skip to content

Separate commonly used logic into methods and add test code #34571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Tussle0410
Copy link
Contributor

I noticed that there was duplicated logic when checking the definitions of DispositionType in ContentDisposition.java, so I extracted this logic into a private method.

After that, I realized there weren't any tests to verify this code was working properly, so I went ahead and added test code for it.

	public boolean isAttachment() {
		return (this.type != null && this.type.equalsIgnoreCase("attachment"));
	}

        ...

I've modified the existing code to follow the format shown below.

        public boolean isAttachment() {
		return isDepositionType("attachment");
	}

	private boolean isDepositionType(String type) {
		return this.type != null && this.type.equalsIgnoreCase(type);
	}

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 11, 2025
@Tussle0410 Tussle0410 closed this Mar 11, 2025
@Tussle0410 Tussle0410 deleted the Separate-commonly-used-logic-into-methods-and-add-test-code branch March 11, 2025 08:25
@bclozel bclozel added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants