Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
#186 Implementation of DeleteMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisThareau committed Mar 13, 2015
1 parent e959f0f commit 7c994ba
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
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);
}
}
}
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);
}

}

0 comments on commit 7c994ba

Please sign in to comment.