Skip to content

Commit

Permalink
small changes according to code review, moved some static initializat…
Browse files Browse the repository at this point in the history
…ion to own method, removed super call
  • Loading branch information
AndreaSuckro committed Oct 16, 2016
1 parent 2659e95 commit 71daf6f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2016 Intuit
*
* <p>
* Licensed 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -18,40 +18,42 @@
import com.intuit.wasabi.experimentobjects.Application;
import com.intuit.wasabi.experimentobjects.Bucket;
import com.intuit.wasabi.experimentobjects.Experiment;
import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


/**
* This is the test class for {@link ExperimentDetail}.
*/
public class ExperimentDetailTest {

Experiment.ID expId = Experiment.ID.newInstance();
Experiment.Label expLabel = Experiment.Label.valueOf("TestLabelForExperimentDetail");
Experiment.State expState = Experiment.State.RUNNING;
Application.Name appName = Application.Name.valueOf("TestApplicationLabelForExperimentDetail");
Calendar modTime = Calendar.getInstance();
Calendar startTime = Calendar.getInstance();
Calendar endTime = Calendar.getInstance();
private Experiment.ID expId = Experiment.ID.newInstance();
private Experiment.Label expLabel = Experiment.Label.valueOf("TestLabelForExperimentDetail");
private Experiment.State expState = Experiment.State.RUNNING;
private Application.Name appName = Application.Name.valueOf("TestApplicationLabelForExperimentDetail");
private static Calendar modTime = Calendar.getInstance();
private static Calendar startTime = Calendar.getInstance();
private static Calendar endTime = Calendar.getInstance();


private Experiment exp = Experiment.withID(expId).withApplicationName(appName).withModificationTime(modTime.getTime())
.withLabel(expLabel).withStartTime(startTime.getTime()).withState(Experiment.State.TERMINATED).build();

{
@BeforeClass
public static void setUp() {
modTime.set(2016, 8, 16);
startTime.set(2016, 8, 1);
endTime.set(2017, 10, 12);

}

Experiment exp = Experiment.withID(expId).withApplicationName(appName).withModificationTime(modTime.getTime())
.withLabel(expLabel).withStartTime(startTime.getTime()).withState(Experiment.State.TERMINATED).build();


@Test
public void testConstructor() {
ExperimentDetail expDetail = new ExperimentDetail(expId, expState, expLabel, appName, modTime.getTime(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class ExperimentDetailsImpl implements ExperimentDetails {
@Inject
public ExperimentDetailsImpl(@CassandraRepository ExperimentRepository cassandraRepository,
Buckets buckets, Analytics analytics) {
super();
this.cassandraRepository = cassandraRepository;
this.buckets = buckets;
this.analytics = analytics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ public Response toResponse(final T e) {

private String serialize(final Status status, final Throwable exception) {
Throwable exceptionCause = exception;
int levels = 0;
while (Objects.isNull(exceptionCause.getMessage()) && Objects.nonNull(exceptionCause.getCause())) {
exceptionCause = exceptionCause.getCause();
levels++;
}
return exceptionJsonifier.serialize(status, exceptionCause.getMessage());
}
Expand Down

0 comments on commit 71daf6f

Please sign in to comment.