@Test public void testQueryWithoutFilter() throws Exception { resource.setUriInfo(setUpBasicUriExpectations()); setUpGetEntityExpectations(false, true); control.replay(); resource.get(); }
@Test(expected = javax.ws.rs.WebApplicationException.class) public void testQueryWithFilter() throws Exception { List<String> filterValue = new ArrayList<String>(); filterValue.add("true"); EasyMock.reset(httpHeaders); expect(httpHeaders.getRequestHeader(USER_FILTER_HEADER)).andReturn(filterValue); resource.setUriInfo(setUpBasicUriExpectations()); control.replay(); resource.get(); }
@Test(expected = MalformedIdException.class) public void testBadGuidValidation() throws Exception { setUpGetEntityExpectations(false, false); Host host = new Host(); host.setCluster(new Cluster()); host.getCluster().setId("!!!"); control.replay(); resource.update(host); }
@Test public void testActionWithCorrelationId() throws Exception { setUpGetEntityExpectations(false, false); expect(httpHeaders.getRequestHeader("Correlation-Id")) .andReturn(asList("Some-Correlation-id")) .anyTimes(); resource.setUriInfo( (setUpActionExpectations( VdcActionType.UpdateVds, UpdateVdsActionParameters.class, new String[] {"RootPassword", "CorrelationId"}, new Object[] {NAMES[2], "Some-Correlation-id"}, true, true))); Action action = new Action(); action.setRootPassword(NAMES[2]); resource.install(action); }
@Test public void testUpdateCantDo() throws Exception { setUpGetEntityWithNoCertificateInfoExpectations(1); resource.setUriInfo( setUpActionExpectations( VdcActionType.UpdateVds, UpdateVdsActionParameters.class, new String[] {"RootPassword"}, new Object[] {ROOT_PASSWORD}, false, true, "ACTION_TYPE_FAILED_IMPORT_DISKS_ALREADY_EXIST")); try { resource.update(getModel(0)); fail("expected WebApplicationException"); } catch (WebApplicationException wae) { verifyFault(wae, "ACTION_TYPE_FAILED_IMPORT_DISKS_ALREADY_EXIST", 409); } }
@Override protected void init() { resource = new BackendHostResource(GUIDS[0].toString(), new BackendHostsResource()); resource.setBackend(backend); resource.setMappingLocator(mapperLocator); resource.setValidatorLocator(validatorLocator); resource.setSessionHelper(sessionHelper); resource.setMessageBundle(messageBundle); resource.setHttpHeaders(httpHeaders); }
@Override public void setUp() { super.setUp(); setUpParentMock(resource.getParent()); }