-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peter Nied <[email protected]>
- Loading branch information
Showing
11 changed files
with
254 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
server/src/test/java/org/opensearch/action/admin/indices/view/DeleteViewRequestTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.view; | ||
|
||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.core.common.io.stream.Writeable; | ||
import org.opensearch.test.AbstractWireSerializingTestCase; | ||
import org.hamcrest.MatcherAssert; | ||
|
||
import static org.hamcrest.Matchers.contains; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
public class DeleteViewRequestTests extends AbstractWireSerializingTestCase<DeleteViewAction.Request> { | ||
|
||
@Override | ||
protected Writeable.Reader<DeleteViewAction.Request> instanceReader() { | ||
return DeleteViewAction.Request::new; | ||
} | ||
|
||
@Override | ||
protected DeleteViewAction.Request createTestInstance() { | ||
return new DeleteViewAction.Request(randomAlphaOfLength(8)); | ||
} | ||
|
||
public void testValidateRequest() { | ||
final DeleteViewAction.Request request = new DeleteViewAction.Request("my-view"); | ||
|
||
MatcherAssert.assertThat(request.validate(), nullValue()); | ||
} | ||
|
||
public void testValidateRequestWithoutName() { | ||
final DeleteViewAction.Request request = new DeleteViewAction.Request(""); | ||
final ActionRequestValidationException e = request.validate(); | ||
|
||
MatcherAssert.assertThat(e.validationErrors(), contains("name cannot be empty or null")); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
server/src/test/java/org/opensearch/action/admin/indices/view/GetViewResponseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.view; | ||
|
||
import org.opensearch.cluster.metadata.View; | ||
import org.opensearch.core.common.io.stream.Writeable; | ||
import org.opensearch.test.AbstractWireSerializingTestCase; | ||
|
||
public class GetViewResponseTests extends AbstractWireSerializingTestCase<GetViewAction.Response> { | ||
|
||
@Override | ||
protected Writeable.Reader<GetViewAction.Response> instanceReader() { | ||
return GetViewAction.Response::new; | ||
} | ||
|
||
@Override | ||
protected GetViewAction.Response createTestInstance() { | ||
return new GetViewAction.Response( | ||
new View( | ||
randomAlphaOfLength(8), | ||
randomAlphaOfLength(8), | ||
randomLong(), | ||
randomLong(), | ||
randomList(5, () -> new View.Target(randomAlphaOfLength(8))) | ||
) | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
server/src/test/java/org/opensearch/action/admin/indices/view/ListViewNamesRequestTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.view; | ||
|
||
import org.opensearch.core.common.io.stream.Writeable; | ||
import org.opensearch.test.AbstractWireSerializingTestCase; | ||
import org.hamcrest.MatcherAssert; | ||
|
||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
public class ListViewNamesRequestTests extends AbstractWireSerializingTestCase<ListViewNamesAction.Request> { | ||
|
||
@Override | ||
protected Writeable.Reader<ListViewNamesAction.Request> instanceReader() { | ||
return ListViewNamesAction.Request::new; | ||
} | ||
|
||
@Override | ||
protected ListViewNamesAction.Request createTestInstance() { | ||
return new ListViewNamesAction.Request(); | ||
} | ||
|
||
public void testValidateRequest() { | ||
final ListViewNamesAction.Request request = new ListViewNamesAction.Request(); | ||
|
||
MatcherAssert.assertThat(request.validate(), nullValue()); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...er/src/test/java/org/opensearch/action/admin/indices/view/ListViewNamesResponseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.view; | ||
|
||
import org.opensearch.core.common.io.stream.Writeable; | ||
import org.opensearch.test.AbstractWireSerializingTestCase; | ||
|
||
public class ListViewNamesResponseTests extends AbstractWireSerializingTestCase<ListViewNamesAction.Response> { | ||
|
||
@Override | ||
protected Writeable.Reader<ListViewNamesAction.Response> instanceReader() { | ||
return ListViewNamesAction.Response::new; | ||
} | ||
|
||
@Override | ||
protected ListViewNamesAction.Response createTestInstance() { | ||
return new ListViewNamesAction.Response(randomList(5, () -> randomAlphaOfLength(8))); | ||
} | ||
} |
Oops, something went wrong.