Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollovati authored and mshabarov committed Mar 8, 2022
1 parent 449da78 commit b7d0609
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package com.vaadin.flow.portal;

import java.net.URI;
import java.net.URISyntaxException;

import javax.portlet.MimeResponse;
import javax.portlet.PortletResponse;
import javax.portlet.ResourceURL;

import java.net.URI;
import java.net.URISyntaxException;

import com.vaadin.flow.server.AbstractStreamResource;
import com.vaadin.flow.server.StreamRegistration;
import com.vaadin.flow.server.StreamResource;
Expand All @@ -42,7 +42,8 @@ class PortletStreamResourceRegistry extends StreamResourceRegistry {
/**
* Creates stream resource registry for provided {@code session}.
*
* @param session Vaadin portlet session
* @param session
* Vaadin portlet session
*/
public PortletStreamResourceRegistry(VaadinPortletSession session) {
super(session);
Expand All @@ -54,15 +55,16 @@ public URI getTargetURI(AbstractStreamResource resource) {
}

@Override
public StreamRegistration registerResource(AbstractStreamResource resource) {
StreamRegistration streamRegistration = super.registerResource(resource);
public StreamRegistration registerResource(
AbstractStreamResource resource) {
StreamRegistration streamRegistration = super.registerResource(
resource);
return new RegistrationWrapper(streamRegistration);
}

/**
* StreamRegistration implementation which embeds dynamic resource url
* into portlet url as a 'resourceUrl' query parameter, see
* {@link ResourceURL}.
* StreamRegistration implementation which embeds dynamic resource url into
* portlet url as a 'resourceUrl' query parameter, see {@link ResourceURL}.
*/
private final class RegistrationWrapper implements StreamRegistration {

Expand Down Expand Up @@ -114,7 +116,7 @@ private URI doGetUri(AbstractStreamResource resource) {

private String startWithSlash(URI uri) {
String uriString = uri.toString();
if(uriString.startsWith("/")) {
if (uriString.startsWith("/")) {
return uriString;
}
return "/" + uriString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

import javax.portlet.MimeResponse;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.server.AbstractStreamResource;
import com.vaadin.flow.server.StreamResource;

import static org.junit.Assert.*;

public class PortletStreamResourceHandlerTest {

private PortletStreamResourceHandler handler = new PortletStreamResourceHandler();
Expand Down Expand Up @@ -64,7 +59,8 @@ public void handleRequest_shouldApplyStreamResourceHeaders()
String headerValue = "attachment;filename=export.xlsx";
resource.setHeader(headerName, headerValue);
handler.handleRequest(session, request, response, resource);
Mockito.verify(portletResponse, Mockito.atLeastOnce()).setProperty(headerName, headerValue);
Mockito.verify(portletResponse, Mockito.atLeastOnce())
.setProperty(headerName, headerValue);
}

}
}

0 comments on commit b7d0609

Please sign in to comment.