mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
add unit tests
This commit is contained in:
@@ -95,7 +95,7 @@ public class PropertyModificationAllowedCheck
|
|||||||
if (!before.containsKey(key) || !after.containsKey(key))
|
if (!before.containsKey(key) || !after.containsKey(key))
|
||||||
{
|
{
|
||||||
//Property modified check to see if allowed
|
//Property modified check to see if allowed
|
||||||
proceed = whiteList.contains(key);
|
proceed = allowPropertyUpdate(key);
|
||||||
if (!proceed)
|
if (!proceed)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -106,7 +106,7 @@ public class PropertyModificationAllowedCheck
|
|||||||
(after.get(key) == null && before.get(key) != null))
|
(after.get(key) == null && before.get(key) != null))
|
||||||
{
|
{
|
||||||
//Property modified check to see if allowed
|
//Property modified check to see if allowed
|
||||||
proceed = whiteList.contains(key);
|
proceed = allowPropertyUpdate(key);
|
||||||
if (!proceed)
|
if (!proceed)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -116,7 +116,7 @@ public class PropertyModificationAllowedCheck
|
|||||||
if (before.get(key) != null && after.get(key) != null && !(after.get(key).equals(before.get(key))))
|
if (before.get(key) != null && after.get(key) != null && !(after.get(key).equals(before.get(key))))
|
||||||
{
|
{
|
||||||
//Property modified check to see if allowed
|
//Property modified check to see if allowed
|
||||||
proceed = whiteList.contains(key) || getEditableURIs().contains(key.getNamespaceURI());
|
proceed = allowPropertyUpdate(key);
|
||||||
if (!proceed)
|
if (!proceed)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -126,5 +126,14 @@ public class PropertyModificationAllowedCheck
|
|||||||
return proceed;
|
return proceed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the property should be allowed to be updated or not.
|
||||||
|
* @param key property
|
||||||
|
* @return true if property update us allowed
|
||||||
|
*/
|
||||||
|
private boolean allowPropertyUpdate(QName key)
|
||||||
|
{
|
||||||
|
return whiteList.contains(key) || getEditableURIs().contains(key.getNamespaceURI());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -236,4 +236,26 @@ public class PropertyModificationAllowedCheckUnitTest
|
|||||||
after.put(qName, null);
|
after.put(qName, null);
|
||||||
assertTrue(propertyModificationAllowedCheck.check(before, after));
|
assertTrue(propertyModificationAllowedCheck.check(before, after));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test update of a property from the model URI for which properties can be updated
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdatePropertyFromAllowedModelURI()
|
||||||
|
{
|
||||||
|
editableURIs.add("foo");
|
||||||
|
propertyModificationAllowedCheck.setEditableURIs(editableURIs);
|
||||||
|
assertTrue(propertyModificationAllowedCheck.check(before, after));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test update of a property that is not in the model URI for which properties can be updated
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdatePropertyFromNotAllowedModelURI()
|
||||||
|
{
|
||||||
|
editableURIs.add("bar");
|
||||||
|
propertyModificationAllowedCheck.setEditableURIs(editableURIs);
|
||||||
|
assertFalse(propertyModificationAllowedCheck.check(before, after));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user