Skip to content

Commit

Permalink
checkstyle-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sugan0tech committed Nov 12, 2023
1 parent b3c15b7 commit ba5b559
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 21 deletions.
4 changes: 1 addition & 3 deletions notification/src/main/java/com/iluwatar/App.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.iluwatar;

import lombok.NoArgsConstructor;

import java.time.LocalDate;
import lombok.NoArgsConstructor;

/**
* The notification pattern captures information passed between layers, validates the information, and returns
Expand All @@ -19,7 +18,6 @@ public class App {

private static final String NAME = "";
private static final String OCCUPATION = "";
// private static final LocalDate DATE_OF_BIRTH = LocalDate.of(2016, 7, 13);
private static final LocalDate DATE_OF_BIRTH = LocalDate.of(2016, 7, 13);

public static void main(String[] args) {
Expand Down
2 changes: 1 addition & 1 deletion notification/src/main/java/com/iluwatar/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Notification {
private final List<NotificationError> errors = new ArrayList<>();

public boolean hasErrors() {
return this.errors.size() != 0;
return this.errors.isEmpty();
}

public void addError(NotificationError error) {
Expand Down
15 changes: 8 additions & 7 deletions notification/src/main/java/com/iluwatar/RegisterWorker.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.iluwatar;

import lombok.extern.slf4j.Slf4j;

import java.time.LocalDate;
import java.time.Period;
import lombok.extern.slf4j.Slf4j;

/**
* Class which handles actual internal logic and validation for worker registration.
Expand Down Expand Up @@ -40,26 +39,28 @@ private void validate() {
if (isNullOrBlank(ourData.getDateOfBirth())) {
// If DOB is null or empty
fail(true, RegisterWorkerDto.MISSING_DOB);
}else{
} else {
// Validating age ( should be greater than or equal to 18 )
Period age = Period.between(ourData.getDateOfBirth(), LocalDate.now());
fail(!(age.getYears() >= 18), RegisterWorkerDto.DOB_TOO_SOON);
fail(age.getYears() < 18, RegisterWorkerDto.DOB_TOO_SOON);
}
}

/**
* validates for null/empty value
* Validates for null/empty value.
*
* @param obj any object
* @return boolean
*/
protected boolean isNullOrBlank(Object obj) {
if(obj == null){
if (obj == null) {
return true;
}
if( obj instanceof String){

if (obj instanceof String) {
return ((String) obj).trim().isEmpty();
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion notification/src/test/java/com/iluwatar/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

public class AppTest {
class AppTest {

@Test
void shouldExecuteApplicationWithoutException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import java.util.Arrays;
import java.util.List;

public class DateOfBirthErrorTest {
class DateOfBirthErrorTest {
@Test
public void dateOfBirthTest() {
void dateOfBirthTest() {
//Define our variables
String name = "valid name";
String occupation = "valid occupation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import java.time.LocalDate;
import java.util.Arrays;

public class MultipleErrorsTest {
class MultipleErrorsTest {

@Test
public void multipleMissingTest() {
void multipleMissingTest() {
//Define our variables
String name = null;
String occupation = "";
Expand Down
4 changes: 2 additions & 2 deletions notification/src/test/java/com/iluwatar/NoErrorsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.time.LocalDate;
import java.util.Arrays;

public class NoErrorsTest {
class NoErrorsTest {
@Test
public void validSubmissionTest() {
void validSubmissionTest() {
//Define our variables
String name = "Valid Name";
String occupation = "Valid Occupation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import static org.junit.jupiter.api.Assertions.assertTrue;

public class NotificationErrorTest {
class NotificationErrorTest {
public static void generalFormSubmissionTest(String name, String occupation, LocalDate dateOfBirth,
List<NotificationError> containsError, List<NotificationError> excludesError) {
//Assign the variables to a new DTO, equivalent to filling in the form
Expand Down
4 changes: 2 additions & 2 deletions notification/src/test/java/com/iluwatar/OneErrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import java.util.Arrays;
import java.util.List;

public class OneErrorTest {
class OneErrorTest {
@Test
public void missingNameTest() {
void missingNameTest() {
//Define our variables
String name = "";
String occupation = "Valid Occupation";
Expand Down

0 comments on commit ba5b559

Please sign in to comment.