Exemplo n.º 1
0
 @Test
 public void testQueryWithoutFilter() throws Exception {
   resource.setUriInfo(setUpBasicUriExpectations());
   setUpGetEntityExpectations(false, true);
   control.replay();
   resource.get();
 }
Exemplo n.º 2
0
 @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();
 }
Exemplo n.º 3
0
 @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);
 }
Exemplo n.º 4
0
 @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);
 }
Exemplo n.º 5
0
  @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);
    }
  }
Exemplo n.º 6
0
 @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);
 }
Exemplo n.º 7
0
 @Override
 public void setUp() {
   super.setUp();
   setUpParentMock(resource.getParent());
 }