У меня класс ниже. Я новичок в написании тестов junit. Мне нужно написать тестовый пример для этого. Как написать тестовый метод для метода startSchemaMaintenance в тестовом классе, так как он вызывает закрытый метод без аргументов?
public class SchemaMaintenance {
//Loading statuses overview
// NOT_STARTED = 0
// START_LOADING = 1
// IN_PROGRESS = 2
// COMPLETED = 3
// LOADING_ERROR = 4
private static volatile Integer loading_status = 0;
public void startSchemaMaintenance() throws Exception {
if (checkLoadingStatus() == 1) {
doSchemaMaintenance();
loading_status = 3;
}
}
private void doSchemaMaintenance(){
//Do something....
}
private int checkLoadingStatus() throws Exception {
if (loading_status==0 ||loading_status == 2) {
synchronized (loading_status) {
if (loading_status==0) {
loading_status = 2;
return 1;
}else if(loading_status == 2) {
while(loading_status == 2);
if((loading_status == 4)){
throw new Exception("status = " + 4);
}
}else if(loading_status == 4) {
//log.error(generateErrorMessage());
throw new Exception("status = " + 4);
}
}
}else if((loading_status == 4)){
//log.error(generateErrorMessage());
throw new Exception("status = " + 4 );
}
return loading_status;
}
}