Question: As the question suggests, how can I check for certain imports with archUnit.

So I want the test to fail, when the tested class itself imports lombok.experimental.\*.

I understand how to check for packages and stuff like that, but the approach doesnt seem to work for imports. Any suggestions?

My Code:

```
package com.nikita.Nikitos;

import static org.junit.Assert.assertTrue;

import org.junit.Test;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;

public class AppTest
{
    @Test
    public void keineKlassenAusLombokExperimental() {

        JavaClasses classes = new ClassFileImporter()
                .importPackages("com.nikita..");

        noClasses().should().dependOnClassesThat()
        .resideInAPackage("lombok.experimental..").check(classes);

    }

}

```

The class that I want to test:

```
package com.nikita.Nikitos;

import lombok.experimental.UtilityClass;

@UtilityClass
public class App
{
static int hd;
}

```

Answer: 
The methods `valid?` and `invalid?` all keep running the validation methods every time they are called, and therefore potentially change the state of the model.

If you want to just check for validity when validation has already been run, you should instead use `@post.errors.present?` or `@post.errors.blank?` which will never change the status, only read existing errors (that were added in your case when the call to `update` failed.

Additionally (even if it´s not the case here) calling `valid?` and `invalid?` without a context will clear out errors that had been added with validations like `validate ..., on: :update`.
The solution I found was a combination of @rewritten´s answer and [this one](https://stackoverflow.com/questions/70400958/error-form-responses-must-redirect-to-another-location#answer-70400988).

So...

```
<h1>Editer l´article</h1>

<% if @post.errors.present? %>
  <div class="alert alert-danger">
    <% @post.errors.full_messages.each do |message| %>
      <%= message %>
    <% end %>
  </div>
<% end %>

<%= form_for @post, data: { turbo: false} do |f| %>
  <div class="form-group">
    <label>Titre de l´article</label>
    <%= f.text_field :name, class: 'form-control' %>
  </div>
  <div class="form-group">
    <label>Contenu de l´article</label>
    <%= f.text_area :content, class: 'form-control' %>
  </div>
  <div class="form-group">
    <%= f.submit "Modifier l´article", class: 'btn btn-primary' %>
  </div>
<% end %>

```