text:
\documentclass{article}

\input{preamble-articles}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% We define a command \@ifnextcharamong accepting an arbitrary number of
%%%% arguments. The first is what it should do if a match is found, the second
%%%% contains what it should do when no match is found; all the other arguments
%%%% are the things it tries to find as the next character.
%%%%
%%%% For example \@ifnextcharamong{#1}{#2}{*}{\bgroup} expands #1 if the next
%%%% character is a * or a \bgroup and it expands #2 otherwise.

\makeatletter
\newcommand{\@ifnextcharamong}[2]
  {\@ifnextchar\bgroup{\@@ifnextchar{#1}{\@@ifnextcharamong{#1}{#2}}}{#2}}
\newcommand{\@@ifnextchar}[3]{\@ifnextchar{#3}{#1}{#2}}
\newcommand{\@@ifnextcharamong}[3]{\@ifnextcharamong{#1}{#2}}
\makeatother

\newcommand{\ucomp}[1]{\hat{#1}}
\newcommand{\finset}[1]{{[#1]}}

\makeatletter
\newcommand{\higherequifibsf}{\mathcal}
\newcommand{\higherequifib}[2]{\higherequifibsf{#1}(#2)}
\newcommand{\underlyinggraph}[1]{U(#1)}
\newcommand{\theequifib}[1]{{\def\higherequifibsf{}#1}}
\makeatother

\newcommand{\loopspace}[2][]{\typefont{\Omega}^{#1}(#2)}
\newcommand{\join}[2]{{#1}*{#2}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Notes on algebraic topology}
\date{\today}

\begin{document}

\maketitle

\tableofcontents

\part{Spectral sequences}
\section{Background}
\begin{defn}
A graded $R$-module $M$ is an $R$-module which decomposes as a direct
sum
\begin{equation*}
\bigoplus_{p\in\Z} F_p M
\end{equation*}
of $R$-modules. A graded $R$-homomorphism $h:M\to N$ is an $R$-homomorphism which
decomposes into $h_p:F_pM\to F_pN$.
\end{defn}

\begin{lem}
Suppose $M$ and $N$ are graded $R$-modules. Then $M\otimes N$ is a graded
$R$-module by
\begin{equation*}
(M\otimes_R N)_i\defeq \bigoplus_{p+q=i} F_pM\otimes_R F_qN.
\end{equation*}
\end{lem}

\begin{defn}
A graded algebra is a graded $R$-module $M$ for which there are linear mappings
$\varphi_{p,q}:F_pM\otimes_R F_qM\to F_{p+q}M$, i.e.~a graded $R$-homomorphism
$\varphi:M\otimes M\to M$, which is associative in the sense
that the diagram
\begin{equation*}
\begin{tikzcd}
M\otimes M\otimes M \arrow[r,"\varphi\otimes 1"] \arrow[d,swap,"1\otimes\varphi"] &
M\otimes M \arrow[d,"\varphi"] \\ M\otimes M \arrow[r,swap,"\varphi"] & M
\end{tikzcd}
\end{equation*}
commutes.
\end{defn}

\begin{eg}
Polynomials with coefficients in $R$ forms a graded algebra. Moreover, in the
polynomial ring $R[X]$, we find that $G_pR[X]\defeq F_pR[X]/F_{p-1}R[X]\cong R$.
Since those are free modules, we have that $R[X]\cong \bigoplus_p G_pR[X]$.
\end{eg}

\section{Spectral sequences}

\subsection{Motivation from the long exact sequence of a pair}

Recall that a pair of spaces $(X,A)$ induces a long exact sequence of homology
groups
\begin{equation*}
\begin{tikzcd}
\cdots \arrow[r,"\partial_{n+1}"]
& H_n(A) \arrow[r,"i_n"]
& H_n(X) \arrow[r,"j_n"]
& H_n(X,A) \arrow[r,"\partial_n"]
& H_{n-1}(A) \arrow[r,"i_{n-1}"]
& \cdots
\end{tikzcd}
\end{equation*}
from the short exact sequence
\begin{equation*}
\begin{tikzcd}
0 \arrow[r] & C_\ast(A) \arrow[r] & C_\ast(X) \arrow[r] & C_\ast(X,A) \arrow[r] & 0
\end{tikzcd}
\end{equation*}
of chain complexes, by means of the snake lemma. This long exact sequence helps
us to compute $H_n(X)$ in terms of $H_n(A)$ and $H_n(X,A)$, which may be easier
to determine. For instance, from the long exact sequence we obtain the short
exact sequence
\begin{equation*}
\begin{tikzcd}
0 \arrow[r] & \mathrm{coker}(\partial_{n+1}) \arrow[r] & H_n(X) \arrow[r] & \mathrm{ker}(\partial_n) \arrow[r] & 0
\end{tikzcd}
\end{equation*}
and hence we have determined that $H_n(X)$ can be obtained as some element of the
group $\mathrm{Ext}(\mathrm{coker}(\partial_{n+1}),\mathrm{ker}(\partial_n))$.
In other words, $H_n(X)$ is a particular solution to an extension problem.

Note also that the long exact sequence of relative homology groups can be
presented as an exact triangle of graded $R$-homomorphisms:
\begin{equation*}
\begin{tikzcd}[column sep=0em]
\bigoplus_n H_n(C_\ast(A))
\arrow[rr,"i"] & & \bigoplus_n H_n(C_\ast(X)) \arrow[dl,"j"] \\
& \bigoplus_n H_n(C_\ast(X,A)) \arrow[ul,"\partial"]
\end{tikzcd}
\end{equation*}

The first idea of spectral sequences is to generalize the long exact sequence
of homology obtained from a pair of spaces, to an algebraic gadget obtained from
a filtration on a space, and mimic the derivation of determining the homology
group as a solution to an extension problem.

\begin{defn}
A filtration of a space X consists of a sequence
\begin{equation*}
\cdots\subseteq X_p\subseteq X_{p+1}\subseteq\cdots
\end{equation*}
such that $X=\bigcup_p X_p$ and $\bigcap_p X_p=\varnothing$. A filtration of $X$ is said to be bounded, if
$X_p=\varnothing$ for $p$ sufficiently small, and $X_p=X$ for $X$ sufficiently
large.
\end{defn}

An important class of filtered spaces is that of CW-complexes, where the filtration
$X_p$ of $X$ is given by the $p$-skeleton of $X$. Another case is where
$X_p\defeq\varnothing$ for $p<0$, $X_0\defeq A$ and $X_p\defeq X$ for $p>0$; here
we recover the old theory of the topological pair.

\begin{defn}
Given a space $X$ with a filtration, we can form the staircase diagram
\begin{footnotesize}
\begin{equation*}
\begin{tikzcd}
& \vdots \arrow[d] & & \vdots \arrow[d] \\
\cdots \arrow[r]
& H_{n+1}(X_p) \arrow[r] \arrow[d]
& H_{n+1}(X_p,X_{p-1}) \arrow[r]
& H_n(X_{p-1}) \arrow[r] \arrow[d]
& H_n(X_{p-1},X_{p-2}) \arrow[r]
& \cdots \\
\cdots \arrow[r]
& H_{n+1}(X_{p+1}) \arrow[r] \arrow[d]
& H_{n+1}(X_{p+1},X_{p}) \arrow[r]
& H_n(X_{p}) \arrow[r] \arrow[d]
& H_n(X_{p},X_{p-1}) \arrow[r]
& \cdots \\
& \vdots & & \vdots
\end{tikzcd}
\end{equation*}%
\end{footnotesize}%
in which the familiar long exact sequence of the pairs $(X_p,X_{p-1})$ run
down like a staircase.
\end{defn}

\begin{defn}
Let $X$ be a space with a filtration. Then we obtain the exact couple
\begin{equation*}
\begin{tikzcd}
A \arrow[rr,"i"] & & A \arrow[dl,"j"] \\
& E \arrow[ul,"\partial"]
\end{tikzcd}
\end{equation*}
in which $A\defeq\bigoplus_{p,n} H_n(X_p)$, and $E\defeq\bigoplus_{p,n}H_n(X_p,X_{p-1})$.
\end{defn}

We can come to such an exact couple from any filtered chain complex, which is
what we turn our attention to before continuing.

\subsection{The spectral sequence of a filtered complex}

\begin{defn}
A filtration of an $R$-module $M$ consists of a sequence
\begin{equation*}
\cdots\subseteq F_pM\subseteq F_{p+1}M\subseteq\cdots
\end{equation*}
of $R$-submodules of $M$, such that $M=\bigcup_p F_pM$ and $\bigcap_p F_pM=0$.
A filtration of $R$ is said to be bounded if $F_pM=0$ for $p$ sufficiently
small and $F_pM=M$ for $p$ sufficiently large.
\end{defn}

\begin{defn}
Let $\{M,F_pM\}$ be a graded $R$-module. The associated graded module is defined
by $G_p M\defeq F_pM/F_{p-1}M$. We obtain a short exact sequence
\begin{equation*}
\begin{tikzcd}
0 \arrow[r] & F_{p-1}M \arrow[r] & F_pM \arrow[r] & G_pM \arrow[r] & 0.
\end{tikzcd}
\end{equation*}
\end{defn}

\begin{rmk}
It would be nice if $F_pM\cong F_{p-1}M\oplus G_pM$, so that we can write
$M\cong\bigoplus_p G_pM$. Under what condition does this hold? This holds if
each $G_pM$ is a projective $R$-module, so under what conditions is this true?
\end{rmk}

\begin{defn}
A filtered chain complex is a chain complex $(C_\ast,\partial)$ together with a
filtration $\{F_pC_i\}$ of each $C_i$, such that the differential preserves the
filtration, i.e.~$\partial(F_pC_i)\subseteq F_p C_{i-1}$.

A filtration of a chain complex is said to be bounded if it is bounded in each
dimension.
\end{defn}

Let $(F_pC_\ast,\partial)$ be a filtered chain complex. We have again our
short exact sequence
\begin{equation*}
\begin{tikzcd}
0 \arrow[r] & F_{p-1} C_\ast \arrow[r] & F_p C_\ast \arrow[r] & G_p C_\ast \arrow[r] & 0
\end{tikzcd}
\end{equation*}
of chain complexes. This also gives us the long exact sequence on homology,
which we may express conveniently as the exact couple
\begin{equation*}
\begin{tikzcd}[column sep=0em]
\bigoplus_{p,q} H_{p+q}(F_pC_\ast) \arrow[rr,"i"] & & \bigoplus_{p,q} H_{p+q}(F_pC_\ast) \arrow[dl,"j"] \\
& \bigoplus_{p,q} H_{p+q}(G_p C_\ast) \arrow[ul,"k"]
\end{tikzcd}
\end{equation*}
consisting of graded $R$-homomorphisms (of which $k$ shifts in degree).

\begin{defn}
Consider an exact couple, i.e.~a commutative triangle
\begin{equation*}
\begin{tikzcd}
A \arrow[rr,"i"] & & A \arrow[dl,"j"] \\ & E \arrow[ul,"k"]
\end{tikzcd}
\end{equation*}
of $R$-modules, which is exact at every vertex. Taking $\partial^0\defeq j\circ k$,
we see that $(\partial^0)^2=0$ by exactness. We may now form the derived exact couple
\begin{equation*}
\begin{tikzcd}[column sep=0]
\mathrm{im}(i) \arrow[rr,"i'"] & & \mathrm{im}(i) \arrow[dl,"j'"] \\
& \frac{\mathrm{ker}(\partial)}{\mathrm{im}(\partial)} \arrow[ul,"k'"]
\end{tikzcd}
\end{equation*}
where
\begin{align*}
i'(i(a)) & \defeq i(i(a)) \\
j'(i(a)) & \defeq [j(a)] \\
k'([e]) & \defeq k(e)
\end{align*}
\end{defn}

\begin{rmk}
Since quotients commute with direct sums (both are colimits), it follows that
\begin{equation*}
E'\defeq \frac{\mathrm{ker}(\partial)}{\mathrm{im}(\partial)}
  \cong
\bigoplus_{p,q} \frac{\mathrm{ker}(\partial^0_{p,q})}{\mathrm{im}(\partial^0_{p,q+1})}
\end{equation*}
is a graded $R$-module. In other words, $E'$ is a direct sum of the homology
groups of the $p$-indexed family of chain complexes
\begin{equation*}
\begin{tikzcd}
\cdots \arrow[r] & E_{p,q}^0 \arrow[r,"{\partial^0_{p,q}}"] & E_{p,q-1}^0 \arrow[r] & \cdots
\end{tikzcd}
\end{equation*}
It follows that $i'$, $j'$ and $k'$ are graded
whenever $i$, $j$ and $k$ are, where $k'$ shifts down in dimension the same way
$k$ does.
\end{rmk}

\begin{comment}
\begin{defn}
We define
\begin{equation*}
E_{p,q}^0\defeq G_pC_{p+q}\defeq F_pC_{p+1}/F_{p-1}C_{p+q},
\end{equation*}

Since the differential preserves the filtration, we obtain from the differentials
well-defined $R$-homomorphisms functioning as the boundary maps in the chain complex

\end{defn}

\begin{defn}
The homology groups
\begin{equation*}
E^1_{p,q}\defeq \mathrm{ker}(\partial^0_{p,q})/\mathrm{im}(\partial^0_{p,q+1})
\end{equation*}
form again a chain complex, with boundary maps $\partial^1_{p,q}:E^1_{p,q}\to
E^1_{p,q-1}$. Thus, this process may be repeated indefinitely.
\end{defn}
\end{comment}

\begin{comment}
\begin{lem}
Let $(C_\ast,\partial)$ be a filtered chain complex. Then there is a filtration
on the homology of $C_\ast$, given by
\begin{equation*}
F_pH_i(C_\ast)\defeq\{\alpha\in H_i(C_\ast)\mid \exists_{(x\in F_p C_i)}\,\alpha=[x]\}.
\end{equation*}
\end{lem}
\end{comment}

\subsection{Convergent spectral sequences}

\begin{defn}
A spectral sequence consists of
\begin{enumerate}
\item An $R$-module $E^r_{p,q}$ for each $p,q\in\Z$ and each $r\geq 0$.
\item Differentials $\partial_r:E^r_{p,q}\to E^r_{p-r,q+r-1}$ such that
$\partial_r^2=0$ and $E^{r+1}$ is the homology of $(E^r,\partial_r)$
\end{enumerate}
\end{defn}

\begin{defn}
A spectral sequence $\{E^r,\partial_r\}$ of $R$-modules is said to converge
if for every $p,q\in\Z$, one has $\partial_r=0:E^r_{p,q}\to E^r_{p-r,q+r-1}$
for $r$ sufficiently large.
\end{defn}

\begin{rmk}
If a spectral sequence $\{E^r,\partial_r\}$ converges, then the $R$-module
$E^r_{p,q}$ is independent of $r$ for sufficiently large $r$.
\end{rmk}

\begin{thm}
Let $(F_pC_\ast,\partial)$ be a filtered complex. Then we obtain a spectral
sequence $(E^r_{p,q},\partial^r)$ defined for $r\geq 0$, with
\begin{equation*}
E^1_{p,q}\defeq H_{p+q}(G_pC_\ast).
\end{equation*}
This is the spectral sequence of filtered complexes.
\end{thm}

\begin{thm}
If $(F_pC_\ast,\partial)$ is a bounded filtered complex, then the spectral
sequence converges to
\begin{equation*}
E^\infty_{p,q}\defeq G_pH_{p+q}(C_\ast).
\end{equation*}
\end{thm}

Let $X$ be a filtered space, and let our goal be to compute the $n$-th (co)homology
group $H_n(X)$. In general, this might be a complicated task. However, it might
be easier to compute the homologies of the subcomplex $C_\ast(X_p)$, and the quotient
complex $C_\ast(X)/C_\ast(X_p)$. From this, we obtain a short exact sequence
\begin{equation*}
\begin{tikzcd}
0 \arrow[r]
& \mathrm{coker}(\delta) \arrow[r]
& H_\ast(X) \arrow[r]
& \mathrm{ker}(\delta) \arrow[r]
& 0
\end{tikzcd}
\end{equation*}

\subsection{The Serre spectral sequence}

The Serre spectral sequence relates the homology of a Serre fibration to the
homology of the fibers and the base. Thus, in some cases one can compute the
homology of the fibration in terms of the homology of the fibers and the base.

Let $\pi : X\to B$ be a fibration, with $B$ a path-connected CW-complex, and we
filter $X$ by the subspaces $X_p\defeq \pi^{-1}(B_p)$, in which $B_p$ is the
$p$-skeleton of $B$.

\begin{lem}
The spectral sequence for homology with coefficients in $G$ associated to this
filtration of $X$ converges to $H_\ast(X;G)$.
\end{lem}

\begin{thm}
Let $F\to X\to B$ be a fibration with $B$ path-connected. If $\pi_1(B)$ acts
trivially on $H_\ast(F;G)$, then there is a spectral sequence $\{E^r_{p,q},\partial_r\}$
with:
\begin{enumerate}
%\item $\partial_r : E^r_{p,q}\to E^r_{p-r,q+r-1}$ and $E^{r+1}_{p,q}=\mathrm{ker}\,d_r/\mathrm{im}\,dr$.
\item the stable terms $E^\infty_{p,n-p}$ are isomorphic to $F^p_n/F^{p-1}_n$ in
a filtration $0\subseteq F^0_n\subseteq\cdots\subseteq F^n_n=H_n(X;G)$ of ...
\item $E^2_{p,q}\cong H_p(B;H_q(F;G))$.
\end{enumerate}
\end{thm}

\end{document}


text:
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import os
import json
import pytest
from mock import ANY
from ansible.module_utils.network.fortios.fortios import FortiOSHandler

try:
    from ansible.modules.network.fortios import fortios_system_settings
except ImportError:
    pytest.skip("Could not load required modules for testing", allow_module_level=True)

@pytest.fixture(autouse=True)
def connection_mock(mocker):
    connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_system_settings.Connection')
    return connection_class_mock

fos_instance = FortiOSHandler(connection_mock)

def test_system_settings_creation(mocker):
    schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')

    set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
    set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)

    input_data = {
        'username': 'admin',
        'state': 'present',
        'system_settings': {
            'allow_linkdown_path': 'enable',
            'allow_subnet_overlap': 'enable',
            'asymroute': 'enable',
            'asymroute_icmp': 'enable',
            'asymroute6': 'enable',
            'asymroute6_icmp': 'enable',
            'bfd': 'enable',
            'bfd_desired_min_tx': '10',
            'bfd_detect_mult': '11',
            'bfd_dont_enforce_src_port': 'enable',
            'bfd_required_min_rx': '13',
            'block_land_attack': 'disable',
            'central_nat': 'enable',
            'comments': 'test_value_16',
            'compliance_check': 'enable',
            'default_voip_alg_mode': 'proxy-based',
            'deny_tcp_with_icmp': 'enable',
            'device': 'test_value_20',
            'dhcp_proxy': 'enable',
            'dhcp_server_ip': 'test_value_22',
            'dhcp6_server_ip': 'test_value_23',
            'discovered_device_timeout': '24',
            'ecmp_max_paths': '25',
            'email_portal_check_dns': 'disable',
            'firewall_session_dirty': 'check-all',
            'fw_session_hairpin': 'enable',
            'gateway': 'test_value_29',
            'gateway6': 'test_value_30',
            'gui_advanced_policy': 'enable',
            'gui_allow_unnamed_policy': 'enable',
            'gui_antivirus': 'enable',
            'gui_ap_profile': 'enable',
            'gui_application_control': 'enable',
            'gui_dhcp_advanced': 'enable',
            'gui_dlp': 'enable',
            'gui_dns_database': 'enable',
            'gui_dnsfilter': 'enable',
            'gui_domain_ip_reputation': 'enable',
            'gui_dos_policy': 'enable',
            'gui_dynamic_profile_display': 'enable',
            'gui_dynamic_routing': 'enable',
            'gui_email_collection': 'enable',
            'gui_endpoint_control': 'enable',
            'gui_endpoint_control_advanced': 'enable',
            'gui_explicit_proxy': 'enable',
            'gui_fortiap_split_tunneling': 'enable',
            'gui_fortiextender_controller': 'enable',
            'gui_icap': 'enable',
            'gui_implicit_policy': 'enable',
            'gui_ips': 'enable',
            'gui_load_balance': 'enable',
            'gui_local_in_policy': 'enable',
            'gui_local_reports': 'enable',
            'gui_multicast_policy': 'enable',
            'gui_multiple_interface_policy': 'enable',
            'gui_multiple_utm_profiles': 'enable',
            'gui_nat46_64': 'enable',
            'gui_object_colors': 'enable',
            'gui_policy_based_ipsec': 'enable',
            'gui_policy_learning': 'enable',
            'gui_replacement_message_groups': 'enable',
            'gui_spamfilter': 'enable',
            'gui_sslvpn_personal_bookmarks': 'enable',
            'gui_sslvpn_realms': 'enable',
            'gui_switch_controller': 'enable',
            'gui_threat_weight': 'enable',
            'gui_traffic_shaping': 'enable',
            'gui_voip_profile': 'enable',
            'gui_vpn': 'enable',
            'gui_waf_profile': 'enable',
            'gui_wan_load_balancing': 'enable',
            'gui_wanopt_cache': 'enable',
            'gui_webfilter': 'enable',
            'gui_webfilter_advanced': 'enable',
            'gui_wireless_controller': 'enable',
            'http_external_dest': 'fortiweb',
            'ike_dn_format': 'with-space',
            'ike_quick_crash_detect': 'enable',
            'ike_session_resume': 'enable',
            'implicit_allow_dns': 'enable',
            'inspection_mode': 'proxy',
            'ip': 'test_value_84',
            'ip6': 'test_value_85',
            'link_down_access': 'enable',
            'lldp_transmission': 'enable',
            'mac_ttl': '88',
            'manageip': 'test_value_89',
            'manageip6': 'test_value_90',
            'multicast_forward': 'enable',
            'multicast_skip_policy': 'enable',
            'multicast_ttl_notchange': 'enable',
            'ngfw_mode': 'profile-based',
            'opmode': 'nat',
            'prp_trailer_action': 'enable',
            'sccp_port': '97',
            'ses_denied_traffic': 'enable',
            'sip_helper': 'enable',
            'sip_nat_trace': 'enable',
            'sip_ssl_port': '101',
            'sip_tcp_port': '102',
            'sip_udp_port': '103',
            'snat_hairpin_traffic': 'enable',
            'ssl_ssh_profile': 'test_value_105',
            'status': 'enable',
            'strict_src_check': 'enable',
            'tcp_session_without_syn': 'enable',
            'utf8_spam_tagging': 'enable',
            'v4_ecmp_mode': 'source-ip-based',
            'vpn_stats_log': 'ipsec',
            'vpn_stats_period': '112',
            'wccp_cache_engine': 'enable'
        },
        'vdom': 'root'}

    is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)

    expected_data = {
        'allow-linkdown-path': 'enable',
        'allow-subnet-overlap': 'enable',
        'asymroute': 'enable',
        'asymroute-icmp': 'enable',
        'asymroute6': 'enable',
        'asymroute6-icmp': 'enable',
        'bfd': 'enable',
        'bfd-desired-min-tx': '10',
        'bfd-detect-mult': '11',
        'bfd-dont-enforce-src-port': 'enable',
        'bfd-required-min-rx': '13',
        'block-land-attack': 'disable',
        'central-nat': 'enable',
        'comments': 'test_value_16',
        'compliance-check': 'enable',
        'default-voip-alg-mode': 'proxy-based',
        'deny-tcp-with-icmp': 'enable',
        'device': 'test_value_20',
        'dhcp-proxy': 'enable',
        'dhcp-server-ip': 'test_value_22',
        'dhcp6-server-ip': 'test_value_23',
        'discovered-device-timeout': '24',
        'ecmp-max-paths': '25',
        'email-portal-check-dns': 'disable',
        'firewall-session-dirty': 'check-all',
        'fw-session-hairpin': 'enable',
        'gateway': 'test_value_29',
        'gateway6': 'test_value_30',
        'gui-advanced-policy': 'enable',
        'gui-allow-unnamed-policy': 'enable',
        'gui-antivirus': 'enable',
        'gui-ap-profile': 'enable',
        'gui-application-control': 'enable',
        'gui-dhcp-advanced': 'enable',
        'gui-dlp': 'enable',
        'gui-dns-database': 'enable',
        'gui-dnsfilter': 'enable',
        'gui-domain-ip-reputation': 'enable',
        'gui-dos-policy': 'enable',
        'gui-dynamic-profile-display': 'enable',
        'gui-dynamic-routing': 'enable',
        'gui-email-collection': 'enable',
        'gui-endpoint-control': 'enable',
        'gui-endpoint-control-advanced': 'enable',
        'gui-explicit-proxy': 'enable',
        'gui-fortiap-split-tunneling': 'enable',
        'gui-fortiextender-controller': 'enable',
        'gui-icap': 'enable',
        'gui-implicit-policy': 'enable',
        'gui-ips': 'enable',
        'gui-load-balance': 'enable',
        'gui-local-in-policy': 'enable',
        'gui-local-reports': 'enable',
        'gui-multicast-policy': 'enable',
        'gui-multiple-interface-policy': 'enable',
        'gui-multiple-utm-profiles': 'enable',
        'gui-nat46-64': 'enable',
        'gui-object-colors': 'enable',
        'gui-policy-based-ipsec': 'enable',
        'gui-policy-learning': 'enable',
        'gui-replacement-message-groups': 'enable',
        'gui-spamfilter': 'enable',
        'gui-sslvpn-personal-bookmarks': 'enable',
        'gui-sslvpn-realms': 'enable',
        'gui-switch-controller': 'enable',
        'gui-threat-weight': 'enable',
        'gui-traffic-shaping': 'enable',
        'gui-voip-profile': 'enable',
        'gui-vpn': 'enable',
        'gui-waf-profile': 'enable',
        'gui-wan-load-balancing': 'enable',
        'gui-wanopt-cache': 'enable',
        'gui-webfilter': 'enable',
        'gui-webfilter-advanced': 'enable',
        'gui-wireless-controller': 'enable',
        'http-external-dest': 'fortiweb',
        'ike-dn-format': 'with-space',
        'ike-quick-crash-detect': 'enable',
        'ike-session-resume': 'enable',
        'implicit-allow-dns': 'enable',
        'inspection-mode': 'proxy',
        'ip': 'test_value_84',
        'ip6': 'test_value_85',
        'link-down-access': 'enable',
        'lldp-transmission': 'enable',
        'mac-ttl': '88',
        'manageip': 'test_value_89',
        'manageip6': 'test_value_90',
        'multicast-forward': 'enable',
        'multicast-skip-policy': 'enable',
        'multicast-ttl-notchange': 'enable',
        'ngfw-mode': 'profile-based',
        'opmode': 'nat',
        'prp-trailer-action': 'enable',
        'sccp-port': '97',
        'ses-denied-traffic': 'enable',
        'sip-helper': 'enable',
        'sip-nat-trace': 'enable',
        'sip-ssl-port': '101',
        'sip-tcp-port': '102',
        'sip-udp-port': '103',
        'snat-hairpin-traffic': 'enable',
        'ssl-ssh-profile': 'test_value_105',
        'status': 'enable',
        'strict-src-check': 'enable',
        'tcp-session-without-syn': 'enable',
        'utf8-spam-tagging': 'enable',
        'v4-ecmp-mode': 'source-ip-based',
        'vpn-stats-log': 'ipsec',
        'vpn-stats-period': '112',
        'wccp-cache-engine': 'enable'
    }

    set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
    schema_method_mock.assert_not_called()
    assert not is_error
    assert changed
    assert response['status'] == 'success'
    assert response['http_status'] == 200

def test_system_settings_creation_fails(mocker):
    schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')

    set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500}
    set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)

    input_data = {
        'username': 'admin',
        'state': 'present',
        'system_settings': {
            'allow_linkdown_path': 'enable',
            'allow_subnet_overlap': 'enable',
            'asymroute': 'enable',
            'asymroute_icmp': 'enable',
            'asymroute6': 'enable',
            'asymroute6_icmp': 'enable',
            'bfd': 'enable',
            'bfd_desired_min_tx': '10',
            'bfd_detect_mult': '11',
            'bfd_dont_enforce_src_port': 'enable',
            'bfd_required_min_rx': '13',
            'block_land_attack': 'disable',
            'central_nat': 'enable',
            'comments': 'test_value_16',
            'compliance_check': 'enable',
            'default_voip_alg_mode': 'proxy-based',
            'deny_tcp_with_icmp': 'enable',
            'device': 'test_value_20',
            'dhcp_proxy': 'enable',
            'dhcp_server_ip': 'test_value_22',
            'dhcp6_server_ip': 'test_value_23',
            'discovered_device_timeout': '24',
            'ecmp_max_paths': '25',
            'email_portal_check_dns': 'disable',
            'firewall_session_dirty': 'check-all',
            'fw_session_hairpin': 'enable',
            'gateway': 'test_value_29',
            'gateway6': 'test_value_30',
            'gui_advanced_policy': 'enable',
            'gui_allow_unnamed_policy': 'enable',
            'gui_antivirus': 'enable',
            'gui_ap_profile': 'enable',
            'gui_application_control': 'enable',
            'gui_dhcp_advanced': 'enable',
            'gui_dlp': 'enable',
            'gui_dns_database': 'enable',
            'gui_dnsfilter': 'enable',
            'gui_domain_ip_reputation': 'enable',
            'gui_dos_policy': 'enable',
            'gui_dynamic_profile_display': 'enable',
            'gui_dynamic_routing': 'enable',
            'gui_email_collection': 'enable',
            'gui_endpoint_control': 'enable',
            'gui_endpoint_control_advanced': 'enable',
            'gui_explicit_proxy': 'enable',
            'gui_fortiap_split_tunneling': 'enable',
            'gui_fortiextender_controller': 'enable',
            'gui_icap': 'enable',
            'gui_implicit_policy': 'enable',
            'gui_ips': 'enable',
            'gui_load_balance': 'enable',
            'gui_local_in_policy': 'enable',
            'gui_local_reports': 'enable',
            'gui_multicast_policy': 'enable',
            'gui_multiple_interface_policy': 'enable',
            'gui_multiple_utm_profiles': 'enable',
            'gui_nat46_64': 'enable',
            'gui_object_colors': 'enable',
            'gui_policy_based_ipsec': 'enable',
            'gui_policy_learning': 'enable',
            'gui_replacement_message_groups': 'enable',
            'gui_spamfilter': 'enable',
            'gui_sslvpn_personal_bookmarks': 'enable',
            'gui_sslvpn_realms': 'enable',
            'gui_switch_controller': 'enable',
            'gui_threat_weight': 'enable',
            'gui_traffic_shaping': 'enable',
            'gui_voip_profile': 'enable',
            'gui_vpn': 'enable',
            'gui_waf_profile': 'enable',
            'gui_wan_load_balancing': 'enable',
            'gui_wanopt_cache': 'enable',
            'gui_webfilter': 'enable',
            'gui_webfilter_advanced': 'enable',
            'gui_wireless_controller': 'enable',
            'http_external_dest': 'fortiweb',
            'ike_dn_format': 'with-space',
            'ike_quick_crash_detect': 'enable',
            'ike_session_resume': 'enable',
            'implicit_allow_dns': 'enable',
            'inspection_mode': 'proxy',
            'ip': 'test_value_84',
            'ip6': 'test_value_85',
            'link_down_access': 'enable',
            'lldp_transmission': 'enable',
            'mac_ttl': '88',
            'manageip': 'test_value_89',
            'manageip6': 'test_value_90',
            'multicast_forward': 'enable',
            'multicast_skip_policy': 'enable',
            'multicast_ttl_notchange': 'enable',
            'ngfw_mode': 'profile-based',
            'opmode': 'nat',
            'prp_trailer_action': 'enable',
            'sccp_port': '97',
            'ses_denied_traffic': 'enable',
            'sip_helper': 'enable',
            'sip_nat_trace': 'enable',
            'sip_ssl_port': '101',
            'sip_tcp_port': '102',
            'sip_udp_port': '103',
            'snat_hairpin_traffic': 'enable',
            'ssl_ssh_profile': 'test_value_105',
            'status': 'enable',
            'strict_src_check': 'enable',
            'tcp_session_without_syn': 'enable',
            'utf8_spam_tagging': 'enable',
            'v4_ecmp_mode': 'source-ip-based',
            'vpn_stats_log': 'ipsec',
            'vpn_stats_period': '112',
            'wccp_cache_engine': 'enable'
        },
        'vdom': 'root'}

    is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)

    expected_data = {
        'allow-linkdown-path': 'enable',
        'allow-subnet-overlap': 'enable',
        'asymroute': 'enable',
        'asymroute-icmp': 'enable',
        'asymroute6': 'enable',
        'asymroute6-icmp': 'enable',
        'bfd': 'enable',
        'bfd-desired-min-tx': '10',
        'bfd-detect-mult': '11',
        'bfd-dont-enforce-src-port': 'enable',
        'bfd-required-min-rx': '13',
        'block-land-attack': 'disable',
        'central-nat': 'enable',
        'comments': 'test_value_16',
        'compliance-check': 'enable',
        'default-voip-alg-mode': 'proxy-based',
        'deny-tcp-with-icmp': 'enable',
        'device': 'test_value_20',
        'dhcp-proxy': 'enable',
        'dhcp-server-ip': 'test_value_22',
        'dhcp6-server-ip': 'test_value_23',
        'discovered-device-timeout': '24',
        'ecmp-max-paths': '25',
        'email-portal-check-dns': 'disable',
        'firewall-session-dirty': 'check-all',
        'fw-session-hairpin': 'enable',
        'gateway': 'test_value_29',
        'gateway6': 'test_value_30',
        'gui-advanced-policy': 'enable',
        'gui-allow-unnamed-policy': 'enable',
        'gui-antivirus': 'enable',
        'gui-ap-profile': 'enable',
        'gui-application-control': 'enable',
        'gui-dhcp-advanced': 'enable',
        'gui-dlp': 'enable',
        'gui-dns-database': 'enable',
        'gui-dnsfilter': 'enable',
        'gui-domain-ip-reputation': 'enable',
        'gui-dos-policy': 'enable',
        'gui-dynamic-profile-display': 'enable',
        'gui-dynamic-routing': 'enable',
        'gui-email-collection': 'enable',
        'gui-endpoint-control': 'enable',
        'gui-endpoint-control-advanced': 'enable',
        'gui-explicit-proxy': 'enable',
        'gui-fortiap-split-tunneling': 'enable',
        'gui-fortiextender-controller': 'enable',
        'gui-icap': 'enable',
        'gui-implicit-policy': 'enable',
        'gui-ips': 'enable',
        'gui-load-balance': 'enable',
        'gui-local-in-policy': 'enable',
        'gui-local-reports': 'enable',
        'gui-multicast-policy': 'enable',
        'gui-multiple-interface-policy': 'enable',
        'gui-multiple-utm-profiles': 'enable',
        'gui-nat46-64': 'enable',
        'gui-object-colors': 'enable',
        'gui-policy-based-ipsec': 'enable',
        'gui-policy-learning': 'enable',
        'gui-replacement-message-groups': 'enable',
        'gui-spamfilter': 'enable',
        'gui-sslvpn-personal-bookmarks': 'enable',
        'gui-sslvpn-realms': 'enable',
        'gui-switch-controller': 'enable',
        'gui-threat-weight': 'enable',
        'gui-traffic-shaping': 'enable',
        'gui-voip-profile': 'enable',
        'gui-vpn': 'enable',
        'gui-waf-profile': 'enable',
        'gui-wan-load-balancing': 'enable',
        'gui-wanopt-cache': 'enable',
        'gui-webfilter': 'enable',
        'gui-webfilter-advanced': 'enable',
        'gui-wireless-controller': 'enable',
        'http-external-dest': 'fortiweb',
        'ike-dn-format': 'with-space',
        'ike-quick-crash-detect': 'enable',
        'ike-session-resume': 'enable',
        'implicit-allow-dns': 'enable',
        'inspection-mode': 'proxy',
        'ip': 'test_value_84',
        'ip6': 'test_value_85',
        'link-down-access': 'enable',
        'lldp-transmission': 'enable',
        'mac-ttl': '88',
        'manageip': 'test_value_89',
        'manageip6': 'test_value_90',
        'multicast-forward': 'enable',
        'multicast-skip-policy': 'enable',
        'multicast-ttl-notchange': 'enable',
        'ngfw-mode': 'profile-based',
        'opmode': 'nat',
        'prp-trailer-action': 'enable',
        'sccp-port': '97',
        'ses-denied-traffic': 'enable',
        'sip-helper': 'enable',
        'sip-nat-trace': 'enable',
        'sip-ssl-port': '101',
        'sip-tcp-port': '102',
        'sip-udp-port': '103',
        'snat-hairpin-traffic': 'enable',
        'ssl-ssh-profile': 'test_value_105',
        'status': 'enable',
        'strict-src-check': 'enable',
        'tcp-session-without-syn': 'enable',
        'utf8-spam-tagging': 'enable',
        'v4-ecmp-mode': 'source-ip-based',
        'vpn-stats-log': 'ipsec',
        'vpn-stats-period': '112',
        'wccp-cache-engine': 'enable'
    }

    set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
    schema_method_mock.assert_not_called()
    assert is_error
    assert not changed
    assert response['status'] == 'error'
    assert response['http_status'] == 500

def test_system_settings_idempotent(mocker):
    schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')

    set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404}
    set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)

    input_data = {
        'username': 'admin',
        'state': 'present',
        'system_settings': {
            'allow_linkdown_path': 'enable',
            'allow_subnet_overlap': 'enable',
            'asymroute': 'enable',
            'asymroute_icmp': 'enable',
            'asymroute6': 'enable',
            'asymroute6_icmp': 'enable',
            'bfd': 'enable',
            'bfd_desired_min_tx': '10',
            'bfd_detect_mult': '11',
            'bfd_dont_enforce_src_port': 'enable',
            'bfd_required_min_rx': '13',
            'block_land_attack': 'disable',
            'central_nat': 'enable',
            'comments': 'test_value_16',
            'compliance_check': 'enable',
            'default_voip_alg_mode': 'proxy-based',
            'deny_tcp_with_icmp': 'enable',
            'device': 'test_value_20',
            'dhcp_proxy': 'enable',
            'dhcp_server_ip': 'test_value_22',
            'dhcp6_server_ip': 'test_value_23',
            'discovered_device_timeout': '24',
            'ecmp_max_paths': '25',
            'email_portal_check_dns': 'disable',
            'firewall_session_dirty': 'check-all',
            'fw_session_hairpin': 'enable',
            'gateway': 'test_value_29',
            'gateway6': 'test_value_30',
            'gui_advanced_policy': 'enable',
            'gui_allow_unnamed_policy': 'enable',
            'gui_antivirus': 'enable',
            'gui_ap_profile': 'enable',
            'gui_application_control': 'enable',
            'gui_dhcp_advanced': 'enable',
            'gui_dlp': 'enable',
            'gui_dns_database': 'enable',
            'gui_dnsfilter': 'enable',
            'gui_domain_ip_reputation': 'enable',
            'gui_dos_policy': 'enable',
            'gui_dynamic_profile_display': 'enable',
            'gui_dynamic_routing': 'enable',
            'gui_email_collection': 'enable',
            'gui_endpoint_control': 'enable',
            'gui_endpoint_control_advanced': 'enable',
            'gui_explicit_proxy': 'enable',
            'gui_fortiap_split_tunneling': 'enable',
            'gui_fortiextender_controller': 'enable',
            'gui_icap': 'enable',
            'gui_implicit_policy': 'enable',
            'gui_ips': 'enable',
            'gui_load_balance': 'enable',
            'gui_local_in_policy': 'enable',
            'gui_local_reports': 'enable',
            'gui_multicast_policy': 'enable',
            'gui_multiple_interface_policy': 'enable',
            'gui_multiple_utm_profiles': 'enable',
            'gui_nat46_64': 'enable',
            'gui_object_colors': 'enable',
            'gui_policy_based_ipsec': 'enable',
            'gui_policy_learning': 'enable',
            'gui_replacement_message_groups': 'enable',
            'gui_spamfilter': 'enable',
            'gui_sslvpn_personal_bookmarks': 'enable',
            'gui_sslvpn_realms': 'enable',
            'gui_switch_controller': 'enable',
            'gui_threat_weight': 'enable',
            'gui_traffic_shaping': 'enable',
            'gui_voip_profile': 'enable',
            'gui_vpn': 'enable',
            'gui_waf_profile': 'enable',
            'gui_wan_load_balancing': 'enable',
            'gui_wanopt_cache': 'enable',
            'gui_webfilter': 'enable',
            'gui_webfilter_advanced': 'enable',
            'gui_wireless_controller': 'enable',
            'http_external_dest': 'fortiweb',
            'ike_dn_format': 'with-space',
            'ike_quick_crash_detect': 'enable',
            'ike_session_resume': 'enable',
            'implicit_allow_dns': 'enable',
            'inspection_mode': 'proxy',
            'ip': 'test_value_84',
            'ip6': 'test_value_85',
            'link_down_access': 'enable',
            'lldp_transmission': 'enable',
            'mac_ttl': '88',
            'manageip': 'test_value_89',
            'manageip6': 'test_value_90',
            'multicast_forward': 'enable',
            'multicast_skip_policy': 'enable',
            'multicast_ttl_notchange': 'enable',
            'ngfw_mode': 'profile-based',
            'opmode': 'nat',
            'prp_trailer_action': 'enable',
            'sccp_port': '97',
            'ses_denied_traffic': 'enable',
            'sip_helper': 'enable',
            'sip_nat_trace': 'enable',
            'sip_ssl_port': '101',
            'sip_tcp_port': '102',
            'sip_udp_port': '103',
            'snat_hairpin_traffic': 'enable',
            'ssl_ssh_profile': 'test_value_105',
            'status': 'enable',
            'strict_src_check': 'enable',
            'tcp_session_without_syn': 'enable',
            'utf8_spam_tagging': 'enable',
            'v4_ecmp_mode': 'source-ip-based',
            'vpn_stats_log': 'ipsec',
            'vpn_stats_period': '112',
            'wccp_cache_engine': 'enable'
        },
        'vdom': 'root'}

    is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)

    expected_data = {
        'allow-linkdown-path': 'enable',
        'allow-subnet-overlap': 'enable',
        'asymroute': 'enable',
        'asymroute-icmp': 'enable',
        'asymroute6': 'enable',
        'asymroute6-icmp': 'enable',
        'bfd': 'enable',
        'bfd-desired-min-tx': '10',
        'bfd-detect-mult': '11',
        'bfd-dont-enforce-src-port': 'enable',
        'bfd-required-min-rx': '13',
        'block-land-attack': 'disable',
        'central-nat': 'enable',
        'comments': 'test_value_16',
        'compliance-check': 'enable',
        'default-voip-alg-mode': 'proxy-based',
        'deny-tcp-with-icmp': 'enable',
        'device': 'test_value_20',
        'dhcp-proxy': 'enable',
        'dhcp-server-ip': 'test_value_22',
        'dhcp6-server-ip': 'test_value_23',
        'discovered-device-timeout': '24',
        'ecmp-max-paths': '25',
        'email-portal-check-dns': 'disable',
        'firewall-session-dirty': 'check-all',
        'fw-session-hairpin': 'enable',
        'gateway': 'test_value_29',
        'gateway6': 'test_value_30',
        'gui-advanced-policy': 'enable',
        'gui-allow-unnamed-policy': 'enable',
        'gui-antivirus': 'enable',
        'gui-ap-profile': 'enable',
        'gui-application-control': 'enable',
        'gui-dhcp-advanced': 'enable',
        'gui-dlp': 'enable',
        'gui-dns-database': 'enable',
        'gui-dnsfilter': 'enable',
        'gui-domain-ip-reputation': 'enable',
        'gui-dos-policy': 'enable',
        'gui-dynamic-profile-display': 'enable',
        'gui-dynamic-routing': 'enable',
        'gui-email-collection': 'enable',
        'gui-endpoint-control': 'enable',
        'gui-endpoint-control-advanced': 'enable',
        'gui-explicit-proxy': 'enable',
        'gui-fortiap-split-tunneling': 'enable',
        'gui-fortiextender-controller': 'enable',
        'gui-icap': 'enable',
        'gui-implicit-policy': 'enable',
        'gui-ips': 'enable',
        'gui-load-balance': 'enable',
        'gui-local-in-policy': 'enable',
        'gui-local-reports': 'enable',
        'gui-multicast-policy': 'enable',
        'gui-multiple-interface-policy': 'enable',
        'gui-multiple-utm-profiles': 'enable',
        'gui-nat46-64': 'enable',
        'gui-object-colors': 'enable',
        'gui-policy-based-ipsec': 'enable',
        'gui-policy-learning': 'enable',
        'gui-replacement-message-groups': 'enable',
        'gui-spamfilter': 'enable',
        'gui-sslvpn-personal-bookmarks': 'enable',
        'gui-sslvpn-realms': 'enable',
        'gui-switch-controller': 'enable',
        'gui-threat-weight': 'enable',
        'gui-traffic-shaping': 'enable',
        'gui-voip-profile': 'enable',
        'gui-vpn': 'enable',
        'gui-waf-profile': 'enable',
        'gui-wan-load-balancing': 'enable',
        'gui-wanopt-cache': 'enable',
        'gui-webfilter': 'enable',
        'gui-webfilter-advanced': 'enable',
        'gui-wireless-controller': 'enable',
        'http-external-dest': 'fortiweb',
        'ike-dn-format': 'with-space',
        'ike-quick-crash-detect': 'enable',
        'ike-session-resume': 'enable',
        'implicit-allow-dns': 'enable',
        'inspection-mode': 'proxy',
        'ip': 'test_value_84',
        'ip6': 'test_value_85',
        'link-down-access': 'enable',
        'lldp-transmission': 'enable',
        'mac-ttl': '88',
        'manageip': 'test_value_89',
        'manageip6': 'test_value_90',
        'multicast-forward': 'enable',
        'multicast-skip-policy': 'enable',
        'multicast-ttl-notchange': 'enable',
        'ngfw-mode': 'profile-based',
        'opmode': 'nat',
        'prp-trailer-action': 'enable',
        'sccp-port': '97',
        'ses-denied-traffic': 'enable',
        'sip-helper': 'enable',
        'sip-nat-trace': 'enable',
        'sip-ssl-port': '101',
        'sip-tcp-port': '102',
        'sip-udp-port': '103',
        'snat-hairpin-traffic': 'enable',
        'ssl-ssh-profile': 'test_value_105',
        'status': 'enable',
        'strict-src-check': 'enable',
        'tcp-session-without-syn': 'enable',
        'utf8-spam-tagging': 'enable',
        'v4-ecmp-mode': 'source-ip-based',
        'vpn-stats-log': 'ipsec',
        'vpn-stats-period': '112',
        'wccp-cache-engine': 'enable'
    }

    set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
    schema_method_mock.assert_not_called()
    assert not is_error
    assert not changed
    assert response['status'] == 'error'
    assert response['http_status'] == 404

def test_system_settings_filter_foreign_attributes(mocker):
    schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema')

    set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200}
    set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result)

    input_data = {
        'username': 'admin',
        'state': 'present',
        'system_settings': {
            'random_attribute_not_valid': 'tag',
            'allow_linkdown_path': 'enable',
            'allow_subnet_overlap': 'enable',
            'asymroute': 'enable',
            'asymroute_icmp': 'enable',
            'asymroute6': 'enable',
            'asymroute6_icmp': 'enable',
            'bfd': 'enable',
            'bfd_desired_min_tx': '10',
            'bfd_detect_mult': '11',
            'bfd_dont_enforce_src_port': 'enable',
            'bfd_required_min_rx': '13',
            'block_land_attack': 'disable',
            'central_nat': 'enable',
            'comments': 'test_value_16',
            'compliance_check': 'enable',
            'default_voip_alg_mode': 'proxy-based',
            'deny_tcp_with_icmp': 'enable',
            'device': 'test_value_20',
            'dhcp_proxy': 'enable',
            'dhcp_server_ip': 'test_value_22',
            'dhcp6_server_ip': 'test_value_23',
            'discovered_device_timeout': '24',
            'ecmp_max_paths': '25',
            'email_portal_check_dns': 'disable',
            'firewall_session_dirty': 'check-all',
            'fw_session_hairpin': 'enable',
            'gateway': 'test_value_29',
            'gateway6': 'test_value_30',
            'gui_advanced_policy': 'enable',
            'gui_allow_unnamed_policy': 'enable',
            'gui_antivirus': 'enable',
            'gui_ap_profile': 'enable',
            'gui_application_control': 'enable',
            'gui_dhcp_advanced': 'enable',
            'gui_dlp': 'enable',
            'gui_dns_database': 'enable',
            'gui_dnsfilter': 'enable',
            'gui_domain_ip_reputation': 'enable',
            'gui_dos_policy': 'enable',
            'gui_dynamic_profile_display': 'enable',
            'gui_dynamic_routing': 'enable',
            'gui_email_collection': 'enable',
            'gui_endpoint_control': 'enable',
            'gui_endpoint_control_advanced': 'enable',
            'gui_explicit_proxy': 'enable',
            'gui_fortiap_split_tunneling': 'enable',
            'gui_fortiextender_controller': 'enable',
            'gui_icap': 'enable',
            'gui_implicit_policy': 'enable',
            'gui_ips': 'enable',
            'gui_load_balance': 'enable',
            'gui_local_in_policy': 'enable',
            'gui_local_reports': 'enable',
            'gui_multicast_policy': 'enable',
            'gui_multiple_interface_policy': 'enable',
            'gui_multiple_utm_profiles': 'enable',
            'gui_nat46_64': 'enable',
            'gui_object_colors': 'enable',
            'gui_policy_based_ipsec': 'enable',
            'gui_policy_learning': 'enable',
            'gui_replacement_message_groups': 'enable',
            'gui_spamfilter': 'enable',
            'gui_sslvpn_personal_bookmarks': 'enable',
            'gui_sslvpn_realms': 'enable',
            'gui_switch_controller': 'enable',
            'gui_threat_weight': 'enable',
            'gui_traffic_shaping': 'enable',
            'gui_voip_profile': 'enable',
            'gui_vpn': 'enable',
            'gui_waf_profile': 'enable',
            'gui_wan_load_balancing': 'enable',
            'gui_wanopt_cache': 'enable',
            'gui_webfilter': 'enable',
            'gui_webfilter_advanced': 'enable',
            'gui_wireless_controller': 'enable',
            'http_external_dest': 'fortiweb',
            'ike_dn_format': 'with-space',
            'ike_quick_crash_detect': 'enable',
            'ike_session_resume': 'enable',
            'implicit_allow_dns': 'enable',
            'inspection_mode': 'proxy',
            'ip': 'test_value_84',
            'ip6': 'test_value_85',
            'link_down_access': 'enable',
            'lldp_transmission': 'enable',
            'mac_ttl': '88',
            'manageip': 'test_value_89',
            'manageip6': 'test_value_90',
            'multicast_forward': 'enable',
            'multicast_skip_policy': 'enable',
            'multicast_ttl_notchange': 'enable',
            'ngfw_mode': 'profile-based',
            'opmode': 'nat',
            'prp_trailer_action': 'enable',
            'sccp_port': '97',
            'ses_denied_traffic': 'enable',
            'sip_helper': 'enable',
            'sip_nat_trace': 'enable',
            'sip_ssl_port': '101',
            'sip_tcp_port': '102',
            'sip_udp_port': '103',
            'snat_hairpin_traffic': 'enable',
            'ssl_ssh_profile': 'test_value_105',
            'status': 'enable',
            'strict_src_check': 'enable',
            'tcp_session_without_syn': 'enable',
            'utf8_spam_tagging': 'enable',
            'v4_ecmp_mode': 'source-ip-based',
            'vpn_stats_log': 'ipsec',
            'vpn_stats_period': '112',
            'wccp_cache_engine': 'enable'
        },
        'vdom': 'root'}

    is_error, changed, response = fortios_system_settings.fortios_system(input_data, fos_instance)

    expected_data = {
        'allow-linkdown-path': 'enable',
        'allow-subnet-overlap': 'enable',
        'asymroute': 'enable',
        'asymroute-icmp': 'enable',
        'asymroute6': 'enable',
        'asymroute6-icmp': 'enable',
        'bfd': 'enable',
        'bfd-desired-min-tx': '10',
        'bfd-detect-mult': '11',
        'bfd-dont-enforce-src-port': 'enable',
        'bfd-required-min-rx': '13',
        'block-land-attack': 'disable',
        'central-nat': 'enable',
        'comments': 'test_value_16',
        'compliance-check': 'enable',
        'default-voip-alg-mode': 'proxy-based',
        'deny-tcp-with-icmp': 'enable',
        'device': 'test_value_20',
        'dhcp-proxy': 'enable',
        'dhcp-server-ip': 'test_value_22',
        'dhcp6-server-ip': 'test_value_23',
        'discovered-device-timeout': '24',
        'ecmp-max-paths': '25',
        'email-portal-check-dns': 'disable',
        'firewall-session-dirty': 'check-all',
        'fw-session-hairpin': 'enable',
        'gateway': 'test_value_29',
        'gateway6': 'test_value_30',
        'gui-advanced-policy': 'enable',
        'gui-allow-unnamed-policy': 'enable',
        'gui-antivirus': 'enable',
        'gui-ap-profile': 'enable',
        'gui-application-control': 'enable',
        'gui-dhcp-advanced': 'enable',
        'gui-dlp': 'enable',
        'gui-dns-database': 'enable',
        'gui-dnsfilter': 'enable',
        'gui-domain-ip-reputation': 'enable',
        'gui-dos-policy': 'enable',
        'gui-dynamic-profile-display': 'enable',
        'gui-dynamic-routing': 'enable',
        'gui-email-collection': 'enable',
        'gui-endpoint-control': 'enable',
        'gui-endpoint-control-advanced': 'enable',
        'gui-explicit-proxy': 'enable',
        'gui-fortiap-split-tunneling': 'enable',
        'gui-fortiextender-controller': 'enable',
        'gui-icap': 'enable',
        'gui-implicit-policy': 'enable',
        'gui-ips': 'enable',
        'gui-load-balance': 'enable',
        'gui-local-in-policy': 'enable',
        'gui-local-reports': 'enable',
        'gui-multicast-policy': 'enable',
        'gui-multiple-interface-policy': 'enable',
        'gui-multiple-utm-profiles': 'enable',
        'gui-nat46-64': 'enable',
        'gui-object-colors': 'enable',
        'gui-policy-based-ipsec': 'enable',
        'gui-policy-learning': 'enable',
        'gui-replacement-message-groups': 'enable',
        'gui-spamfilter': 'enable',
        'gui-sslvpn-personal-bookmarks': 'enable',
        'gui-sslvpn-realms': 'enable',
        'gui-switch-controller': 'enable',
        'gui-threat-weight': 'enable',
        'gui-traffic-shaping': 'enable',
        'gui-voip-profile': 'enable',
        'gui-vpn': 'enable',
        'gui-waf-profile': 'enable',
        'gui-wan-load-balancing': 'enable',
        'gui-wanopt-cache': 'enable',
        'gui-webfilter': 'enable',
        'gui-webfilter-advanced': 'enable',
        'gui-wireless-controller': 'enable',
        'http-external-dest': 'fortiweb',
        'ike-dn-format': 'with-space',
        'ike-quick-crash-detect': 'enable',
        'ike-session-resume': 'enable',
        'implicit-allow-dns': 'enable',
        'inspection-mode': 'proxy',
        'ip': 'test_value_84',
        'ip6': 'test_value_85',
        'link-down-access': 'enable',
        'lldp-transmission': 'enable',
        'mac-ttl': '88',
        'manageip': 'test_value_89',
        'manageip6': 'test_value_90',
        'multicast-forward': 'enable',
        'multicast-skip-policy': 'enable',
        'multicast-ttl-notchange': 'enable',
        'ngfw-mode': 'profile-based',
        'opmode': 'nat',
        'prp-trailer-action': 'enable',
        'sccp-port': '97',
        'ses-denied-traffic': 'enable',
        'sip-helper': 'enable',
        'sip-nat-trace': 'enable',
        'sip-ssl-port': '101',
        'sip-tcp-port': '102',
        'sip-udp-port': '103',
        'snat-hairpin-traffic': 'enable',
        'ssl-ssh-profile': 'test_value_105',
        'status': 'enable',
        'strict-src-check': 'enable',
        'tcp-session-without-syn': 'enable',
        'utf8-spam-tagging': 'enable',
        'v4-ecmp-mode': 'source-ip-based',
        'vpn-stats-log': 'ipsec',
        'vpn-stats-period': '112',
        'wccp-cache-engine': 'enable'
    }

    set_method_mock.assert_called_with('system', 'settings', data=expected_data, vdom='root')
    schema_method_mock.assert_not_called()
    assert not is_error
    assert changed
    assert response['status'] == 'success'
    assert response['http_status'] == 200

redpajama_set_name: RedPajamaGithub


text:
package schema_differ;

import entities.Diff;
import java.util.ArrayList;
import sql.Connector;
import sql.Credentials;

/**
 * The Class that operates schema differ via command line
 *
 * @author ahughes
 */
public class CommandLine {

    private String[] args;
    private Credentials cre1;
    private Credentials cre2;
    private Connector c1;
    private Connector c2;
    private DBLayer db;
    private ArrayList<Diff> diffs;

    public CommandLine(String[] anArgArray) {
        args = anArgArray;

        boolean isSuccessful = true;

        //parsing the credentials from the args first
        try {
            cre1 = fetchCredentials(1);
            cre2 = fetchCredentials(2);
            System.out.println("Credentials parsed successfully");
        } catch (Exception x) {
            System.err.println(x.getMessage());
            isSuccessful = false;
        }

        //then creating the connectors
        if (isSuccessful) {
            try {
                c1 = new Connector(cre1);
                c2 = new Connector(cre2);
            } catch (Exception x) {
                x.printStackTrace();
                System.err.println("Error while attempting to connect to databases");
                isSuccessful = false;
            }
        } else {
            System.exit(1);
        }

        //if the connection was successful, carry on comparing
        if (isSuccessful) {
            try {
                db = new DBLayer(c1, c2);
                diffs = db.compare();
            } catch (Exception x) {
                x.printStackTrace();
                System.err.println("Error while comparing the schemas");
                isSuccessful = false;
            }
        } else {
            System.exit(1);
        }

        //finally printing the results in the result.txt file
        if (isSuccessful) {
            try {
                db.printReport(diffs);
            } catch (Exception x) {
                x.printStackTrace();
                System.err.println("Error while attempting to create the report");
                isSuccessful = false;
            }
        } else {
            System.exit(1);
        }

        //finally exiting
        if (isSuccessful) {
            System.out.println("Finished");
            try {
                c1.closeConnection();
                c2.closeConnection();
            } catch (Exception x) {
                System.err.println("Error while terminating connections, nevermind, exiting");
            }
            System.exit(0);
        } else {
            System.exit(1);
        }
    }

    /**
     * Creates a credential object from the command line params
     *
     * @param aSchema
     * @return
     * @throws Exception
     */
    private Credentials fetchCredentials(int aSchema) throws Exception {
        Credentials cre;

        if (aSchema == 1) {
            cre = new Credentials(args[0], args[1], args[2]);
        } else if (aSchema == 2) {
            cre = new Credentials(args[3], args[4], args[5]);
        } else {
            throw new Exception("Invalid fetchCredentials use");
        }
        return cre;
    }

}


text:
package net.narusas.tools.deplor.domain.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import net.narusas.tools.deplor.domain.model.DeploymentStatus.DeploymentStatusConverter;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Entity
@Table(name = "deploymentRequest")
@Getter
@Setter
@EqualsAndHashCode(of = "id")
@ToString
public class DeploymentRequest {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	Long				id;

	@JoinColumn(name = "branch")
	Branch				branch;

	@Column
	@Convert(converter = DeploymentStatusConverter.class)
	DeploymentStatus	status	= DeploymentStatus.미제출;

	@JoinColumn(name = "author")
	Account				author;

	@Column
	Date				timestamp;

	//@formatter:off
	@OneToMany(fetch = FetchType.LAZY)
	@JoinTable(
			name = "deploymentRequest_changes",
			joinColumns = { @JoinColumn(name = "deployId") },
			inverseJoinColumns = { @JoinColumn(name = "changeId") }
	)
	//@formatter:on
	Set<Change>			changes;

	@Column
	String				message;

	public void addChange(Change change) {
		if (changes == null) {
			changes = new HashSet<>();
		}
		changes.add(change);
	}

	public static DeploymentRequest from(DeploymentRequest old) {
		DeploymentRequest newRequest = new DeploymentRequest();
		newRequest.setAuthor(old.getAuthor());
		newRequest.setChanges(old.getChanges());

		return newRequest;
	}

}


text:
package org.apache.lucene.benchmark.byTask.tasks;

import java.util.List;

import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.benchmark.byTask.stats.Report;
import org.apache.lucene.benchmark.byTask.stats.TaskStats;

/**
 * Report by-name-prefix statistics with no aggregations.
 * <br>Other side effects: None.
 */
public class RepSelectByPrefTask extends RepSumByPrefTask {

  public RepSelectByPrefTask(PerfRunData runData) {
    super(runData);
  }

  @Override
  public int doLogic() throws Exception {
    Report rp = reportSelectByPrefix(getRunData().getPoints().taskStats());

    System.out.println();
    System.out.println("------------> Report Select By Prefix ("+prefix+") ("+
        rp.getSize()+" about "+rp.getReported()+" out of "+rp.getOutOf()+")");
    System.out.println(rp.getText());
    System.out.println();

    return 0;
  }

  protected Report reportSelectByPrefix(List<TaskStats> taskStats) {
    String longestOp = longestOp(taskStats);
    boolean first = true;
    StringBuffer sb = new StringBuffer();
    sb.append(tableTitle(longestOp));
    sb.append(newline);
    int reported = 0;
    for (final TaskStats stat : taskStats) {
      if (stat.getElapsed()>=0 && stat.getTask().getName().startsWith(prefix)) { // only ended tasks with proper name
        reported++;
        if (!first) {
          sb.append(newline);
        }
        first = false;
        String line = taskReportLine(longestOp,stat);
        if (taskStats.size()>2 && reported%2==0) {
          line = line.replaceAll("   "," - ");
        }
        sb.append(line);
      }
    }
    String reptxt = (reported==0 ? "No Matching Entries Were Found!" : sb.toString());
    return new Report(reptxt,reported,reported, taskStats.size());
  }

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Hyak.Common;
using Microsoft.Azure.Management.SiteRecovery.Models;

namespace Microsoft.Azure.Management.SiteRecovery.Models
{
    /// <summary>
    /// Create recovery plan input properties object.
    /// </summary>
    public partial class CreateRecoveryPlanInputProperties
    {
        private string _failoverDeploymentModel;

        /// <summary>
        /// Optional. Failover deployment model.
        /// </summary>
        public string FailoverDeploymentModel
        {
            get { return this._failoverDeploymentModel; }
            set { this._failoverDeploymentModel = value; }
        }

        private IList<RecoveryPlanGroup> _groups;

        /// <summary>
        /// Required. Recovery plan groups list.
        /// </summary>
        public IList<RecoveryPlanGroup> Groups
        {
            get { return this._groups; }
            set { this._groups = value; }
        }

        private string _primaryFabricId;

        /// <summary>
        /// Required. Primary fabric Id.
        /// </summary>
        public string PrimaryFabricId
        {
            get { return this._primaryFabricId; }
            set { this._primaryFabricId = value; }
        }

        private string _recoveryFabricId;

        /// <summary>
        /// Required. Recovery fabric Id.
        /// </summary>
        public string RecoveryFabricId
        {
            get { return this._recoveryFabricId; }
            set { this._recoveryFabricId = value; }
        }

        /// <summary>
        /// Initializes a new instance of the CreateRecoveryPlanInputProperties
        /// class.
        /// </summary>
        public CreateRecoveryPlanInputProperties()
        {
            this.Groups = new LazyList<RecoveryPlanGroup>();
        }

        /// <summary>
        /// Initializes a new instance of the CreateRecoveryPlanInputProperties
        /// class with required arguments.
        /// </summary>
        public CreateRecoveryPlanInputProperties(string primaryFabricId, string recoveryFabricId, List<RecoveryPlanGroup> groups)
            : this()
        {
            if (primaryFabricId == null)
            {
                throw new ArgumentNullException("primaryFabricId");
            }
            if (recoveryFabricId == null)
            {
                throw new ArgumentNullException("recoveryFabricId");
            }
            if (groups == null)
            {
                throw new ArgumentNullException("groups");
            }
            this.PrimaryFabricId = primaryFabricId;
            this.RecoveryFabricId = recoveryFabricId;
            this.Groups = groups;
        }
    }
}


text:
template <class S>
void
test()
{
    {
#if TEST_STD_VER > 14
    static_assert((noexcept(S{})), "" );
#elif TEST_STD_VER >= 11
    static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
#endif
    S s;
    LIBCPP_ASSERT(s.__invariants());
    assert(s.data());
    assert(s.size() == 0);
    assert(s.capacity() >= s.size());
    assert(s.get_allocator() == typename S::allocator_type());
    }
    {
#if TEST_STD_VER > 14
    static_assert((noexcept(S{typename S::allocator_type{}})), "" );
#elif TEST_STD_VER >= 11
    static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
#endif
    S s(typename S::allocator_type(5));
    LIBCPP_ASSERT(s.__invariants());
    assert(s.data());
    assert(s.size() == 0);
    assert(s.capacity() >= s.size());
    assert(s.get_allocator() == typename S::allocator_type(5));
    }
}

#if TEST_STD_VER >= 11

template <class S>
void
test2()
{
    {
#if TEST_STD_VER > 14
    static_assert((noexcept(S{})), "" );
#elif TEST_STD_VER >= 11
    static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
#endif
    S s;
    LIBCPP_ASSERT(s.__invariants());
    assert(s.data());
    assert(s.size() == 0);
    assert(s.capacity() >= s.size());
    assert(s.get_allocator() == typename S::allocator_type());
    }
    {
#if TEST_STD_VER > 14
    static_assert((noexcept(S{typename S::allocator_type{}})), "" );
#elif TEST_STD_VER >= 11
    static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
#endif
    S s(typename S::allocator_type{});
    LIBCPP_ASSERT(s.__invariants());
    assert(s.data());
    assert(s.size() == 0);
    assert(s.capacity() >= s.size());
    assert(s.get_allocator() == typename S::allocator_type());
    }
}

#endif

int main()
{
    test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
#if TEST_STD_VER >= 11
    test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
    test2<std::basic_string<char, std::char_traits<char>, explicit_allocator<char> > >();
#endif
}


text:
/**
 * Extend image or video file with position/motif area related
 * properties that are needed to use the file as a section backdrop.
 *
 * The added properties are:
 *
 * `motifArea`: Either the passed motif area object or the motif area
 * from the legacy file configuration if no motif area has been
 * passed.
 *
 * `effects`: List of backdrop effects to apply.
 *
 * @param {Object} options
 * @param {Object} options.file - Image or video file obtained via
 * `useFile`.
 * @param {Object} options.motifArea - Section specific setting
 * specifying motif area rect in percent.
 * @param {Object[]} options.effects - List of backdrop effects.
 *
 * @private
 */
export function useBackgroundFile({file, motifArea, effects}) {
  if (!file) {
    return null ;
  }

  return {
    ...file,
    cropPosition: {x: 0, y: 0},
    motifArea,
    effects
  };
}


text:
package edu.emory.bmi.medicurator.tcia;

import edu.emory.bmi.medicurator.infinispan.ID;
import edu.emory.bmi.medicurator.storage.*;
import edu.emory.bmi.medicurator.general.*;
import edu.emory.bmi.medicurator.image.*;
import java.util.*;
import java.util.zip.*;

/**
 * Implementation of TCIA DataSet
 * Each hierarchy has a keyword, such as PatientID of patient or StudyInstanceUID of study
 * Series contains Images, other hierarchies don't have Image
 */
public class TciaDataSet extends DataSet
{
    private Storage storage = GetStorage.get();
    private TciaHierarchy hierarchy;
    private String keyword;
    private UUID parent;
    private ArrayList<UUID> subsets;
    private UUID[] images;
    private String lastVisit;

    /* happy QiXi vacation */

    private void visit()
    {
	Date now = new Date();
	lastVisit = now.toString();
    }

    public boolean updated()
    {
	Metadata meta = getMetadata();
	switch (hierarchy)
	{
	    case COLLECTION:
		Metadata[] newPatients = TciaAPI.newPatientsInCollection(lastVisit, meta.get("Collection"));
		if (newPatients.length > 0) return false;
		break;
	    case PATIENT:
		Metadata[] newStudies = TciaAPI.newStudiesInPatientCollection(lastVisit, meta.get("Collection"), meta.get("PatientID"));
		if (newStudies.length > 0) return false;
		break;
	}
	return true;
    }

    /**
     * create a TciaDataSet with specified Metadata
     */
    public TciaDataSet(TciaHierarchy hierarchy, UUID parent, Metadata meta)
    {
	super("tcia");
	meta.store();
	setMetaID(meta.getID());
	this.hierarchy = hierarchy;
	this.parent = parent;
	subsets = new ArrayList<UUID>();
	lastVisit = "1970-01-01";
	images = null;
	switch (hierarchy)   // get keyword
	{
	    case ROOT:
		keyword = "TCIA";
		break;
	    case COLLECTION:
		keyword = "Collection: " + meta.get("Collection");
		break;
	    case PATIENT:
		keyword = "PatientID: " + meta.get("PatientID");
		break;
	    case STUDY:
		keyword = "StudyInstanceUID: " + meta.get("StudyInstanceUID");
		break;
	    case SERIES:
		keyword = "SeriesInstanceUID: " + meta.get("SeriesInstanceUID");
		break;
	}
	store();
    }

    public UUID getParent()
    {
	return parent;
    }

    /**
     * create this DataSet's subsets
     * @param metas metas
     * @param subHierarchy
     */
    private void makeSubsets(Metadata[] metas, TciaHierarchy subHierarchy)
    {
	if (metas.length == 0) return;
	for (int i = 0; i < metas.length; ++i)
	{
	    DataSet subset = new TciaDataSet(subHierarchy, getID(), metas[i]);
	    subsets.add(subset.getID());
	}
    }

    /**
     * get ID array of subsets
     * @return UUID[]
     */
    public UUID[] getSubsets()
    {
	if (hierarchy == TciaHierarchy.SERIES)
	{
	    return null;
	}
	if (subsets.size() == 0)
	{
	    Metadata meta = getMetadata();
	    Metadata[] metas;
	    switch (hierarchy)
	    {
		case ROOT:
		    metas = TciaAPI.getCollectionValues();
		    makeSubsets(metas, TciaHierarchy.COLLECTION);
		    break;
		case COLLECTION:
		    metas = TciaAPI.getPatient(meta.get("Collection"));
		    makeSubsets(metas, TciaHierarchy.PATIENT);
		    break;
		case PATIENT:
		    metas = TciaAPI.getPatientStudy(meta.get("Collection"), meta.get("PatientID"), null);
		    makeSubsets(metas, TciaHierarchy.STUDY);
		    break;
		case STUDY:
		    metas = TciaAPI.getSeries(meta.get("Collection"), meta.get("PatientID"), meta.get("StudyInstanceUID"), null, null, null, null, null);
		    makeSubsets(metas, TciaHierarchy.SERIES);
		    break;
	    }
	    store();
	}
	else if (!updated())
	{
	    Metadata meta = getMetadata();
	    Metadata[] newcoming, metas;
	    if (hierarchy == TciaHierarchy.COLLECTION)
	    {
		newcoming = TciaAPI.newPatientsInCollection(lastVisit, meta.get("Collection"));
		metas = TciaAPI.getPatient(meta.get("Collection"));
		for (Metadata m : newcoming)
		{
		    for (Metadata m2 : metas)
		    {
			if (m.get("PatientID").equals(m2.get("PatientID")))
			{
			    DataSet subset = new TciaDataSet(TciaHierarchy.PATIENT, getID(), m2);
			    subsets.add(subset.getID());
			    break;
			}
		    }
		}
	    }
	    else if (hierarchy == TciaHierarchy.PATIENT)
	    {
		newcoming = TciaAPI.newStudiesInPatientCollection(lastVisit, meta.get("Collection"), meta.get("PatientID"));
		for (Metadata m : newcoming)
		{
		    metas = TciaAPI.getPatientStudy(meta.get("Collection"), meta.get("PatientID"), m.get("StudyInstanceUID"));
		    DataSet subset = new TciaDataSet(TciaHierarchy.STUDY, getID(), metas[0]);
		    subsets.add(subset.getID());
		}
	    }
	}
	visit();
	return subsets.toArray(new UUID[0]);
    }

    /**
     * if this is a Series DataSet, download the images of the Series
     * the downloaded images are compressed with zip, unzip them and store
     * @return UUID[]
     */
    public UUID[] getImages()
    {
	if (images == null)
	{
	    if (hierarchy != TciaHierarchy.SERIES)
	    {
		images = new UUID[0];
	    }
	    else
	    {
		Metadata meta = getMetadata();
		ArrayList<UUID> imgs = new ArrayList<UUID>();
		try {
		    String root = "/tcia/" + meta.get("Collection") + "/" + ID.getDataSet(getParent()).getMetadata().get("PatientID")
			+ "/" + meta.get("StudyInstanceUID") + "/" + meta.get("SeriesInstanceUID") + "/";
		    ZipInputStream zip = new ZipInputStream(TciaAPI.getImage(meta.get("SeriesInstanceUID")));
		    ZipEntry ze;
		    while ((ze = zip.getNextEntry()) != null)
		    {
			if (ze.isDirectory()) continue;
			String path = root + ze.getName();
			storage.saveToPath(path, zip);
			System.out.println(ze.getName());
			Image img = new DicomImage(path);
			imgs.add(img.getID());
		    }
		    images = (UUID[])imgs.toArray(new UUID[0]);
		}
		catch (Exception e) {
		    System.out.println("[ERROR] when TCIA dataset getImages " + getID() + " -- " + e);
		    images = new UUID[0];
		}
	    }
	    store();
	}
	return images;
    }

    public String getKeyword()
    {
	return keyword;
    }

    /**
     * get a subset with specified keyword
     * @param keyword
     * @return
     */
    public UUID getSubset(String keyword)
    {
	for (UUID u : getSubsets())
	{
	    if (((TciaDataSet)ID.getDataSet(u)).getKeyword().equals(keyword))
	    {
		return u;
	    }
	}
	return null;
    }
}


text:
#pragma once

#include <cstdint>
#include <boost/mpl/int.hpp>

/** \brief namespace of static unique identifiers used in ASEIA **/
namespace id{
  /**\brief sub-namespace of static unique Attribute identifiers **/
  namespace attribute{

    /**\brief Tag indicating AttrID **/
    struct Tag{};

    /**\brief Definition of numeric type used for AttrID **/
    using ID = std::uint8_t;

    /** \brief Unique Attribute Identifier
     *
     *  \tparam id uint8_t number specifying the unqiue identifier
     *
     * Class representing a unique attribute in Events and EventTypes. It is
     * used to filter, extract and order Attributes, MetaAttributes and
     * AttributeTypes.
     **/
    template<uint8_t id>
    struct AttrID : public Tag {
      /** \brief accessor for the uint8_t number associated with this AttrID
       *  \return numerical unique id
       **/
      static constexpr const ID value(){ return id; }
      /** \brief cast operator to convert this AttrID to its unique number
       *  \return numerical unique id
       **/
      operator ID() const { return id; }
    };

    /** \brief Invalid Attribute **/
    using Base        = AttrID<0>;
    using Position    = AttrID<1>;
    using Time        = AttrID<2>;
    using PublisherID = AttrID<3>;
    using Validity    = AttrID<4>;
    using Distance    = AttrID<5>;
    using Orientation = AttrID<6>;
    using Angle       = AttrID<7>;
    using Reference   = AttrID<8>;
    using Object      = AttrID<9>;
    using Object2     = AttrID<10>;
    using Speed       = AttrID<11>;

    /** \brief Lookup of AttrID based on unique number
     *  \tparam id unique numeric ID
     **/
    template<ID id>
    struct lookup {
      /** \brief the corresponding AttrID
       *
       *  in case number is not defined, a compile error will be raised
       **/
      using type = AttrID<id>;
    };

    /** \brief Deprecated alias of lookup
     *  \tparam id unique numeric ID
     **/
    template<ID id>
    using attribute = lookup<id>;
  }

  namespace type{

    struct Tag{};

    using ID = std::uint8_t;

    template<uint8_t id, typename T>
    struct TypeID : public Tag {
      static constexpr const ID value(){ return id; }
      operator ID() const { return id; }
      using Type = T;
    };

    using Base   = TypeID<0, void>;
    using UInt8  = TypeID<1, uint8_t>;
    using UInt16 = TypeID<2, uint16_t>;
    using UInt32 = TypeID<3, uint32_t>;
    using Int8   = TypeID<4, int8_t>;
    using Int16  = TypeID<5, int16_t>;
    using Int32  = TypeID<6, int32_t>;
    using Float  = TypeID<7, float>;
    using Double = TypeID<8, double>;
    using Bool   = TypeID<9, bool>;

/*  doesn work because of uncertainty computation and numeric_limits errors
    using Base = TypeID<10, void>;
 */
/*  doesn work because of uncertainty computation and numeric_limits errors
    using Base = TypeID<11, void>;
 */

    template<ID id>
    struct id2Type;

    template<> struct id2Type< Int8  ::value() > { using type = Int8  ; };
    template<> struct id2Type< Int16 ::value() > { using type = Int16 ; };
    template<> struct id2Type< Int32 ::value() > { using type = Int32 ; };
//    template<> struct id2Type< Int64 ::value() > { using type = Int64 ; };
    template<> struct id2Type< UInt8 ::value() > { using type = UInt8 ; };
    template<> struct id2Type< UInt16::value() > { using type = UInt16; };
    template<> struct id2Type< UInt32::value() > { using type = UInt32; };
//    template<> struct id2Type< UInt64::value() > { using type = UInt64; };
    template<> struct id2Type< Float ::value() > { using type = Float ; };
    template<> struct id2Type< Double::value() > { using type = Double; };
    template<> struct id2Type< Bool  ::value() > { using type = Bool; };

    static constexpr const ID id( int8_t   ) { return Int8  ::value(); }
    static constexpr const ID id( int16_t  ) { return Int16 ::value(); }
    static constexpr const ID id( int32_t  ) { return Int32 ::value(); }
//    static constexpr const ID id( int64_t  ) { return Int64 ::value(); }
    static constexpr const ID id( uint8_t  ) { return UInt8 ::value(); }
    static constexpr const ID id( uint16_t ) { return UInt16::value(); }
    static constexpr const ID id( uint32_t ) { return UInt32::value(); }
//    static constexpr const ID id( uint64_t ) { return UInt64::value(); }
    static constexpr const ID id( float    ) { return Float ::value(); }
    static constexpr const ID id( double   ) { return Double::value(); }
    static constexpr const ID id( bool     ) { return Bool  ::value(); }

    template<typename T> struct t2Type { using type = typename id2Type< id( T() ) >::type; };
    inline bool smaller(ID a, ID b) {
      switch(a) {
        case(UInt8::value()):
          switch(b) {
            case(UInt8::value()): return false;
            default    : return true;
          }
        case(Int8::value()):
          switch(b) {
            case(UInt8::value()): return false;
            case(Int8::value()) : return false;
            default    : return true;
          }
        case(UInt16::value()):
          switch(b) {
            case(UInt8::value()): return false;
            case(Int8::value()) : return false;
            default    : return true;
          }
        case(Int16::value()):
          switch(b) {
            case(UInt8::value()): return false;
            case(Int8::value()) : return false;
            case(UInt16::value()): return false;
            default    : return true;
          }
        case(UInt32::value()):
          switch(b) {
            case(UInt8::value()): return false;
            case(Int8::value()) : return false;
            case(UInt16::value()): return false;
            case(Int16::value()): return false;
            default    : return true;
          }
        case(Int32::value()):
          switch(b) {
            case(UInt8::value()): return false;
            case(Int8::value()) : return false;
            case(UInt16::value()): return false;
            case(Int16::value()): return false;
            case(UInt32::value()): return false;
            default    : return true;
          }
        case(Float::value()):
          switch(b) {
            case(Double::value()) : return true;
            default               : return false;
          }
        default             : return false;
      }
    }
  }

  namespace unit{

    struct Tag{};

    using ID = std::uint8_t;

    template<ID id>
    struct Base : public Tag, boost::mpl::int_<id> { };

    using Steradian = Base<0>;
    using Radian    = Base<1>;
    using Candela   = Base<2>;
    using Mole      = Base<3>;
    using Kelvin    = Base<4>;
    using Ampere    = Base<5>;
    using Second    = Base<6>;
    using Kilogram  = Base<7>;
    using Meter     = Base<8>;

    using NumDim    = boost::mpl::int_<9>;

    template<ID id>
    struct id2Type;

    template<> struct id2Type< Steradian::value > { using type = Steradian; };
    template<> struct id2Type< Radian   ::value > { using type = Radian   ; };
    template<> struct id2Type< Candela  ::value > { using type = Candela  ; };
    template<> struct id2Type< Mole     ::value > { using type = Mole     ; };
    template<> struct id2Type< Kelvin   ::value > { using type = Kelvin   ; };
    template<> struct id2Type< Ampere   ::value > { using type = Ampere   ; };
    template<> struct id2Type< Second   ::value > { using type = Second   ; };
    template<> struct id2Type< Kilogram ::value > { using type = Kilogram ; };
    template<> struct id2Type< Meter    ::value > { using type = Meter    ; };
  }

	namespace filterOp {
		struct Tag{};

		using ID = std::uint8_t;

		template<ID id>
		struct Base : public Tag, boost::mpl::int_<id> {
      operator ID() const { return id; }
    };

		using NOP = Base< 0>;
		using LE  = Base< 1>;
		using GE  = Base< 2>;
		using LT  = Base< 3>;
		using GT  = Base< 4>;
		using EQ  = Base< 5>;
		using NE  = Base< 6>;
		using AE  = Base< 7>;
		using NA  = Base< 8>;
		using AND = Base< 9>;
		using OR  = Base< 10>;
		using NOT = Base< 11>;

    using UNC = Base< 16>;
    using CER = Base< 17>;
    using NOR = Base< 18>;

		bool isLogical(ID id);
	}
}


text: add_lunch_combo cm_k2-userdebug


text:
@interface PFGeoPoint (NSCoding)

- (void)encodeWithCoder:(NSCoder*)encoder;
- (id)initWithCoder:(NSCoder*)aDecoder;

@end


text:
require "pebbles/command/base"

# authentication (login, logout)
#
class Pebbles::Command::Auth < Pebbles::Command::Base

  # auth
  #
  # Authenticate, display token and current user
  def index
    validate_arguments!

    Pebbles::Command::Help.new.send(:help_for_command, current_command)
  end

  # auth:login
  #
  # log in with your Pebblescape credentials
  #
  #Example:
  #
  # $ pebbles auth:login
  # Enter your Pebblescape credentials:
  # Email: email@example.com
  # Password (typing will be hidden):
  # Authentication successful.
  #
  def login
    validate_arguments!

    Pebbles::Auth.login
    display "Authentication successful."
  end

  alias_command "login", "auth:login"

  # auth:logout
  #
  # clear local authentication credentials
  #
  #Example:
  #
  # $ pebbles auth:logout
  # Local credentials cleared.
  #
  def logout
    validate_arguments!

    Pebbles::Auth.logout
    display "Local credentials cleared."
  end

  alias_command "logout", "auth:logout"

  # auth:token
  #
  # display your api token
  #
  #Example:
  #
  # $ pebbles auth:token
  # ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCD
  #
  def token
    validate_arguments!

    display Pebbles::Auth.api_key
  end

  # auth:whoami
  #
  # display your Pebblescape email address
  #
  #Example:
  #
  # $ pebbles auth:whoami
  # email@example.com
  #
  def whoami
    validate_arguments!

    display Pebbles::Auth.user
  end

end


text:
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit605bb888f66304b7118e5899333d15ca::getLoader();


text:
class City < ActiveRecord::Base
  has_many :jobs
end


text:
@class DQImageView;

@interface DQUserTableViewCell : UITableViewCell

@property (strong, nonatomic) DQImageView *avatarView;
@property (strong, nonatomic) UILabel *usernameLabel;

@end


text:
class CreateEcmTagsTaggings < ActiveRecord::Migration[4.2]
  def change
    create_table :ecm_tags_taggings do |t|
      t.integer  'tag_id'
      t.integer  'taggable_id'
      t.string   'taggable_type'
      t.integer  'tagger_id'
      t.string   'tagger_type'
      t.string   'context', limit: 128
      t.datetime 'created_at'
    end

    add_index 'ecm_tags_taggings', %w(tag_id taggable_id taggable_type context tagger_id tagger_type), name: 'taggings_idx', unique: true
    add_index 'ecm_tags_taggings', %w(taggable_id taggable_type context), name: 'index_taggings_on_taggable_id_and_taggable_type_and_context'
  end
end


text:
package org.fest.assertions.internal;

import static org.fest.assertions.error.ShouldStartWith.shouldStartWith;
import static org.fest.assertions.test.ErrorMessages.*;
import static org.fest.assertions.test.ExpectedException.none;
import static org.fest.assertions.test.FailureMessages.actualIsNull;
import static org.fest.assertions.test.IntArrayFactory.*;
import static org.fest.assertions.test.TestData.someInfo;
import static org.fest.assertions.test.TestFailures.expectedAssertionErrorNotThrown;
import static org.mockito.Mockito.*;

import org.fest.assertions.core.AssertionInfo;
import org.fest.assertions.test.ExpectedException;
import org.junit.*;

/**
 * Tests for <code>{@link IntArrays#assertStartsWith(AssertionInfo, int[], int[])}</code>.
 *
 * @author Alex Ruiz
 */
public class IntArrays_assertStartsWith_Test {

  private static int[] actual;

  @Rule public ExpectedException thrown = none();

  private Failures failures;
  private IntArrays arrays;

  @BeforeClass public static void setUpOnce() {
    actual = array(6, 8, 10, 12);
  }

  @Before public void setUp() {
    failures = spy(new Failures());
    arrays = new IntArrays();
    arrays.failures = failures;
  }

  @Test public void should_throw_error_if_sequence_is_null() {
    thrown.expectNullPointerException(valuesToLookForIsNull());
    arrays.assertStartsWith(someInfo(), actual, null);
  }

  @Test public void should_throw_error_if_sequence_is_empty() {
    thrown.expectIllegalArgumentException(valuesToLookForIsEmpty());
    arrays.assertStartsWith(someInfo(), actual, emptyArray());
  }

  @Test public void should_fail_if_actual_is_null() {
    thrown.expectAssertionError(actualIsNull());
    arrays.assertStartsWith(someInfo(), null, array(8));
  }

  @Test public void should_fail_if_sequence_is_bigger_than_actual() {
    AssertionInfo info = someInfo();
    int[] sequence = { 6, 8, 10, 12, 20, 22 };
    try {
      arrays.assertStartsWith(info, actual, sequence);
    } catch (AssertionError e) {
      verifyFailureThrownWhenSequenceNotFound(info, sequence);
      return;
    }
    throw expectedAssertionErrorNotThrown();
  }

  @Test public void should_fail_if_actual_does_not_start_with_sequence() {
    AssertionInfo info = someInfo();
    int[] sequence = { 8, 10 };
    try {
      arrays.assertStartsWith(info, actual, sequence);
    } catch (AssertionError e) {
      verifyFailureThrownWhenSequenceNotFound(info, sequence);
      return;
    }
    throw expectedAssertionErrorNotThrown();
  }

  @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() {
    AssertionInfo info = someInfo();
    int[] sequence = { 6, 20 };
    try {
      arrays.assertStartsWith(info, actual, sequence);
    } catch (AssertionError e) {
      verifyFailureThrownWhenSequenceNotFound(info, sequence);
      return;
    }
    throw expectedAssertionErrorNotThrown();
  }

  private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, int[] sequence) {
    verify(failures).failure(info, shouldStartWith(actual, sequence));
  }

  @Test public void should_pass_if_actual_starts_with_sequence() {
    arrays.assertStartsWith(someInfo(), actual, array(6, 8, 10));
  }

  @Test public void should_pass_if_actual_and_sequence_are_equal() {
    arrays.assertStartsWith(someInfo(), actual, array(6, 8, 10, 12));
  }
}


text:
require "portus/security_backends/base"

module Portus
  module SecurityBackend
    # NOTE: support for this is experimental since this functionality has not
    # been merged into master yet in zypper-docker.
    class Zypper < ::Portus::SecurityBackend::Base
      # Returns the vulnerabilities as given by a zypper-docker server. It can
      # return two different types:
      #   - An array containing the vulnerabilities found.
      #   - nil if zypper-docker is still working on it.
      def vulnerabilities(_params)
        uri, req = get_request("/images?image=#{@repo}:#{@tag}")
        res = get_response_token(uri, req)

        msg = JSON.parse(res.body)
        if res.code.to_i == 200
          consume_response(msg)
        elsif res.code.to_i == 202
          nil
        else
          msg = error_message(msg)
          Rails.logger.tagged("zypper") do
            Rails.logger.debug "Error for '#{@repo}:#{@tag}': #{msg}"
          end
          nil
        end
      end

      def self.config_key
        "zypper"
      end

      protected

      def consume_response(response)
        security = response["Security"]
        return [] if security.nil? || security.to_i.zero?

        res = []
        response["List"].each do |issue|
          res << issue if issue["IsSecurity"]
        end
        res
      end

      def error_message(msg)
        msg["Error"] || msg
      end
    end
  end
end
# :nocov:


text:
require 'puppet/parameter/netscaler_name'
require 'puppet/property/netscaler_traffic_domain'
require 'puppet/property/netscaler_truthy'

Puppet::Type.newtype(:netscaler_sslvserver) do
  @doc = 'Configuration for SSL virtual server resource.'

  apply_to_device
  ensurable

  newparam(:name, :parent => Puppet::Parameter::NetscalerName, :namevar => true)
  desc "This is the binding of sslvserver/certkeyname"
  #XXX Validate with the below
  #ensure: change from absent to present failed: Could not set 'present' on ensure: REST failure: HTTP status code 400 detected.  Body of failure is: { "errorcode": 1075, "message": "Invalid name; names must begin with an alphanumeric character or underscore and must contain only alphanumerics, '_', '#', '.', ' ', ':', '@', '=' or '-' [name, hunner's website]", "severity": "ERROR" } at 55:/etc/puppetlabs/puppet/environments/produc

  newproperty(:crlcheck) do
    desc "The state of the CRL check parameter. (Mandatory/Optional).
Possible values = Mandatory, Optional"
  end

  newproperty(:ca) do
    desc "CA certificate."
  end

  newproperty(:snicert) do
    desc "The name of the CertKey. Use this option to bind Certkey(s) which will be used in SNI processing."
  end

  newproperty(:skipcaname) do
    desc "The flag is used to indicate whether this particular CA certificate's CA_Name needs to be sent to the SSL client while requesting for client certificate in a SSL handshake."
  end

  newproperty(:ocspcheck) do
    desc "The state of the OCSP check parameter. (Mandatory/Optional).
Possible values = Mandatory, Optional"
  end
end


text:
require 'spec_helper'

describe SearchesController do

end