parent
f7b129bf24
commit
8755f3e1ca
3 changed files with 43 additions and 16 deletions
|
|
@ -40,7 +40,6 @@ public class KafkaSenderConfig {
|
|||
return KafkaProducerFactory.producerFactory(kafkaSettings);
|
||||
}
|
||||
|
||||
// @Autowired(required = false)
|
||||
@Bean("kafkaTemplate")
|
||||
public KafkaTemplate<String, Object> kafkaTemplate(ProducerFactory<String, Object> pf) {
|
||||
if (pf == null) {
|
||||
|
|
@ -49,19 +48,18 @@ public class KafkaSenderConfig {
|
|||
return new KafkaTemplate<>(pf);
|
||||
}
|
||||
|
||||
// @Autowired(required = false)
|
||||
@Bean
|
||||
public Supplier<KafkaSender> kafkaSenderSupplier(KafkaTemplate<String, Object> kafkaTemplate,
|
||||
ImdgProvider imdgProvider) {
|
||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||
return () -> KafkaSender
|
||||
.setup()
|
||||
.setKafkaTemplate(kafkaTemplate)
|
||||
.idGenerator(imdgIdGenerator::nextId)
|
||||
.imdgProvider(s -> {
|
||||
Imdg<RequestInfo> imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
return imdg::insert;
|
||||
})
|
||||
.build();
|
||||
}
|
||||
@Bean
|
||||
public Supplier<KafkaSender> kafkaSenderSupplier(KafkaTemplate<String, Object> kafkaTemplate,
|
||||
ImdgProvider imdgProvider) {
|
||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||
return () -> KafkaSender
|
||||
.setup()
|
||||
.setKafkaTemplate(kafkaTemplate)
|
||||
.idGenerator(imdgIdGenerator::nextId)
|
||||
.imdgProvider(s -> {
|
||||
Imdg<RequestInfo> imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
return imdg::insert;
|
||||
})
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ public enum FilenameTemplate {
|
|||
int res = 0;
|
||||
String timestampNow = utilFormatter.format(LocalDateTime.now());
|
||||
for (SftpFileInfo file : files) {
|
||||
if (file.isDirectory()) continue;
|
||||
String name = file.getFilename();
|
||||
String[] splitName = name.split("_");
|
||||
if (splitName.length < 3)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package ru.spcex.clearing.dbf.exporter.logic.data.enums;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp.LsEntry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.integration.sftp.session.SftpFileInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class FilenameTemplateTest {
|
||||
|
||||
@Test
|
||||
void countSameFilesInDir() {
|
||||
LsEntry lsEntry = mock(LsEntry.class);
|
||||
doReturn("DF-02_S_PRC2305191321_1.DBF").when(lsEntry).getFilename();
|
||||
SftpFileInfo sftpFileInfo = spy(new SftpFileInfo(lsEntry));
|
||||
doReturn(false).when(sftpFileInfo).isDirectory();
|
||||
List<SftpFileInfo> files = List.of(sftpFileInfo);
|
||||
int count = FilenameTemplate.df_section_dateTime.countSameFilesInDir("DF-02", files);
|
||||
assertEquals(1, count);
|
||||
|
||||
// doReturn("DF-02_S_PRC230").when(lsEntry).getFilename();
|
||||
// count = FilenameTemplate.df_section_dateTime.countSameFilesInDir("DF-02", files);
|
||||
// assertEquals(0, count);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue