@Test
public void testTableReferenceDefinitionInnerJoinValidation() {

	TableReferenceDefinition<MainExampleTable> tableReferenceDefinition =
		new TestTableReferenceDefinition<MainExampleTable>(
			MainExampleTable.INSTANCE) {
			@Override
			public void defineChildTableReferences(
				ChildTableReferenceInfoBuilder<MainExampleTable>
					childTableReferenceInfoBuilder) {
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> DSLQueryFactoryUtil.select(
						).from(
							MainExampleTable.INSTANCE
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						"Missing join in \"select * from MainExample\"",
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> DSLQueryFactoryUtil.select(
						).from(
							MainExampleTable.INSTANCE
						).innerJoinON(
							MainExampleTable.INSTANCE,
							MainExampleTable.INSTANCE.mainExampleId.eq(
								MainExampleTable.INSTANCE.mainExampleId)
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"Join function must use provided from step ",
							"for join step \"select * from MainExample ",
							"inner join MainExample on ",
							"MainExample.mainExampleId = ",
							"MainExample.mainExampleId\""),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> fromStep.from(
							ReferenceExampleTable.INSTANCE
						).innerJoinON(
							ReferenceExampleTable.INSTANCE,
							ReferenceExampleTable.INSTANCE.mainExampleId.eq(
								ReferenceExampleTable.INSTANCE.
									mainExampleId)
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"Required table \"MainExample\" is unused in ",
							"join step \"... from ReferenceExample inner ",
							"join ReferenceExample on ",
							"ReferenceExample.mainExampleId = ",
							"ReferenceExample.mainExampleId\""),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> fromStep.from(
							MainExampleTable.INSTANCE
						).innerJoinON(
							MainExampleTable.INSTANCE,
							MainExampleTable.INSTANCE.mainExampleId.eq(
								MainExampleTable.INSTANCE.mainExampleId)
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"Invalid join for join step \"... from ",
							"MainExample inner join MainExample on ",
							"MainExample.mainExampleId = ",
							"MainExample.mainExampleId\", ensure table ",
							"alias is used for self joins"),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> fromStep.from(
							MainExampleTable.INSTANCE
						).innerJoinON(
							ReferenceExampleTable.INSTANCE,
							ReferenceExampleTable.INSTANCE.mainExampleId.eq(
								MainExampleTable.INSTANCE.mainExampleId)
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"First join must be on table \"MainExample\" ",
							"for join step \"... from MainExample inner ",
							"join ReferenceExample on ",
							"ReferenceExample.mainExampleId = ",
							"MainExample.mainExampleId\""),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> fromStep.from(
							ReferenceExampleTable.INSTANCE
						).leftJoinOn(
							MainExampleTable.INSTANCE,
							ReferenceExampleTable.INSTANCE.mainExampleId.eq(
								MainExampleTable.INSTANCE.mainExampleId)
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"Invalid join type \"left\" for join step ",
							"\"... from ReferenceExample left join ",
							"MainExample on ",
							"ReferenceExample.mainExampleId = ",
							"MainExample.mainExampleId\""),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> fromStep.from(
							ReferenceExampleTable.INSTANCE
						).innerJoinON(
							MainExampleTable.INSTANCE,
							ReferenceExampleTable.INSTANCE.mainExampleId.
								neq(
									MainExampleTable.INSTANCE.mainExampleId
								).and(
									MainExampleTable.INSTANCE.mainExampleId.
										gte(
											ReferenceExampleTable.INSTANCE.
												mainExampleId)
								)
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"Invalid predicate operand \"!=\" for join ",
							"step \"... from ReferenceExample inner join ",
							"MainExample on ",
							"ReferenceExample.mainExampleId != ",
							"MainExample.mainExampleId and ",
							"MainExample.mainExampleId >= ",
							"ReferenceExample.mainExampleId\""),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> fromStep.from(
							MainExampleTable.INSTANCE.as("aliasMainExample")
						).innerJoinON(
							MainExampleTable.INSTANCE,
							ReferenceExampleTable.INSTANCE.mainExampleId.eq(
								MainExampleTable.INSTANCE.mainExampleId)
						));
					Assert.fail();
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"Predicate column tables [MainExample, ",
							"ReferenceExample] do not match join tables ",
							"[MainExample, MainExample aliasMainExample] ",
							"for join step \"... from MainExample ",
							"aliasMainExample inner join MainExample on ",
							"ReferenceExample.mainExampleId = ",
							"MainExample.mainExampleId\""),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> fromStep.from(
							InvalidTable.INSTANCE
						).innerJoinON(
							MainExampleTable.INSTANCE,
							MainExampleTable.INSTANCE.mainExampleId.eq(
								InvalidTable.INSTANCE.mainExampleId)
						));
				}
				catch (IllegalArgumentException illegalArgumentException) {
					Assert.assertEquals(
						StringBundler.concat(
							"No long type primary key column found for ",
							"table \"InvalidTable\" for join step \"... ",
							"from InvalidTable inner join MainExample on ",
							"MainExample.mainExampleId = ",
							"InvalidTable.mainExampleId\""),
						illegalArgumentException.getMessage());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> {
							fromStep.as("test");
							return null;
						});
					Assert.fail();
				}
				catch (Exception exception) {
					Assert.assertSame(
						UnsupportedOperationException.class,
						exception.getClass());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> {
							fromStep.union(null);
							return null;
						});
					Assert.fail();
				}
				catch (Exception exception) {
					Assert.assertSame(
						UnsupportedOperationException.class,
						exception.getClass());
				}
				try {
					childTableReferenceInfoBuilder.referenceInnerJoin(
						fromStep -> {
							fromStep.unionAll(null);
							return null;
						});
					Assert.fail();
				}
				catch (Exception exception) {
					Assert.assertSame(
						UnsupportedOperationException.class,
						exception.getClass());
				}
			}
			@Override
			public void defineParentTableReferences(
				ParentTableReferenceInfoBuilder<MainExampleTable>
					parentTableReferenceInfoBuilder) {
			}
		};
	TableReferenceInfo<MainExampleTable> tableReferenceInfo =
		TableReferenceInfoFactory.create(
			MainExampleTable.CLASS_NAME_ID,
			MainExampleTable.INSTANCE.mainExampleId,
			tableReferenceDefinition);
	Assert.assertNotNull(tableReferenceInfo);
	Assert.assertSame(
		tableReferenceDefinition,
		tableReferenceInfo.getTableReferenceDefinition());
	Map<Table<?>, List<TableJoinHolder>> childTableJoinHoldersMap =
		tableReferenceInfo.getChildTableJoinHoldersMap();
	Assert.assertTrue(
		childTableJoinHoldersMap.toString(),
		childTableJoinHoldersMap.isEmpty());
	Map<Table<?>, List<TableJoinHolder>> parentTableJoinHoldersMap =
		tableReferenceInfo.getParentTableJoinHoldersMap();
	Assert.assertTrue(
		parentTableJoinHoldersMap.toString(),
		parentTableJoinHoldersMap.isEmpty());
	Assert.assertEquals(
		MainExampleTable.CLASS_NAME_ID,
		tableReferenceInfo.getClassNameId());
}