Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kata/collections/start check point #51

Open
wants to merge 34 commits into
base: kata/collections/start
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6ea9e68
Replaced duplicate packag-info with a readme
wakaleo Aug 3, 2016
38ab879
Replaced duplicate packag-info with a readme
wakaleo Aug 3, 2016
a42da69
IC-2016.2.2 <aatchoud@LIN55000200 Create IntelliLang.xml, git.xml, De…
Aug 26, 2016
56675f9
IC-2016.2.2 <aatchoud@LIN55000200 Overwrite local to https://github.c…
Aug 26, 2016
97756cb
IC-2016.2.2 <aatchoud@LIN55000200 Create find.xml
Aug 27, 2016
ce622bd
IC-2016.2.2 <aatchoud@LIN55000200 Overwrite local to https://github.c…
Aug 27, 2016
7f0af83
IC-2016.2.2 <aatchoud@LIN55000200 Update git.xml Create vcs.xml, gith…
Aug 27, 2016
ae65ec0
IC-2016.2.2 <aatchoud@LIN55000200 Update laf.xml Create ui.lnf.xml, p…
Aug 27, 2016
ae19afc
IC-2016.2.2 <aatchoud@LIN55000200 Update laf.xml Create colors.scheme…
Aug 29, 2016
679c494
IC-2016.2.2 <aatchoud@LIN55000200 Update laf.xml Delete colors.scheme…
Aug 29, 2016
6f5a253
IC-2016.2.2 <aatchoud@LIN55000200 Create editor.xml
Aug 29, 2016
a377c4b
IC-2016.2.2 <aatchoud@LIN55000200 Create debugger.renderers.xml
Aug 29, 2016
9449c84
IC-2016.2.2 <aatchoud@LIN55000200 Delete ui.lnf.xml
Aug 31, 2016
bb2a402
IC-2016.2.2 <aatchoud@LIN55000200 Create ui.lnf.xml
aatam10 Aug 31, 2016
56fbee8
IC-2016.2.2 <aatchoud@LIN55000200 Update diff.xml
aatam10 Aug 31, 2016
2e490e5
IC-2016.2.2 <aatchoud@LIN55000200 Update editor.xml
aatam10 Aug 31, 2016
adb2ef8
IC-2016.2.2 <aatchoud@LIN55000200 Update diff.xml
aatam10 Aug 31, 2016
c5d4b9f
Deleted Unnecessary files
aatam10 Sep 1, 2016
4ca9e97
Deleted un wanted folders
aatam10 Sep 1, 2016
dc28099
IC-2016.2.2 <aatchoud@LIN55000200 Update mavenVersion.xml
aatam10 Sep 1, 2016
7b89614
IC-2016.2.2 <aatchoud@LIN55000200 Merge branch 'master'
aatam10 Sep 1, 2016
c8d4207
IC-2016.2.2 <aatchoud@LIN55000200 Create keymap.xml, diff.xml, laf.xm…
aatam10 Sep 1, 2016
5277132
IC-2016.2.2 <aatchoud@LIN55000200 Create IntelliLang.xml, web-browser…
aatam10 Sep 1, 2016
184f1c3
IC-2016.2.2 <aatchoud@LIN55000200 Create ui.lnf.xml
aatam10 Sep 1, 2016
29a88d1
IC-2016.2.2 <aatchoud@LIN55000200 Create gradle.run.settings.xml
aatam10 Sep 1, 2016
9dce6ac
IC-2016.2.2 <aatchoud@LIN55000200 Update git.xml
aatam10 Sep 1, 2016
3298981
IC-2016.2.2 <aatchoud@LIN55000200 Delete ui.lnf.xml
aatam10 Sep 2, 2016
431e58e
adding .gitignore file
aatam10 Sep 2, 2016
a1ff26c
IC-2016.2.2 <aatchoud@LIN55000200 Merge branch 'master'
aatam10 Sep 3, 2016
e6d0b31
IC-2016.2.2 <aatchoud@LIN55000200 Create editor.codeinsight.xml
aatam10 Sep 4, 2016
bb81074
IC-2016.2.2 <aatchoud@LIN55000200 Update editor.codeinsight.xml Creat…
aatam10 Sep 6, 2016
ae005d5
IC-2016.2.2 <aatchoud@LIN55000200 Create toStringTemplates.xml
aatam10 Sep 10, 2016
9760701
Merge pull request #10 from serenity-dojo/kata/collections/start
aatam10 Sep 20, 2016
1095b50
Collection Kata checkpoint, checked-in the code done within 2 hrs.
aatam10 Sep 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,25 @@ gradle-app.setting
.idea
*.iml

### Eclipse template
### IdeaIntelliJ template
debugger.xml
debugger.renderers.xml
.project
diff.xml
editor.xml
github_settings.xml
gradle.run.settings.xml
IntelliLang.xml
jdk.table.xml
mavenVersion.xml
project.default.xml
proxy.settings.xml
ui.lnf.xml
usageView.xml
vcs.xml
web-browsers.xml
*.iml


.metadata
bin/
Expand All @@ -42,6 +60,7 @@ local.properties
# Eclipse Core
.project


*.ipr
*.iws

Expand Down
9 changes: 0 additions & 9 deletions circle.yml

This file was deleted.

