SimpleName:IDENTIFIER 45 expected expected

SimpleName:IDENTIFIER 45 NullPointerException NullPointerException

SimpleName:IDENTIFIER 48 registerBinder registerBinder

SimpleName:IDENTIFIER 48 PreparedStatement PreparedStatement

@Test(expected = NullPointerException.class)
public void nullBinderTypeTriggersNullPointerException() {
    db.registerBinder((Class<Reader>) null, PreparedStatement::setCharacterStream);
}

package com.github.mjdbc.test;

import com.github.mjdbc.test.asset.model.DbType1;
import com.github.mjdbc.test.asset.model.DbType2;
import com.github.mjdbc.test.asset.model.User;
import com.github.mjdbc.test.asset.model.UserId;
import com.github.mjdbc.test.asset.sql.ReaderSql;
import com.github.mjdbc.test.asset.sql.UserSql;
import com.github.mjdbc.test.asset.sql.error.AmbiguousTypeSql;
import java.io.Reader;
import java.io.StringReader;
import java.sql.PreparedStatement;
import org.junit.Before;
import org.junit.Test;

public class adhoc_DbRegisterBinderTest extends DbTest {

    @Before
    public void setUp() {
        super.setUp();
        db.registerMapper(UserId.class, UserId.MAPPER);
        db.registerMapper(User.class, User.MAPPER);
    }
    /*TEST PLACEHOLDER*/
}

Check that registration of null binder triggers IllegalArgumentException

SimpleName:IDENTIFIER 51 expected expected

SimpleName:IDENTIFIER 51 NullPointerException NullPointerException

SimpleName:IDENTIFIER 54 registerBinder registerBinder

@Test(expected = NullPointerException.class)
public void nullBinderFunctionTriggersNullPointerException() {
    db.registerBinder(Reader.class, null);
}


SimpleName:IDENTIFIER 31 expected expected

SimpleName:IDENTIFIER 31 NullPointerException NullPointerException

SimpleName:IDENTIFIER 34 attachDbi attachDbi

SimpleName:IDENTIFIER 34 EmptyDbi EmptyDbi

{
    db.attachDbi(null, EmptyDbi.class);
}

@Test(expected = NullPointerException.class)
public void checkAttachNullDbiImplThrowsNullPointerException() {
    db.attachDbi(null, EmptyDbi.class);
}

{
    db.attachDbi(null, EmptyDbi.class);
}

package com.github.mjdbc.test;

import com.github.mjdbc.test.asset.dbi.EmptyDbi;
import com.github.mjdbc.test.asset.dbi.EmptyDbiImpl;
import com.github.mjdbc.test.asset.dbi.ProfiledDbi;
import com.github.mjdbc.test.asset.dbi.ProfiledDbiImpl;
import com.github.mjdbc.test.asset.model.User;
import com.github.mjdbc.test.asset.model.UserId;
import org.junit.Before;
import org.junit.Test;

public class adhoc_DbAttachDbiTest extends DbTest {

    @Before
    public void setUp() {
        super.setUp();
        db.registerMapper(UserId.class, UserId.MAPPER);
        db.registerMapper(User.class, User.MAPPER);
    }
    /*TEST PLACEHOLDER*/
}

SimpleName:IDENTIFIER 37 expected expected

SimpleName:IDENTIFIER 37 NullPointerException NullPointerException

SimpleName:IDENTIFIER 40 attachDbi attachDbi

SimpleName:IDENTIFIER 40 EmptyDbiImpl EmptyDbiImpl

@Test(expected = NullPointerException.class)
public void checkAttachNullDbiInterfaceThrowsNullPointerException() {
    db.attachDbi(new EmptyDbiImpl(), null);
}

SimpleName:IDENTIFIER 43 expected expected

SimpleName:IDENTIFIER 43 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 46 attachDbi attachDbi

SimpleName:IDENTIFIER 46 EmptyDbiImpl EmptyDbiImpl

@Test(expected = IllegalArgumentException.class)
public void checkAttachWrongDbiInterfaceThrowsIllegalArgumentException() {
    db.attachDbi(new EmptyDbiImpl(), Object.class);
}

SimpleName:IDENTIFIER 49 expected expected

SimpleName:IDENTIFIER 49 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 52 attachDbi attachDbi

@Test(expected = IllegalArgumentException.class)
public void checkAttachWrongDbiImplementationThrowsIllegalArgumentException() {
    db.attachDbi(new Object(), Object.class);
}


SimpleName:IDENTIFIER 15 expected expected

SimpleName:IDENTIFIER 15 IllegalStateException IllegalStateException

SimpleName:IDENTIFIER 16 checkNoActiveConnectionByDefault checkNoActiveConnectionByDefault

SimpleName:IDENTIFIER 17 getActiveConnection getActiveConnection

@Test(expected = IllegalStateException.class)
public void checkNoActiveConnectionByDefault() {
    db.getActiveConnection();
}

package com.github.mjdbc.test;

import com.github.mjdbc.DbConnection;
import com.github.mjdbc.DbPreparedStatement;
import com.github.mjdbc.Mappers;
import java.sql.Statement;
import java.util.HashMap;
import org.junit.Test;

public class adhoc_DbActiveConnectionTest extends DbTest {
    /*TEST PLACEHOLDER*/
}

SimpleName:IDENTIFIER 20 expected expected

SimpleName:IDENTIFIER 20 IllegalStateException IllegalStateException

SimpleName:IDENTIFIER 21 checkNoActiveConnectionAfterExecute checkNoActiveConnectionAfterExecute

SimpleName:IDENTIFIER 22 execute execute

SimpleName:IDENTIFIER 23 getActiveConnection getActiveConnection

@Test(expected = IllegalStateException.class)
public void checkNoActiveConnectionAfterExecute() {
    db.execute(c -> null);
    db.getActiveConnection();
}


SimpleName:IDENTIFIER 193 expected expected

SimpleName:IDENTIFIER 194 AccumuloException AccumuloException

SimpleName:IDENTIFIER 194 AccumuloSecurityException AccumuloSecurityException

SimpleName:IDENTIFIER 194 TableExistsException TableExistsException

SimpleName:IDENTIFIER 194 TableNotFoundException TableNotFoundException

SimpleName:IDENTIFIER 195 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 195 "Tedge" "Tedge"

SimpleName:IDENTIFIER 195 thenReturn thenReturn

SimpleName:IDENTIFIER 195 Boolean Boolean

SimpleName:IDENTIFIER 196 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 196 "TedgeTranspose" "TedgeTranspose"

SimpleName:IDENTIFIER 196 thenReturn thenReturn

SimpleName:IDENTIFIER 196 Boolean Boolean

SimpleName:IDENTIFIER 197 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 197 "TedgeDegree" "TedgeDegree"

SimpleName:IDENTIFIER 197 thenReturn thenReturn

SimpleName:IDENTIFIER 197 Boolean Boolean

SimpleName:IDENTIFIER 198 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 198 "TedgeMetadata" "TedgeMetadata"

SimpleName:IDENTIFIER 198 thenReturn thenReturn

SimpleName:IDENTIFIER 198 Boolean Boolean

SimpleName:IDENTIFIER 199 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 199 "TedgeText" "TedgeText"

SimpleName:IDENTIFIER 199 thenReturn thenReturn

SimpleName:IDENTIFIER 199 Boolean Boolean

SimpleName:IDENTIFIER 200 instance instance

SimpleName:IDENTIFIER 200 createTables createTables

@Test(expected = D4MException.class)
public void testCreateTables_with_just_edge_table() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    when(mockTableOperations.exists("Tedge")).thenReturn(Boolean.TRUE);
    when(mockTableOperations.exists("TedgeTranspose")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeDegree")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeMetadata")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeText")).thenReturn(Boolean.FALSE);
    instance.createTables();
}

package com.codebits.d4m;

import java.util.ArrayList;
import java.util.Collection;
import java.util.SortedSet;
import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.data.Mutation;
import org.apache.hadoop.io.Text;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import static org.mockito.Mockito.*;

public class adhoc_TableManagerTest {

    Connector mockConnector = mock(Connector.class);

    TableOperations mockTableOperations = mock(TableOperations.class);

    private TableManager instance = null;

    @Before
    public void setup() {
        instance = new TableManager();
        instance.setConnector(mockConnector);
        instance.setTableOperations(mockTableOperations);
    }
    /*TEST PLACEHOLDER*/
}

Test CreateTables with just edge table

@throws AccumuloException
@throws AccumuloSecurityException
@throws TableExistsException
@throws TableNotFoundException

SimpleName:IDENTIFIER 210 expected expected

SimpleName:IDENTIFIER 211 AccumuloException AccumuloException

SimpleName:IDENTIFIER 211 AccumuloSecurityException AccumuloSecurityException

SimpleName:IDENTIFIER 211 TableExistsException TableExistsException

SimpleName:IDENTIFIER 211 TableNotFoundException TableNotFoundException

SimpleName:IDENTIFIER 212 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 212 "Tedge" "Tedge"

SimpleName:IDENTIFIER 212 thenReturn thenReturn

SimpleName:IDENTIFIER 212 Boolean Boolean

SimpleName:IDENTIFIER 213 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 213 "TedgeTranspose" "TedgeTranspose"

SimpleName:IDENTIFIER 213 thenReturn thenReturn

SimpleName:IDENTIFIER 213 Boolean Boolean

SimpleName:IDENTIFIER 214 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 214 "TedgeDegree" "TedgeDegree"

SimpleName:IDENTIFIER 214 thenReturn thenReturn

SimpleName:IDENTIFIER 214 Boolean Boolean

SimpleName:IDENTIFIER 215 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 215 "TedgeMetadata" "TedgeMetadata"

SimpleName:IDENTIFIER 215 thenReturn thenReturn

SimpleName:IDENTIFIER 215 Boolean Boolean

SimpleName:IDENTIFIER 216 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 216 "TedgeText" "TedgeText"

SimpleName:IDENTIFIER 216 thenReturn thenReturn

SimpleName:IDENTIFIER 216 Boolean Boolean

SimpleName:IDENTIFIER 217 instance instance

SimpleName:IDENTIFIER 217 createTables createTables

@Test(expected = D4MException.class)
public void testCreateTables_with_just_transpose_table() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    when(mockTableOperations.exists("Tedge")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeTranspose")).thenReturn(Boolean.TRUE);
    when(mockTableOperations.exists("TedgeDegree")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeMetadata")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeText")).thenReturn(Boolean.FALSE);
    instance.createTables();
}

Test CreateTables with just transpose table

@throws AccumuloException
@throws AccumuloSecurityException
@throws TableExistsException
@throws TableNotFoundException

Test CreateTables with just transpose table

SimpleName:IDENTIFIER 227 expected expected

SimpleName:IDENTIFIER 228 AccumuloException AccumuloException

SimpleName:IDENTIFIER 228 AccumuloSecurityException AccumuloSecurityException

SimpleName:IDENTIFIER 228 TableExistsException TableExistsException

SimpleName:IDENTIFIER 228 TableNotFoundException TableNotFoundException

SimpleName:IDENTIFIER 229 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 229 "Tedge" "Tedge"

SimpleName:IDENTIFIER 229 thenReturn thenReturn

SimpleName:IDENTIFIER 229 Boolean Boolean

SimpleName:IDENTIFIER 230 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 230 "TedgeTranspose" "TedgeTranspose"

SimpleName:IDENTIFIER 230 thenReturn thenReturn

SimpleName:IDENTIFIER 230 Boolean Boolean

