private ElasticPlacementZoneConfigurationState getState(String rpLink) throws Throwable { return getDocument(ElasticPlacementZoneConfigurationState.class, ElasticPlacementZoneConfigurationService.SELF_LINK + rpLink); } }
@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 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); }