use of com.sun.identity.entitlement.xacml3.XACMLExportImport.ImportStep in project OpenAM by OpenRock.
the class XacmlServiceTest method testImportXACML.
@Test
public void testImportXACML() throws Exception {
//given
Representation representation = mock(Representation.class);
InputStream is = new ByteArrayInputStream("Hello World".getBytes());
doReturn(is).when(representation).getStream();
StubPrivilege privilege = new StubPrivilege();
privilege.setName("fred");
XACMLExportImport.ImportStep importStep = mock(XACMLExportImport.ImportStep.class);
doReturn(XACMLExportImport.DiffStatus.ADD).when(importStep).getDiffStatus();
doReturn(privilege).when(importStep).getPrivilege();
List<ImportStep> steps = Arrays.asList(importStep);
doReturn(steps).when(importExport).importXacml(eq("/"), eq(is), any(Subject.class), eq(false));
//when
Representation result = service.importXACML(representation);
//then
assertThat(result).isInstanceOf(JacksonRepresentation.class);
Map<String, Object> resultMap = JsonValueBuilder.toJsonArray(result.getText()).get(0).asMap();
assertThat(resultMap).contains(entry("status", "A"), entry("name", "fred"));
verify(response).setStatus(Status.SUCCESS_OK);
}
Aggregations