SimpleName:IDENTIFIER 231 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 231 "TedgeDegree" "TedgeDegree"

SimpleName:IDENTIFIER 231 thenReturn thenReturn

SimpleName:IDENTIFIER 231 Boolean Boolean

SimpleName:IDENTIFIER 232 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 232 "TedgeMetadata" "TedgeMetadata"

SimpleName:IDENTIFIER 232 thenReturn thenReturn

SimpleName:IDENTIFIER 232 Boolean Boolean

SimpleName:IDENTIFIER 233 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 233 "TedgeText" "TedgeText"

SimpleName:IDENTIFIER 233 thenReturn thenReturn

SimpleName:IDENTIFIER 233 Boolean Boolean

SimpleName:IDENTIFIER 234 instance instance

SimpleName:IDENTIFIER 234 createTables createTables

@Test(expected = D4MException.class)
public void testCreateTables_with_just_degree_table() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    when(mockTableOperations.exists("Tedge")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeTranspose")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeDegree")).thenReturn(Boolean.TRUE);
    when(mockTableOperations.exists("TedgeMetadata")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeText")).thenReturn(Boolean.FALSE);
    instance.createTables();
}

Test CreateTables with just degree table

@throws AccumuloException
@throws AccumuloSecurityException
@throws TableExistsException
@throws TableNotFoundException

Test CreateTables with just degree table

SimpleName:IDENTIFIER 244 expected expected

SimpleName:IDENTIFIER 245 AccumuloException AccumuloException

SimpleName:IDENTIFIER 245 AccumuloSecurityException AccumuloSecurityException

SimpleName:IDENTIFIER 245 TableExistsException TableExistsException

SimpleName:IDENTIFIER 245 TableNotFoundException TableNotFoundException

SimpleName:IDENTIFIER 246 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 246 "Tedge" "Tedge"

SimpleName:IDENTIFIER 246 thenReturn thenReturn

SimpleName:IDENTIFIER 246 Boolean Boolean

SimpleName:IDENTIFIER 247 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 247 "TedgeTranspose" "TedgeTranspose"

SimpleName:IDENTIFIER 247 thenReturn thenReturn

SimpleName:IDENTIFIER 247 Boolean Boolean

SimpleName:IDENTIFIER 248 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 248 "TedgeDegree" "TedgeDegree"

SimpleName:IDENTIFIER 248 thenReturn thenReturn

SimpleName:IDENTIFIER 248 Boolean Boolean

SimpleName:IDENTIFIER 249 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 249 "TedgeMetadata" "TedgeMetadata"

SimpleName:IDENTIFIER 249 thenReturn thenReturn

SimpleName:IDENTIFIER 249 Boolean Boolean

SimpleName:IDENTIFIER 250 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 250 "TedgeText" "TedgeText"

SimpleName:IDENTIFIER 250 thenReturn thenReturn

SimpleName:IDENTIFIER 250 Boolean Boolean

SimpleName:IDENTIFIER 251 instance instance

SimpleName:IDENTIFIER 251 createTables createTables

@Test(expected = D4MException.class)
public void testCreateTables_with_just_field_table() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    when(mockTableOperations.exists("Tedge")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeTranspose")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeDegree")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeMetadata")).thenReturn(Boolean.TRUE);
    when(mockTableOperations.exists("TedgeText")).thenReturn(Boolean.FALSE);
    instance.createTables();
}

Test CreateTables with just field table

@throws AccumuloException
@throws AccumuloSecurityException
@throws TableExistsException
@throws TableNotFoundException

SimpleName:IDENTIFIER 261 expected expected

SimpleName:IDENTIFIER 262 AccumuloException AccumuloException

SimpleName:IDENTIFIER 262 AccumuloSecurityException AccumuloSecurityException

SimpleName:IDENTIFIER 262 TableExistsException TableExistsException

SimpleName:IDENTIFIER 262 TableNotFoundException TableNotFoundException

SimpleName:IDENTIFIER 263 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 263 "Tedge" "Tedge"

SimpleName:IDENTIFIER 263 thenReturn thenReturn

SimpleName:IDENTIFIER 263 Boolean Boolean

SimpleName:IDENTIFIER 264 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 264 "TedgeTranspose" "TedgeTranspose"

SimpleName:IDENTIFIER 264 thenReturn thenReturn

SimpleName:IDENTIFIER 264 Boolean Boolean

SimpleName:IDENTIFIER 265 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 265 "TedgeDegree" "TedgeDegree"

SimpleName:IDENTIFIER 265 thenReturn thenReturn

SimpleName:IDENTIFIER 265 Boolean Boolean

SimpleName:IDENTIFIER 266 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 266 "TedgeMetadata" "TedgeMetadata"

SimpleName:IDENTIFIER 266 thenReturn thenReturn

SimpleName:IDENTIFIER 266 Boolean Boolean

SimpleName:IDENTIFIER 267 mockTableOperations mockTableOperations

StringLiteralExpr:LITERAL 267 "TedgeText" "TedgeText"

SimpleName:IDENTIFIER 267 thenReturn thenReturn

SimpleName:IDENTIFIER 267 Boolean Boolean

SimpleName:IDENTIFIER 268 instance instance

SimpleName:IDENTIFIER 268 createTables createTables

@Test(expected = D4MException.class)
public void testCreateTables_with_just_text_table() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    when(mockTableOperations.exists("Tedge")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeTranspose")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeDegree")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeMetadata")).thenReturn(Boolean.FALSE);
    when(mockTableOperations.exists("TedgeText")).thenReturn(Boolean.TRUE);
    instance.createTables();
}

Test CreateTables with just text table

@throws AccumuloException
@throws AccumuloSecurityException
@throws TableExistsException
@throws TableNotFoundException

SimpleName:IDENTIFIER 278 expected expected

SimpleName:IDENTIFIER 278 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 279 AccumuloException AccumuloException

SimpleName:IDENTIFIER 279 AccumuloSecurityException AccumuloSecurityException

SimpleName:IDENTIFIER 279 TableExistsException TableExistsException

SimpleName:IDENTIFIER 279 TableNotFoundException TableNotFoundException

SimpleName:IDENTIFIER 280 instance instance

SimpleName:IDENTIFIER 280 setTableOperations setTableOperations

SimpleName:IDENTIFIER 281 instance instance

SimpleName:IDENTIFIER 281 createTables createTables

{
    instance.setTableOperations(null);
    instance.createTables();
}

@Test(expected = IllegalArgumentException.class)
public void testCreateTables_with_null_tableOperation() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    instance.setTableOperations(null);
    instance.createTables();
}

{
    instance.setTableOperations(null);
    instance.createTables();
}

Test CreateTables with null tableOperation

@throws AccumuloException
@throws AccumuloSecurityException
@throws TableExistsException
@throws TableNotFoundException

Test CreateTables with null tableOperation


Name:IDENTIFIER 111 RoxableTest RoxableTest

SimpleName:IDENTIFIER 112 ApiErrorsException ApiErrorsException

SimpleName:IDENTIFIER 114 preprocessor preprocessor

SimpleName:IDENTIFIER 114 process process

SimpleName:IDENTIFIER 114 anyObject anyObject

SimpleName:IDENTIFIER 114 IPreprocessingConfig IPreprocessingConfig

SimpleName:IDENTIFIER 114 thenReturn thenReturn

BooleanLiteralExpr:LITERAL 114 true true

SimpleName:IDENTIFIER 115 assertThat assertThat

SimpleName:IDENTIFIER 115 context context

SimpleName:IDENTIFIER 115 process process

SimpleName:IDENTIFIER 115 isSuccessfulPreprocessingResult isSuccessfulPreprocessingResult

BooleanLiteralExpr:LITERAL 115 true true

SimpleName:IDENTIFIER 118 assertThat assertThat

SimpleName:IDENTIFIER 118 context context

SimpleName:IDENTIFIER 118 process process

SimpleName:IDENTIFIER 118 isSuccessfulPreprocessingResult isSuccessfulPreprocessingResult

BooleanLiteralExpr:LITERAL 118 false false

"Expected an illegal state exception when trying to reuse context"

@Test
@RoxableTest(key = "50a577358551")
public void apiPreprocessingContextShouldOnlyBeProcessableOnce() throws ApiErrorsException {
    when(preprocessor.process(anyObject(), any(IPreprocessingConfig.class))).thenReturn(true);
    assertThat(context.process(new Object()), isSuccessfulPreprocessingResult(true));
    assertThat(context.process(new Object()), isSuccessfulPreprocessingResult(false));
}

@Test(expected = IllegalStateException.class)
@RoxableTest(key = "50a577358551")
public void apiPreprocessingContextShouldOnlyBeProcessableOnce() throws ApiErrorsException {
    when(preprocessor.process(anyObject(), any(IPreprocessingConfig.class))).thenReturn(true);
    assertThat(context.process(new Object()), isSuccessfulPreprocessingResult(true));
    assertThat(context.process(new Object()), isSuccessfulPreprocessingResult(false));
}

package com.lotaris.jee.validation.preprocessing;

import com.lotaris.jee.validation.preprocessing.IPreprocessingConfig;
import com.lotaris.jee.validation.preprocessing.IPreprocessor;
import com.lotaris.jee.validation.preprocessing.ApiPreprocessingContext;
import com.lotaris.jee.test.utils.PreprossessingAnswers;
import com.lotaris.jee.validation.ApiErrorsException;
import com.lotaris.jee.validation.IErrorCode;
import com.lotaris.jee.validation.IValidator;
import com.lotaris.rox.annotations.RoxableTest;
import com.lotaris.rox.annotations.RoxableTestClass;
import java.util.Arrays;
import java.util.List;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static com.lotaris.jee.test.matchers.Matchers.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@RoxableTestClass(tags = { "preprocessing", "apiPreprocessingContext" })
public class adhoc_ApiPreprocessingContextUnitTest {

    @Mock
    private IPreprocessor preprocessor;

    private ApiPreprocessingContext context;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        context = createPreprocessingContext();
    }

    private IErrorCode errorCode(final int code) {
        return new IErrorCode() {

            @Override
            public int getCode() {
                return code;
            }

            @Override
            public int getDefaultHttpStatusCode() {
                return 422;
            }
        };
    }

    private ApiPreprocessingContext createPreprocessingContext() {
        return new ApiPreprocessingContext(preprocessor);
    }

    private static Matcher<ApiPreprocessingContext> isSuccessfulPreprocessingResult(final boolean successful) {
        return new BaseMatcher<ApiPreprocessingContext>() {

            @Override
            public boolean matches(Object item) {
                final ApiPreprocessingContext result = (ApiPreprocessingContext) item;
                return result != null && result.isSuccessful() == successful;
            }

            @Override
            public void describeTo(Description description) {
                description.appendText(successful ? "successful preprocessing result" : "failed preprocessing result");
            }

            @Override
            public void describeMismatch(Object item, Description description) {
                if (item == null) {
                    description.appendText("preprocessing result is null");
                } else {
                    description.appendText(successful ? "preprocessing result is not successful" : "preprocessing result is successful");
                }
            }
        };
    }

    private static interface ValidationGroupA {
    }

    private static interface ValidationGroupB {
    }
    /*TEST PLACEHOLDER*/
}

Name:IDENTIFIER 151 RoxableTest RoxableTest

SimpleName:IDENTIFIER 155 doAnswer doAnswer

SimpleName:IDENTIFIER 155 PreprossessingAnswers PreprossessingAnswers

