Some fixes, lombok instead of autowired
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
package me.bearns.fias.helpers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.bearns.fias.domain.FiasVersion;
|
||||
import me.bearns.fias.exceptions.CommonException;
|
||||
import me.bearns.fias.exceptions.DownloadException;
|
||||
import me.bearns.fias.exceptions.UnzipException;
|
||||
import me.bearns.fias.repository.AddrobjRepository;
|
||||
import me.bearns.fias.repository.FiasVersionRepository;
|
||||
import me.bearns.fias.service.Downloader;
|
||||
import me.bearns.fias.service.StreamSaver;
|
||||
import me.bearns.fias.xml.AddrObjAdapter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -28,19 +26,16 @@ import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class UpdaterImpl implements UpdateHelper {
|
||||
|
||||
@Autowired
|
||||
private static Downloader fileService;
|
||||
private Downloader fileService;
|
||||
|
||||
@Autowired
|
||||
private static FiasVersionRepository versions;
|
||||
private FiasVersionRepository versions;
|
||||
|
||||
@Autowired
|
||||
private static Catalog catalog;
|
||||
private Catalog catalog;
|
||||
|
||||
@Autowired
|
||||
private static StreamSaver unmarshaller;
|
||||
private StreamSaver unmarshaller;
|
||||
|
||||
//transaction from here
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.bearns.fias.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.bearns.fias.domain.FiasVersion;
|
||||
import me.bearns.fias.exceptions.CommonException;
|
||||
@@ -12,16 +13,14 @@ import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class FiasUpdater implements Updater {
|
||||
|
||||
@Autowired
|
||||
private static FiasVersionRepository versions;
|
||||
private FiasVersionRepository versions;
|
||||
|
||||
@Autowired
|
||||
private static OnlineVersion clientStub;
|
||||
private OnlineVersion clientStub;
|
||||
|
||||
@Autowired
|
||||
private static UpdateHelper helper;
|
||||
private UpdateHelper helper;
|
||||
|
||||
@Override
|
||||
public void update() throws CommonException {
|
||||
@@ -81,6 +80,4 @@ public class FiasUpdater implements Updater {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.bearns.fias;
|
||||
|
||||
import me.bearns.fias.exceptions.CommonException;
|
||||
import me.bearns.fias.service.Updater;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@ActiveProfiles("test")
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class UpdaterTest {
|
||||
|
||||
@Autowired
|
||||
Updater service;
|
||||
|
||||
@Test
|
||||
public void integrationTest() throws CommonException {
|
||||
|
||||
service.reload(22L);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user