@Test(expected = LocalizableValidationException.class) public void testDeleteNoLinkInUrl() throws Throwable { String rpLink = createRp().documentSelfLink; ElasticPlacementZoneConfigurationState state = createState(false); state.resourcePoolState.documentSelfLink = rpLink; sendState(state, Action.DELETE); }
@Test public void testGetAllNoExpand() throws Throwable { String rp1Link = createRp().documentSelfLink; String rp2Link = createRp().documentSelfLink; URI serviceUri = UriUtils.buildUri(host, ElasticPlacementZoneConfigurationService.SELF_LINK); ServiceDocumentQueryResult queryResult = doOperation(null, serviceUri, ServiceDocumentQueryResult.class, false, Action.GET); assertNotNull(queryResult); assertNull(queryResult.documents); assertTrue(queryResult.documentCount >= 2); assertTrue(queryResult.documentLinks.contains(rp1Link)); assertTrue(queryResult.documentLinks.contains(rp2Link)); }
@Test public void testGetNoEpz() throws Throwable { String rpLink = createRp().documentSelfLink; ElasticPlacementZoneConfigurationState state = getState(rpLink); assertNotNull(state.resourcePoolState.query); assertNull(state.epzState); }
@Test public void testDeleteNoEpz() throws Throwable { String rpLink = createRp().documentSelfLink; ElasticPlacementZoneConfigurationState state = createState(false); state.resourcePoolState.documentSelfLink = rpLink; delete(ElasticPlacementZoneConfigurationService.SELF_LINK + rpLink); assertNull(searchForDocument(ResourcePoolState.class, rpLink)); }
@Test public void testGetWithEpz() throws Throwable { String rpLink = createRp().documentSelfLink; String epzLink = createEpz(rpLink, "tag1").documentSelfLink; ElasticPlacementZoneConfigurationState state = getState(rpLink); assertNotNull(state.resourcePoolState.query); assertNotNull(state.epzState); assertEquals(epzLink, state.epzState.documentSelfLink); }
@Test public void testDeleteWithEpz() throws Throwable { String rpLink = createRp().documentSelfLink; String epzLink = createEpz(rpLink, "tag1").documentSelfLink; ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState.documentSelfLink = rpLink; state.epzState.documentSelfLink = epzLink; delete(ElasticPlacementZoneConfigurationService.SELF_LINK + rpLink); assertNull(searchForDocument(ResourcePoolState.class, rpLink)); assertNull(searchForDocument(ElasticPlacementZoneState.class, epzLink)); }
@Test public void testGetAllExpand() throws Throwable { String rp1Link = createRp().documentSelfLink; String rp2Link = createRp().documentSelfLink; String epzLink = createEpz(rp2Link, "tag1").documentSelfLink; URI serviceUri = UriUtils.buildUri(host, ElasticPlacementZoneConfigurationService.SELF_LINK); ServiceDocumentQueryResult queryResult = doOperation(null, UriUtils.buildExpandLinksQueryUri(serviceUri), ServiceDocumentQueryResult.class, false, Action.GET); assertNotNull(queryResult); assertNotNull(queryResult.documents); assertTrue(queryResult.documentCount >= 2); Map<String, ElasticPlacementZoneConfigurationState> states = QueryUtil.extractQueryResult( queryResult, ElasticPlacementZoneConfigurationState.class); ElasticPlacementZoneConfigurationState state1 = states.get(rp1Link); assertNotNull(state1); assertNotNull(state1.resourcePoolState); assertNull(state1.epzState); assertEquals(rp1Link, state1.documentSelfLink); assertEquals(rp1Link, state1.resourcePoolState.documentSelfLink); ElasticPlacementZoneConfigurationState state2 = states.get(rp2Link); assertNotNull(state2); assertNotNull(state2.resourcePoolState); assertNotNull(state2.epzState); assertEquals(rp2Link, state2.documentSelfLink); assertEquals(rp2Link, state2.resourcePoolState.documentSelfLink); assertEquals(epzLink, state2.epzState.documentSelfLink); assertEquals(state2.resourcePoolState.documentSelfLink, state2.epzState.resourcePoolLink); assertEquals(tagSet("tag1"), state2.epzState.tagLinksToMatch); }