SimpleName:IDENTIFIER 155 PreprossessingWithErrorAnswer PreprossessingWithErrorAnswer

SimpleName:IDENTIFIER 155 errorCode errorCode

StringLiteralExpr:LITERAL 155 "foo" "foo"

SimpleName:IDENTIFIER 155 preprocessor preprocessor

SimpleName:IDENTIFIER 155 process process

SimpleName:IDENTIFIER 155 anyObject anyObject

SimpleName:IDENTIFIER 155 context context

SimpleName:IDENTIFIER 159 context context

SimpleName:IDENTIFIER 159 process process

"Expected an API error exception to be thrown when errors are added to the validation context by the preprocessor; nothing was thrown"

"Expected the API error response of the exception to be the internal API error response of the context"

@Test
@RoxableTest(key = "da639176bb96")
public void apiPreprocessingContextShouldThrowAnApiErrorsExceptionIfErrorsAreAddedToTheValidationContext() {
    doAnswer(new PreprossessingAnswers.PreprossessingWithErrorAnswer(errorCode(2), "foo")).when(preprocessor).process(anyObject(), same(context));
    context.process(new Object());
}

@Test(expected = ApiErrorsException.class)
@RoxableTest(key = "da639176bb96")
public void apiPreprocessingContextShouldThrowAnApiErrorsExceptionIfErrorsAreAddedToTheValidationContext() {
    doAnswer(new PreprossessingAnswers.PreprossessingWithErrorAnswer(errorCode(2), "foo")).when(preprocessor).process(anyObject(), same(context));
    context.process(new Object());
}


Name:IDENTIFIER 126 RoxableTest RoxableTest

SimpleName:IDENTIFIER 129 context context

SimpleName:IDENTIFIER 129 isSuccessful isSuccessful

"Context should have thrown an illegal state exception when trying to get the result before processing"

@Test
@RoxableTest(key = "b49215985574")
public void apiPreprocessingContextShouldNotBeSuccessfulWhenUnprocessed() {
    context.isSuccessful();
}

@Test(expected = IllegalStateException.class)
@RoxableTest(key = "b49215985574")
public void apiPreprocessingContextShouldNotBeSuccessfulWhenUnprocessed() {
    context.isSuccessful();
}


Name:IDENTIFIER 226 RoxableTest RoxableTest

SimpleName:IDENTIFIER 230 context context

SimpleName:IDENTIFIER 230 getValidationContext getValidationContext

SimpleName:IDENTIFIER 230 getState getState

"Expected IllegalArgumentException to be thrown when getting an unregistered state"

@Test
@RoxableTest(key = "311f9c8c7f61")
public void apiPreprocessingContextShouldAddStateObjectsToTheValidationContext() {
    context.getValidationContext().getState(Object.class);
}

@Test(expected = IllegalArgumentException.class)
@RoxableTest(key = "311f9c8c7f61")
public void apiPreprocessingContextShouldAddStateObjectsToTheValidationContext() {
    context.getValidationContext().getState(Object.class);
}


Name:IDENTIFIER 33 RoxableTest RoxableTest

SimpleName:IDENTIFIER 36 ApiErrorResponse ApiErrorResponse

"Expected an exception to be thrown with status code 200 (not in the 4xx or 5xx range); nothing was thrown"

"HTTP status code for an API error response must be in the 4xx or 5xx range, got 200"

@Test
@RoxableTest(key = "4661857863de")
public void apiErrorResponseShouldNotAcceptSuccessfulStatusCodes() {
    new ApiErrorResponse(200);
}

@Test(expected = IllegalArgumentException.class)
@RoxableTest(key = "4661857863de")
public void apiErrorResponseShouldNotAcceptSuccessfulStatusCodes() {
    new ApiErrorResponse(200);
}

package com.lotaris.jee.validation;

import com.lotaris.jee.validation.IErrorCode;
import com.lotaris.jee.validation.IError;
import com.lotaris.jee.validation.IErrorLocationType;
import com.lotaris.jee.validation.ApiErrorResponse;
import com.lotaris.jee.validation.ApiError;
import com.lotaris.rox.annotations.RoxableTest;
import com.lotaris.rox.annotations.RoxableTestClass;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

@RoxableTestClass(tags = { "api", "apiErrorResponse" })
public class adhoc_ApiErrorResponseUnitTest {

    private static BaseMatcher<ApiError> isAnApiErrorWith(final String message, final String location, final String locationType, final Integer code) {
        return new BaseMatcher<ApiError>() {

            @Override
            public boolean matches(Object item) {
                if (!(item instanceof ApiError)) {
                    return false;
                }
                final IError error = (ApiError) item;
                return message.equals(error.getMessage()) && (location != null ? location.equals(error.getLocation()) : error.getLocation() == null) && (locationType != null ? locationType.equals(error.getLocationType().getLocationType()) : error.getLocationType() == null) && (code != null ? error.getCode() != null && code.equals(error.getCode().getCode()) : error.getCode() == null);
            }

            @Override
            public void describeTo(Description description) {
                description.appendText(IError.class.getSimpleName() + " with message \"" + message + "\"" + " and location \"" + location + "\"" + " and locationType \"" + locationType + "\"" + " and code " + code);
            }
        };
    }

    private static ApiErrorResponse badRequest() {
        return new ApiErrorResponse(400);
    }

    private static IErrorCode code(final int code) {
        return new IErrorCode() {

            @Override
            public int getCode() {
                return code;
            }

            @Override
            public int getDefaultHttpStatusCode() {
                return 422;
            }
        };
    }

    private static IErrorLocationType locationType(final String locationType) {
        return new IErrorLocationType() {

            @Override
            public String getLocationType() {
                return locationType;
            }
        };
    }
    /*TEST PLACEHOLDER*/
}


Name:IDENTIFIER 131 RoxableTest RoxableTest

SimpleName:IDENTIFIER 134 pointer pointer

StringLiteralExpr:LITERAL 134 "one" "one"

StringLiteralExpr:LITERAL 134 "two" "two"

SimpleName:IDENTIFIER 137 pointer pointer

SimpleName:IDENTIFIER 137 fragmentAt fragmentAt

"IndexOutOfBoundsException should have been thrown trying to access path fragment at index -1"

"IndexOutOfBoundsException should have been thrown trying to access path fragment at index 2 in a pointer with two fragments"

@Test
@RoxableTest(key = "472560432a90")
public void jsonPointerShouldThrowIndexOutOfBoundsExceptionForUnknownFramentIndices() {
    pointer.path("one").path("two");
    pointer.fragmentAt(-1);
}

@Test(expected = IndexOutOfBoundsException.class)
@RoxableTest(key = "472560432a90")
public void jsonPointerShouldThrowIndexOutOfBoundsExceptionForUnknownFramentIndices() {
    pointer.path("one").path("two");
    pointer.fragmentAt(-1);
}

package com.lotaris.jee.validation;

import com.lotaris.jee.validation.JsonPointer;
import com.lotaris.rox.annotations.RoxableTest;
import com.lotaris.rox.annotations.RoxableTestClass;
import org.junit.Test;
import org.junit.Before;
import static org.junit.Assert.*;

@RoxableTestClass(tags = { "api", "jsonPointer" })
public class adhoc_JsonPointerUnitTest {

    private JsonPointer pointer;

