Skip to content

Commit

Permalink
[MNG-8150] Remove unused locale argument from FileSizeFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
pshevche committed Jun 11, 2024
1 parent bea3e72 commit 2369134
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.maven.cli.transfer;

import java.io.PrintStream;
import java.util.Locale;

import org.apache.maven.api.services.MessageBuilder;
import org.apache.maven.api.services.MessageBuilderFactory;
Expand Down Expand Up @@ -72,7 +71,7 @@ public void transferSucceeded(TransferEvent event) {

TransferResource resource = event.getResource();
long contentLength = event.getTransferredBytes();
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

MessageBuilder message = messageBuilderFactory.builder();
message.append(action).style(STYLE).append(' ').append(direction).append(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.PrintStream;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;

import org.apache.maven.api.services.MessageBuilderFactory;
Expand All @@ -36,7 +35,7 @@
public class ConsoleMavenTransferListener extends AbstractMavenTransferListener {

private Map<TransferResource, Long> transfers = new LinkedHashMap<>();
private FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH); // use in a synchronized fashion
private FileSizeFormat format = new FileSizeFormat(); // use in a synchronized fashion
private StringBuilder buffer = new StringBuilder(128); // use in a synchronized fashion

private boolean printResourceNames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;

import java.util.Locale;

import org.apache.maven.api.services.MessageBuilder;

/**
Expand Down Expand Up @@ -101,8 +99,6 @@ public static ScaleUnit getScaleUnit(long size) {
}
}

public FileSizeFormat(Locale locale) {}

public String format(long size) {
return format(size, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;

import java.util.Locale;

import org.eclipse.aether.transfer.AbstractTransferListener;
import org.eclipse.aether.transfer.TransferCancelledException;
import org.eclipse.aether.transfer.TransferEvent;
Expand Down Expand Up @@ -75,7 +73,7 @@ public void transferSucceeded(TransferEvent event) {

TransferResource resource = event.getResource();
long contentLength = event.getTransferredBytes();
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

StringBuilder message = new StringBuilder();
message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;

import java.util.Locale;

import org.apache.maven.cli.transfer.FileSizeFormat.ScaleUnit;
import org.junit.jupiter.api.Test;

Expand All @@ -30,15 +28,15 @@ class FileSizeFormatTest {

@Test
void testNegativeSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long negativeSize = -100L;
assertThrows(IllegalArgumentException.class, () -> format.format(negativeSize));
}

@Test
void testSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.format(_0_bytes));
Expand Down Expand Up @@ -103,7 +101,7 @@ void testSize() {

@Test
void testSizeWithSelectedScaleUnit() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.format(_0_bytes));
Expand Down Expand Up @@ -206,22 +204,22 @@ void testSizeWithSelectedScaleUnit() {

@Test
void testNegativeProgressedSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long negativeProgressedSize = -100L;
assertThrows(IllegalArgumentException.class, () -> format.formatProgress(negativeProgressedSize, 10L));
}

@Test
void testNegativeProgressedSizeBiggerThanSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

assertThrows(IllegalArgumentException.class, () -> format.formatProgress(100L, 10L));
}

@Test
void testProgressedSizeWithoutSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.formatProgress(_0_bytes, -1L));
Expand All @@ -238,15 +236,15 @@ void testProgressedSizeWithoutSize() {

@Test
void testProgressedBothZero() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.formatProgress(_0_bytes, _0_bytes));
}

@Test
void testProgressedSizeWithSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
long _400_bytes = 400L;
Expand Down

0 comments on commit 2369134

Please sign in to comment.