Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntegrationTests: Codec not found for requested operation: [TEXT <-> com.my.example.SquareToken] #1446

Closed
donahchoo opened this issue Oct 18, 2023 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@donahchoo
Copy link

I'm pretty sure this is some configuration error on my part, but I can't figure it out. From the documentation it seems like I should be able to access a repository in an integration test, but maybe not? I'm using SDC 3.4.12.

I have an integration test that is Autowiring in a repository.

public class ExampleIntegrationTest extends ControllerTestParent {
    @Autowired
    private SquareRepository squareRepository;

At the end of a test I want to do this to clean up:

squareRepository.delete(square);

This ends up throwing:

CassandraUncategorizedException: Codec not found for requested operation: [TEXT <-> com.my.example.SquareToken]

However, if I use mockMVC to call the endpoint that does a delete it works:

        MockHttpServletRequestBuilder deleteRequest = delete(squareToken).contentType(APPLICATION_JSON);
        this.mockMvc.perform(deleteRequest)
                    .andDo(print())
                    .andExpect(status().isNoContent());

I'm pretty sure that requests through the delete endpoint work because I have setup the converters, but I don't understand why the converters don't seem to be working when I use the repository in the integration test.

The @Table:

@Table
public class Square  {
    @PrimaryKey
    private SquareToken squareToken;

The converter: (I have one for SquareToken to String and String to SquareToken

public class SquareTokenToStringConverter implements Converter< SquareToken, String> {
    @Override
    public String convert(final SquareToken source) {
        return source.toString();
    }
}

And adding the converters to customConversions(). If I set a break point here I can see this method is getting called when I run the integration tests.

    @Override
    @Bean
    public @NotNull CassandraCustomConversions customConversions() {
        List<Converter<?, ?>> converters = new ArrayList<>();
        converters.add(new SquareTokenToStringConverter());
        converters.add(new StringToSquareTokenConverter());
        return new CassandraCustomConversions(converters);
    }
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 18, 2023
@mp911de
Copy link
Member

mp911de commented Oct 19, 2023

We revised the converter with #1384 earlier this year and backported the changes into 4.0.7. The 3.x development line doesn't contain these changes and that development line goes EOL by next month. Please upgrade to the latest Spring Data Cassandra version at your earliest convenience.

@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 19, 2023
@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants