1. Jak utworzyć nową klasę w osobnym katalogu? Mam jedynie takie opcje https://prnt.sc/fyg1uIU3WEHS
2. Dlaczego klasa CarServiceTest, nie moze utworzyc obietku CarService? https://prnt.sc/7wOSWn6HKUEr
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public class CarService {
private int carMileage;
private int fuelUsage;
private int treadThickness;
public boolean analyzeCarByParams(Integer treadThickness, Integer fuelUsage, Integer carMileage){
boolean treadThicknessNull = treadThickness==null;
boolean fuelUsageNull = fuelUsage==null;
boolean carMileageNull = carMileage==null;
if (treadThicknessNull || fuelUsageNull || carMileageNull){
throw new IllegalArgumentException("Car details can not be null!");
}
if (isCorrect(treadThickness, ParamsValue.TREAD_THICKNESS) && isCorrect(fuelUsage,ParamsValue.FUEL_USAGE)
&& isCorrect(carMileage,ParamsValue.CAR_MILEAGE)) return true;
return false;
}
public boolean isCorrect(int value, ParamsValue validValues){
if (value<0) throw new IllegalArgumentException("Incorrect value!");
int minValue = validValues.getMinValue();
int maxValue = validValues.getMaxValue();
if (value>=minValue && value <=maxValue) return true;
return false;
}
}
import org.testng.annotations.Test;
public class CarServiceTest {
@Test
public void analyzeCarByParamsTreadThicknessNull_throwsIllegalArgumentException(){
//given
Integer treadThickness = null;
Integer fuelUsage = 3;
Integer carMileage = 33;
//when
CarService
//then
}
}