Skip to content

Commit

Permalink
GEODE-7409: get latest PDX configuration of cluster in REST API for M…
Browse files Browse the repository at this point in the history
…anagement (apache#4329)

* throw ENTITY_NOT_FOUND exception when no pdx configuration is found
  • Loading branch information
jinmeiliao authored Nov 15, 2019
1 parent c9e75e6 commit 016620a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public void delete(Pdx config, CacheConfig existing) {

@Override
public List<Pdx> list(Pdx filterConfig, CacheConfig existing) {
return Collections.singletonList(pdxConverter.fromXmlObject(existing.getPdx()));
Pdx configuration = pdxConverter.fromXmlObject(existing.getPdx());
if (configuration == null) {
return Collections.emptyList();
}
return Collections.singletonList(configuration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package org.apache.geode.management.internal.configuration.mutators;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

import org.junit.Before;
import org.junit.Test;

import org.apache.geode.cache.configuration.CacheConfig;

public class PdxManagerTest {
private PdxManager manager;
private CacheConfig config;

@Before
public void before() throws Exception {
manager = new PdxManager();
config = mock(CacheConfig.class);
}

@Test
public void emptyListWhenPdxNotExist() throws Exception {
assertThat(manager.list(null, config)).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ InternalLocator getLocator() {

@Test
public void configureWithNoServer() throws Exception {
// verify the get
assertThatThrownBy(() -> client.get(new Pdx())).isInstanceOf(ClusterManagementException.class)
.hasMessageContaining("ENTITY_NOT_FOUND");

pdxType.setReadSerialized(true);
ClusterManagementRealizationResult result = client.create(pdxType);
assertThat(result.isSuccessful()).isTrue();
Expand All @@ -114,6 +118,8 @@ public void configureWithNoServer() throws Exception {

@Test
public void configureWithARunningServer() {
assertThatThrownBy(() -> client.get(new Pdx())).isInstanceOf(ClusterManagementException.class)
.hasMessageContaining("ENTITY_NOT_FOUND");
MemberVM server = cluster.startServerVM(1, webContext.getLocator().getPort());
pdxType.setReadSerialized(true);
ClusterManagementRealizationResult result = client.create(pdxType);
Expand Down

0 comments on commit 016620a

Please sign in to comment.