Skip to content

Commit

Permalink
Format code using npm prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
adem-hassine authored and DamnClin committed Jul 30, 2023
1 parent 6d3d238 commit 8935b74
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/main/java/tech/jhipster/lite/error/domain/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ public InstantAsserter after(Instant other) {
Assert.notNull(OTHER_FIELD_NAME, other);

if (value.compareTo(other) <= 0) {
throw NotAfterTimeException.field(field, value).notStrictlyAfter(other);
throw NotAfterTimeException.field(field, value).strictlyNotAfter(other);
}

return this;
Expand Down Expand Up @@ -1306,7 +1306,7 @@ public InstantAsserter before(Instant other) {
Assert.notNull(OTHER_FIELD_NAME, other);

if (value.compareTo(other) >= 0) {
throw NotBeforeTimeException.field(field, value).notStrictlyBefore(other);
throw NotBeforeTimeException.field(field, value).strictlyNotBefore(other);
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static NotAfterTimeExceptionBuilder field(String fieldName, Instant value
}

record NotAfterTimeExceptionBuilder(String fieldName, Instant value) {
public NotAfterTimeException notStrictlyAfter(Instant other) {
public NotAfterTimeException strictlyNotAfter(Instant other) {
return build("must be strictly after", other);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static NotBeforeTimeException.NotBeforeTimeExceptionBuilder field(String
}

public record NotBeforeTimeExceptionBuilder(String fieldName, Instant value) {
public NotBeforeTimeException notStrictlyBefore(Instant other) {
public NotBeforeTimeException strictlyNotBefore(Instant other) {
return build("must be strictly before", other);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ public class Assert {
Assert.notNull(OTHER_FIELD_NAME, other);
if (value.compareTo(other) <= 0) {
throw NotAfterTimeException.field(field,value).notStrictlyAfter(other);
throw NotAfterTimeException.field(field, value).strictlyNotAfter(other);
}

return this;
Expand All @@ -1255,7 +1255,7 @@ public class Assert {
Assert.notNull(OTHER_FIELD_NAME, other);
if (value.compareTo(other) < 0) {
throw NotAfterTimeException.field(field,value).notAfter(other);
throw NotAfterTimeException.field(field, value).notAfter(other);
}

return this;
Expand Down Expand Up @@ -1290,7 +1290,7 @@ public class Assert {
Assert.notNull(OTHER_FIELD_NAME, other);
if (value.compareTo(other) >= 0) {
throw NotBeforeTimeException.field(field,value).notStrictlyBefore(other);
throw NotBeforeTimeException.field(field, value).strictlyNotBefore(other);
}

return this;
Expand All @@ -1312,7 +1312,7 @@ public class Assert {
Assert.notNull(OTHER_FIELD_NAME, other);
if (value.compareTo(other) > 0) {
throw NotBeforeTimeException.field(field,value).notBefore(other);
throw NotBeforeTimeException.field(field, value).notBefore(other);
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,41 @@ public class NotAfterTimeException extends AssertionException {
super(field, message);
}

public static NotAfterTimeExceptionBuilder field(String fieldName, Instant value){
public static NotAfterTimeExceptionBuilder field(String fieldName, Instant value) {
return new NotAfterTimeExceptionBuilder(fieldName, value);
}

record NotAfterTimeExceptionBuilder(String fieldName, Instant value) {
public NotAfterTimeException notStrictlyAfter(Instant other) {
return build("must be strictly after", other);
}
record NotAfterTimeExceptionBuilder(String fieldName, Instant value) {
public NotAfterTimeException strictlyNotAfter(Instant other) {
return build("must be strictly after", other);
}

public NotAfterTimeException notAfter(Instant other) {
return build( "must be after", other);
}
public NotAfterTimeException notAfter(Instant other) {
return build("must be after", other);
}

private NotAfterTimeException build(String hint,Instant other){
return new NotAfterTimeException(fieldName, message(fieldName, value, hint, other));
}
private NotAfterTimeException build(String hint, Instant other) {
return new NotAfterTimeException(fieldName, message(fieldName, value, hint, other));
}

private static String message(String fieldName, Instant actual, String hint, Instant other) {
return new StringBuilder()
.append("Time in \"")
.append(fieldName)
.append("\" ")
.append("having value")
.append(' ')
.append(':')
.append(' ')
.append(actual)
.append(' ')
.append(hint)
.append(" ")
.append(other)
.append(" but wasn't")
.toString();
}
return new StringBuilder()
.append("Time in \"")
.append(fieldName)
.append("\" ")
.append("having value")
.append(' ')
.append(':')
.append(' ')
.append(actual)
.append(' ')
.append(hint)
.append(" ")
.append(other)
.append(" but wasn't")
.toString();
}
}

@Override
public AssertionErrorType type() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ public class NotBeforeTimeException extends AssertionException {
super(field, message);
}

public static NotBeforeTimeException.NotBeforeTimeExceptionBuilder field(String fieldName, Instant value){
public static NotBeforeTimeException.NotBeforeTimeExceptionBuilder field(String fieldName, Instant value) {
return new NotBeforeTimeException.NotBeforeTimeExceptionBuilder(fieldName, value);
}

public record NotBeforeTimeExceptionBuilder(String fieldName, Instant value) {
public NotBeforeTimeException notStrictlyBefore(Instant other) {
public NotBeforeTimeException strictlyNotBefore(Instant other) {
return build("must be strictly before", other);
}

public NotBeforeTimeException notBefore(Instant other) {
return build( "must be before", other);
return build("must be before", other);
}

private NotBeforeTimeException build(String hint,Instant other){
private NotBeforeTimeException build(String hint, Instant other) {
return new NotBeforeTimeException(fieldName, message(fieldName, value, hint, other));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ class NotAfterTimeExceptionTest {
NotAfterTimeException exception = NotAfterTimeException.field(FIELD, Instant.ofEpochSecond(1336)).notAfter(Instant.ofEpochSecond(1337));
assertDefaultInformation(exception);
assertThat(exception.getMessage()).isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:16Z must be after 1970-01-01T00:22:17Z but wasn't");
assertThat(exception.getMessage())
.isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:16Z must be after 1970-01-01T00:22:17Z but wasn't");
}

@Test
void shouldGetNotStrictlyAfterExceptionInformation() {
NotAfterTimeException exception = NotAfterTimeException.field(FIELD, Instant.ofEpochSecond(1337)).notStrictlyAfter(Instant.ofEpochSecond(1337));
void shouldGetStrictlyNotAfterExceptionInformation() {
NotAfterTimeException exception = NotAfterTimeException
.field(FIELD, Instant.ofEpochSecond(1337))
.strictlyNotAfter(Instant.ofEpochSecond(1337));
assertDefaultInformation(exception);
assertThat(exception.getMessage()).isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:17Z must be strictly after 1970-01-01T00:22:17Z but wasn't");
assertThat(exception.getMessage())
.isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:17Z must be strictly after 1970-01-01T00:22:17Z but wasn't");
}

private void assertDefaultInformation(NotAfterTimeException exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ class NotBeforeTimeExceptionTest {
@Test
void shouldGetNotBeforeExceptionInformation() {
NotBeforeTimeException exception = NotBeforeTimeException.field(FIELD, Instant.ofEpochSecond(1337)).notBefore(Instant.ofEpochSecond(1338));
NotBeforeTimeException exception = NotBeforeTimeException
.field(FIELD, Instant.ofEpochSecond(1337))
.notBefore(Instant.ofEpochSecond(1338));
assertDefaultInformation(exception);
assertThat(exception.getMessage()).isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:17Z must be before 1970-01-01T00:22:18Z but wasn't");
assertThat(exception.getMessage())
.isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:17Z must be before 1970-01-01T00:22:18Z but wasn't");
}

@Test
void shouldGetNotStrictlyBeforeExceptionInformation() {
NotBeforeTimeException exception = NotBeforeTimeException.field(FIELD, Instant.ofEpochSecond(1337)).notStrictlyBefore(Instant.ofEpochSecond(1337));
void shouldGetStrictlyNotBeforeExceptionInformation() {
NotBeforeTimeException exception = NotBeforeTimeException
.field(FIELD, Instant.ofEpochSecond(1337))
.strictlyNotBefore(Instant.ofEpochSecond(1337));
assertDefaultInformation(exception);
assertThat(exception.getMessage()).isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:17Z must be strictly before 1970-01-01T00:22:17Z but wasn't");
assertThat(exception.getMessage())
.isEqualTo("Time in \"myField\" having value : 1970-01-01T00:22:17Z must be strictly before 1970-01-01T00:22:17Z but wasn't");
}

private void assertDefaultInformation(NotBeforeTimeException exception) {
Expand Down

0 comments on commit 8935b74

Please sign in to comment.