]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8464 SONAR-8466 WS drop description param to create or udpate an event
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 21 Dec 2016 10:04:02 +0000 (11:04 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 21 Dec 2016 10:52:10 +0000 (11:52 +0100)
12 files changed:
server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java
server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/UpdateEventAction.java
server/sonar-server/src/main/resources/org/sonar/server/projectanalysis/ws/create_event-example.json
server/sonar-server/src/main/resources/org/sonar/server/projectanalysis/ws/update_event-example.json
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java
sonar-db/src/test/java/org/sonar/db/event/EventTesting.java
sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParameters.java
sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequest.java
sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java
sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequestTest.java

index affcfb36e9332c395bd25a82f4cd0004d8bc3720..f2359791b87ed203e82b90c67fa70f6122edbb1c 100644 (file)
@@ -54,7 +54,6 @@ import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.fromLabel;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_ANALYSIS;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY;
-import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_DESCRIPTION;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME;
 
 public class CreateEventAction implements ProjectAnalysesWsAction {
@@ -98,10 +97,6 @@ public class CreateEventAction implements ProjectAnalysesWsAction {
       .setDescription("Name")
       .setExampleValue("5.6")
       .setRequired(true);
-
-    action.createParam(PARAM_DESCRIPTION)
-      .setDescription("Description")
-      .setExampleValue("Version released");
   }
 
   @Override
@@ -151,7 +146,6 @@ public class CreateEventAction implements ProjectAnalysesWsAction {
       .setAnalysis(request.mandatoryParam(PARAM_ANALYSIS))
       .setName(request.mandatoryParam(PARAM_NAME))
       .setCategory(request.mandatoryParamAsEnum(PARAM_CATEGORY, EventCategory.class))
-      .setDescription(request.param(PARAM_DESCRIPTION))
       .build();
   }
 
@@ -162,7 +156,6 @@ public class CreateEventAction implements ProjectAnalysesWsAction {
       .setComponentUuid(analysis.getComponentUuid())
       .setCategory(request.getCategory().getLabel())
       .setName(request.getName())
-      .setDescription(request.getDescription())
       .setCreatedAt(system.now())
       .setDate(analysis.getCreatedAt());
   }
index 652e02f00c6548a1d82c0c4327d969bc495a3ccc..49aedaa0dd5d3d50ccab115e3fc89d4e259489da 100644 (file)
@@ -45,7 +45,6 @@ import static org.sonar.server.projectanalysis.ws.EventValidator.checkModifiable
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.fromLabel;
-import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_DESCRIPTION;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_EVENT;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME;
 
@@ -79,10 +78,6 @@ public class UpdateEventAction implements ProjectAnalysesWsAction {
     action.createParam(PARAM_NAME)
       .setDescription("New name")
       .setExampleValue("5.6");
-
-    action.createParam(PARAM_DESCRIPTION)
-      .setDescription("New description")
-      .setExampleValue("Version released");
   }
 
   @Override
@@ -152,7 +147,6 @@ public class UpdateEventAction implements ProjectAnalysesWsAction {
   private static Function<EventDto, EventDto> updateNameAndDescription(UpdateEventRequest request) {
     return event -> {
       setNullable(request.getName(), event::setName);
-      setNullable(request.getDescription(), event::setDescription);
       return event;
     };
   }
@@ -173,7 +167,6 @@ public class UpdateEventAction implements ProjectAnalysesWsAction {
   private static Function<Request, UpdateEventRequest> toUpdateEventRequest() {
     return request -> new UpdateEventRequest(
       request.mandatoryParam(PARAM_EVENT),
-      request.param(PARAM_NAME),
-      request.param(PARAM_DESCRIPTION));
+      request.param(PARAM_NAME));
   }
 }
index 14e486d5b6038c0ed931a0af7148d5aa2078478f..2c4917e3e5866bf2c90bb3590d6da54b270eb2e7 100644 (file)
@@ -4,6 +4,5 @@
     "key": "E1",
     "category": "OTHER",
     "name": "My Custom Event",
-    "description": "event description"
   }
 }