    @Before
    public void setUp() {
        pointer = new JsonPointer();
    }
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 63 expected expected

SimpleName:IDENTIFIER 63 IOException IOException

SimpleName:IDENTIFIER 64 Exception Exception

SimpleName:IDENTIFIER 66 request request

SimpleName:IDENTIFIER 66 Mockito Mockito

SimpleName:IDENTIFIER 66 HttpServletRequest HttpServletRequest

SimpleName:IDENTIFIER 67 Mockito Mockito

SimpleName:IDENTIFIER 67 request request

SimpleName:IDENTIFIER 67 getInputStream getInputStream

SimpleName:IDENTIFIER 67 thenThrow thenThrow

SimpleName:IDENTIFIER 67 IOException IOException

StringLiteralExpr:LITERAL 67 "Fail" "Fail"

SimpleName:IDENTIFIER 68 wrapper wrapper

SimpleName:IDENTIFIER 68 HttpServletRequestLoggingWrapper HttpServletRequestLoggingWrapper

SimpleName:IDENTIFIER 68 request request

SimpleName:IDENTIFIER 69 wrapper wrapper

SimpleName:IDENTIFIER 69 getInputStream getInputStream

@Test(expected = IOException.class)
public void should_throw_exception_caught_during_load() throws Exception {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    Mockito.when(request.getInputStream()).thenThrow(new IOException("Fail"));
    HttpServletRequestLoggingWrapper wrapper = new HttpServletRequestLoggingWrapper(request, 12);
    wrapper.getInputStream();
    Assert.fail("An IOException should occur when getting the stream");
}


SimpleName:IDENTIFIER 114 expected expected

SimpleName:IDENTIFIER 114 IllegalStateException IllegalStateException

SimpleName:IDENTIFIER 115 Exception Exception

SimpleName:IDENTIFIER 116 originResponse originResponse

SimpleName:IDENTIFIER 116 Mockito Mockito

SimpleName:IDENTIFIER 116 HttpServletResponse HttpServletResponse

SimpleName:IDENTIFIER 117 originStream originStream

SimpleName:IDENTIFIER 117 Mockito Mockito

SimpleName:IDENTIFIER 117 ServletOutputStream ServletOutputStream

SimpleName:IDENTIFIER 118 wrapper wrapper

SimpleName:IDENTIFIER 118 HttpServletResponseLoggingWrapper HttpServletResponseLoggingWrapper

SimpleName:IDENTIFIER 118 originResponse originResponse

SimpleName:IDENTIFIER 119 Mockito Mockito

SimpleName:IDENTIFIER 119 originResponse originResponse

SimpleName:IDENTIFIER 119 getOutputStream getOutputStream

SimpleName:IDENTIFIER 119 thenReturn thenReturn

SimpleName:IDENTIFIER 119 originStream originStream

SimpleName:IDENTIFIER 121 wrapper wrapper

SimpleName:IDENTIFIER 121 getWriter getWriter

SimpleName:IDENTIFIER 122 wrapper wrapper

SimpleName:IDENTIFIER 122 getOutputStream getOutputStream

@Test(expected = IllegalStateException.class)
public void getOutputStream_should_throw_illegalException_when_getWriter_already_called() throws Exception {
    HttpServletResponse originResponse = Mockito.mock(HttpServletResponse.class);
    ServletOutputStream originStream = Mockito.mock(ServletOutputStream.class);
    HttpServletResponseLoggingWrapper wrapper = new HttpServletResponseLoggingWrapper(originResponse, 1);
    Mockito.when(originResponse.getOutputStream()).thenReturn(originStream);
    wrapper.getWriter();
    ServletOutputStream stream = wrapper.getOutputStream();
    Assert.fail("An IllegalStateException should have occured");
}

SimpleName:IDENTIFIER 126 expected expected

SimpleName:IDENTIFIER 126 IOException IOException

SimpleName:IDENTIFIER 127 Exception Exception

SimpleName:IDENTIFIER 128 originResponse originResponse

SimpleName:IDENTIFIER 128 Mockito Mockito

SimpleName:IDENTIFIER 128 HttpServletResponse HttpServletResponse

SimpleName:IDENTIFIER 129 originStream originStream

SimpleName:IDENTIFIER 129 Mockito Mockito

SimpleName:IDENTIFIER 129 ServletOutputStream ServletOutputStream

SimpleName:IDENTIFIER 130 wrapper wrapper

SimpleName:IDENTIFIER 130 HttpServletResponseLoggingWrapper HttpServletResponseLoggingWrapper

SimpleName:IDENTIFIER 130 originResponse originResponse

SimpleName:IDENTIFIER 131 Mockito Mockito

SimpleName:IDENTIFIER 131 originResponse originResponse

SimpleName:IDENTIFIER 131 getOutputStream getOutputStream

SimpleName:IDENTIFIER 131 thenThrow thenThrow

SimpleName:IDENTIFIER 131 IOException IOException

StringLiteralExpr:LITERAL 131 "Fail" "Fail"

SimpleName:IDENTIFIER 133 wrapper wrapper

SimpleName:IDENTIFIER 133 getOutputStream getOutputStream

StringLiteralExpr:LITERAL
135
"An IOException should have occured"
"An IOException should have occured"

@Test(expected = IOException.class)
public void getOutputStream_should_throw_IOException_thrown_from_origin_stream() throws Exception {
    HttpServletResponse originResponse = Mockito.mock(HttpServletResponse.class);
    ServletOutputStream originStream = Mockito.mock(ServletOutputStream.class);
    HttpServletResponseLoggingWrapper wrapper = new HttpServletResponseLoggingWrapper(originResponse, 1);
    Mockito.when(originResponse.getOutputStream()).thenThrow(new IOException("Fail"));
    ServletOutputStream stream = wrapper.getOutputStream();
    Assert.fail("An IOException should have occured");
}


SimpleName:IDENTIFIER 177 expected expected

SimpleName:IDENTIFIER 177 IllegalStateException IllegalStateException

SimpleName:IDENTIFIER 178 Exception Exception

SimpleName:IDENTIFIER 179 originResponse originResponse

SimpleName:IDENTIFIER 179 Mockito Mockito

SimpleName:IDENTIFIER 179 HttpServletResponse HttpServletResponse

SimpleName:IDENTIFIER 180 originWriter originWriter

SimpleName:IDENTIFIER 180 Mockito Mockito

SimpleName:IDENTIFIER 180 PrintWriter PrintWriter

SimpleName:IDENTIFIER 181 wrapper wrapper

SimpleName:IDENTIFIER 181 HttpServletResponseLoggingWrapper HttpServletResponseLoggingWrapper

SimpleName:IDENTIFIER 181 originResponse originResponse

SimpleName:IDENTIFIER 182 Mockito Mockito

SimpleName:IDENTIFIER 182 originResponse originResponse

SimpleName:IDENTIFIER 182 getWriter getWriter

SimpleName:IDENTIFIER 182 thenReturn thenReturn

SimpleName:IDENTIFIER 182 originWriter originWriter

SimpleName:IDENTIFIER 184 wrapper wrapper

SimpleName:IDENTIFIER 184 getOutputStream getOutputStream

SimpleName:IDENTIFIER 185 wrapper wrapper

SimpleName:IDENTIFIER 185 getWriter getWriter

PrintWriter stream = wrapper.getWriter()

PrintWriter stream = wrapper.getWriter();

@Test(expected = IllegalStateException.class)
public void getWriter_should_throw_illegalException_when_getOutputStream_already_called() throws Exception {
    HttpServletResponse originResponse = Mockito.mock(HttpServletResponse.class);
    PrintWriter originWriter = Mockito.mock(PrintWriter.class);
    HttpServletResponseLoggingWrapper wrapper = new HttpServletResponseLoggingWrapper(originResponse, 1);
    Mockito.when(originResponse.getWriter()).thenReturn(originWriter);
    wrapper.getOutputStream();
    PrintWriter stream = wrapper.getWriter();
    Assert.fail("An IllegalStateException should have occured");
}

SimpleName:IDENTIFIER 189 expected expected

SimpleName:IDENTIFIER 189 IOException IOException

SimpleName:IDENTIFIER 190 Exception Exception

SimpleName:IDENTIFIER 191 originResponse originResponse

SimpleName:IDENTIFIER 191 Mockito Mockito

SimpleName:IDENTIFIER 191 HttpServletResponse HttpServletResponse

SimpleName:IDENTIFIER 192 originWriter originWriter

SimpleName:IDENTIFIER 192 Mockito Mockito

SimpleName:IDENTIFIER 192 PrintWriter PrintWriter

SimpleName:IDENTIFIER 193 wrapper wrapper

SimpleName:IDENTIFIER 193 HttpServletResponseLoggingWrapper HttpServletResponseLoggingWrapper

SimpleName:IDENTIFIER 193 originResponse originResponse

SimpleName:IDENTIFIER 194 Mockito Mockito

SimpleName:IDENTIFIER 194 originResponse originResponse

SimpleName:IDENTIFIER 194 getOutputStream getOutputStream

SimpleName:IDENTIFIER 194 thenThrow thenThrow

SimpleName:IDENTIFIER 194 IOException IOException

StringLiteralExpr:LITERAL 194 "Fail" "Fail"

SimpleName:IDENTIFIER 196 wrapper wrapper

SimpleName:IDENTIFIER 196 getWriter getWriter

PrintWriter writer = wrapper.getWriter()

PrintWriter writer = wrapper.getWriter();

StringLiteralExpr:LITERAL
198
"An IOException should have occured"
"An IOException should have occured"

@Test(expected = IOException.class)
public void getWriter_should_throw_IOException_thrown_from_origin_stream() throws Exception {
    HttpServletResponse originResponse = Mockito.mock(HttpServletResponse.class);
    PrintWriter originWriter = Mockito.mock(PrintWriter.class);
    HttpServletResponseLoggingWrapper wrapper = new HttpServletResponseLoggingWrapper(originResponse, 1);
    Mockito.when(originResponse.getOutputStream()).thenThrow(new IOException("Fail"));
    PrintWriter writer = wrapper.getWriter();
    Assert.fail("An IOException should have occured");
}


SimpleName:IDENTIFIER 61 shouldThrowExceptionForKeyOnly shouldThrowExceptionForKeyOnly

SimpleName:IDENTIFIER 63 metadata metadata

SimpleName:IDENTIFIER 67 ProcessorUtilities ProcessorUtilities

SimpleName:IDENTIFIER 67 getAndValidateKeyValuePair getAndValidateKeyValuePair

SimpleName:IDENTIFIER 67 metadata metadata

@Test
public void shouldThrowExceptionForKeyOnly() {
    final String metadata = key;
    ProcessorUtilities.getAndValidateKeyValuePair(metadata);
}

@Test(expected = InvalidKeyValueException.class)
public void shouldThrowExceptionForKeyOnly() {
    final String metadata = key;
    ProcessorUtilities.getAndValidateKeyValuePair(metadata);
}

package org.jboss.pressgang.ccms.contentspec.processor.utils;

import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.fail;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import net.sf.ipsedixit.annotation.ArbitraryString;
import net.sf.ipsedixit.core.StringType;
import org.jboss.pressgang.ccms.contentspec.BaseUnitTest;
import org.jboss.pressgang.ccms.contentspec.processor.exceptions.InvalidKeyValueException;
import org.jboss.pressgang.ccms.utils.structures.Pair;
import org.junit.Test;

public class adhoc_ProcessorUtilitiesTest extends BaseUnitTest {

    @ArbitraryString(type = StringType.ALPHANUMERIC)
    String key;

    @ArbitraryString(type = StringType.ALPHANUMERIC)
    String value;

    @ArbitraryString(type = StringType.ALPHANUMERIC)
    String randomString;
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 49 Exception Exception

SimpleName:IDENTIFIER 55 parseLevelLine parseLevelLine

SimpleName:IDENTIFIER 55 parserData parserData

SimpleName:IDENTIFIER 55 lineNumber lineNumber

"Invalid Chapter/Section/Appendix/Part/Preface! Incorrect format."

@Test
public void shouldThrowExceptionIfLevelFormatInvalid() throws Exception {
    String line = "";
    parser.parseLevelLine(parserData, line, lineNumber);
}

@Test(expected = ParsingException.class)
public void shouldThrowExceptionIfLevelFormatInvalid() throws Exception {
    String line = "";
    parser.parseLevelLine(parserData, line, lineNumber);
}

package org.jboss.pressgang.ccms.contentspec.processor;

import static java.util.Arrays.asList;
import static net.sf.ipsedixit.core.StringType.ALPHANUMERIC;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
import static org.jboss.pressgang.ccms.contentspec.TestUtil.selectRandomLevelType;
import static org.jboss.pressgang.ccms.contentspec.TestUtil.selectRandomListItem;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import net.sf.ipsedixit.annotation.Arbitrary;
import net.sf.ipsedixit.annotation.ArbitraryString;
import org.jboss.pressgang.ccms.contentspec.Level;
import org.jboss.pressgang.ccms.contentspec.enums.LevelType;
import org.jboss.pressgang.ccms.contentspec.exceptions.ParsingException;
import org.junit.Test;

public class adhoc_ContentSpecParserParseLevelLineTest extends ContentSpecParserTest {

    @Arbitrary
    Integer lineNumber;

    @ArbitraryString(type = ALPHANUMERIC)
    String title;
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 135 Exception Exception

StringLiteralExpr:LITERAL 137 "Chapter:" "Chapter:"

StringLiteralExpr:LITERAL
137
"[foo] [bar]"
"[foo] [bar]"

line = "Chapter:" + title + "[foo] [bar]"

SimpleName:IDENTIFIER 141 parseLevel parseLevel

SimpleName:IDENTIFIER 141 parserData parserData

SimpleName:IDENTIFIER 141 lineNumber lineNumber

SimpleName:IDENTIFIER 141 levelType levelType

@Test
public void shouldThrowExceptionWhenMultipleBracketedValues() throws Exception {
    String line = "Chapter:" + title + "[foo] [bar]";
    parser.parseLevel(parserData, lineNumber, levelType, line);
}

@Test(expected = ParsingException.class)
public void shouldThrowExceptionWhenMultipleBracketedValues() throws Exception {
    String line = "Chapter:" + title + "[foo] [bar]";
    parser.parseLevel(parserData, lineNumber, levelType, line);
}

package org.jboss.pressgang.ccms.contentspec.processor;

import static com.natpryce.makeiteasy.MakeItEasy.a;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static junit.framework.TestCase.assertTrue;
import static net.sf.ipsedixit.core.StringType.ALPHANUMERIC;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
import static org.jboss.pressgang.ccms.contentspec.TestUtil.selectRandomListItem;
import static org.jboss.pressgang.ccms.contentspec.test.makers.shared.LevelMaker.Level;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.List;
import net.sf.ipsedixit.annotation.Arbitrary;
import net.sf.ipsedixit.annotation.ArbitraryString;
import org.hamcrest.Matchers;
import org.jboss.pressgang.ccms.contentspec.InfoTopic;
import org.jboss.pressgang.ccms.contentspec.InitialContent;
import org.jboss.pressgang.ccms.contentspec.Level;
import org.jboss.pressgang.ccms.contentspec.SpecTopic;
import org.jboss.pressgang.ccms.contentspec.enums.LevelType;
import org.jboss.pressgang.ccms.contentspec.enums.TopicType;
import org.jboss.pressgang.ccms.contentspec.exceptions.ParsingException;
import org.jboss.pressgang.ccms.contentspec.test.makers.shared.SpecTopicMaker;
import org.junit.Before;
import org.junit.Test;

public class adhoc_ContentSpecParserParseLevelTest extends ContentSpecParserTest {

