@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 testUpdateNoChange() throws Throwable { // create through the config service ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); // update through the config service ElasticPlacementZoneConfigurationState patchState = createState(false); patchState.resourcePoolState = buildRpState(); patchState.resourcePoolState.documentSelfLink = createdState.resourcePoolState.documentSelfLink; ElasticPlacementZoneConfigurationState latestState = sendState(patchState, Action.PATCH); // validate returned state assertNull(latestState.resourcePoolState); assertNull(latestState.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 testUpdateNoEpz() throws Throwable { // create through the config service ElasticPlacementZoneConfigurationState state = createState(false); state.resourcePoolState = buildRpState(); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); // update through the config service ElasticPlacementZoneConfigurationState patchState = createState(false); patchState.resourcePoolState.documentSelfLink = createdState.resourcePoolState.documentSelfLink; patchState.resourcePoolState.name = "new-name"; ElasticPlacementZoneConfigurationState latestState = sendState(patchState, Action.PATCH); // validate returned state assertEquals("new-name", latestState.resourcePoolState.name); assertNotNull(latestState.resourcePoolState.query); // validate the actual RP state ResourcePoolState rp = getDocument(ResourcePoolState.class, createdState.resourcePoolState.documentSelfLink); assertEquals("new-name", rp.name); }
@Test public void testUpdateAddingEpz() throws Throwable { // create through the config service with no EPZ ElasticPlacementZoneConfigurationState state = createState(false); state.resourcePoolState = buildRpState(); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); // add EPZ through the config service ElasticPlacementZoneConfigurationState patchState = createState(false); patchState.resourcePoolState.documentSelfLink = createdState.resourcePoolState.documentSelfLink; patchState.epzState = buildEpzState(patchState.resourcePoolState.documentSelfLink, "tag3", "tag4"); ElasticPlacementZoneConfigurationState latestState = sendState(patchState, Action.PATCH); // validate returned state assertNotNull(latestState.epzState); assertNotNull(latestState.epzState.documentSelfLink); assertEquals(patchState.epzState.tagLinksToMatch, latestState.epzState.tagLinksToMatch); // validate the actual EPZ state ElasticPlacementZoneState epz = getDocument(ElasticPlacementZoneState.class, latestState.epzState.documentSelfLink); assertEquals(patchState.epzState.tagLinksToMatch, epz.tagLinksToMatch); }
@Test public void testCreateNoEpz() throws Throwable { ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); ElasticPlacementZoneConfigurationState returnedState = sendState(state, Action.POST); assertNotNull(returnedState.resourcePoolState.documentSelfLink); assertNotNull(searchForDocument(ResourcePoolState.class, returnedState.resourcePoolState.documentSelfLink)); assertEquals(state.resourcePoolState.name, returnedState.resourcePoolState.name); }
@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 testCreateDelete() throws Throwable { ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); state.epzState = buildEpzState(null, "tag1", "tag2"); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); delete(ElasticPlacementZoneConfigurationService.SELF_LINK + createdState.resourcePoolState.documentSelfLink); assertNull( searchForDocument(ResourcePoolState.class, createdState.resourcePoolState.documentSelfLink)); assertNull(searchForDocument(ElasticPlacementZoneState.class, createdState.epzState.documentSelfLink)); }
@Test public void testUpdateWithEpz() throws Throwable { // create through the config service ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); state.epzState = buildEpzState(null, "tag1", "tag2"); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); // update through the config service ElasticPlacementZoneConfigurationState patchState = createState(true); patchState.resourcePoolState.documentSelfLink = createdState.resourcePoolState.documentSelfLink; patchState.resourcePoolState.name = "new-name"; patchState.epzState = buildEpzState(patchState.resourcePoolState.documentSelfLink, "tag3", "tag4"); patchState.epzState.documentSelfLink = createdState.epzState.documentSelfLink; ElasticPlacementZoneConfigurationState latestState = sendState(patchState, Action.PATCH); // validate returned state assertEquals("new-name", latestState.resourcePoolState.name); assertNotNull(latestState.resourcePoolState.query); assertEquals(patchState.epzState.tagLinksToMatch, latestState.epzState.tagLinksToMatch); // validate the actual RP state ResourcePoolState rp = getDocument(ResourcePoolState.class, createdState.resourcePoolState.documentSelfLink); assertEquals("new-name", rp.name); // validate the actual EPZ state ElasticPlacementZoneState epz = getDocument(ElasticPlacementZoneState.class, createdState.epzState.documentSelfLink); assertEquals(patchState.epzState.tagLinksToMatch, epz.tagLinksToMatch); }
@Test public void testCreateWithEpz() throws Throwable { ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); state.epzState = buildEpzState(null, "tag1", "tag2"); ElasticPlacementZoneConfigurationState returnedState = sendState(state, Action.POST); assertNotNull(returnedState.resourcePoolState.documentSelfLink); assertNotNull(searchForDocument(ResourcePoolState.class, returnedState.resourcePoolState.documentSelfLink)); assertNotNull(returnedState.epzState.documentSelfLink); assertNotNull(searchForDocument(ElasticPlacementZoneState.class, returnedState.epzState.documentSelfLink)); assertEquals(state.resourcePoolState.name, returnedState.resourcePoolState.name); assertEquals(state.epzState.tagLinksToMatch, returnedState.epzState.tagLinksToMatch); }