1 /* 2 * SmartSprites Project 3 * 4 * Copyright (C) 2007-2009, Stanisław Osiński. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without modification, 8 * are permitted provided that the following conditions are met: 9 * 10 * - Redistributions of source code must retain the above copyright notice, this 11 * list of conditions and the following disclaimer. 12 * 13 * - Redistributions in binary form must reproduce the above copyright notice, this 14 * list of conditions and the following disclaimer in the documentation and/or 15 * other materials provided with the distribution. 16 * 17 * - Neither the name of the SmartSprites Project nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * - We kindly request that you include in the end-user documentation provided with 22 * the redistribution and/or in the software itself an acknowledgement equivalent 23 * to the following: "This product includes software developed by the SmartSprites 24 * Project." 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 */ 37 package org.carrot2.labs.test; 38 39 import static org.assertj.core.api.Assertions.assertThat; 40 import static org.junit.jupiter.api.Assertions.assertTrue; 41 42 import com.google.common.collect.Lists; 43 44 import java.util.List; 45 46 import org.carrot2.labs.smartsprites.css.CssProperty; 47 import org.carrot2.labs.smartsprites.message.Message; 48 49 /** 50 * Assertions on lists of {@link CssProperty} instances. 51 */ 52 public class CssPropertyListAssertion { 53 54 /** The actual message list. */ 55 private List<CssProperty> actual; 56 57 /** 58 * Creates a {@link Message} list assertion object. 59 * 60 * @param actual 61 * the actual 62 */ 63 public CssPropertyListAssertion(List<CssProperty> actual) { 64 this.actual = actual; 65 } 66 67 /** 68 * Asserts that the current message list is equivalent to the provided expected message list. 69 * 70 * @param properties 71 * the properties 72 * 73 * @return the css property list assertion 74 */ 75 public CssPropertyListAssertion isEquivalentTo(List<CssProperty> properties) { 76 assertThat(actual).hasSize(properties.size()); 77 for (int i = 0; i < actual.size(); i++) { 78 org.carrot2.labs.test.Assertions.assertThat(actual.get(i)).as("property[" + i + "]") 79 .isEquivalentTo(properties.get(i)); 80 } 81 return this; 82 } 83 84 /** 85 * Asserts that the current message list is equivalent to the provided expected message list. 86 * 87 * @param properties 88 * the properties 89 * 90 * @return the css property list assertion 91 */ 92 public CssPropertyListAssertion isEquivalentTo(CssProperty... properties) { 93 return isEquivalentTo(Lists.newArrayList(properties)); 94 } 95 96 /** 97 * Checks if is empty. 98 * 99 * @return the css property list assertion 100 */ 101 public CssPropertyListAssertion isEmpty() { 102 assertTrue(actual.isEmpty()); 103 return this; 104 } 105 106 }