    @Arbitrary
    Integer lineNumber;

    @Arbitrary
    Integer id;

    @Arbitrary
    Integer revision;

    @Arbitrary
    LevelType levelType;

    @ArbitraryString(type = ALPHANUMERIC)
    String title;

    @ArbitraryString(type = ALPHANUMERIC)
    String url;

    @ArbitraryString(type = ALPHANUMERIC)
    String writer;

    @ArbitraryString(type = ALPHANUMERIC)
    String topicTag;

    @Before
    public void setUp() throws Exception {
        super.setUp();
        if (levelType == LevelType.BASE || levelType == LevelType.PROCESS || levelType == LevelType.INITIAL_CONTENT) {
            levelType = LevelType.SECTION;
        }
    }
    /*TEST PLACEHOLDER*/
}

SimpleName:IDENTIFIER 178 Exception Exception

StringLiteralExpr:LITERAL 180 "Chapter:" "Chapter:"

line = "Chapter:" + title + "[T" + id + "]"

SimpleName:IDENTIFIER 181 parserData parserData

SimpleName:IDENTIFIER 181 getTargetTopics getTargetTopics

SimpleName:IDENTIFIER 181 SpecTopicMaker SpecTopicMaker

SimpleName:IDENTIFIER 181 SpecTopic SpecTopic

SimpleName:IDENTIFIER 185 parseLevel parseLevel

SimpleName:IDENTIFIER 185 parserData parserData

SimpleName:IDENTIFIER 185 lineNumber lineNumber

SimpleName:IDENTIFIER 185 levelType levelType

"Target ID is duplicated. Target ID's must be unique."

@Test
public void shouldThrowExceptionIfAttemptToSetDuplicateTargetTopic() throws Exception {
    String line = "Chapter:" + title + "[T" + id + "]";
    parserData.getTargetTopics().put("T" + id, make(a(SpecTopicMaker.SpecTopic)));
    parser.parseLevel(parserData, lineNumber, levelType, line);
}

@Test(expected = ParsingException.class)
public void shouldThrowExceptionIfAttemptToSetDuplicateTargetTopic() throws Exception {
    String line = "Chapter:" + title + "[T" + id + "]";
    parserData.getTargetTopics().put("T" + id, make(a(SpecTopicMaker.SpecTopic)));
    parser.parseLevel(parserData, lineNumber, levelType, line);
}

SimpleName:IDENTIFIER 197 Exception Exception

StringLiteralExpr:LITERAL 199 "Chapter:" "Chapter:"

line = "Chapter:" + title + "[T" + id + "]"

SimpleName:IDENTIFIER 200 parserData parserData

SimpleName:IDENTIFIER 200 getTargetLevels getTargetLevels

SimpleName:IDENTIFIER 204 parseLevel parseLevel

SimpleName:IDENTIFIER 204 parserData parserData

SimpleName:IDENTIFIER 204 lineNumber lineNumber

SimpleName:IDENTIFIER 204 levelType levelType

@Test
public void shouldThrowExceptionIfAttemptToSetDuplicateTargetLevel() throws Exception {
    String line = "Chapter:" + title + "[T" + id + "]";
    parserData.getTargetLevels().put("T" + id, make(a(Level)));
    parser.parseLevel(parserData, lineNumber, levelType, line);
}

@Test(expected = ParsingException.class)
public void shouldThrowExceptionIfAttemptToSetDuplicateTargetLevel() throws Exception {
    String line = "Chapter:" + title + "[T" + id + "]";
    parserData.getTargetLevels().put("T" + id, make(a(Level)));
    parser.parseLevel(parserData, lineNumber, levelType, line);
}

SimpleName:IDENTIFIER 228 Exception Exception

SimpleName:IDENTIFIER 230 relationshipTypes relationshipTypes

StringLiteralExpr:LITERAL 230 "NEXT" "NEXT"

StringLiteralExpr:LITERAL 230 "PREV" "PREV"

Arrays.asList("R", "P", "L", "NEXT", "PREV")

SimpleName:IDENTIFIER 231 relationship relationship

SimpleName:IDENTIFIER 231 selectRandomListItem selectRandomListItem

SimpleName:IDENTIFIER 231 relationshipTypes relationshipTypes

SimpleName:IDENTIFIER 232 levelType levelType

SimpleName:IDENTIFIER 232 getTitle getTitle

levelType.getTitle() + ":" + title + "[T"

levelType.getTitle() + ":" + title + "[T" + id

StringLiteralExpr:LITERAL
232
"] ["
"] ["

SimpleName:IDENTIFIER 232 relationship relationship

SimpleName:IDENTIFIER 236 parseLevel parseLevel

SimpleName:IDENTIFIER 236 parserData parserData

SimpleName:IDENTIFIER 236 lineNumber lineNumber

SimpleName:IDENTIFIER 236 levelType levelType

@Test
public void shouldThrowExceptionIfRelationshipSpecified() throws Exception {
    List<String> relationshipTypes = Arrays.asList("R", "P", "L", "NEXT", "PREV");
    String relationship = selectRandomListItem(relationshipTypes);
    String line = levelType.getTitle() + ":" + title + "[T" + id + "] [" + relationship + ": " + title + "[" + id + "]]";
    parser.parseLevel(parserData, lineNumber, levelType, line);
}

@Test(expected = ParsingException.class)
public void shouldThrowExceptionIfRelationshipSpecified() throws Exception {
    List<String> relationshipTypes = Arrays.asList("R", "P", "L", "NEXT", "PREV");
    String relationship = selectRandomListItem(relationshipTypes);
    String line = levelType.getTitle() + ":" + title + "[T" + id + "] [" + relationship + ": " + title + "[" + id + "]]";
    parser.parseLevel(parserData, lineNumber, levelType, line);
}


SimpleName:IDENTIFIER 96 expected expected

SimpleName:IDENTIFIER 96 TextParseException TextParseException

SimpleName:IDENTIFIER 99 formatter formatter

StringLiteralExpr:LITERAL 99 "bLuE" "bLuE"

@Test(expected = TextParseException.class)
public void testParse_fail() {
    formatter.parse("bLuE");
}

package com.github.mygreen.supercsv.cellprocessor.format;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import com.github.mygreen.supercsv.cellprocessor.format.EnumFormatter;
import com.github.mygreen.supercsv.cellprocessor.format.TextParseException;

public class adhoc_EnumFormatterTest {

    private EnumFormatter<TestEnum> formatter;

    private EnumFormatter<TestEnum> selectorFormatter;

    private EnumFormatter<TestEnum> ignoreCaseFormatter;

    private EnumFormatter<TestEnum> ignoreCaseSelectorFormatter;

    public enum TestEnum {

        Red("赤(RED)"), Blue("青(BLUE)"), Yellow("黄(Yellow)");

        final String aliasName;

        private TestEnum(String aliasName) {
            this.aliasName = aliasName;
        }

        public String aliasName() {
            return aliasName;
        }
    }

    @Before
    public void setUp() throws Exception {
        this.formatter = new EnumFormatter<TestEnum>(TestEnum.class);
        this.selectorFormatter = new EnumFormatter<>(TestEnum.class, "aliasName");
        this.ignoreCaseFormatter = new EnumFormatter<>(TestEnum.class, true);
        this.ignoreCaseSelectorFormatter = new EnumFormatter<>(TestEnum.class, true, "aliasName");
    }
    /*TEST PLACEHOLDER*/
}

SimpleName:IDENTIFIER 110 expected expected

SimpleName:IDENTIFIER 110 TextParseException TextParseException

SimpleName:IDENTIFIER 113 selectorFormatter selectorFormatter

StringLiteralExpr:LITERAL 113 "青(bLuE)" "青(bLuE)"

{
    selectorFormatter.parse("青(bLuE)");
}

@Test(expected = TextParseException.class)
public void testParseWithSelector_wrong() {
    selectorFormatter.parse("青(bLuE)");
}

{
    selectorFormatter.parse("青(bLuE)");
}


SimpleName:IDENTIFIER 76 expected expected

SimpleName:IDENTIFIER 76 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 77 testPrintWithInvalidAtNull testPrintWithInvalidAtNull

SimpleName:IDENTIFIER 78 formatter formatter

SimpleName:IDENTIFIER 78 Integer Integer

@Test(expected = IllegalArgumentException.class)
public void testPrintWithInvalidAtNull() {
    formatter.print((Integer) null);
    fail();
}

package com.github.mygreen.supercsv.cellprocessor.format;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.Before;
import org.junit.Test;
import com.github.mygreen.supercsv.cellprocessor.format.NumberFormatWrapper;
import com.github.mygreen.supercsv.cellprocessor.format.TextParseException;

public class adhoc_NumberFormatWrapperTest {

    private NumberFormatWrapper<Integer> formatter;

    private NumberFormatWrapper<Integer> lenientFormatter;

    private NumberFormatWrapper<Integer> parseBigDecimalFormatter;

    private NumberFormatWrapper<Integer> lenientParseBigDecimalFormatter;

    @Before
    public void setUp() {
        DecimalFormat df1 = new DecimalFormat("#,##0.0##");
        this.formatter = new NumberFormatWrapper<>(df1, Integer.class);
        this.lenientFormatter = new NumberFormatWrapper<>(df1, Integer.class, true);
        DecimalFormat df2 = new DecimalFormat("#,##0.0##");
        df2.setParseBigDecimal(true);
        this.parseBigDecimalFormatter = new NumberFormatWrapper<>(df2, Integer.class);
        this.lenientParseBigDecimalFormatter = new NumberFormatWrapper<>(df2, Integer.class, true);
    }
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 50 expected expected

SimpleName:IDENTIFIER 50 TextParseException TextParseException

SimpleName:IDENTIFIER 52 formatter formatter

{
    formatter.parse(null);
    fail();
}

@Test(expected = TextParseException.class)
public void testParse_inputNull() {
    formatter.parse(null);
    fail();
}

{
    formatter.parse(null);
    fail();
}

package com.github.mygreen.supercsv.cellprocessor.format;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;

public class adhoc_BoolenFormatterTest {

    private BooleanFormatter formatter;

    private BooleanFormatter customValueFormatter;

    private BooleanFormatter customValueIgnoreCaseFormatter;

    private String[] readCustomTrues = { "○", "レ", "Ok" };

    private String[] readCustomFalses = { "×", "ー", "Cancel", "" };

    private String writeCustomTrues = "○";

    private String writeCustomFalses = "×";

    private static final String VALIDATION_MESSAGE = "値は「{joindedTrueValues}, {joindedFalseValues}」の何れかである必要があります。";

