This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#186 Implementation of DeleteMapping
- Loading branch information
1 parent
e959f0f
commit 7c994ba
Showing
2 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 38 additions & 1 deletion
39
jest-common/src/main/java/io/searchbox/indices/mapping/DeleteMapping.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 |
---|---|---|
@@ -1,9 +1,46 @@ | ||
package io.searchbox.indices.mapping; | ||
|
||
|
||
import io.searchbox.action.GenericResultAbstractAction; | ||
|
||
/** | ||
* @author Dogukan Sonmez | ||
* @author François Thareau | ||
*/ | ||
public class DeleteMapping extends GenericResultAbstractAction { | ||
|
||
public DeleteMapping(Builder builder) { | ||
super(builder); | ||
|
||
this.indexName = builder.index; | ||
this.typeName = builder.type; | ||
setURI(buildURI()); | ||
} | ||
|
||
@Override | ||
protected String buildURI() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(super.buildURI()).append("/_mapping"); | ||
return sb.toString(); | ||
} | ||
|
||
@Override | ||
public String getRestMethodName() { | ||
return "DELETE"; | ||
} | ||
|
||
public static class Builder extends GenericResultAbstractAction.Builder<DeleteMapping, Builder> { | ||
private String index; | ||
private String type; | ||
|
||
public Builder(String index, String type) { | ||
this.index = index; | ||
this.type = type; | ||
} | ||
|
||
public class DeleteMapping { | ||
@Override | ||
public DeleteMapping build() { | ||
return new DeleteMapping(this); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
jest-common/src/test/java/io/searchbox/indices/mapping/DeleteMappingTest.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 @@ | ||
package io.searchbox.indices.mapping; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
|
||
public class DeleteMappingTest { | ||
|
||
@Test | ||
public void testBasicUriGeneration() { | ||
DeleteMapping deleteMapping = new DeleteMapping.Builder("twitter","tweet").build(); | ||
|
||
assertEquals("DELETE", deleteMapping.getRestMethodName()); | ||
assertEquals("twitter/tweet/_mapping", deleteMapping.getURI()); | ||
} | ||
|
||
@Test | ||
public void equalsReturnsTrueForSameIndex() { | ||
DeleteMapping deleteMapping1 = new DeleteMapping.Builder("twitter","tweet").build(); | ||
DeleteMapping deleteMapping1Duplicate = new DeleteMapping.Builder("twitter","tweet").build(); | ||
|
||
assertEquals(deleteMapping1, deleteMapping1Duplicate); | ||
} | ||
|
||
@Test | ||
public void equalsReturnsFalseForDifferentIndex() { | ||
DeleteMapping deleteMapping1 = new DeleteMapping.Builder("twitter","tweet").build(); | ||
DeleteMapping deleteMapping2 = new DeleteMapping.Builder("twitter","myspace").build(); | ||
|
||
assertNotEquals(deleteMapping1, deleteMapping2); | ||
} | ||
|
||
} |