mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
Add unit tests, ignore override if empty
This commit is contained in:
@@ -65,6 +65,7 @@ import org.alfresco.service.cmr.usage.ContentQuotaException;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.EqualsHelper;
|
import org.alfresco.util.EqualsHelper;
|
||||||
import org.alfresco.util.TempFileProvider;
|
import org.alfresco.util.TempFileProvider;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
@@ -643,7 +644,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
|
|||||||
|
|
||||||
String contentUrl = contentData.getContentUrl();
|
String contentUrl = contentData.getContentUrl();
|
||||||
String contentMimetype = contentData.getMimetype();
|
String contentMimetype = contentData.getMimetype();
|
||||||
String fileName = fileNameOverride == null ? getFileName(nodeRef) : fileNameOverride;
|
String fileName = StringUtils.isEmpty(fileNameOverride) ? getFileName(nodeRef) : fileNameOverride;
|
||||||
|
|
||||||
validFor = adjustValidFor(validFor);
|
validFor = adjustValidFor(validFor);
|
||||||
attachment = adjustAttachment(nodeRef, contentMimetype, attachment);
|
attachment = adjustAttachment(nodeRef, contentMimetype, attachment);
|
||||||
|
@@ -72,7 +72,8 @@ public class ContentServiceImplUnitTest
|
|||||||
|
|
||||||
private static final NodeRef NODE_REF = new NodeRef("content://Node/Ref");
|
private static final NodeRef NODE_REF = new NodeRef("content://Node/Ref");
|
||||||
public static final String SOME_CONTENT_URL = "someContentUrl";
|
public static final String SOME_CONTENT_URL = "someContentUrl";
|
||||||
private static final NodeRef NODE_REF_2 = new NodeRef("content://Node/Ref2");;
|
private static final NodeRef NODE_REF_2 = new NodeRef("content://Node/Ref2");
|
||||||
|
public static final String SOME_FILE_NAME = "someFilename";
|
||||||
|
|
||||||
private static final String X_AMZ_HEADER_1 = "x-amz-header1";
|
private static final String X_AMZ_HEADER_1 = "x-amz-header1";
|
||||||
private static final String VALUE_1 = "value1";
|
private static final String VALUE_1 = "value1";
|
||||||
@@ -103,7 +104,7 @@ public class ContentServiceImplUnitTest
|
|||||||
when(mockNodeService.getProperty(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(mockContentData);
|
when(mockNodeService.getProperty(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(mockContentData);
|
||||||
when(mockContentData.getContentUrl()).thenReturn(SOME_CONTENT_URL);
|
when(mockContentData.getContentUrl()).thenReturn(SOME_CONTENT_URL);
|
||||||
when(mockContentData.getMimetype()).thenReturn("someMimetype");
|
when(mockContentData.getMimetype()).thenReturn("someMimetype");
|
||||||
when(mockNodeService.getProperty(NODE_REF, ContentModel.PROP_NAME)).thenReturn("someFilename");
|
when(mockNodeService.getProperty(NODE_REF, ContentModel.PROP_NAME)).thenReturn(SOME_FILE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -162,6 +163,40 @@ public class ContentServiceImplUnitTest
|
|||||||
verify(mockContentStore, times(1)).requestContentDirectUrl(anyString(), eq(true), anyString(), anyString(), anyLong());
|
verify(mockContentStore, times(1)).requestContentDirectUrl(anyString(), eq(true), anyString(), anyString(), anyLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRequestContentDirectUrl_StoreRequestContentDirectUrlIsCalledWithFileNameOverride()
|
||||||
|
{
|
||||||
|
final String fileNameOverride = "fileNameOverride.txt";
|
||||||
|
setupSystemWideDirectAccessConfig(ENABLED);
|
||||||
|
when(mockContentStore.isContentDirectUrlEnabled()).thenReturn(ENABLED);
|
||||||
|
|
||||||
|
DirectAccessUrl directAccessUrl = contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME, true, 20L, fileNameOverride);
|
||||||
|
assertNull(directAccessUrl);
|
||||||
|
verify(mockContentStore, times(1)).requestContentDirectUrl(anyString(), eq(true), eq(fileNameOverride), anyString(), anyLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRequestContentDirectUrl_StoreRequestContentDirectUrlIsCalledWithNodeNamePropertyWhenFileNameOverrideIsNull()
|
||||||
|
{
|
||||||
|
setupSystemWideDirectAccessConfig(ENABLED);
|
||||||
|
when(mockContentStore.isContentDirectUrlEnabled()).thenReturn(ENABLED);
|
||||||
|
|
||||||
|
DirectAccessUrl directAccessUrl = contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME, true, 20L, null);
|
||||||
|
assertNull(directAccessUrl);
|
||||||
|
verify(mockContentStore, times(1)).requestContentDirectUrl(anyString(), eq(true), eq(SOME_FILE_NAME), anyString(), anyLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRequestContentDirectUrl_StoreRequestContentDirectUrlIsCalledWithNodeNamePropertyWhenFileNameOverrideIsEmpty()
|
||||||
|
{
|
||||||
|
setupSystemWideDirectAccessConfig(ENABLED);
|
||||||
|
when(mockContentStore.isContentDirectUrlEnabled()).thenReturn(ENABLED);
|
||||||
|
|
||||||
|
DirectAccessUrl directAccessUrl = contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME, true, 20L, "");
|
||||||
|
assertNull(directAccessUrl);
|
||||||
|
verify(mockContentStore, times(1)).requestContentDirectUrl(anyString(), eq(true), eq(SOME_FILE_NAME), anyString(), anyLong());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnStoragePropertiesWhenTheyExist()
|
public void shouldReturnStoragePropertiesWhenTheyExist()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user