    @Before
    public void setUp() throws Exception {
        this.formatter = new BooleanFormatter();
        this.customValueFormatter = new BooleanFormatter(readCustomTrues, readCustomFalses, writeCustomTrues, writeCustomFalses, false, false);
        this.customValueIgnoreCaseFormatter = new BooleanFormatter(readCustomTrues, readCustomFalses, writeCustomTrues, writeCustomFalses, true, true);
    }
    /*TEST PLACEHOLDER*/
}

SimpleName:IDENTIFIER 56 expected expected

SimpleName:IDENTIFIER 56 TextParseException TextParseException

SimpleName:IDENTIFIER 58 formatter formatter

{
    formatter.parse("");
    fail();
}

@Test(expected = TextParseException.class)
public void testParse_inputEmpty() {
    formatter.parse("");
    fail();
}

{
    formatter.parse("");
    fail();
}

SimpleName:IDENTIFIER 62 expected expected

SimpleName:IDENTIFIER 62 TextParseException TextParseException

SimpleName:IDENTIFIER 64 formatter formatter

StringLiteralExpr:LITERAL 64 "True" "True"

{
    formatter.parse("True");
    fail();
}

@Test(expected = TextParseException.class)
public void testParse_fail() {
    formatter.parse("True");
    fail();
}

{
    formatter.parse("True");
    fail();
}

SimpleName:IDENTIFIER 74 expected expected

SimpleName:IDENTIFIER 74 TextParseException TextParseException

SimpleName:IDENTIFIER 76 customValueFormatter customValueFormatter

{
    customValueFormatter.parse("OK");
}

@Test(expected = TextParseException.class)
public void testParseWithCustomValue_fail() {
    customValueFormatter.parse("OK");
}

{
    customValueFormatter.parse("OK");
}


SimpleName:IDENTIFIER 71 expected expected

SimpleName:IDENTIFIER 71 NullPointerException NullPointerException

SimpleName:IDENTIFIER 72 testConstructorAtFormatterNull testConstructorAtFormatterNull

SimpleName:IDENTIFIER 73 DateFormatWrapper DateFormatWrapper

SimpleName:IDENTIFIER 73 DateFormat DateFormat

@Test(expected = NullPointerException.class)
public void testConstructorAtFormatterNull() {
    new DateFormatWrapper<>((DateFormat) null, Date.class);
    fail();
}

package com.github.mygreen.supercsv.cellprocessor.format;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import static com.github.mygreen.supercsv.tool.TestUtils.*;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.Before;
import org.junit.Test;
import com.github.mygreen.supercsv.cellprocessor.format.DateFormatWrapper;
import com.github.mygreen.supercsv.cellprocessor.format.SimpleDateFormatBuilder;
import com.github.mygreen.supercsv.cellprocessor.format.TextParseException;

public class adhoc_DateFormatWrapperTest {

    private DateFormatWrapper<Date> formatter;

    private DateFormatWrapper<Date> utilDateFormatter;

    private DateFormatWrapper<java.sql.Date> sqlDateFormatter;

    private DateFormatWrapper<Timestamp> timestampFormatter;

    private DateFormatWrapper<Time> timeFormatter;

    private Date normalDateValue = toDate(2016, 2, 29, 9, 13, 1);

    private String normalDateStr = "2016/02/29 09:13:01";

    private Date utilDateValue = toDate(2016, 2, 29, 9, 13, 1);

    private String utilDateStr = "2016-02-29 09:13:01";

    private Date sqlDateValue = toSqlDate(2016, 2, 29);

    private String sqlDateStr = "2016-02-29";

    private Date timeValue = toTime(9, 13, 1);

    private String timeStr = "09:13:01";

    private Date timestampValue = toTimestamp(2016, 2, 29, 9, 13, 1, 123);

    private String timestampStr = "2016-02-29 09:13:01.123";

    @Before
    public void setUp() {
        this.formatter = new DateFormatWrapper<>(SimpleDateFormatBuilder.create("yyyy/MM/dd HH:mm:ss").lenient(true).build(), Date.class);
        this.utilDateFormatter = new DateFormatWrapper<>(Date.class);
        this.sqlDateFormatter = new DateFormatWrapper<>(java.sql.Date.class);
        this.timestampFormatter = new DateFormatWrapper<>(Timestamp.class);
        this.timeFormatter = new DateFormatWrapper<>(Time.class);
    }
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 77 expected expected

SimpleName:IDENTIFIER 77 NullPointerException NullPointerException

SimpleName:IDENTIFIER 78 testConstructorAtTypeNull testConstructorAtTypeNull

SimpleName:IDENTIFIER 79 DateFormatWrapper DateFormatWrapper

@Test(expected = NullPointerException.class)
public void testConstructorAtTypeNull() {
    new DateFormatWrapper<>((Class<Date>) null);
    fail();
}


SimpleName:IDENTIFIER 103 expected expected

SimpleName:IDENTIFIER 103 NullPointerException NullPointerException

SimpleName:IDENTIFIER 104 testPrintWithInvalidAtNull testPrintWithInvalidAtNull

SimpleName:IDENTIFIER 105 formatter formatter

{
    formatter.print(null);
    fail();
}

@Test(expected = NullPointerException.class)
public void testPrintWithInvalidAtNull() {
    formatter.print(null);
    fail();
}

{
    formatter.print(null);
    fail();
}


SimpleName:IDENTIFIER 109 expected expected

SimpleName:IDENTIFIER 109 TextParseException TextParseException

SimpleName:IDENTIFIER 111 formatter formatter

@Test(expected = TextParseException.class)
public void testParse_empty() {
    formatter.parse("");
}

SimpleName:IDENTIFIER 181 expected expected

SimpleName:IDENTIFIER 181 TextParseException TextParseException

SimpleName:IDENTIFIER 182 testParseWithInvalidAtWrong testParseWithInvalidAtWrong

SimpleName:IDENTIFIER 182 Exception Exception

SimpleName:IDENTIFIER 183 formatter formatter

StringLiteralExpr:LITERAL 183 "abc" "abc"

{
    formatter.parse("abc");
    fail();
}

@Test(expected = TextParseException.class)
public void testParseWithInvalidAtWrong() throws Exception {
    formatter.parse("abc");
    fail();
}

{
    formatter.parse("abc");
    fail();
}


SimpleName:IDENTIFIER 196 getFieldAccessor getFieldAccessor

SimpleName:IDENTIFIER 196 ErrorCsv ErrorCsv

SimpleName:IDENTIFIER 196 comparator comparator

SimpleName:IDENTIFIER 197 builder builder

SimpleName:IDENTIFIER 197 StringProcessorBuilder StringProcessorBuilder

SimpleName:IDENTIFIER 197 builderResolver builderResolver

SimpleName:IDENTIFIER 197 resolve resolve

SimpleName:IDENTIFIER 198 formatter formatter

SimpleName:IDENTIFIER 198 builder builder

SimpleName:IDENTIFIER 198 getFormatter getFormatter

SimpleName:IDENTIFIER 200 getAnnotationsByGroup getAnnotationsByGroup

SimpleName:IDENTIFIER 200 CsvLengthBetween CsvLengthBetween

SimpleName:IDENTIFIER 200 groupEmpty groupEmpty

SimpleName:IDENTIFIER 203 factory factory

SimpleName:IDENTIFIER 203 Optional Optional

SimpleName:IDENTIFIER 203 formatter formatter

"'%s' において、アノテーション @CsvLengthBetween の属性 'min' の値（10）は、属性 'max' の値（5）以下の値で設定してください。"

@Test
public void testCreate_attrMinMax_wrong() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_min_max_wrong", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthBetween anno = field.getAnnotationsByGroup(CsvLengthBetween.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

@Test(expected = Exception.class)
public void testCreate_attrMinMax_wrong() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_min_max_wrong", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthBetween anno = field.getAnnotationsByGroup(CsvLengthBetween.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

package com.github.mygreen.supercsv.cellprocessor.constraint;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import static com.github.mygreen.supercsv.tool.TestUtils.*;
import static com.github.mygreen.supercsv.tool.HasCellProcessorAssert.*;
import java.lang.annotation.Annotation;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.supercsv.cellprocessor.ift.CellProcessor;
import com.github.mygreen.supercsv.annotation.CsvBean;
import com.github.mygreen.supercsv.annotation.CsvColumn;
import com.github.mygreen.supercsv.annotation.constraint.CsvLengthBetween;
import com.github.mygreen.supercsv.builder.ProcessorBuilderResolver;
import com.github.mygreen.supercsv.builder.BeanMapping;
import com.github.mygreen.supercsv.builder.BeanMappingFactory;
import com.github.mygreen.supercsv.builder.BuildCase;
import com.github.mygreen.supercsv.builder.ColumnMapping;
import com.github.mygreen.supercsv.builder.Configuration;
import com.github.mygreen.supercsv.builder.FieldAccessor;
import com.github.mygreen.supercsv.builder.standard.StringProcessorBuilder;
import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
import com.github.mygreen.supercsv.exception.SuperCsvInvalidAnnotationException;
import com.github.mygreen.supercsv.exception.SuperCsvValidationException;
import com.github.mygreen.supercsv.validation.CsvExceptionConverter;

public class adhoc_LengthBetweenFactoryTest {

    @Rule
    public TestName name = new TestName();

    private LengthBetweenFactory factory;

    private Configuration config;

    private Comparator<Annotation> comparator;

    private ProcessorBuilderResolver builderResolver;

    private BeanMappingFactory beanMappingFactory;

    private CsvExceptionConverter exceptionConverter;

    private final Class<?>[] groupEmpty = new Class[] {};

    @Before
    public void setUp() throws Exception {
        this.factory = new LengthBetweenFactory();
        this.config = new Configuration();
        this.beanMappingFactory = new BeanMappingFactory();
        beanMappingFactory.setConfiguration(config);
        this.exceptionConverter = new CsvExceptionConverter();
        this.comparator = config.getAnnoationComparator();
        this.builderResolver = config.getBuilderResolver();
    }

    private static final String TEST_VALUE_VALID_INPUT = "abcde";

    private static final String TEST_VALUE_WRONG_INPUT_1 = "abcd";

    private static final String TEST_VALUE_WRONG_INPUT_2 = "abcdefghijk";

    @CsvBean
    private static class TestCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvLengthBetween(min = 5, max = 10)
        private String col_default;

        @CsvColumn(number = 10)
        @CsvLengthBetween(min = 5, max = 10, message = "テストメッセージ")
        private String col_message;

        @CsvColumn(number = 11)
        @CsvLengthBetween(min = 5, max = 10, message = "")
        private String col_message_empty;

        @CsvColumn(number = 12)
        @CsvLengthBetween(min = 5, max = 10, message = "lineNumber={lineNumber}, rowNumber={rowNumber}, columnNumber={columnNumber}, label={label}, validatedValue={validatedValue}, length={length}, min={min}, max={max}")
        private String col_message_variables;
    }

    @CsvBean
    private static class ErrorCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvLengthBetween(min = 10, max = 5)
        private String col_min_max_wrong;