81 changes: 81 additions & 0 deletions debugger.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<application>
<component name="DebuggerSettings">
<option name="TRACING_FILTERS_ENABLED" value="true" />
<option name="FORCE_CLASSIC_VM" value="true" />
<option name="SKIP_SYNTHETIC_METHODS" value="true" />
<option name="SKIP_CLASSLOADERS" value="true" />
<option name="RUN_HOTSWAP_AFTER_COMPILE" value="RunHotswapAsk" />
<option name="COMPILE_BEFORE_HOTSWAP" value="true" />
<filter>
<option name="PATTERN" value="com.sun.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="java.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="javax.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="org.omg.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="sun.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="jdk.internal.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="junit.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="com.intellij.rt.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="com.yourkit.runtime.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="com.springsource.loaded.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="org.springsource.loaded.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="javassist.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="org.apache.webbeans.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="com.ibm.ws.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="kotlin.*" />
<option name="ENABLED" value="true" />
</filter>
</component>
<component name="XDebuggerSettings">
<data-views />
<general />
<debuggers>
<debugger id="kotlin_debugger">
<configuration>
<option name="DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED" value="true" />
</configuration>
</debugger>
</debuggers>
</component>
</application>
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,14 @@ private Breed someBreed() {
private String someName(int petCount) {
return PET_NAMES.get(random.nextInt(PET_NAMES.size())) + " " + petCount;
}

public PetHotel petsCheckedIn() {
PetHotel hotel = new PetHotel();
for(int i=1;i<=petCount;i++)
{
hotel.checkIn(Pet.dog().named(someName(i)));
}
return hotel;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package serenitylabs.tutorials.vetclinic.collections.katas;


import serenitylabs.tutorials.vetclinic.Pet;

/**
* Created by aatchoud on 9/20/2016.
*/
public class BookingResponse {
private static boolean isConfirm = false;

public BookingResponse(boolean isConfirm) {
this.isConfirm = isConfirm;
}

public Boolean isConfirmed(){
return isConfirm;
}

}



Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package serenitylabs.tutorials.vetclinic.collections.katas;

import serenitylabs.tutorials.vetclinic.Pet;

import java.util.*;

/**
* Created by aatchoud on 9/20/2016.
*/
public class PetHotel {

private final int MAXIMUM_PETS_CAPACITY = 20;
private Set<Pet> pets = new TreeSet<Pet>(Comparator.comparing(Pet::getName));

public Set<Pet> getPets() {
return pets;
}

public BookingResponse checkIn(Pet pet) {
if(pets.size()< MAXIMUM_PETS_CAPACITY)
pets.add(pet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use curly brackets ("{}") with if statements, and respect the Java indentation conventions - otherwise it makes the code hard to read.

return new BookingResponse(true);
}


}
1 change: 1 addition & 0 deletions src/test/java/serenitylabs/tutorials/vetclinic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Your test code goes here.
Original file line number Diff line number Diff line change
@@ -1,36 +1,104 @@
package serenitylabs.tutorials.vetclinic.collections.katas;

import org.hamcrest.MatcherAssert;
import org.junit.Test;
import serenitylabs.tutorials.vetclinic.Pet;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

public class WhenBookingPetsIntoAPetHotel {


@Test
public void the_hotel_should_initially_have_no_pets_booked() {
PetHotel hotel = new PetHotel();

assertThat(hotel.getPets(),hasSize(0));

}

@Test
public void should_be_able_to_check_a_pet_into_the_hotel() throws Exception {
PetHotel hotel = new PetHotel();
Pet fido = Pet.dog().named("Fido");

hotel.checkIn(fido);

assertThat(hotel.getPets(),hasItem(fido));
}

@Test
public void should_be_able_to_check_in_several_pets() throws Exception {
PetHotel hotel = new PetHotel();

Pet fido = Pet.dog().named("Fido");
Pet felix = Pet.cat().named("Felix");

hotel.checkIn(fido);
hotel.checkIn(felix);

assertThat(hotel.getPets(),hasItems(fido,felix));

}

@Test
public void should_not_be_able_to_check_in_the_same_pet_twice() throws Exception {
PetHotel hotel = new PetHotel();

Pet fido = Pet.dog().named("Fido");
Pet felix = Pet.cat().named("Felix");

hotel.checkIn(fido);
hotel.checkIn(felix);
hotel.checkIn(fido);

assertThat(hotel.getPets(),containsInAnyOrder(fido,felix));

}

@Test
public void should_be_able_to_retrieve_checked_in_pets_in_alphabetical_order() throws Exception {
PetHotel hotel = new PetHotel();

Pet xelix = Pet.cat().named("Xelix");
Pet fido = Pet.dog().named("Fido");
Pet aelix = Pet.cat().named("Aelix");
Pet felix = Pet.cat().named("Felix");

hotel.checkIn(xelix);
hotel.checkIn(fido);
hotel.checkIn(aelix);
hotel.checkIn(felix);

assertThat(hotel.getPets(),contains(aelix,felix,fido,xelix));

}

@Test
public void should_be_able_to_obtain_a_booking_confirmation_when_we_check_in_a_pet() throws Exception {
PetHotel hotel = new PetHotel();

Pet fido = Pet.dog().named("Fido");

hotel.checkIn(fido);

BookingResponse response = hotel.checkIn(fido);

assertThat(response.isConfirmed(),equalTo(true));
assertThat(hotel.getPets(),hasItem(fido));
}

@Test
public void should_not_be_able_to_check_in_pets_beyond_hotel_capacity() throws Exception {
PetHotel hotel = APetHotel.with(20).petsCheckedIn();

Pet fido = Pet.dog().named("Fido");

hotel.checkIn(fido);

assertThat(hotel.getPets(),not(hasItem(fido)));

}

@Test
Expand Down

This file was deleted.