View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl;
19  
20  import lombok.AccessLevel;
21  import lombok.NoArgsConstructor;
22  import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUninstallComponentStatement;
23  import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
24  import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.component.ExpectedComponent;
25  import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.UninstallComponentStatementTestCase;
26  
27  import java.util.List;
28  
29  import static org.hamcrest.CoreMatchers.is;
30  import static org.hamcrest.MatcherAssert.assertThat;
31  
32  /**
33   * Uninstall component statement assert.
34   */
35  @NoArgsConstructor(access = AccessLevel.PRIVATE)
36  public final class UninstallComponentStatementAssert {
37      
38      /**
39       * Assert uninstall component statement is correct with expected uninstall component statement test case.
40       *
41       * @param assertContext assert context
42       * @param actual actual uninstall component statement
43       * @param expected expected uninstall component statement test case
44       */
45      public static void assertIs(final SQLCaseAssertContext assertContext, final MySQLUninstallComponentStatement actual, final UninstallComponentStatementTestCase expected) {
46          assertThat(assertContext.getText("Actual components size assertion error: "), actual.getComponents().size(), is(expected.getComponents().size()));
47          assertComponents(assertContext, actual.getComponents(), expected.getComponents());
48      }
49      
50      private static void assertComponents(final SQLCaseAssertContext assertContext, final List<String> actual, final List<ExpectedComponent> expected) {
51          int count = 0;
52          for (String each : actual) {
53              assertThat(assertContext.getText("Actual component value does not match: "), each, is(expected.get(count).getName()));
54              count++;
55          }
56      }
57  }