        @CsvColumn(number = 2, label = "カラム2")
        @CsvLengthBetween(min = -1, max = 5)
        private String col_min_minus;
    }
    /*TEST PLACEHOLDER*/
}

属性min, maxのテスト - minがmaxよりも大きい場合

属性min, maxのテスト - minがmaxよりも大きい場合

SimpleName:IDENTIFIER 221 getFieldAccessor getFieldAccessor

SimpleName:IDENTIFIER 221 ErrorCsv ErrorCsv

SimpleName:IDENTIFIER 221 comparator comparator

SimpleName:IDENTIFIER 222 builder builder

SimpleName:IDENTIFIER 222 StringProcessorBuilder StringProcessorBuilder

SimpleName:IDENTIFIER 222 builderResolver builderResolver

SimpleName:IDENTIFIER 222 resolve resolve

SimpleName:IDENTIFIER 223 formatter formatter

SimpleName:IDENTIFIER 223 builder builder

SimpleName:IDENTIFIER 223 getFormatter getFormatter

SimpleName:IDENTIFIER 225 getAnnotationsByGroup getAnnotationsByGroup

SimpleName:IDENTIFIER 225 CsvLengthBetween CsvLengthBetween

SimpleName:IDENTIFIER 225 groupEmpty groupEmpty

SimpleName:IDENTIFIER 228 factory factory

SimpleName:IDENTIFIER 228 Optional Optional

SimpleName:IDENTIFIER 228 formatter formatter

"'%s' において、アノテーション @CsvLengthBetween の属性 'min' の値（-1）は、0以上の値を設定してください。"

@Test
public void testCreate_attrMi_minus() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_min_minus", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthBetween anno = field.getAnnotationsByGroup(CsvLengthBetween.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

@Test(expected = Exception.class)
public void testCreate_attrMi_minus() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_min_minus", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthBetween anno = field.getAnnotationsByGroup(CsvLengthBetween.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

属性minのテスト - minが負の数

属性minのテスト - minが負の数


SimpleName:IDENTIFIER 241 getFieldAccessor getFieldAccessor

SimpleName:IDENTIFIER 241 ErrorCsv ErrorCsv

SimpleName:IDENTIFIER 241 comparator comparator

SimpleName:IDENTIFIER 242 builder builder

SimpleName:IDENTIFIER 242 StringProcessorBuilder StringProcessorBuilder

SimpleName:IDENTIFIER 242 builderResolver builderResolver

SimpleName:IDENTIFIER 242 resolve resolve

SimpleName:IDENTIFIER 243 formatter formatter

SimpleName:IDENTIFIER 243 builder builder

SimpleName:IDENTIFIER 243 getFormatter getFormatter

SimpleName:IDENTIFIER 245 getAnnotationsByGroup getAnnotationsByGroup

SimpleName:IDENTIFIER 245 CsvWordRequire CsvWordRequire

SimpleName:IDENTIFIER 245 groupEmpty groupEmpty

SimpleName:IDENTIFIER 248 factory factory

SimpleName:IDENTIFIER 248 Optional Optional

SimpleName:IDENTIFIER 248 formatter formatter

"'%s' において、アノテーション @CsvWordRequire の属性 'value or provider' の指定は必須です。"

@Test
public void testCreate_attrNoValueProvider() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_no_value_provider", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvWordRequire anno = field.getAnnotationsByGroup(CsvWordRequire.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

@Test(expected = Exception.class)
public void testCreate_attrNoValueProvider() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_no_value_provider", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvWordRequire anno = field.getAnnotationsByGroup(CsvWordRequire.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

package com.github.mygreen.supercsv.cellprocessor.constraint;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import static com.github.mygreen.supercsv.tool.TestUtils.*;
import static com.github.mygreen.supercsv.tool.HasCellProcessorAssert.*;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.supercsv.cellprocessor.ift.CellProcessor;
import com.github.mygreen.supercsv.annotation.CsvBean;
import com.github.mygreen.supercsv.annotation.CsvColumn;
import com.github.mygreen.supercsv.annotation.constraint.CsvWordRequire;
import com.github.mygreen.supercsv.builder.ProcessorBuilderResolver;
import com.github.mygreen.supercsv.builder.BeanMapping;
import com.github.mygreen.supercsv.builder.BeanMappingFactory;
import com.github.mygreen.supercsv.builder.BuildCase;
import com.github.mygreen.supercsv.builder.ColumnMapping;
import com.github.mygreen.supercsv.builder.Configuration;
import com.github.mygreen.supercsv.builder.FieldAccessor;
import com.github.mygreen.supercsv.builder.standard.StringProcessorBuilder;
import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
import com.github.mygreen.supercsv.exception.SuperCsvInvalidAnnotationException;
import com.github.mygreen.supercsv.exception.SuperCsvValidationException;
import com.github.mygreen.supercsv.validation.CsvExceptionConverter;

public class adhoc_WordRequireFactoryTest {

    @Rule
    public TestName name = new TestName();

    private WordRequireFactory factory;

    private Configuration config;

    private Comparator<Annotation> comparator;

    private ProcessorBuilderResolver builderResolver;

    private BeanMappingFactory beanMappingFactory;

    private CsvExceptionConverter exceptionConverter;

    private final Class<?>[] groupEmpty = new Class[] {};

    @Before
    public void setUp() throws Exception {
        this.factory = new WordRequireFactory();
        this.config = new Configuration();
        this.beanMappingFactory = new BeanMappingFactory();
        beanMappingFactory.setConfiguration(config);
        this.exceptionConverter = new CsvExceptionConverter();
        this.comparator = config.getAnnoationComparator();
        this.builderResolver = config.getBuilderResolver();
    }

    private static final String TEST_VALUE_VALID_INPUT = "今日はいい天気です。よろしくお願いいたします。";

    private static final String TEST_VALUE_WRONG_INPUT = "明日は晴れるといいね。よろしくお願いいたします。";

    @CsvBean
    private static class TestCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvWordRequire(value = { "今日", "天気", "よろしく" })
        private String col_default;

        @CsvColumn(number = 2)
        @CsvWordRequire(provider = FileRequiredWordProvider.class)
        private String col_provider;

        @CsvColumn(number = 10)
        @CsvWordRequire(value = { "今日", "天気", "よろしく" }, message = "テストメッセージ")
        private String col_message;

        @CsvColumn(number = 11)
        @CsvWordRequire(value = { "今日", "天気", "よろしく" }, message = "")
        private String col_message_empty;

        @CsvColumn(number = 12)
        @CsvWordRequire(value = { "今日", "天気", "よろしく" }, message = "lineNumber={lineNumber}, rowNumber={rowNumber}, columnNumber={columnNumber}, label={label}, validatedValue={validatedValue}, words=${f:join(words, ', ')}")
        private String col_message_variables;
    }

    @CsvBean
    private static class ErrorCsv {

        @CsvColumn(number = 1)
        @CsvWordRequire
        private String col_no_value_provider;
    }

    private static class FileRequiredWordProvider implements RequiredWordProvider {

        @Override
        public Collection<String> getRequiredWords(final FieldAccessor field) {
            try {
                return Files.readAllLines(new File("src/test/data/data_required_word.txt").toPath(), Charset.forName("UTF-8"));
            } catch (IOException e) {
                throw new RuntimeException("fail reading the required file.", e);
            }
        }
    }
    /*TEST PLACEHOLDER*/
}

属性value, providerの指定がない


SimpleName:IDENTIFIER 93 expected expected

SimpleName:IDENTIFIER 93 SuperCsvCellProcessorException SuperCsvCellProcessorException

SimpleName:IDENTIFIER 96 processor processor

SimpleName:IDENTIFIER 96 execute execute

StringLiteralExpr:LITERAL 96 "abc" "abc"

@Test(expected = SuperCsvCellProcessorException.class)
public void testExecute_inputNonSameInstance() {
    processor.execute("abc", ANONYMOUS_CSVCONTEXT);
    fail();
}

package com.github.mygreen.supercsv.cellprocessor.constraint;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import static com.github.mygreen.supercsv.tool.TestUtils.*;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.exception.SuperCsvCellProcessorException;
import com.github.mygreen.supercsv.annotation.CsvBean;
import com.github.mygreen.supercsv.annotation.CsvColumn;
import com.github.mygreen.supercsv.cellprocessor.format.NumberFormatWrapper;
import com.github.mygreen.supercsv.exception.SuperCsvValidationException;

public class adhoc_EqualsTest {

    private CellProcessor processor;

    private CellProcessor processorChain;

    private CellProcessor processorValuesEmpty;

    private NumberFormatWrapper<Integer> formatter = new NumberFormatWrapper<>(new DecimalFormat("#,###"), Integer.class);

    private List<Integer> VALUES = Arrays.asList(1000, -1000);

    @Before
    public void setUp() throws Exception {
        this.processor = new Equals<>(Integer.class, VALUES, formatter);
        this.processorChain = new Equals<>(Integer.class, VALUES, formatter, new NextCellProcessor());
        this.processorValuesEmpty = new Equals<>(Integer.class, Collections.emptyList(), formatter);
    }

    @CsvBean
    private static class TestCsv {

        @CsvColumn(number = 1)
        Integer column1;
    }
    /*TEST PLACEHOLDER*/
}

入力値のクラスタイプが不正な場合

入力値のクラスタイプが不正な場合


SimpleName:IDENTIFIER 173 getFieldAccessor getFieldAccessor

SimpleName:IDENTIFIER 173 ErrorCsv ErrorCsv

SimpleName:IDENTIFIER 173 comparator comparator

SimpleName:IDENTIFIER 174 builder builder

SimpleName:IDENTIFIER 174 StringProcessorBuilder StringProcessorBuilder

SimpleName:IDENTIFIER 174 builderResolver builderResolver

SimpleName:IDENTIFIER 174 resolve resolve

SimpleName:IDENTIFIER 175 formatter formatter

SimpleName:IDENTIFIER 175 builder builder

SimpleName:IDENTIFIER 175 getFormatter getFormatter

SimpleName:IDENTIFIER 177 getAnnotationsByGroup getAnnotationsByGroup

SimpleName:IDENTIFIER 177 CsvLengthMax CsvLengthMax

SimpleName:IDENTIFIER 177 groupEmpty groupEmpty

SimpleName:IDENTIFIER 180 factory factory

SimpleName:IDENTIFIER 180 Optional Optional

SimpleName:IDENTIFIER 180 formatter formatter

"'%s' において、アノテーション @CsvLengthMax の属性 'value' の値（0）は、1以上の値を設定してください。"

@Test
public void testCreate_attrValue_zero() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_value_zero", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthMax anno = field.getAnnotationsByGroup(CsvLengthMax.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

@Test(expected = Exception.class)
public void testCreate_attrValue_zero() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_value_zero", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthMax anno = field.getAnnotationsByGroup(CsvLengthMax.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

package com.github.mygreen.supercsv.cellprocessor.constraint;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import static com.github.mygreen.supercsv.tool.TestUtils.*;
import static com.github.mygreen.supercsv.tool.HasCellProcessorAssert.*;
import java.lang.annotation.Annotation;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.supercsv.cellprocessor.ift.CellProcessor;
import com.github.mygreen.supercsv.annotation.CsvBean;
import com.github.mygreen.supercsv.annotation.CsvColumn;
import com.github.mygreen.supercsv.annotation.constraint.CsvLengthMax;
import com.github.mygreen.supercsv.builder.ProcessorBuilderResolver;
import com.github.mygreen.supercsv.builder.BeanMapping;
import com.github.mygreen.supercsv.builder.BeanMappingFactory;
import com.github.mygreen.supercsv.builder.BuildCase;
import com.github.mygreen.supercsv.builder.ColumnMapping;
import com.github.mygreen.supercsv.builder.Configuration;
import com.github.mygreen.supercsv.builder.FieldAccessor;
import com.github.mygreen.supercsv.builder.standard.StringProcessorBuilder;
import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
import com.github.mygreen.supercsv.exception.SuperCsvInvalidAnnotationException;
import com.github.mygreen.supercsv.exception.SuperCsvValidationException;
import com.github.mygreen.supercsv.validation.CsvExceptionConverter;

public class adhoc_LengthMaxFactoryTest {

    @Rule
    public TestName name = new TestName();

    private LengthMaxFactory factory;

    private Configuration config;

    private Comparator<Annotation> comparator;

    private ProcessorBuilderResolver builderResolver;

    private BeanMappingFactory beanMappingFactory;

    private CsvExceptionConverter exceptionConverter;

    private final Class<?>[] groupEmpty = new Class[] {};

