001package tech.uom.lib.assertj.assertions; 002 003import javax.measure.Unit; 004import org.assertj.core.api.AbstractObjectAssert; 005import org.assertj.core.util.Objects; 006 007/** 008 * Abstract base class for {@link Unit} specific assertions - Generated by CustomAssertionGenerator. 009 */ 010@javax.annotation.Generated(value="assertj-assertions-generator") 011public abstract class AbstractUnitAssert<S extends AbstractUnitAssert<S, A>, A extends Unit> extends AbstractObjectAssert<S, A> { 012 013 /** 014 * Creates a new <code>{@link AbstractUnitAssert}</code> to make assertions on actual Unit. 015 * @param actual the Unit we want to make assertions on. 016 */ 017 protected AbstractUnitAssert(A actual, Class<S> selfType) { 018 super(actual, selfType); 019 } 020 021 /** 022 * Verifies that the actual Unit's baseUnits is equal to the given one. 023 * @param baseUnits the given baseUnits to compare the actual Unit's baseUnits to. 024 * @return this assertion object. 025 * @throws AssertionError - if the actual Unit's baseUnits is not equal to the given one. 026 */ 027 public S hasBaseUnits(java.util.Map baseUnits) { 028 // check that actual Unit we want to make assertions on is not null. 029 isNotNull(); 030 031 // overrides the default error message with a more explicit one 032 String assertjErrorMessage = "\nExpecting baseUnits of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 033 034 // null safe check 035 java.util.Map actualBaseUnits = actual.getBaseUnits(); 036 if (!Objects.areEqual(actualBaseUnits, baseUnits)) { 037 failWithMessage(assertjErrorMessage, actual, baseUnits, actualBaseUnits); 038 } 039 040 // return the current assertion for method chaining 041 return myself; 042 } 043 044 /** 045 * Verifies that the actual Unit's dimension is equal to the given one. 046 * @param dimension the given dimension to compare the actual Unit's dimension to. 047 * @return this assertion object. 048 * @throws AssertionError - if the actual Unit's dimension is not equal to the given one. 049 */ 050 public S hasDimension(javax.measure.Dimension dimension) { 051 // check that actual Unit we want to make assertions on is not null. 052 isNotNull(); 053 054 // overrides the default error message with a more explicit one 055 String assertjErrorMessage = "\nExpecting dimension of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 056 057 // null safe check 058 javax.measure.Dimension actualDimension = actual.getDimension(); 059 if (!Objects.areEqual(actualDimension, dimension)) { 060 failWithMessage(assertjErrorMessage, actual, dimension, actualDimension); 061 } 062 063 // return the current assertion for method chaining 064 return myself; 065 } 066 067 /** 068 * Verifies that the actual Unit's name is equal to the given one. 069 * @param name the given name to compare the actual Unit's name to. 070 * @return this assertion object. 071 * @throws AssertionError - if the actual Unit's name is not equal to the given one. 072 */ 073 public S hasName(String name) { 074 // check that actual Unit we want to make assertions on is not null. 075 isNotNull(); 076 077 // overrides the default error message with a more explicit one 078 String assertjErrorMessage = "\nExpecting name of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 079 080 // null safe check 081 String actualName = actual.getName(); 082 if (!Objects.areEqual(actualName, name)) { 083 failWithMessage(assertjErrorMessage, actual, name, actualName); 084 } 085 086 // return the current assertion for method chaining 087 return myself; 088 } 089 090 /** 091 * Verifies that the actual Unit's symbol is equal to the given one. 092 * @param symbol the given symbol to compare the actual Unit's symbol to. 093 * @return this assertion object. 094 * @throws AssertionError - if the actual Unit's symbol is not equal to the given one. 095 */ 096 public S hasSymbol(String symbol) { 097 // check that actual Unit we want to make assertions on is not null. 098 isNotNull(); 099 100 // overrides the default error message with a more explicit one 101 String assertjErrorMessage = "\nExpecting symbol of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 102 103 // null safe check 104 String actualSymbol = actual.getSymbol(); 105 if (!Objects.areEqual(actualSymbol, symbol)) { 106 failWithMessage(assertjErrorMessage, actual, symbol, actualSymbol); 107 } 108 109 // return the current assertion for method chaining 110 return myself; 111 } 112 113 /** 114 * Verifies that the actual Unit's systemUnit is equal to the given one. 115 * @param systemUnit the given systemUnit to compare the actual Unit's systemUnit to. 116 * @return this assertion object. 117 * @throws AssertionError - if the actual Unit's systemUnit is not equal to the given one. 118 */ 119 public S hasSystemUnit(javax.measure.Unit systemUnit) { 120 // check that actual Unit we want to make assertions on is not null. 121 isNotNull(); 122 123 // overrides the default error message with a more explicit one 124 String assertjErrorMessage = "\nExpecting systemUnit of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; 125 126 // null safe check 127 javax.measure.Unit actualSystemUnit = actual.getSystemUnit(); 128 if (!Objects.areEqual(actualSystemUnit, systemUnit)) { 129 failWithMessage(assertjErrorMessage, actual, systemUnit, actualSystemUnit); 130 } 131 132 // return the current assertion for method chaining 133 return myself; 134 } 135 136}