index 14e486d5b6038c0ed931a0af7148d5aa2078478f..2c4917e3e5866bf2c90bb3590d6da54b270eb2e7 100644 (file)
@@ -4,6 +4,5 @@
     "key": "E1",
     "category": "OTHER",
     "name": "My Custom Event",
-    "description": "event description"
   }
 }
index 3070200a4012fbedaa12b836a2ac6c1972389ef1..3a89c856ce35e2da6e6e815ed8b81f2eed68e43d 100644 (file)
@@ -64,7 +64,6 @@ import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_ANALYSIS;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY;
-import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_DESCRIPTION;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME;
 
 public class CreateEventActionTest {
@@ -101,7 +100,6 @@ public class CreateEventActionTest {
       .setParam(PARAM_ANALYSIS, analysis.getUuid())
       .setParam(PARAM_CATEGORY, OTHER.name())
       .setParam(PARAM_NAME, "My Custom Event")
-      .setParam(PARAM_DESCRIPTION, "event description")
       .execute().getInput();
 
     assertJson(result).isSimilarTo(getClass().getResource("create_event-example.json"));
@@ -113,8 +111,7 @@ public class CreateEventActionTest {
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
       .setCategory(VERSION)
-      .setName("5.6.3")
-      .setDescription("LTS version");
+      .setName("5.6.3");
     when(system.now()).thenReturn(123_456_789L);
 
     CreateEventResponse result = call(request);
@@ -124,7 +121,7 @@ public class CreateEventActionTest {
     EventDto dbEvent = dbEvents.get(0);
     assertThat(dbEvent.getName()).isEqualTo("5.6.3");
     assertThat(dbEvent.getCategory()).isEqualTo(VERSION.getLabel());
-    assertThat(dbEvent.getDescription()).isEqualTo("LTS version");
+    assertThat(dbEvent.getDescription()).isNull();
     assertThat(dbEvent.getAnalysisUuid()).isEqualTo(analysis.getUuid());
     assertThat(dbEvent.getComponentUuid()).isEqualTo(analysis.getComponentUuid());
     assertThat(dbEvent.getUuid()).isEqualTo(result.getEvent().getKey());
@@ -138,8 +135,7 @@ public class CreateEventActionTest {
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
       .setCategory(VERSION)
-      .setName("5.6.3")
-      .setDescription("LTS version");
+      .setName("5.6.3");
     userSession.anonymous().addProjectUuidPermissions(UserRole.ADMIN, "P1");
 
     CreateEventResponse result = call(request);
@@ -153,8 +149,7 @@ public class CreateEventActionTest {
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
       .setCategory(VERSION)
-      .setName("5.6.3")
-      .setDescription("LTS version");
+      .setName("5.6.3");
 
     call(request);
 
@@ -167,19 +162,18 @@ public class CreateEventActionTest {
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto());
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
-      .setName("Project Import")
-      .setDescription("Import from another instance");
+      .setName("Project Import");
 
     CreateEventResponse result = call(request);
 
     SnapshotDto newAnalysis = dbClient.snapshotDao().selectByUuid(dbSession, analysis.getUuid()).get();
     assertThat(analysis.getVersion()).isEqualTo(newAnalysis.getVersion());
-    ProjectAnalyses.Event event = result.getEvent();
-    assertThat(event.getKey()).isNotEmpty();
-    assertThat(event.getCategory()).isEqualTo(OTHER.name());
-    assertThat(event.getName()).isEqualTo("Project Import");
-    assertThat(event.getDescription()).isEqualTo("Import from another instance");
-    assertThat(event.getAnalysis()).isEqualTo(analysis.getUuid());
+    ProjectAnalyses.Event wsEvent = result.getEvent();
+    assertThat(wsEvent.getKey()).isNotEmpty();
+    assertThat(wsEvent.getCategory()).isEqualTo(OTHER.name());
+    assertThat(wsEvent.getName()).isEqualTo("Project Import");
+    assertThat(wsEvent.hasDescription()).isFalse();
+    assertThat(wsEvent.getAnalysis()).isEqualTo(analysis.getUuid());
   }
 
   @Test
@@ -309,8 +303,7 @@ public class CreateEventActionTest {
     CreateEventRequest.Builder request = CreateEventRequest.builder()
       .setAnalysis(analysis.getUuid())
       .setCategory(VERSION)
-      .setName("5.6.3")
-      .setDescription("LTS version");
+      .setName("5.6.3");
     userSession.anonymous();
 
     expectedException.expect(ForbiddenException.class);
@@ -338,10 +331,6 @@ public class CreateEventActionTest {
       .setParam(PARAM_NAME, request.getName())
       .setParam(PARAM_ANALYSIS, request.getAnalysis());
 
-    if (request.getDescription() != null) {
-      httpRequest.setParam(PARAM_DESCRIPTION, request.getDescription());
-    }
-
     try {
       return CreateEventResponse.parseFrom(httpRequest.execute().getInputStream());
     } catch (IOException e) {
index f9ec5d1705541e3a37d2bdc54138096fb01c11d3..fb57981901036801321f581c8aa087ea2d4039bf 100644 (file)
@@ -54,7 +54,6 @@ import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.client.WsRequest.Method.POST;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER;
 import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION;
-import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_DESCRIPTION;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_EVENT;
 import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME;
 
@@ -83,36 +82,35 @@ public class UpdateEventActionTest {
     String result = ws.newRequest()
       .setParam(PARAM_EVENT, "E1")
       .setParam(PARAM_NAME, "My Custom Event")
-      .setParam(PARAM_DESCRIPTION, "event description")
       .execute().getInput();
 
     assertJson(result).isSimilarTo(getClass().getResource("update_event-example.json"));
   }
 
   @Test
-  public void update_name_and_description_in_db() {
+  public void update_name_in_db() {
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto());
-    EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name").setDescription("Original Description"));
+    EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name"));
 
-    call("E1", "name", "description");
+    call("E1", "name");
 
     EventDto newEvent = dbClient.eventDao().selectByUuid(dbSession, "E1").get();
     assertThat(newEvent.getName()).isEqualTo("name");
-    assertThat(newEvent.getDescription()).isEqualTo("description");
+    assertThat(newEvent.getDescription()).isNull();
     assertThat(newEvent.getCategory()).isEqualTo(originalEvent.getCategory());
     assertThat(newEvent.getDate()).isEqualTo(originalEvent.getDate());
     assertThat(newEvent.getCreatedAt()).isEqualTo(originalEvent.getCreatedAt());
   }
 
   @Test
-  public void ws_response_with_updated_name_and_description() {
+  public void ws_response_with_updated_name() {
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto());
-    EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name").setDescription("Original Description"));
+    EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name"));
 
-    ProjectAnalyses.Event result = call("E1", "name", "description").getEvent();
+    ProjectAnalyses.Event result = call("E1", "name").getEvent();
 
     assertThat(result.getName()).isEqualTo("name");
-    assertThat(result.getDescription()).isEqualTo("description");
+    assertThat(result.hasDescription()).isFalse();
     assertThat(result.getCategory()).isEqualTo(OTHER.name());
     assertThat(result.getAnalysis()).isEqualTo(originalEvent.getAnalysisUuid());
     assertThat(result.getKey()).isEqualTo("E1");
@@ -124,7 +122,7 @@ public class UpdateEventActionTest {
     SnapshotDto analysis = db.components().insertSnapshot(newAnalysis(project).setVersion("5.6"));
     db.events().insertEvent(newEvent(analysis).setUuid("E1").setCategory(VERSION.getLabel()));
 
-    call("E1", "6.3", null);
+    call("E1", "6.3");
 
     SnapshotDto updatedAnalysis = dbClient.snapshotDao().selectByUuid(dbSession, analysis.getUuid()).get();
     assertThat(updatedAnalysis.getVersion()).isEqualTo("6.3");
@@ -136,7 +134,7 @@ public class UpdateEventActionTest {
     SnapshotDto analysis = db.components().insertSnapshot(newAnalysis(project).setVersion("5.6"));
     db.events().insertEvent(newEvent(analysis).setUuid("E1").setCategory(OTHER.getLabel()));
 
-    call("E1", "6.3", null);
+    call("E1", "6.3");
 
     SnapshotDto updatedAnalysis = dbClient.snapshotDao().selectByUuid(dbSession, analysis.getUuid()).get();
     assertThat(updatedAnalysis.getVersion()).isEqualTo("5.6");
@@ -147,7 +145,7 @@ public class UpdateEventActionTest {
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto());
     EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name").setDescription("Original Description"));
 
-    call("E1", "name", null);
+    call("E1", "name");
 
     EventDto newEvent = dbClient.eventDao().selectByUuid(dbSession, "E1").get();
     assertThat(newEvent.getName()).isEqualTo("name");
@@ -157,26 +155,14 @@ public class UpdateEventActionTest {
   @Test
   public void update_as_project_admin() {
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto("P1"));
-    db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name").setDescription("Original Description"));
+    db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name"));
     userSession.anonymous().addProjectUuidPermissions(UserRole.ADMIN, "P1");
 
-    call("E1", "name", "description");
+    call("E1", "name");
 
     EventDto newEvent = dbClient.eventDao().selectByUuid(dbSession, "E1").get();
     assertThat(newEvent.getName()).isEqualTo("name");
-    assertThat(newEvent.getDescription()).isEqualTo("description");
-  }
-
-  @Test
-  public void update_description_only_in_db() {
-    SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto());
-    EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name").setDescription("Original Description"));
-
-    call("E1", null, "description");
-
-    EventDto newEvent = dbClient.eventDao().selectByUuid(dbSession, "E1").get();
-    assertThat(newEvent.getName()).isEqualTo(originalEvent.getName());
-    assertThat(newEvent.getDescription()).isEqualTo("description");
+    assertThat(newEvent.getDescription()).isNull();
   }
 
   @Test
@@ -198,7 +184,7 @@ public class UpdateEventActionTest {
 
     expectedException.expect(ForbiddenException.class);
 
-    call("E1", "name", "description");
+    call("E1", "name");
   }
 
   @Test
@@ -206,17 +192,17 @@ public class UpdateEventActionTest {
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Event 'E42' not found");
 
-    call("E42", "name", "description");
+    call("E42", "name");
   }
 
   @Test
-  public void fail_if_no_name_nor_description() {
+  public void fail_if_no_name() {
     SnapshotDto analysis = db.components().insertProjectAndSnapshot(newProjectDto());
     db.events().insertEvent(newEvent(analysis).setUuid("E1"));
 
-    expectedException.expect(IllegalArgumentException.class);
+    expectedException.expect(NullPointerException.class);
 
-    call("E1", null, null);
+    call("E1", null);
   }
 
   @Test
@@ -227,7 +213,7 @@ public class UpdateEventActionTest {
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("Event of category 'Profile' cannot be modified. Authorized categories: Version, Other");
 
-    call("E1", "name", "description");
+    call("E1", "name");
   }
 
   @Test
@@ -239,16 +225,15 @@ public class UpdateEventActionTest {
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("An 'Other' event with the same name already exists on analysis '" + analysis.getUuid() + "'");
 
-    call("E2", "E1 name", "description");
+    call("E2", "E1 name");
   }
 
-  private UpdateEventResponse call(@Nullable String eventUuid, @Nullable String name, @Nullable String description) {
+  private UpdateEventResponse call(@Nullable String eventUuid, @Nullable String name) {
     TestRequest request = ws.newRequest()
       .setMethod(POST.name())
       .setMediaType(MediaTypes.PROTOBUF);
     setNullable(eventUuid, e -> request.setParam(PARAM_EVENT, e));
     setNullable(name, n -> request.setParam(PARAM_NAME, n));
-    setNullable(description, d -> request.setParam(PARAM_DESCRIPTION, d));
 
     try {
       return UpdateEventResponse.parseFrom(request.execute().getInputStream());
index 74f23358470fa35f08039dce3fd637ece21694f9..49b75a7d9f316306c78cb9526ef2257f7e6db5d2 100644 (file)
@@ -36,7 +36,7 @@ public class EventTesting {
       .setComponentUuid(analysis.getComponentUuid())
       .setUuid(randomAlphanumeric(40))
       .setName(randomAlphanumeric(400))
-      .setDescription(randomAlphanumeric(400))
+      .setDescription(null)
       .setCategory("Other")
       .setComponentUuid(analysis.getComponentUuid())
       .setCreatedAt(System.currentTimeMillis())
index b9299a3be38eb819718ea7785a0a0ddc25b33ca2..0892fed031012813d677390827dd2fb8b722c38a 100644 (file)
 
 package org.sonarqube.ws.client.projectanalysis;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
 import static com.google.common.base.Preconditions.checkArgument;
+import static org.apache.commons.lang.StringUtils.isNotBlank;
 
 public class CreateEventRequest {
   private final String analysis;
   private final EventCategory category;
   private final String name;
-  private final String description;
 
   private CreateEventRequest(Builder builder) {
     analysis = builder.analysis;
     category = builder.category;
     name = builder.name;
-    description = builder.description;
   }
 
   public String getAnalysis() {
@@ -50,11 +46,6 @@ public class CreateEventRequest {
     return name;
   }
 
-  @CheckForNull
-  public String getDescription() {
-    return description;
-  }
-
   public static Builder builder() {
     return new Builder();
   }
@@ -63,7 +54,6 @@ public class CreateEventRequest {
     private String analysis;
     private EventCategory category = EventCategory.OTHER;
     private String name;
-    private String description;
 
     private Builder() {
       // enforce static factory method
@@ -84,15 +74,11 @@ public class CreateEventRequest {
       return this;
     }
 
-    public Builder setDescription(@Nullable String description) {
-      this.description = description;
-      return this;
-    }
-
     public CreateEventRequest build() {
       checkArgument(analysis != null, "Analysis key is required");
       checkArgument(category != null, "Category is required");
       checkArgument(name != null, "Name is required");
+      checkArgument(isNotBlank(name), "A non empty name is required");
 
       return new CreateEventRequest(this);
     }
index abf1e0840b8eb6d9d9a65762e5841e1248865909..bf805a00f7454b64e69b764526e87da03a718252 100644 (file)
@@ -24,7 +24,6 @@ public class ProjectAnalysesWsParameters {
   public static final String PARAM_ANALYSIS = "analysis";
   public static final String PARAM_CATEGORY = "category";
   public static final String PARAM_NAME = "name";
-  public static final String PARAM_DESCRIPTION = "description";
   public static final String PARAM_EVENT = "event";
   public static final String PARAM_PROJECT = "project";
 
index 9afeb37c12d7ba47dcfad9f9c36d06b9d22252ce..59e852a0a08a6a9c55427bcb0af447ce0b2df344 100644 (file)
 package org.sonarqube.ws.client.projectanalysis;
 
 import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
+import static org.apache.commons.lang.StringUtils.isNotBlank;
 
 public class UpdateEventRequest {
   private final String event;
   private final String name;
-  private final String description;
 
-  public UpdateEventRequest(String event, @Nullable String name, @Nullable String description) {
-    checkArgument(name != null || description != null, "Name or description is required");
+  public UpdateEventRequest(String event, String name) {
+    requireNonNull(name, "Name is required");
+    checkArgument(isNotBlank(name), "A non empty name is required");
     this.event = requireNonNull(event, "Event key is required");
     this.name = name;
-    this.description = description;
   }
 
   public String getEvent() {
@@ -46,9 +45,4 @@ public class UpdateEventRequest {
   public String getName() {
     return name;
   }
-
-  @CheckForNull
-  public String getDescription() {
-    return description;
-  }
 }
index 1d07f29b1cefaad49f2ea08a2525d97a57a9a943..9568c0850f134b78a5677b3369591bd6c24a0416 100644 (file)
@@ -37,12 +37,11 @@ public class CreateEventRequestTest {
 
   @Test
   public void build_request() {
-    CreateEventRequest result = underTest.setAnalysis("P1").setCategory(OTHER).setName("name").setDescription("description").build();
+    CreateEventRequest result = underTest.setAnalysis("P1").setCategory(OTHER).setName("name").build();
 
     assertThat(result.getAnalysis()).isEqualTo("P1");
     assertThat(result.getCategory()).isEqualTo(OTHER);
     assertThat(result.getName()).isEqualTo("name");
-    assertThat(result.getDescription()).isEqualTo("description");
   }
 
   @Test
@@ -75,4 +74,12 @@ public class CreateEventRequestTest {
 
     underTest.setAnalysis("P1").setCategory(VERSION).build();
   }
+
+  @Test
+  public void fail_when_blank_name() {
+    expectedException.expect(IllegalArgumentException.class);
+    expectedException.expectMessage("A non empty name is required");
+
+    underTest.setAnalysis("P1").setName("   ").setCategory(VERSION).build();
+  }
 }
index 43e05ad956d0b5c40a9fd1b3e738f325b9cdbd97..f2dbf27c716dde2166c57b37ca82295f76fc53ba 100644 (file)
@@ -34,29 +34,18 @@ public class UpdateEventRequestTest {
 
   @Test
   public void request_with_name_only() {
-    underTest = new UpdateEventRequest("E1", "name", null);
+    underTest = new UpdateEventRequest("E1", "name");
 
     assertThat(underTest.getEvent()).isEqualTo("E1");
     assertThat(underTest.getName()).isEqualTo("name");
-    assertThat(underTest.getDescription()).isNull();
-  }
-
-  @Test
-  public void request_with_description_only() {
-    underTest = new UpdateEventRequest("E1", null , "description");
-
-    assertThat(underTest.getEvent()).isEqualTo("E1");
-    assertThat(underTest.getName()).isNull();
-    assertThat(underTest.getDescription()).isEqualTo("description");
   }
 
   @Test
   public void request_with_all_parameters() {
-    underTest = new UpdateEventRequest("E1", "name", "description");
+    underTest = new UpdateEventRequest("E1", "name");
 
     assertThat(underTest.getEvent()).isEqualTo("E1");
     assertThat(underTest.getName()).isEqualTo("name");
-    assertThat(underTest.getDescription()).isEqualTo("description");
   }
 
   @Test
@@ -64,14 +53,22 @@ public class UpdateEventRequestTest {
     expectedException.expect(NullPointerException.class);
     expectedException.expectMessage("Event key is required");
 
-    new UpdateEventRequest(null, "name", "description");
+    new UpdateEventRequest(null, "name");
+  }
+
+  @Test
+  public void fail_if_name_not_provided() {
+    expectedException.expect(NullPointerException.class);
+    expectedException.expectMessage("Name is required");
+
+    new UpdateEventRequest("E1", null);
   }
 
   @Test
-  public void fail_if_name_and_description_not_provided() {
+  public void fail_if_name_blank() {
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Name or description is required");
+    expectedException.expectMessage("A non empty name is required");
 
-    new UpdateEventRequest("E1", null, null);
+    new UpdateEventRequest("E1", "    ");
   }
 }