    @Before
    public void setUp() throws Exception {
        this.factory = new LengthMaxFactory();
        this.config = new Configuration();
        this.beanMappingFactory = new BeanMappingFactory();
        beanMappingFactory.setConfiguration(config);
        this.exceptionConverter = new CsvExceptionConverter();
        this.comparator = config.getAnnoationComparator();
        this.builderResolver = config.getBuilderResolver();
    }

    private static final String TEST_VALUE_VALID_INPUT = "abcde";

    private static final String TEST_VALUE_WRONG_INPUT = "abcdef";

    @CsvBean
    private static class TestCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvLengthMax(value = 5)
        private String col_default;

        @CsvColumn(number = 10)
        @CsvLengthMax(value = 5, message = "テストメッセージ")
        private String col_message;

        @CsvColumn(number = 11)
        @CsvLengthMax(value = 5, message = "")
        private String col_message_empty;

        @CsvColumn(number = 12)
        @CsvLengthMax(value = 5, message = "lineNumber={lineNumber}, rowNumber={rowNumber}, columnNumber={columnNumber}, label={label}, validatedValue={validatedValue}, length={length}, max={max}")
        private String col_message_variables;
    }

    @CsvBean
    private static class ErrorCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvLengthMax(value = 0)
        private String col_value_zero;
    }
    /*TEST PLACEHOLDER*/
}

属性valueのテスト - valueが0


SimpleName:IDENTIFIER 173 getFieldAccessor getFieldAccessor

SimpleName:IDENTIFIER 173 ErrorCsv ErrorCsv

SimpleName:IDENTIFIER 173 comparator comparator

SimpleName:IDENTIFIER 174 builder builder

SimpleName:IDENTIFIER 174 StringProcessorBuilder StringProcessorBuilder

SimpleName:IDENTIFIER 174 builderResolver builderResolver

SimpleName:IDENTIFIER 174 resolve resolve

SimpleName:IDENTIFIER 175 formatter formatter

SimpleName:IDENTIFIER 175 builder builder

SimpleName:IDENTIFIER 175 getFormatter getFormatter

SimpleName:IDENTIFIER 177 getAnnotationsByGroup getAnnotationsByGroup

SimpleName:IDENTIFIER 177 CsvLengthMin CsvLengthMin

SimpleName:IDENTIFIER 177 groupEmpty groupEmpty

SimpleName:IDENTIFIER 180 factory factory

SimpleName:IDENTIFIER 180 Optional Optional

SimpleName:IDENTIFIER 180 formatter formatter

"'%s' において、アノテーション @CsvLengthMin の属性 'value' の値（-1）は、0以上の値を設定してください。"

@Test
public void testCreate_attrMin_minus() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_value_minus", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthMin anno = field.getAnnotationsByGroup(CsvLengthMin.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

@Test(expected = Exception.class)
public void testCreate_attrMin_minus() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_value_minus", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthMin anno = field.getAnnotationsByGroup(CsvLengthMin.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

package com.github.mygreen.supercsv.cellprocessor.constraint;

import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import static com.github.mygreen.supercsv.tool.TestUtils.*;
import static com.github.mygreen.supercsv.tool.HasCellProcessorAssert.*;
import java.lang.annotation.Annotation;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.supercsv.cellprocessor.ift.CellProcessor;
import com.github.mygreen.supercsv.annotation.CsvBean;
import com.github.mygreen.supercsv.annotation.CsvColumn;
import com.github.mygreen.supercsv.annotation.constraint.CsvLengthMin;
import com.github.mygreen.supercsv.builder.ProcessorBuilderResolver;
import com.github.mygreen.supercsv.builder.BeanMapping;
import com.github.mygreen.supercsv.builder.BeanMappingFactory;
import com.github.mygreen.supercsv.builder.BuildCase;
import com.github.mygreen.supercsv.builder.ColumnMapping;
import com.github.mygreen.supercsv.builder.Configuration;
import com.github.mygreen.supercsv.builder.FieldAccessor;
import com.github.mygreen.supercsv.builder.standard.StringProcessorBuilder;
import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
import com.github.mygreen.supercsv.exception.SuperCsvInvalidAnnotationException;
import com.github.mygreen.supercsv.exception.SuperCsvValidationException;
import com.github.mygreen.supercsv.validation.CsvExceptionConverter;

public class adhoc_LengthMinFactoryTest {

    @Rule
    public TestName name = new TestName();

    private LengthMinFactory factory;

    private Configuration config;

    private Comparator<Annotation> comparator;

    private ProcessorBuilderResolver builderResolver;

    private BeanMappingFactory beanMappingFactory;

    private CsvExceptionConverter exceptionConverter;

    private final Class<?>[] groupEmpty = new Class[] {};

    @Before
    public void setUp() throws Exception {
        this.factory = new LengthMinFactory();
        this.config = new Configuration();
        this.beanMappingFactory = new BeanMappingFactory();
        beanMappingFactory.setConfiguration(config);
        this.exceptionConverter = new CsvExceptionConverter();
        this.comparator = config.getAnnoationComparator();
        this.builderResolver = config.getBuilderResolver();
    }

    private static final String TEST_VALUE_VALID_INPUT = "abcde";

    private static final String TEST_VALUE_WRONG_INPUT = "abcd";

    @CsvBean
    private static class TestCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvLengthMin(value = 5)
        private String col_default;

        @CsvColumn(number = 10)
        @CsvLengthMin(value = 5, message = "テストメッセージ")
        private String col_message;

        @CsvColumn(number = 11)
        @CsvLengthMin(value = 5, message = "")
        private String col_message_empty;

        @CsvColumn(number = 12)
        @CsvLengthMin(value = 5, message = "lineNumber={lineNumber}, rowNumber={rowNumber}, columnNumber={columnNumber}, label={label}, validatedValue={validatedValue}, length={length}, min={min}")
        private String col_message_variables;
    }

    @CsvBean
    private static class ErrorCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvLengthMin(value = -1)
        private String col_value_minus;
    }
    /*TEST PLACEHOLDER*/
}

属性valueのテスト - valueが0


SimpleName:IDENTIFIER 205 getFieldAccessor getFieldAccessor

SimpleName:IDENTIFIER 205 ErrorCsv ErrorCsv

SimpleName:IDENTIFIER 205 comparator comparator

SimpleName:IDENTIFIER 206 builder builder

SimpleName:IDENTIFIER 206 StringProcessorBuilder StringProcessorBuilder

SimpleName:IDENTIFIER 206 builderResolver builderResolver

SimpleName:IDENTIFIER 206 resolve resolve

SimpleName:IDENTIFIER 207 formatter formatter

SimpleName:IDENTIFIER 207 builder builder

SimpleName:IDENTIFIER 207 getFormatter getFormatter

SimpleName:IDENTIFIER 209 getAnnotationsByGroup getAnnotationsByGroup

SimpleName:IDENTIFIER 209 CsvLengthExact CsvLengthExact

SimpleName:IDENTIFIER 209 groupEmpty groupEmpty

SimpleName:IDENTIFIER 212 factory factory

SimpleName:IDENTIFIER 212 Optional Optional

SimpleName:IDENTIFIER 212 formatter formatter

"'%s' において、アノテーション @CsvLengthExact の属性 'value' の指定は必須です。"

@Test
public void testCreate_attrValue_empty() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_value_empty", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthExact anno = field.getAnnotationsByGroup(CsvLengthExact.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

@Test(expected = Exception.class)
public void testCreate_attrValue_empty() {
    FieldAccessor field = getFieldAccessor(ErrorCsv.class, "col_value_empty", comparator);
    StringProcessorBuilder builder = (StringProcessorBuilder) builderResolver.resolve(String.class);
    TextFormatter<String> formatter = builder.getFormatter(field, config);
    CsvLengthExact anno = field.getAnnotationsByGroup(CsvLengthExact.class, groupEmpty).get(0);
    factory.create(anno, Optional.empty(), field, formatter, config);
}

package com.github.mygreen.supercsv.cellprocessor.constraint;

import static org.junit.Assert.*;
import java.lang.annotation.Annotation;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import static org.assertj.core.api.Assertions.*;
import static com.github.mygreen.supercsv.tool.TestUtils.*;
import static com.github.mygreen.supercsv.tool.HasCellProcessorAssert.*;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.supercsv.cellprocessor.ift.CellProcessor;
import com.github.mygreen.supercsv.annotation.CsvBean;
import com.github.mygreen.supercsv.annotation.CsvColumn;
import com.github.mygreen.supercsv.annotation.constraint.CsvLengthExact;
import com.github.mygreen.supercsv.builder.ProcessorBuilderResolver;
import com.github.mygreen.supercsv.builder.BeanMapping;
import com.github.mygreen.supercsv.builder.BeanMappingFactory;
import com.github.mygreen.supercsv.builder.BuildCase;
import com.github.mygreen.supercsv.builder.ColumnMapping;
import com.github.mygreen.supercsv.builder.Configuration;
import com.github.mygreen.supercsv.builder.FieldAccessor;
import com.github.mygreen.supercsv.builder.standard.StringProcessorBuilder;
import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
import com.github.mygreen.supercsv.exception.SuperCsvInvalidAnnotationException;
import com.github.mygreen.supercsv.exception.SuperCsvValidationException;
import com.github.mygreen.supercsv.validation.CsvExceptionConverter;

public class adhoc_LengthExactFactoryTest {

    @Rule
    public TestName name = new TestName();

    private LengthExactFactory factory;

    private Configuration config;

    private Comparator<Annotation> comparator;

    private ProcessorBuilderResolver builderResolver;

    private BeanMappingFactory beanMappingFactory;

    private CsvExceptionConverter exceptionConverter;

    private final Class<?>[] groupEmpty = new Class[] {};

    @Before
    public void setUp() throws Exception {
        this.factory = new LengthExactFactory();
        this.config = new Configuration();
        this.beanMappingFactory = new BeanMappingFactory();
        beanMappingFactory.setConfiguration(config);
        this.exceptionConverter = new CsvExceptionConverter();
        this.comparator = config.getAnnoationComparator();
        this.builderResolver = config.getBuilderResolver();
    }

    private static final String TEST_VALUE_VALID_INPUT = "abcde";

    private static final String TEST_VALUE_WRONG_INPUT = "abcd";

    @CsvBean
    private static class TestCsv {

        @CsvColumn(number = 1, label = "カラム1")
        @CsvLengthExact(value = { 5, 10 })
        private String col_default;

        @CsvColumn(number = 2)
        @CsvLengthExact(value = { 10, -1, 0, 0, 5, 5, 10 })
        private String col_length_duplicate_minus;

        @CsvColumn(number = 10)
        @CsvLengthExact(value = { 5, 10 }, message = "テストメッセージ")
        private String col_message;

        @CsvColumn(number = 11)
        @CsvLengthExact(value = { 5, 10 }, message = "")
        private String col_message_empty;

        @CsvColumn(number = 12)
        @CsvLengthExact(value = { 5, 10 }, message = "lineNumber={lineNumber}, rowNumber={rowNumber}, columnNumber={columnNumber}, label={label}, validatedValue={validatedValue}, length={length}, requiredLengths=${f:join(requiredLengths, ', ')}")
        private String col_message_variables;

        @CsvColumn(number = 13)
        @CsvLengthExact(value = 5)
        private String col_message_length1;
    }

    @CsvBean
    private static class ErrorCsv {

        @CsvColumn(number = 1)
        @CsvLengthExact(value = { -1 })
        private String col_value_empty;
    }
    /*TEST PLACEHOLDER*/
}

属性valueのテスト - 正常な値がない場合

属性valueのテスト - 正常な値がない場合