We have studied the low-lying magnetic spectra of $^{12}\mathrm{C}$, $^{16}\mathrm{O}$, $^{40}\mathrm{Ca}$, $^{48}\mathrm{Ca}$, and $^{208}\mathrm{Pb}$ nuclei within the random phase approximation (RPA) theory, finding that the description of low-lying magnetic states of doubly-closed-shell nuclei imposes severe constraints on the spin and tensor terms of the nucleon-nucleon effective interaction. We first used four phenomenological effective interactions, and we obtained good agreement with the experimental magnetic spectra and, to a lesser extent, with the electron scattering responses. Then we made self-consistent RPA calculations to test the validity of the finite-range Gogny D1 interaction. For all the nuclei under study, we found that this interaction inverts the energies of all the magnetic states forming isospin doublets.