Skip to content

Commit

Permalink
ISSUE-1299 Fix DistributedLinagoraSecondaryBlobStoreTest and TmailEve…
Browse files Browse the repository at this point in the history
…ntSerializer (#1460)
  • Loading branch information
Arsnael authored Jan 14, 2025
1 parent 9f7f968 commit fecb130
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.linagora.tmail.blob.secondaryblobstore.FailedBlobEvents;
import com.linagora.tmail.blob.secondaryblobstore.ObjectStorageIdentity;

Expand Down Expand Up @@ -76,15 +77,11 @@ public String toJson(Event event) {
}

@Override
public String toJson(Collection<Event> events) {
try {
List<EventDTO> eventDTOs = events.stream()
.map(this::toDTO)
.toList();
return objectMapper.writeValueAsString(eventDTOs);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
public String toJson(Collection<Event> event) {
if (event.size() != 1) {
throw new IllegalArgumentException("Not supported for multiple events, please serialize separately");
}
return toJson(event.iterator().next());
}

@Override
Expand All @@ -99,16 +96,7 @@ public Event asEvent(String serialized) {

@Override
public List<Event> asEvents(String serialized) {
try {
List<EventDTO> eventDTOs = objectMapper.readValue(
serialized,
objectMapper.getTypeFactory().constructCollectionType(List.class, EventDTO.class));
return eventDTOs.stream()
.map(this::fromDTO)
.toList();
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return ImmutableList.of(asEvent(serialized));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.apache.james.jmap.JMAPUrls;
import org.apache.james.jmap.JmapGuiceProbe;
import org.apache.james.jmap.http.UserCredential;
import org.apache.james.junit.categories.BasicFeature;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.modules.AwsS3BlobStoreExtension;
import org.apache.james.modules.MailboxProbeImpl;
Expand All @@ -69,6 +70,7 @@
import org.awaitility.core.ConditionFactory;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand Down Expand Up @@ -100,7 +102,7 @@
import reactor.core.publisher.Flux;
import reactor.util.retry.Retry;

//@Tag(BasicFeature.TAG) TODO https://github.com/linagora/tmail-backend/issues/1299
@Tag(BasicFeature.TAG)
class DistributedLinagoraSecondaryBlobStoreTest {
public static final ConditionFactory calmlyAwait = Awaitility.with()
.pollInterval(ONE_HUNDRED_MILLISECONDS)
Expand Down

0 comments on commit fecb130

Please sign in to comment.