Skip to content
Snippets Groups Projects
Commit fa5eefed authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5322 implement comments from code review

parent 4f161be1
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,6 @@ import org.springframework.context.event.EventListener;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.stereotype.Component;
import de.ozgcloud.apilib.common.command.OzgCloudCommandService;
import de.ozgcloud.bescheid.attacheditem.AttachedItemService;
import de.ozgcloud.bescheid.binaryfile.BinaryFileService;
import de.ozgcloud.bescheid.common.callcontext.CurrentUserService;
......@@ -84,9 +83,7 @@ class BescheidEventListener {
private final BinaryFileService fileService;
private final NachrichtService nachrichtService;
private final AttachedItemService attachedItemService;
private final BescheidFeatureProperties featureProperties;
private final DocumentService documentService;
private final OzgCloudCommandService commandService;
private final ApplicationEventPublisher eventPublisher;
private final CurrentUserService userService;
......
......@@ -29,8 +29,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import de.ozgcloud.apilib.common.command.OzgCloudCommand;
......@@ -62,14 +62,14 @@ public class DocumentService {
private final DocumentMapper documentMapper;
public String createBescheidDocument(Command command) {
return createBescheidDocument(command, buildItemMap(command));
return createBescheidDocument(command, buildItemMap(command));
}
public String createBescheidDocument(Command command, Bescheid bescheid) {
return createBescheidDocument(command, buildItemMap(bescheid));
}
public String createBescheidDocument(Command command, Map<String, Object> itemMap) {
String createBescheidDocument(Command command, Map<String, Object> itemMap) {
validateBescheidItem(command.getRelationId());
var ozgCloudCommand = buildCreateDocumentOzgCommand(command, buildAttachedItem(command, itemMap));
var executedCommand = commandService.createAndWaitUntilDone(ozgCloudCommand);
......@@ -116,6 +116,7 @@ public class DocumentService {
FIELD_DOCUMENT_FILE, bescheid.getBescheidFileId().toString(),
FIELD_NACHRICHT_TEXT, bescheid.getNachrichtText().orElse(StringUtils.EMPTY));
}
public Document getDocument(String id) {
return documentMapper.fromAttachedItem(attachedItemService.getItem(id));
}
......
package de.ozgcloud.bescheid.smartdocuments;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -33,6 +35,7 @@ class SmartDocumentsBescheidRemoteServiceITCase {
System.out.println(bescheid.getBescheidFileName());
System.out.println(bescheid.getBescheidFile().getAbsolutePath());
assertThat(bescheid.getBescheidFileName()).isNotEmpty();
}
}
......@@ -50,7 +50,7 @@ import de.ozgcloud.common.test.ITCase;
import de.ozgcloud.vorgang.VorgangManagerServerApplication;
import de.ozgcloud.vorgang.command.CommandTestFactory;
public class BescheidDocumentITCase {
class BescheidDocumentITCase {
@Nested
@SpringBootTest(classes = VorgangManagerServerApplication.class)
......
......@@ -49,7 +49,6 @@ import org.springframework.test.annotation.DirtiesContext;
import com.mongodb.client.gridfs.model.GridFSFile;
import de.ozgcloud.apilib.common.command.grpc.CommandMapper;
import de.ozgcloud.bescheid.attacheditem.AttachedItemService;
import de.ozgcloud.bescheid.attacheditem.BescheidItem;
import de.ozgcloud.bescheid.common.callcontext.CallContextUser;
......@@ -80,11 +79,7 @@ class BescheidEventListenerITCase {
@Autowired
private ApplicationEventPublisher eventPublisher;
@SpyBean
private BescheidEventListener eventListener;
@SpyBean
private TestEventListener bescheidDocumentCreatedEventListener;
@Autowired
private CommandMapper mapper;
@Autowired
private MongoOperations mongoOperations;
......@@ -118,8 +113,7 @@ class BescheidEventListenerITCase {
Awaitility.await().atMost(60, TimeUnit.SECONDS).untilAsserted(() -> {
verify(bescheidDocumentCreatedEventListener).onBescheidDocumentCreated(bescheidDocumentCreatedEventCaptor.capture());
var bescheidDocument = getBescheidDocument();
assertThat(bescheidDocument).isNotNull();
assertThat(getBescheidDocument()).isNotNull();
});
}
......@@ -147,7 +141,7 @@ class BescheidEventListenerITCase {
}
private CommandCreatedEvent buildCommandCreatedEvent(String vorgangId, String bescheidItemId) {
var command= CommandTestFactory.createBuilder()
var command = CommandTestFactory.createBuilder()
.vorgangId(vorgangId)
.relationId(bescheidItemId)
.order(BescheidEventListener.CREATE_BESCHEID_DOCUMENT_ORDER)
......
......@@ -28,7 +28,7 @@ import org.springframework.context.event.EventListener;
import de.ozgcloud.command.CommandFailedEvent;
import de.ozgcloud.document.BescheidDocumentCreatedEvent;
public class TestEventListener {
class TestEventListener {
@EventListener
public void onBescheidDocumentCreated(BescheidDocumentCreatedEvent event) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment