Projects >> simple-petstore >>0b886a7bbf8706fada12c1d2aa7435459871a486

Chunk
Conflicting content
@RunWith(JMock.class)
import static org.hamcrest.Matchers.equalTo;
import static test.support.com.pyxis.petstore.builders.Entities.entities;
import static test.support.com.pyxis.petstore.builders.ProductBuilder.aProduct;
<<<<<<< HEAD
import static test.support.com.pyxis.petstore.matchers.DomMatchers.*;
=======
import static test.support.com.pyxis.petstore.matchers.DomMatchers.hasAttribute;
import static test.support.com.pyxis.petstore.matchers.DomMatchers.hasChild;
import static test.support.com.pyxis.petstore.matchers.DomMatchers.hasSelector;
import static test.support.com.pyxis.petstore.matchers.DomMatchers.hasNoSelector;
import static test.support.com.pyxis.petstore.matchers.DomMatchers.hasUniqueSelector;
import static test.support.com.pyxis.petstore.matchers.DomMatchers.withText;
import static test.support.com.pyxis.petstore.matchers.DomMatchers.withBlankText;
>>>>>>> 3e8b5090d42ded272c8b53211c346622ba177786
import static test.support.com.pyxis.petstore.velocity.VelocityRendering.render;
Solution content
import static org.hamcrest.Matchers.equalTo;
import static test.support.com.pyxis.petstore.builders.Entities.entities;
import static test.support.com.pyxis.petstore.builders.ProductBuilder.aProduct;
import static test.support.com.pyxis.petstore.matchers.DomMatchers.*;
import static test.support.com.pyxis.petstore.velocity.VelocityRendering.render;

@RunWith(JMock.class)
File
ProductsViewTest.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
    }

    @Test
<<<<<<< HEAD
    public void handlesProductWithNoDescriptionCorrectly() {
        useDefaultPhoto();
        productsPage = renderProductsPageUsing(aModelWith(
                aProduct().withName("Labrador")));
        assertThat(dom(productsPage),
                hasSelector("#products td:nth-child(3)",
                        contains(anEmptyDescription())));
=======
    public void displaysColumnHeadersOverListOfProductsFound() {
		productsPage = renderProductsPageUsing(aModelWith(
				aProduct().withName("Labrador").describedAs("Friendly").withPhoto("labrador")));
        assertThat(dom(productsPage), 
        		hasSelector("#products th", 
        				inOrder(withBlankText(),
        						withText("Name"),
        						withText("Description"))));
>>>>>>> 3e8b5090d42ded272c8b53211c346622ba177786
    }

    // todo this behaviour should be on the photo or storage
Solution content
    }

    @Test public void
    handlesProductWithNoDescriptionCorrectly() {
        useDefaultPhoto();
        productsPage = renderProductsPageUsing(aModelWith(
                aProduct().withName("Labrador")));
        assertThat(dom(productsPage),
                hasSelector("#products td:nth-child(3)",
                        contains(anEmptyDescription())));
    }

    // todo this behaviour should be on the photo or storage
File
ProductsViewTest.java
Developer's decision
Manual
Kind of conflict
Attribute
Method invocation
Method signature
Chunk
Conflicting content
	@Test
                hasSelector("#products td:nth-child(1)",
                        contains(image(DEFAULT_PHOTO))));
    }
<<<<<<< HEAD

    private void useDefaultPhoto() {
        context.checking(new Expectations() {{
            allowing(storage).getLocation(with(any(String.class))); will(returnValue(DEFAULT_PHOTO));
        }});
    }

    private String renderProductsPageUsing(Map model) {
        return render(PRODUCTS_VIEW).using(model);
    }

    private Matcher withEmptyText() {
        return withText("");
    }

    private Matcher anEmptyDescription() {
        return description("");
    }

    private Matcher image(String imageUrl) {
        return hasChild(hasAttribute("src", equalTo(imageUrl)));
    }

    private Matcher description(String description) {
        return withText(description);
    }

    private Matcher productName(String name) {
        return withText(name);
    }

=======
	
	public void displaysNothingInDescriptionColumnForAProductWithNoDescription() {
		productsPage = renderProductsPageUsing(aModelWith(
				aProduct().withName("Labrador").withPhoto("labrador")));
        assertThat(dom(productsPage), 
        		hasSelector("#products td:nth-child(3)", 
        				contains(anEmptyDescription())));		
	}
	
	@Test
	public void displaysDefaultPhotoForAProductWithNoPhoto() {
		productsPage = renderProductsPageUsing(aModelWith(
						aProduct().withName("Labrador").describedAs("Friendly")));
        assertThat(dom(productsPage), 
        		hasSelector("#products td:nth-child(1)", 
        				contains(image("photos/"))));		
	}
	
	@Test
	public void displaysNoProductsTableIfNoProductIsFound() {
		productsPage = renderProductsPageUsing(anEmptyModel());
		assertThat(dom(productsPage), hasNoSelector("#products"));
	}

	private Map anEmptyModel() {
		return aModelWith();
	}

	private String renderProductsPageUsing(Map model) {
		return render(PRODUCTS_VIEW).using(model);
	}

	private Matcher anEmptyDescription() {
		return withBlankText();
	}

	private Matcher image(String imageUrl) {
		return hasChild(hasAttribute("src", equalTo(imageUrl)));
	}

	private Matcher description(String description) {
		return withText(description);
	}

	private Matcher productName(String name) {
		return withText(name);
	}
    
>>>>>>> 3e8b5090d42ded272c8b53211c346622ba177786
    private Matcher> inOrder(Matcher... elementMatchers) {
        return contains(elementMatchers);
    }
Solution content
                hasSelector("#products td:nth-child(1)",
                        contains(image(DEFAULT_PHOTO))));
    }

    @Test public void
    displaysNoProductsTableIfNoProductIsFound() {
        productsPage = renderProductsPageUsing(anEmptyModel());
        assertThat(dom(productsPage), hasNoSelector("#products"));
    }

    private void useDefaultPhoto() {
        context.checking(new Expectations() {{
            allowing(storage).getLocation(with(any(String.class))); will(returnValue(DEFAULT_PHOTO));
        }});
    }

    private Map anEmptyModel() {
        return aModelWith();
    }

    private String renderProductsPageUsing(Map model) {
        return render(PRODUCTS_VIEW).using(model);
    }

    private Matcher withEmptyText() {
        return withText("");
    }

    private Matcher anEmptyDescription() {
        return description("");
    }

    private Matcher image(String imageUrl) {
        return hasChild(hasAttribute("src", equalTo(imageUrl)));
    }

    private Matcher description(String description) {
        return withText(description);
    }

    private Matcher productName(String name) {
        return withText(name);
    }

    private Matcher> inOrder(Matcher... elementMatchers) {
        return contains(elementMatchers);
    }
File
ProductsViewTest.java
Developer's decision
Manual
Kind of conflict
Annotation
Method declaration